babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5158. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Collisions/intersectionInfo" {
  6862. import { Nullable } from "babylonjs/types";
  6863. /**
  6864. * @hidden
  6865. */
  6866. export class IntersectionInfo {
  6867. bu: Nullable<number>;
  6868. bv: Nullable<number>;
  6869. distance: number;
  6870. faceId: number;
  6871. subMeshId: number;
  6872. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6873. }
  6874. }
  6875. declare module "babylonjs/Culling/boundingSphere" {
  6876. import { DeepImmutable } from "babylonjs/types";
  6877. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6878. import { Plane } from "babylonjs/Maths/math.plane";
  6879. /**
  6880. * Class used to store bounding sphere information
  6881. */
  6882. export class BoundingSphere {
  6883. /**
  6884. * Gets the center of the bounding sphere in local space
  6885. */
  6886. readonly center: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in local space
  6889. */
  6890. radius: number;
  6891. /**
  6892. * Gets the center of the bounding sphere in world space
  6893. */
  6894. readonly centerWorld: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in world space
  6897. */
  6898. radiusWorld: number;
  6899. /**
  6900. * Gets the minimum vector in local space
  6901. */
  6902. readonly minimum: Vector3;
  6903. /**
  6904. * Gets the maximum vector in local space
  6905. */
  6906. readonly maximum: Vector3;
  6907. private _worldMatrix;
  6908. private static readonly TmpVector3;
  6909. /**
  6910. * Creates a new bounding sphere
  6911. * @param min defines the minimum vector (in local space)
  6912. * @param max defines the maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6916. /**
  6917. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6918. * @param min defines the new minimum vector (in local space)
  6919. * @param max defines the new maximum vector (in local space)
  6920. * @param worldMatrix defines the new world matrix
  6921. */
  6922. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Scale the current bounding sphere by applying a scale factor
  6925. * @param factor defines the scale factor to apply
  6926. * @returns the current bounding box
  6927. */
  6928. scale(factor: number): BoundingSphere;
  6929. /**
  6930. * Gets the world matrix of the bounding box
  6931. * @returns a matrix
  6932. */
  6933. getWorldMatrix(): DeepImmutable<Matrix>;
  6934. /** @hidden */
  6935. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Tests if the bounding sphere is intersecting the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if the bounding sphere center is in between the frustum planes.
  6944. * Used for optimistic fast inclusion.
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if the sphere center is in between the frustum planes
  6947. */
  6948. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding sphere
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding sphere
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Checks if two sphere intersct
  6957. * @param sphere0 sphere 0
  6958. * @param sphere1 sphere 1
  6959. * @returns true if the speres intersect
  6960. */
  6961. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingBox" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6967. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6968. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6969. import { Plane } from "babylonjs/Maths/math.plane";
  6970. /**
  6971. * Class used to store bounding box information
  6972. */
  6973. export class BoundingBox implements ICullable {
  6974. /**
  6975. * Gets the 8 vectors representing the bounding box in local space
  6976. */
  6977. readonly vectors: Vector3[];
  6978. /**
  6979. * Gets the center of the bounding box in local space
  6980. */
  6981. readonly center: Vector3;
  6982. /**
  6983. * Gets the center of the bounding box in world space
  6984. */
  6985. readonly centerWorld: Vector3;
  6986. /**
  6987. * Gets the extend size in local space
  6988. */
  6989. readonly extendSize: Vector3;
  6990. /**
  6991. * Gets the extend size in world space
  6992. */
  6993. readonly extendSizeWorld: Vector3;
  6994. /**
  6995. * Gets the OBB (object bounding box) directions
  6996. */
  6997. readonly directions: Vector3[];
  6998. /**
  6999. * Gets the 8 vectors representing the bounding box in world space
  7000. */
  7001. readonly vectorsWorld: Vector3[];
  7002. /**
  7003. * Gets the minimum vector in world space
  7004. */
  7005. readonly minimumWorld: Vector3;
  7006. /**
  7007. * Gets the maximum vector in world space
  7008. */
  7009. readonly maximumWorld: Vector3;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * @hidden
  7022. */
  7023. _tag: number;
  7024. /**
  7025. * Creates a new bounding box
  7026. * @param min defines the minimum vector (in local space)
  7027. * @param max defines the maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7031. /**
  7032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7033. * @param min defines the new minimum vector (in local space)
  7034. * @param max defines the new maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Scale the current bounding box by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding box
  7042. */
  7043. scale(factor: number): BoundingBox;
  7044. /**
  7045. * Gets the world matrix of the bounding box
  7046. * @returns a matrix
  7047. */
  7048. getWorldMatrix(): DeepImmutable<Matrix>;
  7049. /** @hidden */
  7050. _update(world: DeepImmutable<Matrix>): void;
  7051. /**
  7052. * Tests if the bounding box is intersecting the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if the bounding box is entirely inside the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an inclusion
  7061. */
  7062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if a point is inside the bounding box
  7065. * @param point defines the point to test
  7066. * @returns true if the point is inside the bounding box
  7067. */
  7068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a bounding sphere
  7071. * @param sphere defines the sphere to test
  7072. * @returns true if there is an intersection
  7073. */
  7074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7077. * @param min defines the min vector to use
  7078. * @param max defines the max vector to use
  7079. * @returns true if there is an intersection
  7080. */
  7081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7082. /**
  7083. * Tests if two bounding boxes are intersections
  7084. * @param box0 defines the first box to test
  7085. * @param box1 defines the second box to test
  7086. * @returns true if there is an intersection
  7087. */
  7088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7089. /**
  7090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7091. * @param minPoint defines the minimum vector of the bounding box
  7092. * @param maxPoint defines the maximum vector of the bounding box
  7093. * @param sphereCenter defines the sphere center
  7094. * @param sphereRadius defines the sphere radius
  7095. * @returns true if there is an intersection
  7096. */
  7097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7098. /**
  7099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @return true if there is an inclusion
  7103. */
  7104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @return true if there is an intersection
  7110. */
  7111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. }
  7113. }
  7114. declare module "babylonjs/Collisions/collider" {
  7115. import { Nullable, IndicesArray } from "babylonjs/types";
  7116. import { Vector3 } from "babylonjs/Maths/math.vector";
  7117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. /** @hidden */
  7120. export class Collider {
  7121. /** Define if a collision was found */
  7122. collisionFound: boolean;
  7123. /**
  7124. * Define last intersection point in local space
  7125. */
  7126. intersectionPoint: Vector3;
  7127. /**
  7128. * Define last collided mesh
  7129. */
  7130. collidedMesh: Nullable<AbstractMesh>;
  7131. private _collisionPoint;
  7132. private _planeIntersectionPoint;
  7133. private _tempVector;
  7134. private _tempVector2;
  7135. private _tempVector3;
  7136. private _tempVector4;
  7137. private _edge;
  7138. private _baseToVertex;
  7139. private _destinationPoint;
  7140. private _slidePlaneNormal;
  7141. private _displacementVector;
  7142. /** @hidden */
  7143. _radius: Vector3;
  7144. /** @hidden */
  7145. _retry: number;
  7146. private _velocity;
  7147. private _basePoint;
  7148. private _epsilon;
  7149. /** @hidden */
  7150. _velocityWorldLength: number;
  7151. /** @hidden */
  7152. _basePointWorld: Vector3;
  7153. private _velocityWorld;
  7154. private _normalizedVelocity;
  7155. /** @hidden */
  7156. _initialVelocity: Vector3;
  7157. /** @hidden */
  7158. _initialPosition: Vector3;
  7159. private _nearestDistance;
  7160. private _collisionMask;
  7161. get collisionMask(): number;
  7162. set collisionMask(mask: number);
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. get slidePlaneNormal(): Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Plane } from "babylonjs/Maths/math.plane";
  7187. import { Collider } from "babylonjs/Collisions/collider";
  7188. /**
  7189. * Interface for cullable objects
  7190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7191. */
  7192. export interface ICullable {
  7193. /**
  7194. * Checks if the object or part of the object is in the frustum
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isInFrustum(frustumPlanes: Plane[]): boolean;
  7199. /**
  7200. * Checks if a cullable object (mesh...) is in the camera frustum
  7201. * Unlike isInFrustum this cheks the full bounding box
  7202. * @param frustumPlanes Camera near/planes
  7203. * @returns true if the object is in frustum otherwise false
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7206. }
  7207. /**
  7208. * Info for a bounding data of a mesh
  7209. */
  7210. export class BoundingInfo implements ICullable {
  7211. /**
  7212. * Bounding box for the mesh
  7213. */
  7214. readonly boundingBox: BoundingBox;
  7215. /**
  7216. * Bounding sphere for the mesh
  7217. */
  7218. readonly boundingSphere: BoundingSphere;
  7219. private _isLocked;
  7220. private static readonly TmpVector3;
  7221. /**
  7222. * Constructs bounding info
  7223. * @param minimum min vector of the bounding box/sphere
  7224. * @param maximum max vector of the bounding box/sphere
  7225. * @param worldMatrix defines the new world matrix
  7226. */
  7227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7228. /**
  7229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7230. * @param min defines the new minimum vector (in local space)
  7231. * @param max defines the new maximum vector (in local space)
  7232. * @param worldMatrix defines the new world matrix
  7233. */
  7234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7235. /**
  7236. * min vector of the bounding box/sphere
  7237. */
  7238. get minimum(): Vector3;
  7239. /**
  7240. * max vector of the bounding box/sphere
  7241. */
  7242. get maximum(): Vector3;
  7243. /**
  7244. * If the info is locked and won't be updated to avoid perf overhead
  7245. */
  7246. get isLocked(): boolean;
  7247. set isLocked(value: boolean);
  7248. /**
  7249. * Updates the bounding sphere and box
  7250. * @param world world matrix to be used to update
  7251. */
  7252. update(world: DeepImmutable<Matrix>): void;
  7253. /**
  7254. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7255. * @param center New center of the bounding info
  7256. * @param extend New extend of the bounding info
  7257. * @returns the current bounding info
  7258. */
  7259. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7260. /**
  7261. * Scale the current bounding info by applying a scale factor
  7262. * @param factor defines the scale factor to apply
  7263. * @returns the current bounding info
  7264. */
  7265. scale(factor: number): BoundingInfo;
  7266. /**
  7267. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7268. * @param frustumPlanes defines the frustum to test
  7269. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7270. * @returns true if the bounding info is in the frustum planes
  7271. */
  7272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7273. /**
  7274. * Gets the world distance between the min and max points of the bounding box
  7275. */
  7276. get diagonalLength(): number;
  7277. /**
  7278. * Checks if a cullable object (mesh...) is in the camera frustum
  7279. * Unlike isInFrustum this cheks the full bounding box
  7280. * @param frustumPlanes Camera near/planes
  7281. * @returns true if the object is in frustum otherwise false
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /** @hidden */
  7285. _checkCollision(collider: Collider): boolean;
  7286. /**
  7287. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7288. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7289. * @param point the point to check intersection with
  7290. * @returns if the point intersects
  7291. */
  7292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7293. /**
  7294. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7295. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7296. * @param boundingInfo the bounding info to check intersection with
  7297. * @param precise if the intersection should be done using OBB
  7298. * @returns if the bounding info intersects
  7299. */
  7300. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7301. }
  7302. }
  7303. declare module "babylonjs/Maths/math.functions" {
  7304. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7305. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7306. /**
  7307. * Extracts minimum and maximum values from a list of indexed positions
  7308. * @param positions defines the positions to use
  7309. * @param indices defines the indices to the positions
  7310. * @param indexStart defines the start index
  7311. * @param indexCount defines the end index
  7312. * @param bias defines bias value to add to the result
  7313. * @return minimum and maximum values
  7314. */
  7315. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7316. minimum: Vector3;
  7317. maximum: Vector3;
  7318. };
  7319. /**
  7320. * Extracts minimum and maximum values from a list of positions
  7321. * @param positions defines the positions to use
  7322. * @param start defines the start index in the positions array
  7323. * @param count defines the number of positions to handle
  7324. * @param bias defines bias value to add to the result
  7325. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. }
  7333. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7335. /** @hidden */
  7336. export class WebGLDataBuffer extends DataBuffer {
  7337. private _buffer;
  7338. constructor(resource: WebGLBuffer);
  7339. get underlyingResource(): any;
  7340. }
  7341. }
  7342. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7344. import { Nullable } from "babylonjs/types";
  7345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7346. /** @hidden */
  7347. export class WebGLPipelineContext implements IPipelineContext {
  7348. engine: ThinEngine;
  7349. program: Nullable<WebGLProgram>;
  7350. context?: WebGLRenderingContext;
  7351. vertexShader?: WebGLShader;
  7352. fragmentShader?: WebGLShader;
  7353. isParallelCompiled: boolean;
  7354. onCompiled?: () => void;
  7355. transformFeedback?: WebGLTransformFeedback | null;
  7356. vertexCompilationError: Nullable<string>;
  7357. fragmentCompilationError: Nullable<string>;
  7358. programLinkError: Nullable<string>;
  7359. programValidationError: Nullable<string>;
  7360. get isAsync(): boolean;
  7361. get isReady(): boolean;
  7362. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7363. _getVertexShaderCode(): string | null;
  7364. _getFragmentShaderCode(): string | null;
  7365. }
  7366. }
  7367. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7368. import { FloatArray, Nullable } from "babylonjs/types";
  7369. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7370. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7371. module "babylonjs/Engines/thinEngine" {
  7372. interface ThinEngine {
  7373. /**
  7374. * Create an uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param elements defines the content of the uniform buffer
  7377. * @returns the webGL uniform buffer
  7378. */
  7379. createUniformBuffer(elements: FloatArray): DataBuffer;
  7380. /**
  7381. * Create a dynamic uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Update an existing uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param uniformBuffer defines the target uniform buffer
  7391. * @param elements defines the content to update
  7392. * @param offset defines the offset in the uniform buffer where update should start
  7393. * @param count defines the size of the data to update
  7394. */
  7395. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7396. /**
  7397. * Bind an uniform buffer to the current webGL context
  7398. * @param buffer defines the buffer to bind
  7399. */
  7400. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7401. /**
  7402. * Bind a buffer to the current webGL context at a given location
  7403. * @param buffer defines the buffer to bind
  7404. * @param location defines the index where to bind the buffer
  7405. */
  7406. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7407. /**
  7408. * Bind a specific block at a given index in a specific shader program
  7409. * @param pipelineContext defines the pipeline context to use
  7410. * @param blockName defines the block name
  7411. * @param index defines the index where to bind the block
  7412. */
  7413. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7414. }
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/uniformBuffer" {
  7418. import { Nullable, FloatArray } from "babylonjs/types";
  7419. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7420. import { Engine } from "babylonjs/Engines/engine";
  7421. import { Effect } from "babylonjs/Materials/effect";
  7422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7424. import { Color3 } from "babylonjs/Maths/math.color";
  7425. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7426. /**
  7427. * Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. */
  7436. export class UniformBuffer {
  7437. private _engine;
  7438. private _buffer;
  7439. private _data;
  7440. private _bufferData;
  7441. private _dynamic?;
  7442. private _uniformLocations;
  7443. private _uniformSizes;
  7444. private _uniformLocationPointer;
  7445. private _needSync;
  7446. private _noUBO;
  7447. private _currentEffect;
  7448. /** @hidden */
  7449. _alreadyBound: boolean;
  7450. private static _MAX_UNIFORM_SIZE;
  7451. private static _tempBuffer;
  7452. /**
  7453. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7458. /**
  7459. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7464. /**
  7465. * Lambda to Update a single float in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateFloat: (name: string, x: number) => void;
  7470. /**
  7471. * Lambda to Update a vec2 of float in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7476. /**
  7477. * Lambda to Update a vec3 of float in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7482. /**
  7483. * Lambda to Update a vec4 of float in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateMatrix: (name: string, mat: Matrix) => void;
  7494. /**
  7495. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateVector3: (name: string, vector: Vector3) => void;
  7500. /**
  7501. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateVector4: (name: string, vector: Vector4) => void;
  7506. /**
  7507. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7512. /**
  7513. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7518. /**
  7519. * Instantiates a new Uniform buffer objects.
  7520. *
  7521. * Handles blocks of uniform on the GPU.
  7522. *
  7523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7524. *
  7525. * For more information, please refer to :
  7526. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7527. * @param engine Define the engine the buffer is associated with
  7528. * @param data Define the data contained in the buffer
  7529. * @param dynamic Define if the buffer is updatable
  7530. */
  7531. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7532. /**
  7533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7534. * or just falling back on setUniformXXX calls.
  7535. */
  7536. get useUbo(): boolean;
  7537. /**
  7538. * Indicates if the WebGL underlying uniform buffer is in sync
  7539. * with the javascript cache data.
  7540. */
  7541. get isSync(): boolean;
  7542. /**
  7543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7544. * Also, a dynamic UniformBuffer will disable cache verification and always
  7545. * update the underlying WebGL uniform buffer to the GPU.
  7546. * @returns if Dynamic, otherwise false
  7547. */
  7548. isDynamic(): boolean;
  7549. /**
  7550. * The data cache on JS side.
  7551. * @returns the underlying data as a float array
  7552. */
  7553. getData(): Float32Array;
  7554. /**
  7555. * The underlying WebGL Uniform buffer.
  7556. * @returns the webgl buffer
  7557. */
  7558. getBuffer(): Nullable<DataBuffer>;
  7559. /**
  7560. * std140 layout specifies how to align data within an UBO structure.
  7561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7562. * for specs.
  7563. */
  7564. private _fillAlignment;
  7565. /**
  7566. * Adds an uniform in the buffer.
  7567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7568. * for the layout to be correct !
  7569. * @param name Name of the uniform, as used in the uniform block in the shader.
  7570. * @param size Data size, or data directly.
  7571. */
  7572. addUniform(name: string, size: number | number[]): void;
  7573. /**
  7574. * Adds a Matrix 4x4 to the uniform buffer.
  7575. * @param name Name of the uniform, as used in the uniform block in the shader.
  7576. * @param mat A 4x4 matrix.
  7577. */
  7578. addMatrix(name: string, mat: Matrix): void;
  7579. /**
  7580. * Adds a vec2 to the uniform buffer.
  7581. * @param name Name of the uniform, as used in the uniform block in the shader.
  7582. * @param x Define the x component value of the vec2
  7583. * @param y Define the y component value of the vec2
  7584. */
  7585. addFloat2(name: string, x: number, y: number): void;
  7586. /**
  7587. * Adds a vec3 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param x Define the x component value of the vec3
  7590. * @param y Define the y component value of the vec3
  7591. * @param z Define the z component value of the vec3
  7592. */
  7593. addFloat3(name: string, x: number, y: number, z: number): void;
  7594. /**
  7595. * Adds a vec3 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. * @param color Define the vec3 from a Color
  7598. */
  7599. addColor3(name: string, color: Color3): void;
  7600. /**
  7601. * Adds a vec4 to the uniform buffer.
  7602. * @param name Name of the uniform, as used in the uniform block in the shader.
  7603. * @param color Define the rgb components from a Color
  7604. * @param alpha Define the a component of the vec4
  7605. */
  7606. addColor4(name: string, color: Color3, alpha: number): void;
  7607. /**
  7608. * Adds a vec3 to the uniform buffer.
  7609. * @param name Name of the uniform, as used in the uniform block in the shader.
  7610. * @param vector Define the vec3 components from a Vector
  7611. */
  7612. addVector3(name: string, vector: Vector3): void;
  7613. /**
  7614. * Adds a Matrix 3x3 to the uniform buffer.
  7615. * @param name Name of the uniform, as used in the uniform block in the shader.
  7616. */
  7617. addMatrix3x3(name: string): void;
  7618. /**
  7619. * Adds a Matrix 2x2 to the uniform buffer.
  7620. * @param name Name of the uniform, as used in the uniform block in the shader.
  7621. */
  7622. addMatrix2x2(name: string): void;
  7623. /**
  7624. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7625. */
  7626. create(): void;
  7627. /** @hidden */
  7628. _rebuild(): void;
  7629. /**
  7630. * Updates the WebGL Uniform Buffer on the GPU.
  7631. * If the `dynamic` flag is set to true, no cache comparison is done.
  7632. * Otherwise, the buffer will be updated only if the cache differs.
  7633. */
  7634. update(): void;
  7635. /**
  7636. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7637. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7638. * @param data Define the flattened data
  7639. * @param size Define the size of the data.
  7640. */
  7641. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7642. private _valueCache;
  7643. private _cacheMatrix;
  7644. private _updateMatrix3x3ForUniform;
  7645. private _updateMatrix3x3ForEffect;
  7646. private _updateMatrix2x2ForEffect;
  7647. private _updateMatrix2x2ForUniform;
  7648. private _updateFloatForEffect;
  7649. private _updateFloatForUniform;
  7650. private _updateFloat2ForEffect;
  7651. private _updateFloat2ForUniform;
  7652. private _updateFloat3ForEffect;
  7653. private _updateFloat3ForUniform;
  7654. private _updateFloat4ForEffect;
  7655. private _updateFloat4ForUniform;
  7656. private _updateMatrixForEffect;
  7657. private _updateMatrixForUniform;
  7658. private _updateVector3ForEffect;
  7659. private _updateVector3ForUniform;
  7660. private _updateVector4ForEffect;
  7661. private _updateVector4ForUniform;
  7662. private _updateColor3ForEffect;
  7663. private _updateColor3ForUniform;
  7664. private _updateColor4ForEffect;
  7665. private _updateColor4ForUniform;
  7666. /**
  7667. * Sets a sampler uniform on the effect.
  7668. * @param name Define the name of the sampler.
  7669. * @param texture Define the texture to set in the sampler
  7670. */
  7671. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7672. /**
  7673. * Directly updates the value of the uniform in the cache AND on the GPU.
  7674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7675. * @param data Define the flattened data
  7676. */
  7677. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7678. /**
  7679. * Binds this uniform buffer to an effect.
  7680. * @param effect Define the effect to bind the buffer to
  7681. * @param name Name of the uniform block in the shader.
  7682. */
  7683. bindToEffect(effect: Effect, name: string): void;
  7684. /**
  7685. * Disposes the uniform buffer.
  7686. */
  7687. dispose(): void;
  7688. }
  7689. }
  7690. declare module "babylonjs/Misc/iInspectable" {
  7691. /**
  7692. * Enum that determines the text-wrapping mode to use.
  7693. */
  7694. export enum InspectableType {
  7695. /**
  7696. * Checkbox for booleans
  7697. */
  7698. Checkbox = 0,
  7699. /**
  7700. * Sliders for numbers
  7701. */
  7702. Slider = 1,
  7703. /**
  7704. * Vector3
  7705. */
  7706. Vector3 = 2,
  7707. /**
  7708. * Quaternions
  7709. */
  7710. Quaternion = 3,
  7711. /**
  7712. * Color3
  7713. */
  7714. Color3 = 4,
  7715. /**
  7716. * String
  7717. */
  7718. String = 5
  7719. }
  7720. /**
  7721. * Interface used to define custom inspectable properties.
  7722. * This interface is used by the inspector to display custom property grids
  7723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7724. */
  7725. export interface IInspectable {
  7726. /**
  7727. * Gets the label to display
  7728. */
  7729. label: string;
  7730. /**
  7731. * Gets the name of the property to edit
  7732. */
  7733. propertyName: string;
  7734. /**
  7735. * Gets the type of the editor to use
  7736. */
  7737. type: InspectableType;
  7738. /**
  7739. * Gets the minimum value of the property when using in "slider" mode
  7740. */
  7741. min?: number;
  7742. /**
  7743. * Gets the maximum value of the property when using in "slider" mode
  7744. */
  7745. max?: number;
  7746. /**
  7747. * Gets the setp to use when using in "slider" mode
  7748. */
  7749. step?: number;
  7750. }
  7751. }
  7752. declare module "babylonjs/Misc/timingTools" {
  7753. /**
  7754. * Class used to provide helper for timing
  7755. */
  7756. export class TimingTools {
  7757. /**
  7758. * Polyfill for setImmediate
  7759. * @param action defines the action to execute after the current execution block
  7760. */
  7761. static SetImmediate(action: () => void): void;
  7762. }
  7763. }
  7764. declare module "babylonjs/Misc/instantiationTools" {
  7765. /**
  7766. * Class used to enable instatition of objects by class name
  7767. */
  7768. export class InstantiationTools {
  7769. /**
  7770. * Use this object to register external classes like custom textures or material
  7771. * to allow the laoders to instantiate them
  7772. */
  7773. static RegisteredExternalClasses: {
  7774. [key: string]: Object;
  7775. };
  7776. /**
  7777. * Tries to instantiate a new object from a given class name
  7778. * @param className defines the class name to instantiate
  7779. * @returns the new object or null if the system was not able to do the instantiation
  7780. */
  7781. static Instantiate(className: string): any;
  7782. }
  7783. }
  7784. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7785. /**
  7786. * Define options used to create a depth texture
  7787. */
  7788. export class DepthTextureCreationOptions {
  7789. /** Specifies whether or not a stencil should be allocated in the texture */
  7790. generateStencil?: boolean;
  7791. /** Specifies whether or not bilinear filtering is enable on the texture */
  7792. bilinearFiltering?: boolean;
  7793. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7794. comparisonFunction?: number;
  7795. /** Specifies if the created texture is a cube texture */
  7796. isCube?: boolean;
  7797. }
  7798. }
  7799. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7801. import { Nullable } from "babylonjs/types";
  7802. import { Scene } from "babylonjs/scene";
  7803. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7804. module "babylonjs/Engines/thinEngine" {
  7805. interface ThinEngine {
  7806. /**
  7807. * Creates a depth stencil cube texture.
  7808. * This is only available in WebGL 2.
  7809. * @param size The size of face edge in the cube texture.
  7810. * @param options The options defining the cube texture.
  7811. * @returns The cube texture
  7812. */
  7813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7814. /**
  7815. * Creates a cube texture
  7816. * @param rootUrl defines the url where the files to load is located
  7817. * @param scene defines the current scene
  7818. * @param files defines the list of files to load (1 per face)
  7819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7820. * @param onLoad defines an optional callback raised when the texture is loaded
  7821. * @param onError defines an optional callback raised if there is an issue to load the texture
  7822. * @param format defines the format of the data
  7823. * @param forcedExtension defines the extension to use to pick the right loader
  7824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7831. /**
  7832. * Creates a cube texture
  7833. * @param rootUrl defines the url where the files to load is located
  7834. * @param scene defines the current scene
  7835. * @param files defines the list of files to load (1 per face)
  7836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7837. * @param onLoad defines an optional callback raised when the texture is loaded
  7838. * @param onError defines an optional callback raised if there is an issue to load the texture
  7839. * @param format defines the format of the data
  7840. * @param forcedExtension defines the extension to use to pick the right loader
  7841. * @returns the cube texture as an InternalTexture
  7842. */
  7843. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7844. /**
  7845. * Creates a cube texture
  7846. * @param rootUrl defines the url where the files to load is located
  7847. * @param scene defines the current scene
  7848. * @param files defines the list of files to load (1 per face)
  7849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7850. * @param onLoad defines an optional callback raised when the texture is loaded
  7851. * @param onError defines an optional callback raised if there is an issue to load the texture
  7852. * @param format defines the format of the data
  7853. * @param forcedExtension defines the extension to use to pick the right loader
  7854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @returns the cube texture as an InternalTexture
  7858. */
  7859. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7860. /** @hidden */
  7861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7862. /** @hidden */
  7863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7864. /** @hidden */
  7865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7866. /** @hidden */
  7867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7868. /**
  7869. * @hidden
  7870. */
  7871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7872. }
  7873. }
  7874. }
  7875. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7876. import { Nullable } from "babylonjs/types";
  7877. import { Scene } from "babylonjs/scene";
  7878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7882. import { Observable } from "babylonjs/Misc/observable";
  7883. /**
  7884. * Class for creating a cube texture
  7885. */
  7886. export class CubeTexture extends BaseTexture {
  7887. private _delayedOnLoad;
  7888. /**
  7889. * Observable triggered once the texture has been loaded.
  7890. */
  7891. onLoadObservable: Observable<CubeTexture>;
  7892. /**
  7893. * The url of the texture
  7894. */
  7895. url: string;
  7896. /**
  7897. * Gets or sets the center of the bounding box associated with the cube texture.
  7898. * It must define where the camera used to render the texture was set
  7899. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7900. */
  7901. boundingBoxPosition: Vector3;
  7902. private _boundingBoxSize;
  7903. /**
  7904. * Gets or sets the size of the bounding box associated with the cube texture
  7905. * When defined, the cubemap will switch to local mode
  7906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7907. * @example https://www.babylonjs-playground.com/#RNASML
  7908. */
  7909. set boundingBoxSize(value: Vector3);
  7910. /**
  7911. * Returns the bounding box size
  7912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7913. */
  7914. get boundingBoxSize(): Vector3;
  7915. protected _rotationY: number;
  7916. /**
  7917. * Sets texture matrix rotation angle around Y axis in radians.
  7918. */
  7919. set rotationY(value: number);
  7920. /**
  7921. * Gets texture matrix rotation angle around Y axis radians.
  7922. */
  7923. get rotationY(): number;
  7924. /**
  7925. * Are mip maps generated for this texture or not.
  7926. */
  7927. get noMipmap(): boolean;
  7928. private _noMipmap;
  7929. private _files;
  7930. protected _forcedExtension: Nullable<string>;
  7931. private _extensions;
  7932. private _textureMatrix;
  7933. private _format;
  7934. private _createPolynomials;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @return the cube texture
  7969. */
  7970. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7971. /**
  7972. * Get the current class name of the texture useful for serialization or dynamic coding.
  7973. * @returns "CubeTexture"
  7974. */
  7975. getClassName(): string;
  7976. /**
  7977. * Update the url (and optional buffer) of this texture if url was null during construction.
  7978. * @param url the url of the texture
  7979. * @param forcedExtension defines the extension to use
  7980. * @param onLoad callback called when the texture is loaded (defaults to null)
  7981. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7982. */
  7983. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7984. /**
  7985. * Delays loading of the cube texture
  7986. * @param forcedExtension defines the extension to use
  7987. */
  7988. delayLoad(forcedExtension?: string): void;
  7989. /**
  7990. * Returns the reflection texture matrix
  7991. * @returns the reflection texture matrix
  7992. */
  7993. getReflectionTextureMatrix(): Matrix;
  7994. /**
  7995. * Sets the reflection texture matrix
  7996. * @param value Reflection texture matrix
  7997. */
  7998. setReflectionTextureMatrix(value: Matrix): void;
  7999. /**
  8000. * Parses text to create a cube texture
  8001. * @param parsedTexture define the serialized text to read from
  8002. * @param scene defines the hosting scene
  8003. * @param rootUrl defines the root url of the cube texture
  8004. * @returns a cube texture
  8005. */
  8006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8007. /**
  8008. * Makes a clone, or deep copy, of the cube texture
  8009. * @returns a new cube texture
  8010. */
  8011. clone(): CubeTexture;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/materialDefines" {
  8015. /**
  8016. * Manages the defines for the Material
  8017. */
  8018. export class MaterialDefines {
  8019. /** @hidden */
  8020. protected _keys: string[];
  8021. private _isDirty;
  8022. /** @hidden */
  8023. _renderId: number;
  8024. /** @hidden */
  8025. _areLightsDirty: boolean;
  8026. /** @hidden */
  8027. _areLightsDisposed: boolean;
  8028. /** @hidden */
  8029. _areAttributesDirty: boolean;
  8030. /** @hidden */
  8031. _areTexturesDirty: boolean;
  8032. /** @hidden */
  8033. _areFresnelDirty: boolean;
  8034. /** @hidden */
  8035. _areMiscDirty: boolean;
  8036. /** @hidden */
  8037. _areImageProcessingDirty: boolean;
  8038. /** @hidden */
  8039. _normals: boolean;
  8040. /** @hidden */
  8041. _uvs: boolean;
  8042. /** @hidden */
  8043. _needNormals: boolean;
  8044. /** @hidden */
  8045. _needUVs: boolean;
  8046. [id: string]: any;
  8047. /**
  8048. * Specifies if the material needs to be re-calculated
  8049. */
  8050. get isDirty(): boolean;
  8051. /**
  8052. * Marks the material to indicate that it has been re-calculated
  8053. */
  8054. markAsProcessed(): void;
  8055. /**
  8056. * Marks the material to indicate that it needs to be re-calculated
  8057. */
  8058. markAsUnprocessed(): void;
  8059. /**
  8060. * Marks the material to indicate all of its defines need to be re-calculated
  8061. */
  8062. markAllAsDirty(): void;
  8063. /**
  8064. * Marks the material to indicate that image processing needs to be re-calculated
  8065. */
  8066. markAsImageProcessingDirty(): void;
  8067. /**
  8068. * Marks the material to indicate the lights need to be re-calculated
  8069. * @param disposed Defines whether the light is dirty due to dispose or not
  8070. */
  8071. markAsLightDirty(disposed?: boolean): void;
  8072. /**
  8073. * Marks the attribute state as changed
  8074. */
  8075. markAsAttributesDirty(): void;
  8076. /**
  8077. * Marks the texture state as changed
  8078. */
  8079. markAsTexturesDirty(): void;
  8080. /**
  8081. * Marks the fresnel state as changed
  8082. */
  8083. markAsFresnelDirty(): void;
  8084. /**
  8085. * Marks the misc state as changed
  8086. */
  8087. markAsMiscDirty(): void;
  8088. /**
  8089. * Rebuilds the material defines
  8090. */
  8091. rebuild(): void;
  8092. /**
  8093. * Specifies if two material defines are equal
  8094. * @param other - A material define instance to compare to
  8095. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8096. */
  8097. isEqual(other: MaterialDefines): boolean;
  8098. /**
  8099. * Clones this instance's defines to another instance
  8100. * @param other - material defines to clone values to
  8101. */
  8102. cloneTo(other: MaterialDefines): void;
  8103. /**
  8104. * Resets the material define values
  8105. */
  8106. reset(): void;
  8107. /**
  8108. * Converts the material define values to a string
  8109. * @returns - String of material define information
  8110. */
  8111. toString(): string;
  8112. }
  8113. }
  8114. declare module "babylonjs/Materials/colorCurves" {
  8115. import { Effect } from "babylonjs/Materials/effect";
  8116. /**
  8117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8119. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8121. */
  8122. export class ColorCurves {
  8123. private _dirty;
  8124. private _tempColor;
  8125. private _globalCurve;
  8126. private _highlightsCurve;
  8127. private _midtonesCurve;
  8128. private _shadowsCurve;
  8129. private _positiveCurve;
  8130. private _negativeCurve;
  8131. private _globalHue;
  8132. private _globalDensity;
  8133. private _globalSaturation;
  8134. private _globalExposure;
  8135. /**
  8136. * Gets the global Hue value.
  8137. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8138. */
  8139. get globalHue(): number;
  8140. /**
  8141. * Sets the global Hue value.
  8142. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8143. */
  8144. set globalHue(value: number);
  8145. /**
  8146. * Gets the global Density value.
  8147. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8148. * Values less than zero provide a filter of opposite hue.
  8149. */
  8150. get globalDensity(): number;
  8151. /**
  8152. * Sets the global Density value.
  8153. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. set globalDensity(value: number);
  8157. /**
  8158. * Gets the global Saturation value.
  8159. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8160. */
  8161. get globalSaturation(): number;
  8162. /**
  8163. * Sets the global Saturation value.
  8164. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8165. */
  8166. set globalSaturation(value: number);
  8167. /**
  8168. * Gets the global Exposure value.
  8169. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8170. */
  8171. get globalExposure(): number;
  8172. /**
  8173. * Sets the global Exposure value.
  8174. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8175. */
  8176. set globalExposure(value: number);
  8177. private _highlightsHue;
  8178. private _highlightsDensity;
  8179. private _highlightsSaturation;
  8180. private _highlightsExposure;
  8181. /**
  8182. * Gets the highlights Hue value.
  8183. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8184. */
  8185. get highlightsHue(): number;
  8186. /**
  8187. * Sets the highlights Hue value.
  8188. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8189. */
  8190. set highlightsHue(value: number);
  8191. /**
  8192. * Gets the highlights Density value.
  8193. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8194. * Values less than zero provide a filter of opposite hue.
  8195. */
  8196. get highlightsDensity(): number;
  8197. /**
  8198. * Sets the highlights Density value.
  8199. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. set highlightsDensity(value: number);
  8203. /**
  8204. * Gets the highlights Saturation value.
  8205. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8206. */
  8207. get highlightsSaturation(): number;
  8208. /**
  8209. * Sets the highlights Saturation value.
  8210. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8211. */
  8212. set highlightsSaturation(value: number);
  8213. /**
  8214. * Gets the highlights Exposure value.
  8215. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8216. */
  8217. get highlightsExposure(): number;
  8218. /**
  8219. * Sets the highlights Exposure value.
  8220. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8221. */
  8222. set highlightsExposure(value: number);
  8223. private _midtonesHue;
  8224. private _midtonesDensity;
  8225. private _midtonesSaturation;
  8226. private _midtonesExposure;
  8227. /**
  8228. * Gets the midtones Hue value.
  8229. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8230. */
  8231. get midtonesHue(): number;
  8232. /**
  8233. * Sets the midtones Hue value.
  8234. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8235. */
  8236. set midtonesHue(value: number);
  8237. /**
  8238. * Gets the midtones Density value.
  8239. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. get midtonesDensity(): number;
  8243. /**
  8244. * Sets the midtones Density value.
  8245. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. set midtonesDensity(value: number);
  8249. /**
  8250. * Gets the midtones Saturation value.
  8251. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8252. */
  8253. get midtonesSaturation(): number;
  8254. /**
  8255. * Sets the midtones Saturation value.
  8256. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8257. */
  8258. set midtonesSaturation(value: number);
  8259. /**
  8260. * Gets the midtones Exposure value.
  8261. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8262. */
  8263. get midtonesExposure(): number;
  8264. /**
  8265. * Sets the midtones Exposure value.
  8266. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8267. */
  8268. set midtonesExposure(value: number);
  8269. private _shadowsHue;
  8270. private _shadowsDensity;
  8271. private _shadowsSaturation;
  8272. private _shadowsExposure;
  8273. /**
  8274. * Gets the shadows Hue value.
  8275. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8276. */
  8277. get shadowsHue(): number;
  8278. /**
  8279. * Sets the shadows Hue value.
  8280. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8281. */
  8282. set shadowsHue(value: number);
  8283. /**
  8284. * Gets the shadows Density value.
  8285. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. get shadowsDensity(): number;
  8289. /**
  8290. * Sets the shadows Density value.
  8291. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. set shadowsDensity(value: number);
  8295. /**
  8296. * Gets the shadows Saturation value.
  8297. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8298. */
  8299. get shadowsSaturation(): number;
  8300. /**
  8301. * Sets the shadows Saturation value.
  8302. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8303. */
  8304. set shadowsSaturation(value: number);
  8305. /**
  8306. * Gets the shadows Exposure value.
  8307. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8308. */
  8309. get shadowsExposure(): number;
  8310. /**
  8311. * Sets the shadows Exposure value.
  8312. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8313. */
  8314. set shadowsExposure(value: number);
  8315. /**
  8316. * Returns the class name
  8317. * @returns The class name
  8318. */
  8319. getClassName(): string;
  8320. /**
  8321. * Binds the color curves to the shader.
  8322. * @param colorCurves The color curve to bind
  8323. * @param effect The effect to bind to
  8324. * @param positiveUniform The positive uniform shader parameter
  8325. * @param neutralUniform The neutral uniform shader parameter
  8326. * @param negativeUniform The negative uniform shader parameter
  8327. */
  8328. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8329. /**
  8330. * Prepare the list of uniforms associated with the ColorCurves effects.
  8331. * @param uniformsList The list of uniforms used in the effect
  8332. */
  8333. static PrepareUniforms(uniformsList: string[]): void;
  8334. /**
  8335. * Returns color grading data based on a hue, density, saturation and exposure value.
  8336. * @param filterHue The hue of the color filter.
  8337. * @param filterDensity The density of the color filter.
  8338. * @param saturation The saturation.
  8339. * @param exposure The exposure.
  8340. * @param result The result data container.
  8341. */
  8342. private getColorGradingDataToRef;
  8343. /**
  8344. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8345. * @param value The input slider value in range [-100,100].
  8346. * @returns Adjusted value.
  8347. */
  8348. private static applyColorGradingSliderNonlinear;
  8349. /**
  8350. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8351. * @param hue The hue (H) input.
  8352. * @param saturation The saturation (S) input.
  8353. * @param brightness The brightness (B) input.
  8354. * @result An RGBA color represented as Vector4.
  8355. */
  8356. private static fromHSBToRef;
  8357. /**
  8358. * Returns a value clamped between min and max
  8359. * @param value The value to clamp
  8360. * @param min The minimum of value
  8361. * @param max The maximum of value
  8362. * @returns The clamped value.
  8363. */
  8364. private static clamp;
  8365. /**
  8366. * Clones the current color curve instance.
  8367. * @return The cloned curves
  8368. */
  8369. clone(): ColorCurves;
  8370. /**
  8371. * Serializes the current color curve instance to a json representation.
  8372. * @return a JSON representation
  8373. */
  8374. serialize(): any;
  8375. /**
  8376. * Parses the color curve from a json representation.
  8377. * @param source the JSON source to parse
  8378. * @return The parsed curves
  8379. */
  8380. static Parse(source: any): ColorCurves;
  8381. }
  8382. }
  8383. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8384. import { Observable } from "babylonjs/Misc/observable";
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Color4 } from "babylonjs/Maths/math.color";
  8387. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8388. import { Effect } from "babylonjs/Materials/effect";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8391. /**
  8392. * Interface to follow in your material defines to integrate easily the
  8393. * Image proccessing functions.
  8394. * @hidden
  8395. */
  8396. export interface IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. EXPOSURE: boolean;
  8405. COLORCURVES: boolean;
  8406. COLORGRADING: boolean;
  8407. COLORGRADING3D: boolean;
  8408. SAMPLER3DGREENDEPTH: boolean;
  8409. SAMPLER3DBGRMAP: boolean;
  8410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8411. }
  8412. /**
  8413. * @hidden
  8414. */
  8415. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8416. IMAGEPROCESSING: boolean;
  8417. VIGNETTE: boolean;
  8418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8419. VIGNETTEBLENDMODEOPAQUE: boolean;
  8420. TONEMAPPING: boolean;
  8421. TONEMAPPING_ACES: boolean;
  8422. CONTRAST: boolean;
  8423. COLORCURVES: boolean;
  8424. COLORGRADING: boolean;
  8425. COLORGRADING3D: boolean;
  8426. SAMPLER3DGREENDEPTH: boolean;
  8427. SAMPLER3DBGRMAP: boolean;
  8428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8429. EXPOSURE: boolean;
  8430. constructor();
  8431. }
  8432. /**
  8433. * This groups together the common properties used for image processing either in direct forward pass
  8434. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8435. * or not.
  8436. */
  8437. export class ImageProcessingConfiguration {
  8438. /**
  8439. * Default tone mapping applied in BabylonJS.
  8440. */
  8441. static readonly TONEMAPPING_STANDARD: number;
  8442. /**
  8443. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8444. * to other engines rendering to increase portability.
  8445. */
  8446. static readonly TONEMAPPING_ACES: number;
  8447. /**
  8448. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8449. */
  8450. colorCurves: Nullable<ColorCurves>;
  8451. private _colorCurvesEnabled;
  8452. /**
  8453. * Gets wether the color curves effect is enabled.
  8454. */
  8455. get colorCurvesEnabled(): boolean;
  8456. /**
  8457. * Sets wether the color curves effect is enabled.
  8458. */
  8459. set colorCurvesEnabled(value: boolean);
  8460. private _colorGradingTexture;
  8461. /**
  8462. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8463. */
  8464. get colorGradingTexture(): Nullable<BaseTexture>;
  8465. /**
  8466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8467. */
  8468. set colorGradingTexture(value: Nullable<BaseTexture>);
  8469. private _colorGradingEnabled;
  8470. /**
  8471. * Gets wether the color grading effect is enabled.
  8472. */
  8473. get colorGradingEnabled(): boolean;
  8474. /**
  8475. * Sets wether the color grading effect is enabled.
  8476. */
  8477. set colorGradingEnabled(value: boolean);
  8478. private _colorGradingWithGreenDepth;
  8479. /**
  8480. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8481. */
  8482. get colorGradingWithGreenDepth(): boolean;
  8483. /**
  8484. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8485. */
  8486. set colorGradingWithGreenDepth(value: boolean);
  8487. private _colorGradingBGR;
  8488. /**
  8489. * Gets wether the color grading texture contains BGR values.
  8490. */
  8491. get colorGradingBGR(): boolean;
  8492. /**
  8493. * Sets wether the color grading texture contains BGR values.
  8494. */
  8495. set colorGradingBGR(value: boolean);
  8496. /** @hidden */
  8497. _exposure: number;
  8498. /**
  8499. * Gets the Exposure used in the effect.
  8500. */
  8501. get exposure(): number;
  8502. /**
  8503. * Sets the Exposure used in the effect.
  8504. */
  8505. set exposure(value: number);
  8506. private _toneMappingEnabled;
  8507. /**
  8508. * Gets wether the tone mapping effect is enabled.
  8509. */
  8510. get toneMappingEnabled(): boolean;
  8511. /**
  8512. * Sets wether the tone mapping effect is enabled.
  8513. */
  8514. set toneMappingEnabled(value: boolean);
  8515. private _toneMappingType;
  8516. /**
  8517. * Gets the type of tone mapping effect.
  8518. */
  8519. get toneMappingType(): number;
  8520. /**
  8521. * Sets the type of tone mapping effect used in BabylonJS.
  8522. */
  8523. set toneMappingType(value: number);
  8524. protected _contrast: number;
  8525. /**
  8526. * Gets the contrast used in the effect.
  8527. */
  8528. get contrast(): number;
  8529. /**
  8530. * Sets the contrast used in the effect.
  8531. */
  8532. set contrast(value: number);
  8533. /**
  8534. * Vignette stretch size.
  8535. */
  8536. vignetteStretch: number;
  8537. /**
  8538. * Vignette centre X Offset.
  8539. */
  8540. vignetteCentreX: number;
  8541. /**
  8542. * Vignette centre Y Offset.
  8543. */
  8544. vignetteCentreY: number;
  8545. /**
  8546. * Vignette weight or intensity of the vignette effect.
  8547. */
  8548. vignetteWeight: number;
  8549. /**
  8550. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8551. * if vignetteEnabled is set to true.
  8552. */
  8553. vignetteColor: Color4;
  8554. /**
  8555. * Camera field of view used by the Vignette effect.
  8556. */
  8557. vignetteCameraFov: number;
  8558. private _vignetteBlendMode;
  8559. /**
  8560. * Gets the vignette blend mode allowing different kind of effect.
  8561. */
  8562. get vignetteBlendMode(): number;
  8563. /**
  8564. * Sets the vignette blend mode allowing different kind of effect.
  8565. */
  8566. set vignetteBlendMode(value: number);
  8567. private _vignetteEnabled;
  8568. /**
  8569. * Gets wether the vignette effect is enabled.
  8570. */
  8571. get vignetteEnabled(): boolean;
  8572. /**
  8573. * Sets wether the vignette effect is enabled.
  8574. */
  8575. set vignetteEnabled(value: boolean);
  8576. private _applyByPostProcess;
  8577. /**
  8578. * Gets wether the image processing is applied through a post process or not.
  8579. */
  8580. get applyByPostProcess(): boolean;
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. set applyByPostProcess(value: boolean);
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. get isEnabled(): boolean;
  8590. /**
  8591. * Sets wether the image processing is enabled or not.
  8592. */
  8593. set isEnabled(value: boolean);
  8594. /**
  8595. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. /**
  8603. * Gets the current class name.
  8604. * @return "ImageProcessingConfiguration"
  8605. */
  8606. getClassName(): string;
  8607. /**
  8608. * Prepare the list of uniforms associated with the Image Processing effects.
  8609. * @param uniforms The list of uniforms used in the effect
  8610. * @param defines the list of defines currently in use
  8611. */
  8612. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8613. /**
  8614. * Prepare the list of samplers associated with the Image Processing effects.
  8615. * @param samplersList The list of uniforms used in the effect
  8616. * @param defines the list of defines currently in use
  8617. */
  8618. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8619. /**
  8620. * Prepare the list of defines associated to the shader.
  8621. * @param defines the list of defines to complete
  8622. * @param forPostProcess Define if we are currently in post process mode or not
  8623. */
  8624. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8625. /**
  8626. * Returns true if all the image processing information are ready.
  8627. * @returns True if ready, otherwise, false
  8628. */
  8629. isReady(): boolean;
  8630. /**
  8631. * Binds the image processing to the shader.
  8632. * @param effect The effect to bind to
  8633. * @param overrideAspectRatio Override the aspect ratio of the effect
  8634. */
  8635. bind(effect: Effect, overrideAspectRatio?: number): void;
  8636. /**
  8637. * Clones the current image processing instance.
  8638. * @return The cloned image processing
  8639. */
  8640. clone(): ImageProcessingConfiguration;
  8641. /**
  8642. * Serializes the current image processing instance to a json representation.
  8643. * @return a JSON representation
  8644. */
  8645. serialize(): any;
  8646. /**
  8647. * Parses the image processing from a json representation.
  8648. * @param source the JSON source to parse
  8649. * @return The parsed image processing
  8650. */
  8651. static Parse(source: any): ImageProcessingConfiguration;
  8652. private static _VIGNETTEMODE_MULTIPLY;
  8653. private static _VIGNETTEMODE_OPAQUE;
  8654. /**
  8655. * Used to apply the vignette as a mix with the pixel color.
  8656. */
  8657. static get VIGNETTEMODE_MULTIPLY(): number;
  8658. /**
  8659. * Used to apply the vignette as a replacement of the pixel color.
  8660. */
  8661. static get VIGNETTEMODE_OPAQUE(): number;
  8662. }
  8663. }
  8664. declare module "babylonjs/Shaders/postprocess.vertex" {
  8665. /** @hidden */
  8666. export var postprocessVertexShader: {
  8667. name: string;
  8668. shader: string;
  8669. };
  8670. }
  8671. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8673. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8674. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8675. module "babylonjs/Engines/thinEngine" {
  8676. interface ThinEngine {
  8677. /**
  8678. * Creates a new render target texture
  8679. * @param size defines the size of the texture
  8680. * @param options defines the options used to create the texture
  8681. * @returns a new render target texture stored in an InternalTexture
  8682. */
  8683. createRenderTargetTexture(size: number | {
  8684. width: number;
  8685. height: number;
  8686. layers?: number;
  8687. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8688. /**
  8689. * Creates a depth stencil texture.
  8690. * This is only available in WebGL 2 or with the depth texture extension available.
  8691. * @param size The size of face edge in the texture.
  8692. * @param options The options defining the texture.
  8693. * @returns The texture
  8694. */
  8695. createDepthStencilTexture(size: number | {
  8696. width: number;
  8697. height: number;
  8698. layers?: number;
  8699. }, options: DepthTextureCreationOptions): InternalTexture;
  8700. /** @hidden */
  8701. _createDepthStencilTexture(size: number | {
  8702. width: number;
  8703. height: number;
  8704. layers?: number;
  8705. }, options: DepthTextureCreationOptions): InternalTexture;
  8706. }
  8707. }
  8708. }
  8709. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8710. /**
  8711. * Defines the kind of connection point for node based material
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointTypes {
  8714. /** Float */
  8715. Float = 1,
  8716. /** Int */
  8717. Int = 2,
  8718. /** Vector2 */
  8719. Vector2 = 4,
  8720. /** Vector3 */
  8721. Vector3 = 8,
  8722. /** Vector4 */
  8723. Vector4 = 16,
  8724. /** Color3 */
  8725. Color3 = 32,
  8726. /** Color4 */
  8727. Color4 = 64,
  8728. /** Matrix */
  8729. Matrix = 128,
  8730. /** Custom object */
  8731. Object = 256,
  8732. /** Detect type based on connection */
  8733. AutoDetect = 1024,
  8734. /** Output type that will be defined by input type */
  8735. BasedOnInput = 2048
  8736. }
  8737. }
  8738. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8739. /**
  8740. * Enum used to define the target of a block
  8741. */
  8742. export enum NodeMaterialBlockTargets {
  8743. /** Vertex shader */
  8744. Vertex = 1,
  8745. /** Fragment shader */
  8746. Fragment = 2,
  8747. /** Neutral */
  8748. Neutral = 4,
  8749. /** Vertex and Fragment */
  8750. VertexAndFragment = 3
  8751. }
  8752. }
  8753. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8754. /**
  8755. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8756. */
  8757. export enum NodeMaterialBlockConnectionPointMode {
  8758. /** Value is an uniform */
  8759. Uniform = 0,
  8760. /** Value is a mesh attribute */
  8761. Attribute = 1,
  8762. /** Value is a varying between vertex and fragment shaders */
  8763. Varying = 2,
  8764. /** Mode is undefined */
  8765. Undefined = 3
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8769. /**
  8770. * Enum used to define system values e.g. values automatically provided by the system
  8771. */
  8772. export enum NodeMaterialSystemValues {
  8773. /** World */
  8774. World = 1,
  8775. /** View */
  8776. View = 2,
  8777. /** Projection */
  8778. Projection = 3,
  8779. /** ViewProjection */
  8780. ViewProjection = 4,
  8781. /** WorldView */
  8782. WorldView = 5,
  8783. /** WorldViewProjection */
  8784. WorldViewProjection = 6,
  8785. /** CameraPosition */
  8786. CameraPosition = 7,
  8787. /** Fog Color */
  8788. FogColor = 8,
  8789. /** Delta time */
  8790. DeltaTime = 9
  8791. }
  8792. }
  8793. declare module "babylonjs/Maths/math.axis" {
  8794. import { Vector3 } from "babylonjs/Maths/math.vector";
  8795. /** Defines supported spaces */
  8796. export enum Space {
  8797. /** Local (object) space */
  8798. LOCAL = 0,
  8799. /** World space */
  8800. WORLD = 1,
  8801. /** Bone space */
  8802. BONE = 2
  8803. }
  8804. /** Defines the 3 main axes */
  8805. export class Axis {
  8806. /** X axis */
  8807. static X: Vector3;
  8808. /** Y axis */
  8809. static Y: Vector3;
  8810. /** Z axis */
  8811. static Z: Vector3;
  8812. }
  8813. }
  8814. declare module "babylonjs/Maths/math.frustum" {
  8815. import { Matrix } from "babylonjs/Maths/math.vector";
  8816. import { DeepImmutable } from "babylonjs/types";
  8817. import { Plane } from "babylonjs/Maths/math.plane";
  8818. /**
  8819. * Represents a camera frustum
  8820. */
  8821. export class Frustum {
  8822. /**
  8823. * Gets the planes representing the frustum
  8824. * @param transform matrix to be applied to the returned planes
  8825. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8826. */
  8827. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8828. /**
  8829. * Gets the near frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the far frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the left frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Gets the right frustum plane transformed by the transform matrix
  8848. * @param transform transformation matrix to be applied to the resulting frustum plane
  8849. * @param frustumPlane the resuling frustum plane
  8850. */
  8851. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8852. /**
  8853. * Gets the top frustum plane transformed by the transform matrix
  8854. * @param transform transformation matrix to be applied to the resulting frustum plane
  8855. * @param frustumPlane the resuling frustum plane
  8856. */
  8857. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8858. /**
  8859. * Gets the bottom frustum plane transformed by the transform matrix
  8860. * @param transform transformation matrix to be applied to the resulting frustum plane
  8861. * @param frustumPlane the resuling frustum plane
  8862. */
  8863. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8864. /**
  8865. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8866. * @param transform transformation matrix to be applied to the resulting frustum planes
  8867. * @param frustumPlanes the resuling frustum planes
  8868. */
  8869. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8870. }
  8871. }
  8872. declare module "babylonjs/Maths/math.size" {
  8873. /**
  8874. * Interface for the size containing width and height
  8875. */
  8876. export interface ISize {
  8877. /**
  8878. * Width
  8879. */
  8880. width: number;
  8881. /**
  8882. * Heighht
  8883. */
  8884. height: number;
  8885. }
  8886. /**
  8887. * Size containing widht and height
  8888. */
  8889. export class Size implements ISize {
  8890. /**
  8891. * Width
  8892. */
  8893. width: number;
  8894. /**
  8895. * Height
  8896. */
  8897. height: number;
  8898. /**
  8899. * Creates a Size object from the given width and height (floats).
  8900. * @param width width of the new size
  8901. * @param height height of the new size
  8902. */
  8903. constructor(width: number, height: number);
  8904. /**
  8905. * Returns a string with the Size width and height
  8906. * @returns a string with the Size width and height
  8907. */
  8908. toString(): string;
  8909. /**
  8910. * "Size"
  8911. * @returns the string "Size"
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Returns the Size hash code.
  8916. * @returns a hash code for a unique width and height
  8917. */
  8918. getHashCode(): number;
  8919. /**
  8920. * Updates the current size from the given one.
  8921. * @param src the given size
  8922. */
  8923. copyFrom(src: Size): void;
  8924. /**
  8925. * Updates in place the current Size from the given floats.
  8926. * @param width width of the new size
  8927. * @param height height of the new size
  8928. * @returns the updated Size.
  8929. */
  8930. copyFromFloats(width: number, height: number): Size;
  8931. /**
  8932. * Updates in place the current Size from the given floats.
  8933. * @param width width to set
  8934. * @param height height to set
  8935. * @returns the updated Size.
  8936. */
  8937. set(width: number, height: number): Size;
  8938. /**
  8939. * Multiplies the width and height by numbers
  8940. * @param w factor to multiple the width by
  8941. * @param h factor to multiple the height by
  8942. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8943. */
  8944. multiplyByFloats(w: number, h: number): Size;
  8945. /**
  8946. * Clones the size
  8947. * @returns a new Size copied from the given one.
  8948. */
  8949. clone(): Size;
  8950. /**
  8951. * True if the current Size and the given one width and height are strictly equal.
  8952. * @param other the other size to compare against
  8953. * @returns True if the current Size and the given one width and height are strictly equal.
  8954. */
  8955. equals(other: Size): boolean;
  8956. /**
  8957. * The surface of the Size : width * height (float).
  8958. */
  8959. get surface(): number;
  8960. /**
  8961. * Create a new size of zero
  8962. * @returns a new Size set to (0.0, 0.0)
  8963. */
  8964. static Zero(): Size;
  8965. /**
  8966. * Sums the width and height of two sizes
  8967. * @param otherSize size to add to this size
  8968. * @returns a new Size set as the addition result of the current Size and the given one.
  8969. */
  8970. add(otherSize: Size): Size;
  8971. /**
  8972. * Subtracts the width and height of two
  8973. * @param otherSize size to subtract to this size
  8974. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8975. */
  8976. subtract(otherSize: Size): Size;
  8977. /**
  8978. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8979. * @param start starting size to lerp between
  8980. * @param end end size to lerp between
  8981. * @param amount amount to lerp between the start and end values
  8982. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8983. */
  8984. static Lerp(start: Size, end: Size, amount: number): Size;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.vertexFormat" {
  8988. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8989. /**
  8990. * Contains position and normal vectors for a vertex
  8991. */
  8992. export class PositionNormalVertex {
  8993. /** the position of the vertex (defaut: 0,0,0) */
  8994. position: Vector3;
  8995. /** the normal of the vertex (defaut: 0,1,0) */
  8996. normal: Vector3;
  8997. /**
  8998. * Creates a PositionNormalVertex
  8999. * @param position the position of the vertex (defaut: 0,0,0)
  9000. * @param normal the normal of the vertex (defaut: 0,1,0)
  9001. */
  9002. constructor(
  9003. /** the position of the vertex (defaut: 0,0,0) */
  9004. position?: Vector3,
  9005. /** the normal of the vertex (defaut: 0,1,0) */
  9006. normal?: Vector3);
  9007. /**
  9008. * Clones the PositionNormalVertex
  9009. * @returns the cloned PositionNormalVertex
  9010. */
  9011. clone(): PositionNormalVertex;
  9012. }
  9013. /**
  9014. * Contains position, normal and uv vectors for a vertex
  9015. */
  9016. export class PositionNormalTextureVertex {
  9017. /** the position of the vertex (defaut: 0,0,0) */
  9018. position: Vector3;
  9019. /** the normal of the vertex (defaut: 0,1,0) */
  9020. normal: Vector3;
  9021. /** the uv of the vertex (default: 0,0) */
  9022. uv: Vector2;
  9023. /**
  9024. * Creates a PositionNormalTextureVertex
  9025. * @param position the position of the vertex (defaut: 0,0,0)
  9026. * @param normal the normal of the vertex (defaut: 0,1,0)
  9027. * @param uv the uv of the vertex (default: 0,0)
  9028. */
  9029. constructor(
  9030. /** the position of the vertex (defaut: 0,0,0) */
  9031. position?: Vector3,
  9032. /** the normal of the vertex (defaut: 0,1,0) */
  9033. normal?: Vector3,
  9034. /** the uv of the vertex (default: 0,0) */
  9035. uv?: Vector2);
  9036. /**
  9037. * Clones the PositionNormalTextureVertex
  9038. * @returns the cloned PositionNormalTextureVertex
  9039. */
  9040. clone(): PositionNormalTextureVertex;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math" {
  9044. export * from "babylonjs/Maths/math.axis";
  9045. export * from "babylonjs/Maths/math.color";
  9046. export * from "babylonjs/Maths/math.constants";
  9047. export * from "babylonjs/Maths/math.frustum";
  9048. export * from "babylonjs/Maths/math.path";
  9049. export * from "babylonjs/Maths/math.plane";
  9050. export * from "babylonjs/Maths/math.size";
  9051. export * from "babylonjs/Maths/math.vector";
  9052. export * from "babylonjs/Maths/math.vertexFormat";
  9053. export * from "babylonjs/Maths/math.viewport";
  9054. }
  9055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9056. /**
  9057. * Enum defining the type of animations supported by InputBlock
  9058. */
  9059. export enum AnimatedInputBlockTypes {
  9060. /** No animation */
  9061. None = 0,
  9062. /** Time based animation. Will only work for floats */
  9063. Time = 1
  9064. }
  9065. }
  9066. declare module "babylonjs/Lights/shadowLight" {
  9067. import { Camera } from "babylonjs/Cameras/camera";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. /**
  9073. * Interface describing all the common properties and methods a shadow light needs to implement.
  9074. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9075. * as well as binding the different shadow properties to the effects.
  9076. */
  9077. export interface IShadowLight extends Light {
  9078. /**
  9079. * The light id in the scene (used in scene.findLighById for instance)
  9080. */
  9081. id: string;
  9082. /**
  9083. * The position the shdow will be casted from.
  9084. */
  9085. position: Vector3;
  9086. /**
  9087. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9088. */
  9089. direction: Vector3;
  9090. /**
  9091. * The transformed position. Position of the light in world space taking parenting in account.
  9092. */
  9093. transformedPosition: Vector3;
  9094. /**
  9095. * The transformed direction. Direction of the light in world space taking parenting in account.
  9096. */
  9097. transformedDirection: Vector3;
  9098. /**
  9099. * The friendly name of the light in the scene.
  9100. */
  9101. name: string;
  9102. /**
  9103. * Defines the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. /**
  9107. * Defines the shadow projection clipping maximum z value.
  9108. */
  9109. shadowMaxZ: number;
  9110. /**
  9111. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9112. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9113. */
  9114. computeTransformedInformation(): boolean;
  9115. /**
  9116. * Gets the scene the light belongs to.
  9117. * @returns The scene
  9118. */
  9119. getScene(): Scene;
  9120. /**
  9121. * Callback defining a custom Projection Matrix Builder.
  9122. * This can be used to override the default projection matrix computation.
  9123. */
  9124. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9125. /**
  9126. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9127. * @param matrix The materix to updated with the projection information
  9128. * @param viewMatrix The transform matrix of the light
  9129. * @param renderList The list of mesh to render in the map
  9130. * @returns The current light
  9131. */
  9132. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9133. /**
  9134. * Gets the current depth scale used in ESM.
  9135. * @returns The scale
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. }
  9171. /**
  9172. * Base implementation IShadowLight
  9173. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9174. */
  9175. export abstract class ShadowLight extends Light implements IShadowLight {
  9176. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9177. protected _position: Vector3;
  9178. protected _setPosition(value: Vector3): void;
  9179. /**
  9180. * Sets the position the shadow will be casted from. Also use as the light position for both
  9181. * point and spot lights.
  9182. */
  9183. get position(): Vector3;
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. set position(value: Vector3);
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. get direction(): Vector3;
  9196. /**
  9197. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9198. * Also use as the light direction on spot and directional lights.
  9199. */
  9200. set direction(value: Vector3);
  9201. protected _shadowMinZ: number;
  9202. /**
  9203. * Gets the shadow projection clipping minimum z value.
  9204. */
  9205. get shadowMinZ(): number;
  9206. /**
  9207. * Sets the shadow projection clipping minimum z value.
  9208. */
  9209. set shadowMinZ(value: number);
  9210. protected _shadowMaxZ: number;
  9211. /**
  9212. * Sets the shadow projection clipping maximum z value.
  9213. */
  9214. get shadowMaxZ(): number;
  9215. /**
  9216. * Gets the shadow projection clipping maximum z value.
  9217. */
  9218. set shadowMaxZ(value: number);
  9219. /**
  9220. * Callback defining a custom Projection Matrix Builder.
  9221. * This can be used to override the default projection matrix computation.
  9222. */
  9223. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9224. /**
  9225. * The transformed position. Position of the light in world space taking parenting in account.
  9226. */
  9227. transformedPosition: Vector3;
  9228. /**
  9229. * The transformed direction. Direction of the light in world space taking parenting in account.
  9230. */
  9231. transformedDirection: Vector3;
  9232. private _needProjectionMatrixCompute;
  9233. /**
  9234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9236. */
  9237. computeTransformedInformation(): boolean;
  9238. /**
  9239. * Return the depth scale used for the shadow map.
  9240. * @returns the depth scale.
  9241. */
  9242. getDepthScale(): number;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Returns the ShadowLight absolute position in the World.
  9251. * @returns the position vector in world space
  9252. */
  9253. getAbsolutePosition(): Vector3;
  9254. /**
  9255. * Sets the ShadowLight direction toward the passed target.
  9256. * @param target The point to target in local space
  9257. * @returns the updated ShadowLight direction
  9258. */
  9259. setDirectionToTarget(target: Vector3): Vector3;
  9260. /**
  9261. * Returns the light rotation in euler definition.
  9262. * @returns the x y z rotation in local space.
  9263. */
  9264. getRotation(): Vector3;
  9265. /**
  9266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9267. * @returns true if a cube texture needs to be use
  9268. */
  9269. needCube(): boolean;
  9270. /**
  9271. * Detects if the projection matrix requires to be recomputed this frame.
  9272. * @returns true if it requires to be recomputed otherwise, false.
  9273. */
  9274. needProjectionMatrixCompute(): boolean;
  9275. /**
  9276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9277. */
  9278. forceProjectionMatrixCompute(): void;
  9279. /** @hidden */
  9280. _initCache(): void;
  9281. /** @hidden */
  9282. _isSynchronized(): boolean;
  9283. /**
  9284. * Computes the world matrix of the node
  9285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9286. * @returns the world matrix
  9287. */
  9288. computeWorldMatrix(force?: boolean): Matrix;
  9289. /**
  9290. * Gets the minZ used for shadow according to both the scene and the light.
  9291. * @param activeCamera The camera we are returning the min for
  9292. * @returns the depth min z
  9293. */
  9294. getDepthMinZ(activeCamera: Camera): number;
  9295. /**
  9296. * Gets the maxZ used for shadow according to both the scene and the light.
  9297. * @param activeCamera The camera we are returning the max for
  9298. * @returns the depth max z
  9299. */
  9300. getDepthMaxZ(activeCamera: Camera): number;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. }
  9310. }
  9311. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9312. /** @hidden */
  9313. export var packingFunctions: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9319. /** @hidden */
  9320. export var bayerDitherFunctions: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9327. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9328. /** @hidden */
  9329. export var shadowMapFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9335. /** @hidden */
  9336. export var clipPlaneFragmentDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9342. /** @hidden */
  9343. export var clipPlaneFragment: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9349. /** @hidden */
  9350. export var shadowMapFragment: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9357. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9359. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9402. /** @hidden */
  9403. export var shadowMapVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9409. /** @hidden */
  9410. export var clipPlaneVertexDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9416. /** @hidden */
  9417. export var morphTargetsVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9423. /** @hidden */
  9424. export var instancesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9430. /** @hidden */
  9431. export var bonesVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9437. /** @hidden */
  9438. export var shadowMapVertexNormalBias: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9444. /** @hidden */
  9445. export var shadowMapVertexMetric: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9451. /** @hidden */
  9452. export var clipPlaneVertex: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9463. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9468. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9469. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9471. /** @hidden */
  9472. export var shadowMapVertexShader: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9478. /** @hidden */
  9479. export var depthBoxBlurPixelShader: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9485. /** @hidden */
  9486. export var shadowMapFragmentSoftTransparentShadow: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Materials/effectFallbacks" {
  9492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9493. import { Effect } from "babylonjs/Materials/effect";
  9494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9495. /**
  9496. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9497. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9498. */
  9499. export class EffectFallbacks implements IEffectFallbacks {
  9500. private _defines;
  9501. private _currentRank;
  9502. private _maxRank;
  9503. private _mesh;
  9504. /**
  9505. * Removes the fallback from the bound mesh.
  9506. */
  9507. unBindMesh(): void;
  9508. /**
  9509. * Adds a fallback on the specified property.
  9510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9511. * @param define The name of the define in the shader
  9512. */
  9513. addFallback(rank: number, define: string): void;
  9514. /**
  9515. * Sets the mesh to use CPU skinning when needing to fallback.
  9516. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9517. * @param mesh The mesh to use the fallbacks.
  9518. */
  9519. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9520. /**
  9521. * Checks to see if more fallbacks are still availible.
  9522. */
  9523. get hasMoreFallbacks(): boolean;
  9524. /**
  9525. * Removes the defines that should be removed when falling back.
  9526. * @param currentDefines defines the current define statements for the shader.
  9527. * @param effect defines the current effect we try to compile
  9528. * @returns The resulting defines with defines of the current rank removed.
  9529. */
  9530. reduce(currentDefines: string, effect: Effect): string;
  9531. }
  9532. }
  9533. declare module "babylonjs/Actions/action" {
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Condition } from "babylonjs/Actions/condition";
  9536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9537. import { Scene } from "babylonjs/scene";
  9538. import { ActionManager } from "babylonjs/Actions/actionManager";
  9539. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9540. import { Node } from "babylonjs/node";
  9541. /**
  9542. * Interface used to define Action
  9543. */
  9544. export interface IAction {
  9545. /**
  9546. * Trigger for the action
  9547. */
  9548. trigger: number;
  9549. /** Options of the trigger */
  9550. triggerOptions: any;
  9551. /**
  9552. * Gets the trigger parameters
  9553. * @returns the trigger parameters
  9554. */
  9555. getTriggerParameter(): any;
  9556. /**
  9557. * Internal only - executes current action event
  9558. * @hidden
  9559. */
  9560. _executeCurrent(evt?: ActionEvent): void;
  9561. /**
  9562. * Serialize placeholder for child classes
  9563. * @param parent of child
  9564. * @returns the serialized object
  9565. */
  9566. serialize(parent: any): any;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _prepare(): void;
  9572. /**
  9573. * Internal only - manager for action
  9574. * @hidden
  9575. */
  9576. _actionManager: AbstractActionManager;
  9577. /**
  9578. * Adds action to chain of actions, may be a DoNothingAction
  9579. * @param action defines the next action to execute
  9580. * @returns The action passed in
  9581. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9582. */
  9583. then(action: IAction): IAction;
  9584. }
  9585. /**
  9586. * The action to be carried out following a trigger
  9587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9588. */
  9589. export class Action implements IAction {
  9590. /** the trigger, with or without parameters, for the action */
  9591. triggerOptions: any;
  9592. /**
  9593. * Trigger for the action
  9594. */
  9595. trigger: number;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. private _nextActiveAction;
  9602. private _child;
  9603. private _condition?;
  9604. private _triggerParameter;
  9605. /**
  9606. * An event triggered prior to action being executed.
  9607. */
  9608. onBeforeExecuteObservable: Observable<Action>;
  9609. /**
  9610. * Creates a new Action
  9611. * @param triggerOptions the trigger, with or without parameters, for the action
  9612. * @param condition an optional determinant of action
  9613. */
  9614. constructor(
  9615. /** the trigger, with or without parameters, for the action */
  9616. triggerOptions: any, condition?: Condition);
  9617. /**
  9618. * Internal only
  9619. * @hidden
  9620. */
  9621. _prepare(): void;
  9622. /**
  9623. * Gets the trigger parameters
  9624. * @returns the trigger parameters
  9625. */
  9626. getTriggerParameter(): any;
  9627. /**
  9628. * Internal only - executes current action event
  9629. * @hidden
  9630. */
  9631. _executeCurrent(evt?: ActionEvent): void;
  9632. /**
  9633. * Execute placeholder for child classes
  9634. * @param evt optional action event
  9635. */
  9636. execute(evt?: ActionEvent): void;
  9637. /**
  9638. * Skips to next active action
  9639. */
  9640. skipToNextActiveAction(): void;
  9641. /**
  9642. * Adds action to chain of actions, may be a DoNothingAction
  9643. * @param action defines the next action to execute
  9644. * @returns The action passed in
  9645. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9646. */
  9647. then(action: Action): Action;
  9648. /**
  9649. * Internal only
  9650. * @hidden
  9651. */
  9652. _getProperty(propertyPath: string): string;
  9653. /**
  9654. * Internal only
  9655. * @hidden
  9656. */
  9657. _getEffectiveTarget(target: any, propertyPath: string): any;
  9658. /**
  9659. * Serialize placeholder for child classes
  9660. * @param parent of child
  9661. * @returns the serialized object
  9662. */
  9663. serialize(parent: any): any;
  9664. /**
  9665. * Internal only called by serialize
  9666. * @hidden
  9667. */
  9668. protected _serialize(serializedAction: any, parent?: any): any;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. static _SerializeValueAsString: (value: any) => string;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. static _GetTargetProperty: (target: Scene | Node) => {
  9679. name: string;
  9680. targetType: string;
  9681. value: string;
  9682. };
  9683. }
  9684. }
  9685. declare module "babylonjs/Actions/condition" {
  9686. import { ActionManager } from "babylonjs/Actions/actionManager";
  9687. /**
  9688. * A Condition applied to an Action
  9689. */
  9690. export class Condition {
  9691. /**
  9692. * Internal only - manager for action
  9693. * @hidden
  9694. */
  9695. _actionManager: ActionManager;
  9696. /**
  9697. * Internal only
  9698. * @hidden
  9699. */
  9700. _evaluationId: number;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. _currentResult: boolean;
  9706. /**
  9707. * Creates a new Condition
  9708. * @param actionManager the manager of the action the condition is applied to
  9709. */
  9710. constructor(actionManager: ActionManager);
  9711. /**
  9712. * Check if the current condition is valid
  9713. * @returns a boolean
  9714. */
  9715. isValid(): boolean;
  9716. /**
  9717. * Internal only
  9718. * @hidden
  9719. */
  9720. _getProperty(propertyPath: string): string;
  9721. /**
  9722. * Internal only
  9723. * @hidden
  9724. */
  9725. _getEffectiveTarget(target: any, propertyPath: string): any;
  9726. /**
  9727. * Serialize placeholder for child classes
  9728. * @returns the serialized object
  9729. */
  9730. serialize(): any;
  9731. /**
  9732. * Internal only
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedCondition: any): any;
  9736. }
  9737. /**
  9738. * Defines specific conditional operators as extensions of Condition
  9739. */
  9740. export class ValueCondition extends Condition {
  9741. /** path to specify the property of the target the conditional operator uses */
  9742. propertyPath: string;
  9743. /** the value compared by the conditional operator against the current value of the property */
  9744. value: any;
  9745. /** the conditional operator, default ValueCondition.IsEqual */
  9746. operator: number;
  9747. /**
  9748. * Internal only
  9749. * @hidden
  9750. */
  9751. private static _IsEqual;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. private static _IsDifferent;
  9757. /**
  9758. * Internal only
  9759. * @hidden
  9760. */
  9761. private static _IsGreater;
  9762. /**
  9763. * Internal only
  9764. * @hidden
  9765. */
  9766. private static _IsLesser;
  9767. /**
  9768. * returns the number for IsEqual
  9769. */
  9770. static get IsEqual(): number;
  9771. /**
  9772. * Returns the number for IsDifferent
  9773. */
  9774. static get IsDifferent(): number;
  9775. /**
  9776. * Returns the number for IsGreater
  9777. */
  9778. static get IsGreater(): number;
  9779. /**
  9780. * Returns the number for IsLesser
  9781. */
  9782. static get IsLesser(): number;
  9783. /**
  9784. * Internal only The action manager for the condition
  9785. * @hidden
  9786. */
  9787. _actionManager: ActionManager;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. private _target;
  9793. /**
  9794. * Internal only
  9795. * @hidden
  9796. */
  9797. private _effectiveTarget;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. private _property;
  9803. /**
  9804. * Creates a new ValueCondition
  9805. * @param actionManager manager for the action the condition applies to
  9806. * @param target for the action
  9807. * @param propertyPath path to specify the property of the target the conditional operator uses
  9808. * @param value the value compared by the conditional operator against the current value of the property
  9809. * @param operator the conditional operator, default ValueCondition.IsEqual
  9810. */
  9811. constructor(actionManager: ActionManager, target: any,
  9812. /** path to specify the property of the target the conditional operator uses */
  9813. propertyPath: string,
  9814. /** the value compared by the conditional operator against the current value of the property */
  9815. value: any,
  9816. /** the conditional operator, default ValueCondition.IsEqual */
  9817. operator?: number);
  9818. /**
  9819. * Compares the given value with the property value for the specified conditional operator
  9820. * @returns the result of the comparison
  9821. */
  9822. isValid(): boolean;
  9823. /**
  9824. * Serialize the ValueCondition into a JSON compatible object
  9825. * @returns serialization object
  9826. */
  9827. serialize(): any;
  9828. /**
  9829. * Gets the name of the conditional operator for the ValueCondition
  9830. * @param operator the conditional operator
  9831. * @returns the name
  9832. */
  9833. static GetOperatorName(operator: number): string;
  9834. }
  9835. /**
  9836. * Defines a predicate condition as an extension of Condition
  9837. */
  9838. export class PredicateCondition extends Condition {
  9839. /** defines the predicate function used to validate the condition */
  9840. predicate: () => boolean;
  9841. /**
  9842. * Internal only - manager for action
  9843. * @hidden
  9844. */
  9845. _actionManager: ActionManager;
  9846. /**
  9847. * Creates a new PredicateCondition
  9848. * @param actionManager manager for the action the condition applies to
  9849. * @param predicate defines the predicate function used to validate the condition
  9850. */
  9851. constructor(actionManager: ActionManager,
  9852. /** defines the predicate function used to validate the condition */
  9853. predicate: () => boolean);
  9854. /**
  9855. * @returns the validity of the predicate condition
  9856. */
  9857. isValid(): boolean;
  9858. }
  9859. /**
  9860. * Defines a state condition as an extension of Condition
  9861. */
  9862. export class StateCondition extends Condition {
  9863. /** Value to compare with target state */
  9864. value: string;
  9865. /**
  9866. * Internal only - manager for action
  9867. * @hidden
  9868. */
  9869. _actionManager: ActionManager;
  9870. /**
  9871. * Internal only
  9872. * @hidden
  9873. */
  9874. private _target;
  9875. /**
  9876. * Creates a new StateCondition
  9877. * @param actionManager manager for the action the condition applies to
  9878. * @param target of the condition
  9879. * @param value to compare with target state
  9880. */
  9881. constructor(actionManager: ActionManager, target: any,
  9882. /** Value to compare with target state */
  9883. value: string);
  9884. /**
  9885. * Gets a boolean indicating if the current condition is met
  9886. * @returns the validity of the state
  9887. */
  9888. isValid(): boolean;
  9889. /**
  9890. * Serialize the StateCondition into a JSON compatible object
  9891. * @returns serialization object
  9892. */
  9893. serialize(): any;
  9894. }
  9895. }
  9896. declare module "babylonjs/Actions/directActions" {
  9897. import { Action } from "babylonjs/Actions/action";
  9898. import { Condition } from "babylonjs/Actions/condition";
  9899. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9900. /**
  9901. * This defines an action responsible to toggle a boolean once triggered.
  9902. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9903. */
  9904. export class SwitchBooleanAction extends Action {
  9905. /**
  9906. * The path to the boolean property in the target object
  9907. */
  9908. propertyPath: string;
  9909. private _target;
  9910. private _effectiveTarget;
  9911. private _property;
  9912. /**
  9913. * Instantiate the action
  9914. * @param triggerOptions defines the trigger options
  9915. * @param target defines the object containing the boolean
  9916. * @param propertyPath defines the path to the boolean property in the target object
  9917. * @param condition defines the trigger related conditions
  9918. */
  9919. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9920. /** @hidden */
  9921. _prepare(): void;
  9922. /**
  9923. * Execute the action toggle the boolean value.
  9924. */
  9925. execute(): void;
  9926. /**
  9927. * Serializes the actions and its related information.
  9928. * @param parent defines the object to serialize in
  9929. * @returns the serialized object
  9930. */
  9931. serialize(parent: any): any;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set a the state field of the target
  9935. * to a desired value once triggered.
  9936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9937. */
  9938. export class SetStateAction extends Action {
  9939. /**
  9940. * The value to store in the state field.
  9941. */
  9942. value: string;
  9943. private _target;
  9944. /**
  9945. * Instantiate the action
  9946. * @param triggerOptions defines the trigger options
  9947. * @param target defines the object containing the state property
  9948. * @param value defines the value to store in the state field
  9949. * @param condition defines the trigger related conditions
  9950. */
  9951. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9952. /**
  9953. * Execute the action and store the value on the target state property.
  9954. */
  9955. execute(): void;
  9956. /**
  9957. * Serializes the actions and its related information.
  9958. * @param parent defines the object to serialize in
  9959. * @returns the serialized object
  9960. */
  9961. serialize(parent: any): any;
  9962. }
  9963. /**
  9964. * This defines an action responsible to set a property of the target
  9965. * to a desired value once triggered.
  9966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class SetValueAction extends Action {
  9969. /**
  9970. * The path of the property to set in the target.
  9971. */
  9972. propertyPath: string;
  9973. /**
  9974. * The value to set in the property
  9975. */
  9976. value: any;
  9977. private _target;
  9978. private _effectiveTarget;
  9979. private _property;
  9980. /**
  9981. * Instantiate the action
  9982. * @param triggerOptions defines the trigger options
  9983. * @param target defines the object containing the property
  9984. * @param propertyPath defines the path of the property to set in the target
  9985. * @param value defines the value to set in the property
  9986. * @param condition defines the trigger related conditions
  9987. */
  9988. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9989. /** @hidden */
  9990. _prepare(): void;
  9991. /**
  9992. * Execute the action and set the targetted property to the desired value.
  9993. */
  9994. execute(): void;
  9995. /**
  9996. * Serializes the actions and its related information.
  9997. * @param parent defines the object to serialize in
  9998. * @returns the serialized object
  9999. */
  10000. serialize(parent: any): any;
  10001. }
  10002. /**
  10003. * This defines an action responsible to increment the target value
  10004. * to a desired value once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class IncrementValueAction extends Action {
  10008. /**
  10009. * The path of the property to increment in the target.
  10010. */
  10011. propertyPath: string;
  10012. /**
  10013. * The value we should increment the property by.
  10014. */
  10015. value: any;
  10016. private _target;
  10017. private _effectiveTarget;
  10018. private _property;
  10019. /**
  10020. * Instantiate the action
  10021. * @param triggerOptions defines the trigger options
  10022. * @param target defines the object containing the property
  10023. * @param propertyPath defines the path of the property to increment in the target
  10024. * @param value defines the value value we should increment the property by
  10025. * @param condition defines the trigger related conditions
  10026. */
  10027. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10028. /** @hidden */
  10029. _prepare(): void;
  10030. /**
  10031. * Execute the action and increment the target of the value amount.
  10032. */
  10033. execute(): void;
  10034. /**
  10035. * Serializes the actions and its related information.
  10036. * @param parent defines the object to serialize in
  10037. * @returns the serialized object
  10038. */
  10039. serialize(parent: any): any;
  10040. }
  10041. /**
  10042. * This defines an action responsible to start an animation once triggered.
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10044. */
  10045. export class PlayAnimationAction extends Action {
  10046. /**
  10047. * Where the animation should start (animation frame)
  10048. */
  10049. from: number;
  10050. /**
  10051. * Where the animation should stop (animation frame)
  10052. */
  10053. to: number;
  10054. /**
  10055. * Define if the animation should loop or stop after the first play.
  10056. */
  10057. loop?: boolean;
  10058. private _target;
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param target defines the target animation or animation name
  10063. * @param from defines from where the animation should start (animation frame)
  10064. * @param end defines where the animation should stop (animation frame)
  10065. * @param loop defines if the animation should loop or stop after the first play
  10066. * @param condition defines the trigger related conditions
  10067. */
  10068. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10069. /** @hidden */
  10070. _prepare(): void;
  10071. /**
  10072. * Execute the action and play the animation.
  10073. */
  10074. execute(): void;
  10075. /**
  10076. * Serializes the actions and its related information.
  10077. * @param parent defines the object to serialize in
  10078. * @returns the serialized object
  10079. */
  10080. serialize(parent: any): any;
  10081. }
  10082. /**
  10083. * This defines an action responsible to stop an animation once triggered.
  10084. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10085. */
  10086. export class StopAnimationAction extends Action {
  10087. private _target;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param target defines the target animation or animation name
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and stop the animation.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible that does nothing once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class DoNothingAction extends Action {
  10113. /**
  10114. * Instantiate the action
  10115. * @param triggerOptions defines the trigger options
  10116. * @param condition defines the trigger related conditions
  10117. */
  10118. constructor(triggerOptions?: any, condition?: Condition);
  10119. /**
  10120. * Execute the action and do nothing.
  10121. */
  10122. execute(): void;
  10123. /**
  10124. * Serializes the actions and its related information.
  10125. * @param parent defines the object to serialize in
  10126. * @returns the serialized object
  10127. */
  10128. serialize(parent: any): any;
  10129. }
  10130. /**
  10131. * This defines an action responsible to trigger several actions once triggered.
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10133. */
  10134. export class CombineAction extends Action {
  10135. /**
  10136. * The list of aggregated animations to run.
  10137. */
  10138. children: Action[];
  10139. /**
  10140. * Instantiate the action
  10141. * @param triggerOptions defines the trigger options
  10142. * @param children defines the list of aggregated animations to run
  10143. * @param condition defines the trigger related conditions
  10144. */
  10145. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10146. /** @hidden */
  10147. _prepare(): void;
  10148. /**
  10149. * Execute the action and executes all the aggregated actions.
  10150. */
  10151. execute(evt: ActionEvent): void;
  10152. /**
  10153. * Serializes the actions and its related information.
  10154. * @param parent defines the object to serialize in
  10155. * @returns the serialized object
  10156. */
  10157. serialize(parent: any): any;
  10158. }
  10159. /**
  10160. * This defines an action responsible to run code (external event) once triggered.
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10162. */
  10163. export class ExecuteCodeAction extends Action {
  10164. /**
  10165. * The callback function to run.
  10166. */
  10167. func: (evt: ActionEvent) => void;
  10168. /**
  10169. * Instantiate the action
  10170. * @param triggerOptions defines the trigger options
  10171. * @param func defines the callback function to run
  10172. * @param condition defines the trigger related conditions
  10173. */
  10174. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10175. /**
  10176. * Execute the action and run the attached code.
  10177. */
  10178. execute(evt: ActionEvent): void;
  10179. }
  10180. /**
  10181. * This defines an action responsible to set the parent property of the target once triggered.
  10182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10183. */
  10184. export class SetParentAction extends Action {
  10185. private _parent;
  10186. private _target;
  10187. /**
  10188. * Instantiate the action
  10189. * @param triggerOptions defines the trigger options
  10190. * @param target defines the target containing the parent property
  10191. * @param parent defines from where the animation should start (animation frame)
  10192. * @param condition defines the trigger related conditions
  10193. */
  10194. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10195. /** @hidden */
  10196. _prepare(): void;
  10197. /**
  10198. * Execute the action and set the parent property.
  10199. */
  10200. execute(): void;
  10201. /**
  10202. * Serializes the actions and its related information.
  10203. * @param parent defines the object to serialize in
  10204. * @returns the serialized object
  10205. */
  10206. serialize(parent: any): any;
  10207. }
  10208. }
  10209. declare module "babylonjs/Actions/actionManager" {
  10210. import { Nullable } from "babylonjs/types";
  10211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10212. import { Scene } from "babylonjs/scene";
  10213. import { IAction } from "babylonjs/Actions/action";
  10214. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10216. /**
  10217. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10218. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class ActionManager extends AbstractActionManager {
  10222. /**
  10223. * Nothing
  10224. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10225. */
  10226. static readonly NothingTrigger: number;
  10227. /**
  10228. * On pick
  10229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10230. */
  10231. static readonly OnPickTrigger: number;
  10232. /**
  10233. * On left pick
  10234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10235. */
  10236. static readonly OnLeftPickTrigger: number;
  10237. /**
  10238. * On right pick
  10239. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10240. */
  10241. static readonly OnRightPickTrigger: number;
  10242. /**
  10243. * On center pick
  10244. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10245. */
  10246. static readonly OnCenterPickTrigger: number;
  10247. /**
  10248. * On pick down
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10250. */
  10251. static readonly OnPickDownTrigger: number;
  10252. /**
  10253. * On double pick
  10254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10255. */
  10256. static readonly OnDoublePickTrigger: number;
  10257. /**
  10258. * On pick up
  10259. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10260. */
  10261. static readonly OnPickUpTrigger: number;
  10262. /**
  10263. * On pick out.
  10264. * This trigger will only be raised if you also declared a OnPickDown
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnPickOutTrigger: number;
  10268. /**
  10269. * On long press
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnLongPressTrigger: number;
  10273. /**
  10274. * On pointer over
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnPointerOverTrigger: number;
  10278. /**
  10279. * On pointer out
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnPointerOutTrigger: number;
  10283. /**
  10284. * On every frame
  10285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10286. */
  10287. static readonly OnEveryFrameTrigger: number;
  10288. /**
  10289. * On intersection enter
  10290. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10291. */
  10292. static readonly OnIntersectionEnterTrigger: number;
  10293. /**
  10294. * On intersection exit
  10295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10296. */
  10297. static readonly OnIntersectionExitTrigger: number;
  10298. /**
  10299. * On key down
  10300. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10301. */
  10302. static readonly OnKeyDownTrigger: number;
  10303. /**
  10304. * On key up
  10305. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10306. */
  10307. static readonly OnKeyUpTrigger: number;
  10308. private _scene;
  10309. /**
  10310. * Creates a new action manager
  10311. * @param scene defines the hosting scene
  10312. */
  10313. constructor(scene: Scene);
  10314. /**
  10315. * Releases all associated resources
  10316. */
  10317. dispose(): void;
  10318. /**
  10319. * Gets hosting scene
  10320. * @returns the hosting scene
  10321. */
  10322. getScene(): Scene;
  10323. /**
  10324. * Does this action manager handles actions of any of the given triggers
  10325. * @param triggers defines the triggers to be tested
  10326. * @return a boolean indicating whether one (or more) of the triggers is handled
  10327. */
  10328. hasSpecificTriggers(triggers: number[]): boolean;
  10329. /**
  10330. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10331. * speed.
  10332. * @param triggerA defines the trigger to be tested
  10333. * @param triggerB defines the trigger to be tested
  10334. * @return a boolean indicating whether one (or more) of the triggers is handled
  10335. */
  10336. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10337. /**
  10338. * Does this action manager handles actions of a given trigger
  10339. * @param trigger defines the trigger to be tested
  10340. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10341. * @return whether the trigger is handled
  10342. */
  10343. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10344. /**
  10345. * Does this action manager has pointer triggers
  10346. */
  10347. get hasPointerTriggers(): boolean;
  10348. /**
  10349. * Does this action manager has pick triggers
  10350. */
  10351. get hasPickTriggers(): boolean;
  10352. /**
  10353. * Registers an action to this action manager
  10354. * @param action defines the action to be registered
  10355. * @return the action amended (prepared) after registration
  10356. */
  10357. registerAction(action: IAction): Nullable<IAction>;
  10358. /**
  10359. * Unregisters an action to this action manager
  10360. * @param action defines the action to be unregistered
  10361. * @return a boolean indicating whether the action has been unregistered
  10362. */
  10363. unregisterAction(action: IAction): Boolean;
  10364. /**
  10365. * Process a specific trigger
  10366. * @param trigger defines the trigger to process
  10367. * @param evt defines the event details to be processed
  10368. */
  10369. processTrigger(trigger: number, evt?: IActionEvent): void;
  10370. /** @hidden */
  10371. _getEffectiveTarget(target: any, propertyPath: string): any;
  10372. /** @hidden */
  10373. _getProperty(propertyPath: string): string;
  10374. /**
  10375. * Serialize this manager to a JSON object
  10376. * @param name defines the property name to store this manager
  10377. * @returns a JSON representation of this manager
  10378. */
  10379. serialize(name: string): any;
  10380. /**
  10381. * Creates a new ActionManager from a JSON data
  10382. * @param parsedActions defines the JSON data to read from
  10383. * @param object defines the hosting mesh
  10384. * @param scene defines the hosting scene
  10385. */
  10386. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10387. /**
  10388. * Get a trigger name by index
  10389. * @param trigger defines the trigger index
  10390. * @returns a trigger name
  10391. */
  10392. static GetTriggerName(trigger: number): string;
  10393. }
  10394. }
  10395. declare module "babylonjs/Sprites/sprite" {
  10396. import { Vector3 } from "babylonjs/Maths/math.vector";
  10397. import { Nullable } from "babylonjs/types";
  10398. import { ActionManager } from "babylonjs/Actions/actionManager";
  10399. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10400. import { Color4 } from "babylonjs/Maths/math.color";
  10401. import { Observable } from "babylonjs/Misc/observable";
  10402. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10403. import { Animation } from "babylonjs/Animations/animation";
  10404. /**
  10405. * Class used to represent a sprite
  10406. * @see https://doc.babylonjs.com/babylon101/sprites
  10407. */
  10408. export class Sprite implements IAnimatable {
  10409. /** defines the name */
  10410. name: string;
  10411. /** Gets or sets the current world position */
  10412. position: Vector3;
  10413. /** Gets or sets the main color */
  10414. color: Color4;
  10415. /** Gets or sets the width */
  10416. width: number;
  10417. /** Gets or sets the height */
  10418. height: number;
  10419. /** Gets or sets rotation angle */
  10420. angle: number;
  10421. /** Gets or sets the cell index in the sprite sheet */
  10422. cellIndex: number;
  10423. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10424. cellRef: string;
  10425. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10426. invertU: boolean;
  10427. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10428. invertV: boolean;
  10429. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10430. disposeWhenFinishedAnimating: boolean;
  10431. /** Gets the list of attached animations */
  10432. animations: Nullable<Array<Animation>>;
  10433. /** Gets or sets a boolean indicating if the sprite can be picked */
  10434. isPickable: boolean;
  10435. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10436. useAlphaForPicking: boolean;
  10437. /** @hidden */
  10438. _xOffset: number;
  10439. /** @hidden */
  10440. _yOffset: number;
  10441. /** @hidden */
  10442. _xSize: number;
  10443. /** @hidden */
  10444. _ySize: number;
  10445. /**
  10446. * Gets or sets the associated action manager
  10447. */
  10448. actionManager: Nullable<ActionManager>;
  10449. /**
  10450. * An event triggered when the control has been disposed
  10451. */
  10452. onDisposeObservable: Observable<Sprite>;
  10453. private _animationStarted;
  10454. private _loopAnimation;
  10455. private _fromIndex;
  10456. private _toIndex;
  10457. private _delay;
  10458. private _direction;
  10459. private _manager;
  10460. private _time;
  10461. private _onAnimationEnd;
  10462. /**
  10463. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10464. */
  10465. isVisible: boolean;
  10466. /**
  10467. * Gets or sets the sprite size
  10468. */
  10469. get size(): number;
  10470. set size(value: number);
  10471. /**
  10472. * Returns a boolean indicating if the animation is started
  10473. */
  10474. get animationStarted(): boolean;
  10475. /**
  10476. * Gets or sets the unique id of the sprite
  10477. */
  10478. uniqueId: number;
  10479. /**
  10480. * Gets the manager of this sprite
  10481. */
  10482. get manager(): ISpriteManager;
  10483. /**
  10484. * Creates a new Sprite
  10485. * @param name defines the name
  10486. * @param manager defines the manager
  10487. */
  10488. constructor(
  10489. /** defines the name */
  10490. name: string, manager: ISpriteManager);
  10491. /**
  10492. * Returns the string "Sprite"
  10493. * @returns "Sprite"
  10494. */
  10495. getClassName(): string;
  10496. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10497. get fromIndex(): number;
  10498. set fromIndex(value: number);
  10499. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10500. get toIndex(): number;
  10501. set toIndex(value: number);
  10502. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10503. get loopAnimation(): boolean;
  10504. set loopAnimation(value: boolean);
  10505. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10506. get delay(): number;
  10507. set delay(value: number);
  10508. /**
  10509. * Starts an animation
  10510. * @param from defines the initial key
  10511. * @param to defines the end key
  10512. * @param loop defines if the animation must loop
  10513. * @param delay defines the start delay (in ms)
  10514. * @param onAnimationEnd defines a callback to call when animation ends
  10515. */
  10516. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10517. /** Stops current animation (if any) */
  10518. stopAnimation(): void;
  10519. /** @hidden */
  10520. _animate(deltaTime: number): void;
  10521. /** Release associated resources */
  10522. dispose(): void;
  10523. /**
  10524. * Serializes the sprite to a JSON object
  10525. * @returns the JSON object
  10526. */
  10527. serialize(): any;
  10528. /**
  10529. * Parses a JSON object to create a new sprite
  10530. * @param parsedSprite The JSON object to parse
  10531. * @param manager defines the hosting manager
  10532. * @returns the new sprite
  10533. */
  10534. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10535. }
  10536. }
  10537. declare module "babylonjs/Collisions/pickingInfo" {
  10538. import { Nullable } from "babylonjs/types";
  10539. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10540. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10541. import { Sprite } from "babylonjs/Sprites/sprite";
  10542. import { Ray } from "babylonjs/Culling/ray";
  10543. /**
  10544. * Information about the result of picking within a scene
  10545. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10546. */
  10547. export class PickingInfo {
  10548. /** @hidden */
  10549. _pickingUnavailable: boolean;
  10550. /**
  10551. * If the pick collided with an object
  10552. */
  10553. hit: boolean;
  10554. /**
  10555. * Distance away where the pick collided
  10556. */
  10557. distance: number;
  10558. /**
  10559. * The location of pick collision
  10560. */
  10561. pickedPoint: Nullable<Vector3>;
  10562. /**
  10563. * The mesh corresponding the the pick collision
  10564. */
  10565. pickedMesh: Nullable<AbstractMesh>;
  10566. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10567. bu: number;
  10568. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10569. bv: number;
  10570. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10571. faceId: number;
  10572. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10573. subMeshFaceId: number;
  10574. /** Id of the the submesh that was picked */
  10575. subMeshId: number;
  10576. /** If a sprite was picked, this will be the sprite the pick collided with */
  10577. pickedSprite: Nullable<Sprite>;
  10578. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10579. thinInstanceIndex: number;
  10580. /**
  10581. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10582. */
  10583. originMesh: Nullable<AbstractMesh>;
  10584. /**
  10585. * The ray that was used to perform the picking.
  10586. */
  10587. ray: Nullable<Ray>;
  10588. /**
  10589. * Gets the normal correspodning to the face the pick collided with
  10590. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10591. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10592. * @returns The normal correspodning to the face the pick collided with
  10593. */
  10594. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10595. /**
  10596. * Gets the texture coordinates of where the pick occured
  10597. * @returns the vector containing the coordnates of the texture
  10598. */
  10599. getTextureCoordinates(): Nullable<Vector2>;
  10600. }
  10601. }
  10602. declare module "babylonjs/Culling/ray" {
  10603. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10604. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10606. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10607. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10608. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10609. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10610. import { Plane } from "babylonjs/Maths/math.plane";
  10611. /**
  10612. * Class representing a ray with position and direction
  10613. */
  10614. export class Ray {
  10615. /** origin point */
  10616. origin: Vector3;
  10617. /** direction */
  10618. direction: Vector3;
  10619. /** length of the ray */
  10620. length: number;
  10621. private static readonly _TmpVector3;
  10622. private _tmpRay;
  10623. /**
  10624. * Creates a new ray
  10625. * @param origin origin point
  10626. * @param direction direction
  10627. * @param length length of the ray
  10628. */
  10629. constructor(
  10630. /** origin point */
  10631. origin: Vector3,
  10632. /** direction */
  10633. direction: Vector3,
  10634. /** length of the ray */
  10635. length?: number);
  10636. /**
  10637. * Checks if the ray intersects a box
  10638. * This does not account for the ray lenght by design to improve perfs.
  10639. * @param minimum bound of the box
  10640. * @param maximum bound of the box
  10641. * @param intersectionTreshold extra extend to be added to the box in all direction
  10642. * @returns if the box was hit
  10643. */
  10644. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10645. /**
  10646. * Checks if the ray intersects a box
  10647. * This does not account for the ray lenght by design to improve perfs.
  10648. * @param box the bounding box to check
  10649. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10650. * @returns if the box was hit
  10651. */
  10652. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10653. /**
  10654. * If the ray hits a sphere
  10655. * @param sphere the bounding sphere to check
  10656. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10657. * @returns true if it hits the sphere
  10658. */
  10659. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10660. /**
  10661. * If the ray hits a triange
  10662. * @param vertex0 triangle vertex
  10663. * @param vertex1 triangle vertex
  10664. * @param vertex2 triangle vertex
  10665. * @returns intersection information if hit
  10666. */
  10667. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10668. /**
  10669. * Checks if ray intersects a plane
  10670. * @param plane the plane to check
  10671. * @returns the distance away it was hit
  10672. */
  10673. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10674. /**
  10675. * Calculate the intercept of a ray on a given axis
  10676. * @param axis to check 'x' | 'y' | 'z'
  10677. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10678. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10679. */
  10680. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10681. /**
  10682. * Checks if ray intersects a mesh
  10683. * @param mesh the mesh to check
  10684. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10685. * @returns picking info of the intersecton
  10686. */
  10687. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10688. /**
  10689. * Checks if ray intersects a mesh
  10690. * @param meshes the meshes to check
  10691. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10692. * @param results array to store result in
  10693. * @returns Array of picking infos
  10694. */
  10695. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10696. private _comparePickingInfo;
  10697. private static smallnum;
  10698. private static rayl;
  10699. /**
  10700. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10701. * @param sega the first point of the segment to test the intersection against
  10702. * @param segb the second point of the segment to test the intersection against
  10703. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10704. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10705. */
  10706. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10707. /**
  10708. * Update the ray from viewport position
  10709. * @param x position
  10710. * @param y y position
  10711. * @param viewportWidth viewport width
  10712. * @param viewportHeight viewport height
  10713. * @param world world matrix
  10714. * @param view view matrix
  10715. * @param projection projection matrix
  10716. * @returns this ray updated
  10717. */
  10718. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10719. /**
  10720. * Creates a ray with origin and direction of 0,0,0
  10721. * @returns the new ray
  10722. */
  10723. static Zero(): Ray;
  10724. /**
  10725. * Creates a new ray from screen space and viewport
  10726. * @param x position
  10727. * @param y y position
  10728. * @param viewportWidth viewport width
  10729. * @param viewportHeight viewport height
  10730. * @param world world matrix
  10731. * @param view view matrix
  10732. * @param projection projection matrix
  10733. * @returns new ray
  10734. */
  10735. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10736. /**
  10737. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10738. * transformed to the given world matrix.
  10739. * @param origin The origin point
  10740. * @param end The end point
  10741. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10742. * @returns the new ray
  10743. */
  10744. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10745. /**
  10746. * Transforms a ray by a matrix
  10747. * @param ray ray to transform
  10748. * @param matrix matrix to apply
  10749. * @returns the resulting new ray
  10750. */
  10751. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10752. /**
  10753. * Transforms a ray by a matrix
  10754. * @param ray ray to transform
  10755. * @param matrix matrix to apply
  10756. * @param result ray to store result in
  10757. */
  10758. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10759. /**
  10760. * Unproject a ray from screen space to object space
  10761. * @param sourceX defines the screen space x coordinate to use
  10762. * @param sourceY defines the screen space y coordinate to use
  10763. * @param viewportWidth defines the current width of the viewport
  10764. * @param viewportHeight defines the current height of the viewport
  10765. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10766. * @param view defines the view matrix to use
  10767. * @param projection defines the projection matrix to use
  10768. */
  10769. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10770. }
  10771. /**
  10772. * Type used to define predicate used to select faces when a mesh intersection is detected
  10773. */
  10774. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10775. module "babylonjs/scene" {
  10776. interface Scene {
  10777. /** @hidden */
  10778. _tempPickingRay: Nullable<Ray>;
  10779. /** @hidden */
  10780. _cachedRayForTransform: Ray;
  10781. /** @hidden */
  10782. _pickWithRayInverseMatrix: Matrix;
  10783. /** @hidden */
  10784. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10785. /** @hidden */
  10786. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10787. /** @hidden */
  10788. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10789. }
  10790. }
  10791. }
  10792. declare module "babylonjs/sceneComponent" {
  10793. import { Scene } from "babylonjs/scene";
  10794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10795. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10796. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10797. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10798. import { Nullable } from "babylonjs/types";
  10799. import { Camera } from "babylonjs/Cameras/camera";
  10800. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10801. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10802. import { AbstractScene } from "babylonjs/abstractScene";
  10803. import { Mesh } from "babylonjs/Meshes/mesh";
  10804. /**
  10805. * Groups all the scene component constants in one place to ease maintenance.
  10806. * @hidden
  10807. */
  10808. export class SceneComponentConstants {
  10809. static readonly NAME_EFFECTLAYER: string;
  10810. static readonly NAME_LAYER: string;
  10811. static readonly NAME_LENSFLARESYSTEM: string;
  10812. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10813. static readonly NAME_PARTICLESYSTEM: string;
  10814. static readonly NAME_GAMEPAD: string;
  10815. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10816. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10817. static readonly NAME_PREPASSRENDERER: string;
  10818. static readonly NAME_DEPTHRENDERER: string;
  10819. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10820. static readonly NAME_SPRITE: string;
  10821. static readonly NAME_OUTLINERENDERER: string;
  10822. static readonly NAME_PROCEDURALTEXTURE: string;
  10823. static readonly NAME_SHADOWGENERATOR: string;
  10824. static readonly NAME_OCTREE: string;
  10825. static readonly NAME_PHYSICSENGINE: string;
  10826. static readonly NAME_AUDIO: string;
  10827. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10828. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10829. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10830. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10831. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10832. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10833. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10834. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10835. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10836. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10837. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10838. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10839. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10840. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10841. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10842. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10843. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10845. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10846. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10847. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10848. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10849. static readonly STEP_AFTERRENDER_AUDIO: number;
  10850. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10851. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10852. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10853. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10854. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10855. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10856. static readonly STEP_POINTERMOVE_SPRITE: number;
  10857. static readonly STEP_POINTERDOWN_SPRITE: number;
  10858. static readonly STEP_POINTERUP_SPRITE: number;
  10859. }
  10860. /**
  10861. * This represents a scene component.
  10862. *
  10863. * This is used to decouple the dependency the scene is having on the different workloads like
  10864. * layers, post processes...
  10865. */
  10866. export interface ISceneComponent {
  10867. /**
  10868. * The name of the component. Each component must have a unique name.
  10869. */
  10870. name: string;
  10871. /**
  10872. * The scene the component belongs to.
  10873. */
  10874. scene: Scene;
  10875. /**
  10876. * Register the component to one instance of a scene.
  10877. */
  10878. register(): void;
  10879. /**
  10880. * Rebuilds the elements related to this component in case of
  10881. * context lost for instance.
  10882. */
  10883. rebuild(): void;
  10884. /**
  10885. * Disposes the component and the associated ressources.
  10886. */
  10887. dispose(): void;
  10888. }
  10889. /**
  10890. * This represents a SERIALIZABLE scene component.
  10891. *
  10892. * This extends Scene Component to add Serialization methods on top.
  10893. */
  10894. export interface ISceneSerializableComponent extends ISceneComponent {
  10895. /**
  10896. * Adds all the elements from the container to the scene
  10897. * @param container the container holding the elements
  10898. */
  10899. addFromContainer(container: AbstractScene): void;
  10900. /**
  10901. * Removes all the elements in the container from the scene
  10902. * @param container contains the elements to remove
  10903. * @param dispose if the removed element should be disposed (default: false)
  10904. */
  10905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10906. /**
  10907. * Serializes the component data to the specified json object
  10908. * @param serializationObject The object to serialize to
  10909. */
  10910. serialize(serializationObject: any): void;
  10911. }
  10912. /**
  10913. * Strong typing of a Mesh related stage step action
  10914. */
  10915. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10916. /**
  10917. * Strong typing of a Evaluate Sub Mesh related stage step action
  10918. */
  10919. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10920. /**
  10921. * Strong typing of a Active Mesh related stage step action
  10922. */
  10923. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10924. /**
  10925. * Strong typing of a Camera related stage step action
  10926. */
  10927. export type CameraStageAction = (camera: Camera) => void;
  10928. /**
  10929. * Strong typing of a Camera Frame buffer related stage step action
  10930. */
  10931. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10932. /**
  10933. * Strong typing of a Render Target related stage step action
  10934. */
  10935. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10936. /**
  10937. * Strong typing of a RenderingGroup related stage step action
  10938. */
  10939. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10940. /**
  10941. * Strong typing of a Mesh Render related stage step action
  10942. */
  10943. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10944. /**
  10945. * Strong typing of a simple stage step action
  10946. */
  10947. export type SimpleStageAction = () => void;
  10948. /**
  10949. * Strong typing of a render target action.
  10950. */
  10951. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10952. /**
  10953. * Strong typing of a pointer move action.
  10954. */
  10955. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10956. /**
  10957. * Strong typing of a pointer up/down action.
  10958. */
  10959. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10960. /**
  10961. * Representation of a stage in the scene (Basically a list of ordered steps)
  10962. * @hidden
  10963. */
  10964. export class Stage<T extends Function> extends Array<{
  10965. index: number;
  10966. component: ISceneComponent;
  10967. action: T;
  10968. }> {
  10969. /**
  10970. * Hide ctor from the rest of the world.
  10971. * @param items The items to add.
  10972. */
  10973. private constructor();
  10974. /**
  10975. * Creates a new Stage.
  10976. * @returns A new instance of a Stage
  10977. */
  10978. static Create<T extends Function>(): Stage<T>;
  10979. /**
  10980. * Registers a step in an ordered way in the targeted stage.
  10981. * @param index Defines the position to register the step in
  10982. * @param component Defines the component attached to the step
  10983. * @param action Defines the action to launch during the step
  10984. */
  10985. registerStep(index: number, component: ISceneComponent, action: T): void;
  10986. /**
  10987. * Clears all the steps from the stage.
  10988. */
  10989. clear(): void;
  10990. }
  10991. }
  10992. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10993. import { Nullable } from "babylonjs/types";
  10994. import { Observable } from "babylonjs/Misc/observable";
  10995. import { Scene } from "babylonjs/scene";
  10996. import { Sprite } from "babylonjs/Sprites/sprite";
  10997. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10998. import { Ray } from "babylonjs/Culling/ray";
  10999. import { Camera } from "babylonjs/Cameras/camera";
  11000. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11001. import { ISceneComponent } from "babylonjs/sceneComponent";
  11002. module "babylonjs/scene" {
  11003. interface Scene {
  11004. /** @hidden */
  11005. _pointerOverSprite: Nullable<Sprite>;
  11006. /** @hidden */
  11007. _pickedDownSprite: Nullable<Sprite>;
  11008. /** @hidden */
  11009. _tempSpritePickingRay: Nullable<Ray>;
  11010. /**
  11011. * All of the sprite managers added to this scene
  11012. * @see https://doc.babylonjs.com/babylon101/sprites
  11013. */
  11014. spriteManagers: Array<ISpriteManager>;
  11015. /**
  11016. * An event triggered when sprites rendering is about to start
  11017. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11018. */
  11019. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11020. /**
  11021. * An event triggered when sprites rendering is done
  11022. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11023. */
  11024. onAfterSpritesRenderingObservable: Observable<Scene>;
  11025. /** @hidden */
  11026. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11027. /** Launch a ray to try to pick a sprite in the scene
  11028. * @param x position on screen
  11029. * @param y position on screen
  11030. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11031. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11032. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11033. * @returns a PickingInfo
  11034. */
  11035. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11036. /** Use the given ray to pick a sprite in the scene
  11037. * @param ray The ray (in world space) to use to pick meshes
  11038. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11039. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11040. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11041. * @returns a PickingInfo
  11042. */
  11043. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11044. /** @hidden */
  11045. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11046. /** Launch a ray to try to pick sprites in the scene
  11047. * @param x position on screen
  11048. * @param y position on screen
  11049. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11050. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11051. * @returns a PickingInfo array
  11052. */
  11053. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11054. /** Use the given ray to pick sprites in the scene
  11055. * @param ray The ray (in world space) to use to pick meshes
  11056. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11057. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11058. * @returns a PickingInfo array
  11059. */
  11060. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11061. /**
  11062. * Force the sprite under the pointer
  11063. * @param sprite defines the sprite to use
  11064. */
  11065. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11066. /**
  11067. * Gets the sprite under the pointer
  11068. * @returns a Sprite or null if no sprite is under the pointer
  11069. */
  11070. getPointerOverSprite(): Nullable<Sprite>;
  11071. }
  11072. }
  11073. /**
  11074. * Defines the sprite scene component responsible to manage sprites
  11075. * in a given scene.
  11076. */
  11077. export class SpriteSceneComponent implements ISceneComponent {
  11078. /**
  11079. * The component name helpfull to identify the component in the list of scene components.
  11080. */
  11081. readonly name: string;
  11082. /**
  11083. * The scene the component belongs to.
  11084. */
  11085. scene: Scene;
  11086. /** @hidden */
  11087. private _spritePredicate;
  11088. /**
  11089. * Creates a new instance of the component for the given scene
  11090. * @param scene Defines the scene to register the component in
  11091. */
  11092. constructor(scene: Scene);
  11093. /**
  11094. * Registers the component in a given scene
  11095. */
  11096. register(): void;
  11097. /**
  11098. * Rebuilds the elements related to this component in case of
  11099. * context lost for instance.
  11100. */
  11101. rebuild(): void;
  11102. /**
  11103. * Disposes the component and the associated ressources.
  11104. */
  11105. dispose(): void;
  11106. private _pickSpriteButKeepRay;
  11107. private _pointerMove;
  11108. private _pointerDown;
  11109. private _pointerUp;
  11110. }
  11111. }
  11112. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11113. /** @hidden */
  11114. export var fogFragmentDeclaration: {
  11115. name: string;
  11116. shader: string;
  11117. };
  11118. }
  11119. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11120. /** @hidden */
  11121. export var fogFragment: {
  11122. name: string;
  11123. shader: string;
  11124. };
  11125. }
  11126. declare module "babylonjs/Shaders/sprites.fragment" {
  11127. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11128. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11129. /** @hidden */
  11130. export var spritesPixelShader: {
  11131. name: string;
  11132. shader: string;
  11133. };
  11134. }
  11135. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11136. /** @hidden */
  11137. export var fogVertexDeclaration: {
  11138. name: string;
  11139. shader: string;
  11140. };
  11141. }
  11142. declare module "babylonjs/Shaders/sprites.vertex" {
  11143. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11144. /** @hidden */
  11145. export var spritesVertexShader: {
  11146. name: string;
  11147. shader: string;
  11148. };
  11149. }
  11150. declare module "babylonjs/Sprites/spriteManager" {
  11151. import { IDisposable, Scene } from "babylonjs/scene";
  11152. import { Nullable } from "babylonjs/types";
  11153. import { Observable } from "babylonjs/Misc/observable";
  11154. import { Sprite } from "babylonjs/Sprites/sprite";
  11155. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11156. import { Camera } from "babylonjs/Cameras/camera";
  11157. import { Texture } from "babylonjs/Materials/Textures/texture";
  11158. import "babylonjs/Shaders/sprites.fragment";
  11159. import "babylonjs/Shaders/sprites.vertex";
  11160. import { Ray } from "babylonjs/Culling/ray";
  11161. /**
  11162. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11163. */
  11164. export interface ISpriteManager extends IDisposable {
  11165. /**
  11166. * Gets manager's name
  11167. */
  11168. name: string;
  11169. /**
  11170. * Restricts the camera to viewing objects with the same layerMask.
  11171. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11172. */
  11173. layerMask: number;
  11174. /**
  11175. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11176. */
  11177. isPickable: boolean;
  11178. /**
  11179. * Gets the hosting scene
  11180. */
  11181. scene: Scene;
  11182. /**
  11183. * Specifies the rendering group id for this mesh (0 by default)
  11184. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11185. */
  11186. renderingGroupId: number;
  11187. /**
  11188. * Defines the list of sprites managed by the manager.
  11189. */
  11190. sprites: Array<Sprite>;
  11191. /**
  11192. * Gets or sets the spritesheet texture
  11193. */
  11194. texture: Texture;
  11195. /** Defines the default width of a cell in the spritesheet */
  11196. cellWidth: number;
  11197. /** Defines the default height of a cell in the spritesheet */
  11198. cellHeight: number;
  11199. /**
  11200. * Tests the intersection of a sprite with a specific ray.
  11201. * @param ray The ray we are sending to test the collision
  11202. * @param camera The camera space we are sending rays in
  11203. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11205. * @returns picking info or null.
  11206. */
  11207. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11208. /**
  11209. * Intersects the sprites with a ray
  11210. * @param ray defines the ray to intersect with
  11211. * @param camera defines the current active camera
  11212. * @param predicate defines a predicate used to select candidate sprites
  11213. * @returns null if no hit or a PickingInfo array
  11214. */
  11215. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11216. /**
  11217. * Renders the list of sprites on screen.
  11218. */
  11219. render(): void;
  11220. }
  11221. /**
  11222. * Class used to manage multiple sprites on the same spritesheet
  11223. * @see https://doc.babylonjs.com/babylon101/sprites
  11224. */
  11225. export class SpriteManager implements ISpriteManager {
  11226. /** defines the manager's name */
  11227. name: string;
  11228. /** Define the Url to load snippets */
  11229. static SnippetUrl: string;
  11230. /** Snippet ID if the manager was created from the snippet server */
  11231. snippetId: string;
  11232. /** Gets the list of sprites */
  11233. sprites: Sprite[];
  11234. /** Gets or sets the rendering group id (0 by default) */
  11235. renderingGroupId: number;
  11236. /** Gets or sets camera layer mask */
  11237. layerMask: number;
  11238. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11239. fogEnabled: boolean;
  11240. /** Gets or sets a boolean indicating if the sprites are pickable */
  11241. isPickable: boolean;
  11242. /** Defines the default width of a cell in the spritesheet */
  11243. cellWidth: number;
  11244. /** Defines the default height of a cell in the spritesheet */
  11245. cellHeight: number;
  11246. /** Associative array from JSON sprite data file */
  11247. private _cellData;
  11248. /** Array of sprite names from JSON sprite data file */
  11249. private _spriteMap;
  11250. /** True when packed cell data from JSON file is ready*/
  11251. private _packedAndReady;
  11252. private _textureContent;
  11253. /**
  11254. * An event triggered when the manager is disposed.
  11255. */
  11256. onDisposeObservable: Observable<SpriteManager>;
  11257. private _onDisposeObserver;
  11258. /**
  11259. * Callback called when the manager is disposed
  11260. */
  11261. set onDispose(callback: () => void);
  11262. private _capacity;
  11263. private _fromPacked;
  11264. private _spriteTexture;
  11265. private _epsilon;
  11266. private _scene;
  11267. private _vertexData;
  11268. private _buffer;
  11269. private _vertexBuffers;
  11270. private _indexBuffer;
  11271. private _effectBase;
  11272. private _effectFog;
  11273. /**
  11274. * Gets or sets the unique id of the sprite
  11275. */
  11276. uniqueId: number;
  11277. /**
  11278. * Gets the array of sprites
  11279. */
  11280. get children(): Sprite[];
  11281. /**
  11282. * Gets the hosting scene
  11283. */
  11284. get scene(): Scene;
  11285. /**
  11286. * Gets the capacity of the manager
  11287. */
  11288. get capacity(): number;
  11289. /**
  11290. * Gets or sets the spritesheet texture
  11291. */
  11292. get texture(): Texture;
  11293. set texture(value: Texture);
  11294. private _blendMode;
  11295. /**
  11296. * Blend mode use to render the particle, it can be any of
  11297. * the static Constants.ALPHA_x properties provided in this class.
  11298. * Default value is Constants.ALPHA_COMBINE
  11299. */
  11300. get blendMode(): number;
  11301. set blendMode(blendMode: number);
  11302. /** Disables writing to the depth buffer when rendering the sprites.
  11303. * It can be handy to disable depth writing when using textures without alpha channel
  11304. * and setting some specific blend modes.
  11305. */
  11306. disableDepthWrite: boolean;
  11307. /**
  11308. * Creates a new sprite manager
  11309. * @param name defines the manager's name
  11310. * @param imgUrl defines the sprite sheet url
  11311. * @param capacity defines the maximum allowed number of sprites
  11312. * @param cellSize defines the size of a sprite cell
  11313. * @param scene defines the hosting scene
  11314. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11315. * @param samplingMode defines the smapling mode to use with spritesheet
  11316. * @param fromPacked set to false; do not alter
  11317. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11318. */
  11319. constructor(
  11320. /** defines the manager's name */
  11321. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11322. /**
  11323. * Returns the string "SpriteManager"
  11324. * @returns "SpriteManager"
  11325. */
  11326. getClassName(): string;
  11327. private _makePacked;
  11328. private _appendSpriteVertex;
  11329. private _checkTextureAlpha;
  11330. /**
  11331. * Intersects the sprites with a ray
  11332. * @param ray defines the ray to intersect with
  11333. * @param camera defines the current active camera
  11334. * @param predicate defines a predicate used to select candidate sprites
  11335. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11336. * @returns null if no hit or a PickingInfo
  11337. */
  11338. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11339. /**
  11340. * Intersects the sprites with a ray
  11341. * @param ray defines the ray to intersect with
  11342. * @param camera defines the current active camera
  11343. * @param predicate defines a predicate used to select candidate sprites
  11344. * @returns null if no hit or a PickingInfo array
  11345. */
  11346. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11347. /**
  11348. * Render all child sprites
  11349. */
  11350. render(): void;
  11351. /**
  11352. * Release associated resources
  11353. */
  11354. dispose(): void;
  11355. /**
  11356. * Serializes the sprite manager to a JSON object
  11357. * @param serializeTexture defines if the texture must be serialized as well
  11358. * @returns the JSON object
  11359. */
  11360. serialize(serializeTexture?: boolean): any;
  11361. /**
  11362. * Parses a JSON object to create a new sprite manager.
  11363. * @param parsedManager The JSON object to parse
  11364. * @param scene The scene to create the sprite managerin
  11365. * @param rootUrl The root url to use to load external dependencies like texture
  11366. * @returns the new sprite manager
  11367. */
  11368. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11369. /**
  11370. * Creates a sprite manager from a snippet saved in a remote file
  11371. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11372. * @param url defines the url to load from
  11373. * @param scene defines the hosting scene
  11374. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11375. * @returns a promise that will resolve to the new sprite manager
  11376. */
  11377. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11378. /**
  11379. * Creates a sprite manager from a snippet saved by the sprite editor
  11380. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11381. * @param scene defines the hosting scene
  11382. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11383. * @returns a promise that will resolve to the new sprite manager
  11384. */
  11385. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11386. }
  11387. }
  11388. declare module "babylonjs/Misc/gradients" {
  11389. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11390. /** Interface used by value gradients (color, factor, ...) */
  11391. export interface IValueGradient {
  11392. /**
  11393. * Gets or sets the gradient value (between 0 and 1)
  11394. */
  11395. gradient: number;
  11396. }
  11397. /** Class used to store color4 gradient */
  11398. export class ColorGradient implements IValueGradient {
  11399. /**
  11400. * Gets or sets the gradient value (between 0 and 1)
  11401. */
  11402. gradient: number;
  11403. /**
  11404. * Gets or sets first associated color
  11405. */
  11406. color1: Color4;
  11407. /**
  11408. * Gets or sets second associated color
  11409. */
  11410. color2?: Color4 | undefined;
  11411. /**
  11412. * Creates a new color4 gradient
  11413. * @param gradient gets or sets the gradient value (between 0 and 1)
  11414. * @param color1 gets or sets first associated color
  11415. * @param color2 gets or sets first second color
  11416. */
  11417. constructor(
  11418. /**
  11419. * Gets or sets the gradient value (between 0 and 1)
  11420. */
  11421. gradient: number,
  11422. /**
  11423. * Gets or sets first associated color
  11424. */
  11425. color1: Color4,
  11426. /**
  11427. * Gets or sets second associated color
  11428. */
  11429. color2?: Color4 | undefined);
  11430. /**
  11431. * Will get a color picked randomly between color1 and color2.
  11432. * If color2 is undefined then color1 will be used
  11433. * @param result defines the target Color4 to store the result in
  11434. */
  11435. getColorToRef(result: Color4): void;
  11436. }
  11437. /** Class used to store color 3 gradient */
  11438. export class Color3Gradient implements IValueGradient {
  11439. /**
  11440. * Gets or sets the gradient value (between 0 and 1)
  11441. */
  11442. gradient: number;
  11443. /**
  11444. * Gets or sets the associated color
  11445. */
  11446. color: Color3;
  11447. /**
  11448. * Creates a new color3 gradient
  11449. * @param gradient gets or sets the gradient value (between 0 and 1)
  11450. * @param color gets or sets associated color
  11451. */
  11452. constructor(
  11453. /**
  11454. * Gets or sets the gradient value (between 0 and 1)
  11455. */
  11456. gradient: number,
  11457. /**
  11458. * Gets or sets the associated color
  11459. */
  11460. color: Color3);
  11461. }
  11462. /** Class used to store factor gradient */
  11463. export class FactorGradient implements IValueGradient {
  11464. /**
  11465. * Gets or sets the gradient value (between 0 and 1)
  11466. */
  11467. gradient: number;
  11468. /**
  11469. * Gets or sets first associated factor
  11470. */
  11471. factor1: number;
  11472. /**
  11473. * Gets or sets second associated factor
  11474. */
  11475. factor2?: number | undefined;
  11476. /**
  11477. * Creates a new factor gradient
  11478. * @param gradient gets or sets the gradient value (between 0 and 1)
  11479. * @param factor1 gets or sets first associated factor
  11480. * @param factor2 gets or sets second associated factor
  11481. */
  11482. constructor(
  11483. /**
  11484. * Gets or sets the gradient value (between 0 and 1)
  11485. */
  11486. gradient: number,
  11487. /**
  11488. * Gets or sets first associated factor
  11489. */
  11490. factor1: number,
  11491. /**
  11492. * Gets or sets second associated factor
  11493. */
  11494. factor2?: number | undefined);
  11495. /**
  11496. * Will get a number picked randomly between factor1 and factor2.
  11497. * If factor2 is undefined then factor1 will be used
  11498. * @returns the picked number
  11499. */
  11500. getFactor(): number;
  11501. }
  11502. /**
  11503. * Helper used to simplify some generic gradient tasks
  11504. */
  11505. export class GradientHelper {
  11506. /**
  11507. * Gets the current gradient from an array of IValueGradient
  11508. * @param ratio defines the current ratio to get
  11509. * @param gradients defines the array of IValueGradient
  11510. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11511. */
  11512. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11513. }
  11514. }
  11515. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11516. import { Nullable } from "babylonjs/types";
  11517. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11518. import { Scene } from "babylonjs/scene";
  11519. module "babylonjs/Engines/thinEngine" {
  11520. interface ThinEngine {
  11521. /**
  11522. * Creates a raw texture
  11523. * @param data defines the data to store in the texture
  11524. * @param width defines the width of the texture
  11525. * @param height defines the height of the texture
  11526. * @param format defines the format of the data
  11527. * @param generateMipMaps defines if the engine should generate the mip levels
  11528. * @param invertY defines if data must be stored with Y axis inverted
  11529. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11530. * @param compression defines the compression used (null by default)
  11531. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11532. * @returns the raw texture inside an InternalTexture
  11533. */
  11534. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11535. /**
  11536. * Update a raw texture
  11537. * @param texture defines the texture to update
  11538. * @param data defines the data to store in the texture
  11539. * @param format defines the format of the data
  11540. * @param invertY defines if data must be stored with Y axis inverted
  11541. */
  11542. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11543. /**
  11544. * Update a raw texture
  11545. * @param texture defines the texture to update
  11546. * @param data defines the data to store in the texture
  11547. * @param format defines the format of the data
  11548. * @param invertY defines if data must be stored with Y axis inverted
  11549. * @param compression defines the compression used (null by default)
  11550. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11551. */
  11552. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11553. /**
  11554. * Creates a new raw cube texture
  11555. * @param data defines the array of data to use to create each face
  11556. * @param size defines the size of the textures
  11557. * @param format defines the format of the data
  11558. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11559. * @param generateMipMaps defines if the engine should generate the mip levels
  11560. * @param invertY defines if data must be stored with Y axis inverted
  11561. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11562. * @param compression defines the compression used (null by default)
  11563. * @returns the cube texture as an InternalTexture
  11564. */
  11565. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11566. /**
  11567. * Update a raw cube texture
  11568. * @param texture defines the texture to udpdate
  11569. * @param data defines the data to store
  11570. * @param format defines the data format
  11571. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11572. * @param invertY defines if data must be stored with Y axis inverted
  11573. */
  11574. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11575. /**
  11576. * Update a raw cube texture
  11577. * @param texture defines the texture to udpdate
  11578. * @param data defines the data to store
  11579. * @param format defines the data format
  11580. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11581. * @param invertY defines if data must be stored with Y axis inverted
  11582. * @param compression defines the compression used (null by default)
  11583. */
  11584. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11585. /**
  11586. * Update a raw cube texture
  11587. * @param texture defines the texture to udpdate
  11588. * @param data defines the data to store
  11589. * @param format defines the data format
  11590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11591. * @param invertY defines if data must be stored with Y axis inverted
  11592. * @param compression defines the compression used (null by default)
  11593. * @param level defines which level of the texture to update
  11594. */
  11595. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11596. /**
  11597. * Creates a new raw cube texture from a specified url
  11598. * @param url defines the url where the data is located
  11599. * @param scene defines the current scene
  11600. * @param size defines the size of the textures
  11601. * @param format defines the format of the data
  11602. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11603. * @param noMipmap defines if the engine should avoid generating the mip levels
  11604. * @param callback defines a callback used to extract texture data from loaded data
  11605. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11606. * @param onLoad defines a callback called when texture is loaded
  11607. * @param onError defines a callback called if there is an error
  11608. * @returns the cube texture as an InternalTexture
  11609. */
  11610. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11611. /**
  11612. * Creates a new raw cube texture from a specified url
  11613. * @param url defines the url where the data is located
  11614. * @param scene defines the current scene
  11615. * @param size defines the size of the textures
  11616. * @param format defines the format of the data
  11617. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11618. * @param noMipmap defines if the engine should avoid generating the mip levels
  11619. * @param callback defines a callback used to extract texture data from loaded data
  11620. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11621. * @param onLoad defines a callback called when texture is loaded
  11622. * @param onError defines a callback called if there is an error
  11623. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11624. * @param invertY defines if data must be stored with Y axis inverted
  11625. * @returns the cube texture as an InternalTexture
  11626. */
  11627. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11628. /**
  11629. * Creates a new raw 3D texture
  11630. * @param data defines the data used to create the texture
  11631. * @param width defines the width of the texture
  11632. * @param height defines the height of the texture
  11633. * @param depth defines the depth of the texture
  11634. * @param format defines the format of the texture
  11635. * @param generateMipMaps defines if the engine must generate mip levels
  11636. * @param invertY defines if data must be stored with Y axis inverted
  11637. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11638. * @param compression defines the compressed used (can be null)
  11639. * @param textureType defines the compressed used (can be null)
  11640. * @returns a new raw 3D texture (stored in an InternalTexture)
  11641. */
  11642. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11643. /**
  11644. * Update a raw 3D texture
  11645. * @param texture defines the texture to update
  11646. * @param data defines the data to store
  11647. * @param format defines the data format
  11648. * @param invertY defines if data must be stored with Y axis inverted
  11649. */
  11650. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11651. /**
  11652. * Update a raw 3D texture
  11653. * @param texture defines the texture to update
  11654. * @param data defines the data to store
  11655. * @param format defines the data format
  11656. * @param invertY defines if data must be stored with Y axis inverted
  11657. * @param compression defines the used compression (can be null)
  11658. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11659. */
  11660. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11661. /**
  11662. * Creates a new raw 2D array texture
  11663. * @param data defines the data used to create the texture
  11664. * @param width defines the width of the texture
  11665. * @param height defines the height of the texture
  11666. * @param depth defines the number of layers of the texture
  11667. * @param format defines the format of the texture
  11668. * @param generateMipMaps defines if the engine must generate mip levels
  11669. * @param invertY defines if data must be stored with Y axis inverted
  11670. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11671. * @param compression defines the compressed used (can be null)
  11672. * @param textureType defines the compressed used (can be null)
  11673. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11674. */
  11675. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11676. /**
  11677. * Update a raw 2D array texture
  11678. * @param texture defines the texture to update
  11679. * @param data defines the data to store
  11680. * @param format defines the data format
  11681. * @param invertY defines if data must be stored with Y axis inverted
  11682. */
  11683. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11684. /**
  11685. * Update a raw 2D array texture
  11686. * @param texture defines the texture to update
  11687. * @param data defines the data to store
  11688. * @param format defines the data format
  11689. * @param invertY defines if data must be stored with Y axis inverted
  11690. * @param compression defines the used compression (can be null)
  11691. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11692. */
  11693. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11694. }
  11695. }
  11696. }
  11697. declare module "babylonjs/Materials/Textures/rawTexture" {
  11698. import { Scene } from "babylonjs/scene";
  11699. import { Texture } from "babylonjs/Materials/Textures/texture";
  11700. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11701. import { Nullable } from "babylonjs/types";
  11702. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11703. /**
  11704. * Raw texture can help creating a texture directly from an array of data.
  11705. * This can be super useful if you either get the data from an uncompressed source or
  11706. * if you wish to create your texture pixel by pixel.
  11707. */
  11708. export class RawTexture extends Texture {
  11709. /**
  11710. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11711. */
  11712. format: number;
  11713. /**
  11714. * Instantiates a new RawTexture.
  11715. * Raw texture can help creating a texture directly from an array of data.
  11716. * This can be super useful if you either get the data from an uncompressed source or
  11717. * if you wish to create your texture pixel by pixel.
  11718. * @param data define the array of data to use to create the texture
  11719. * @param width define the width of the texture
  11720. * @param height define the height of the texture
  11721. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11722. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11723. * @param generateMipMaps define whether mip maps should be generated or not
  11724. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11725. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11726. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11727. */
  11728. constructor(data: ArrayBufferView, width: number, height: number,
  11729. /**
  11730. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11731. */
  11732. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11733. /**
  11734. * Updates the texture underlying data.
  11735. * @param data Define the new data of the texture
  11736. */
  11737. update(data: ArrayBufferView): void;
  11738. /**
  11739. * Creates a luminance texture from some data.
  11740. * @param data Define the texture data
  11741. * @param width Define the width of the texture
  11742. * @param height Define the height of the texture
  11743. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11744. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11745. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11746. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11747. * @returns the luminance texture
  11748. */
  11749. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11750. /**
  11751. * Creates a luminance alpha texture from some data.
  11752. * @param data Define the texture data
  11753. * @param width Define the width of the texture
  11754. * @param height Define the height of the texture
  11755. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11756. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11757. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11758. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11759. * @returns the luminance alpha texture
  11760. */
  11761. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11762. /**
  11763. * Creates an alpha texture from some data.
  11764. * @param data Define the texture data
  11765. * @param width Define the width of the texture
  11766. * @param height Define the height of the texture
  11767. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11768. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11769. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11770. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11771. * @returns the alpha texture
  11772. */
  11773. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11774. /**
  11775. * Creates a RGB texture from some data.
  11776. * @param data Define the texture data
  11777. * @param width Define the width of the texture
  11778. * @param height Define the height of the texture
  11779. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11780. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11781. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11782. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11783. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11784. * @returns the RGB alpha texture
  11785. */
  11786. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11787. /**
  11788. * Creates a RGBA texture from some data.
  11789. * @param data Define the texture data
  11790. * @param width Define the width of the texture
  11791. * @param height Define the height of the texture
  11792. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11793. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11794. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11795. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11796. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11797. * @returns the RGBA texture
  11798. */
  11799. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11800. /**
  11801. * Creates a R texture from some data.
  11802. * @param data Define the texture data
  11803. * @param width Define the width of the texture
  11804. * @param height Define the height of the texture
  11805. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11806. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11807. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11808. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11809. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11810. * @returns the R texture
  11811. */
  11812. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11813. }
  11814. }
  11815. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11816. import { Scene } from "babylonjs/scene";
  11817. import { ISceneComponent } from "babylonjs/sceneComponent";
  11818. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11819. module "babylonjs/abstractScene" {
  11820. interface AbstractScene {
  11821. /**
  11822. * The list of procedural textures added to the scene
  11823. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11824. */
  11825. proceduralTextures: Array<ProceduralTexture>;
  11826. }
  11827. }
  11828. /**
  11829. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11830. * in a given scene.
  11831. */
  11832. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11833. /**
  11834. * The component name helpfull to identify the component in the list of scene components.
  11835. */
  11836. readonly name: string;
  11837. /**
  11838. * The scene the component belongs to.
  11839. */
  11840. scene: Scene;
  11841. /**
  11842. * Creates a new instance of the component for the given scene
  11843. * @param scene Defines the scene to register the component in
  11844. */
  11845. constructor(scene: Scene);
  11846. /**
  11847. * Registers the component in a given scene
  11848. */
  11849. register(): void;
  11850. /**
  11851. * Rebuilds the elements related to this component in case of
  11852. * context lost for instance.
  11853. */
  11854. rebuild(): void;
  11855. /**
  11856. * Disposes the component and the associated ressources.
  11857. */
  11858. dispose(): void;
  11859. private _beforeClear;
  11860. }
  11861. }
  11862. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11864. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11865. module "babylonjs/Engines/thinEngine" {
  11866. interface ThinEngine {
  11867. /**
  11868. * Creates a new render target cube texture
  11869. * @param size defines the size of the texture
  11870. * @param options defines the options used to create the texture
  11871. * @returns a new render target cube texture stored in an InternalTexture
  11872. */
  11873. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11874. }
  11875. }
  11876. }
  11877. declare module "babylonjs/Shaders/procedural.vertex" {
  11878. /** @hidden */
  11879. export var proceduralVertexShader: {
  11880. name: string;
  11881. shader: string;
  11882. };
  11883. }
  11884. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11885. import { Observable } from "babylonjs/Misc/observable";
  11886. import { Nullable } from "babylonjs/types";
  11887. import { Scene } from "babylonjs/scene";
  11888. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11889. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11890. import { Effect } from "babylonjs/Materials/effect";
  11891. import { Texture } from "babylonjs/Materials/Textures/texture";
  11892. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11893. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11894. import "babylonjs/Shaders/procedural.vertex";
  11895. /**
  11896. * 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.
  11897. * This is the base class of any Procedural texture and contains most of the shareable code.
  11898. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11899. */
  11900. export class ProceduralTexture extends Texture {
  11901. isCube: boolean;
  11902. /**
  11903. * Define if the texture is enabled or not (disabled texture will not render)
  11904. */
  11905. isEnabled: boolean;
  11906. /**
  11907. * Define if the texture must be cleared before rendering (default is true)
  11908. */
  11909. autoClear: boolean;
  11910. /**
  11911. * Callback called when the texture is generated
  11912. */
  11913. onGenerated: () => void;
  11914. /**
  11915. * Event raised when the texture is generated
  11916. */
  11917. onGeneratedObservable: Observable<ProceduralTexture>;
  11918. /** @hidden */
  11919. _generateMipMaps: boolean;
  11920. /** @hidden **/
  11921. _effect: Effect;
  11922. /** @hidden */
  11923. _textures: {
  11924. [key: string]: Texture;
  11925. };
  11926. /** @hidden */
  11927. protected _fallbackTexture: Nullable<Texture>;
  11928. private _size;
  11929. private _currentRefreshId;
  11930. private _frameId;
  11931. private _refreshRate;
  11932. private _vertexBuffers;
  11933. private _indexBuffer;
  11934. private _uniforms;
  11935. private _samplers;
  11936. private _fragment;
  11937. private _floats;
  11938. private _ints;
  11939. private _floatsArrays;
  11940. private _colors3;
  11941. private _colors4;
  11942. private _vectors2;
  11943. private _vectors3;
  11944. private _matrices;
  11945. private _fallbackTextureUsed;
  11946. private _fullEngine;
  11947. private _cachedDefines;
  11948. private _contentUpdateId;
  11949. private _contentData;
  11950. /**
  11951. * Instantiates a new procedural texture.
  11952. * 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.
  11953. * This is the base class of any Procedural texture and contains most of the shareable code.
  11954. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11955. * @param name Define the name of the texture
  11956. * @param size Define the size of the texture to create
  11957. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11958. * @param scene Define the scene the texture belongs to
  11959. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11960. * @param generateMipMaps Define if the texture should creates mip maps or not
  11961. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11962. */
  11963. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11964. /**
  11965. * The effect that is created when initializing the post process.
  11966. * @returns The created effect corresponding the the postprocess.
  11967. */
  11968. getEffect(): Effect;
  11969. /**
  11970. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11971. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11972. */
  11973. getContent(): Nullable<ArrayBufferView>;
  11974. private _createIndexBuffer;
  11975. /** @hidden */
  11976. _rebuild(): void;
  11977. /**
  11978. * Resets the texture in order to recreate its associated resources.
  11979. * This can be called in case of context loss
  11980. */
  11981. reset(): void;
  11982. protected _getDefines(): string;
  11983. /**
  11984. * Is the texture ready to be used ? (rendered at least once)
  11985. * @returns true if ready, otherwise, false.
  11986. */
  11987. isReady(): boolean;
  11988. /**
  11989. * Resets the refresh counter of the texture and start bak from scratch.
  11990. * Could be useful to regenerate the texture if it is setup to render only once.
  11991. */
  11992. resetRefreshCounter(): void;
  11993. /**
  11994. * Set the fragment shader to use in order to render the texture.
  11995. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11996. */
  11997. setFragment(fragment: any): void;
  11998. /**
  11999. * Define the refresh rate of the texture or the rendering frequency.
  12000. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12001. */
  12002. get refreshRate(): number;
  12003. set refreshRate(value: number);
  12004. /** @hidden */
  12005. _shouldRender(): boolean;
  12006. /**
  12007. * Get the size the texture is rendering at.
  12008. * @returns the size (texture is always squared)
  12009. */
  12010. getRenderSize(): number;
  12011. /**
  12012. * Resize the texture to new value.
  12013. * @param size Define the new size the texture should have
  12014. * @param generateMipMaps Define whether the new texture should create mip maps
  12015. */
  12016. resize(size: number, generateMipMaps: boolean): void;
  12017. private _checkUniform;
  12018. /**
  12019. * Set a texture in the shader program used to render.
  12020. * @param name Define the name of the uniform samplers as defined in the shader
  12021. * @param texture Define the texture to bind to this sampler
  12022. * @return the texture itself allowing "fluent" like uniform updates
  12023. */
  12024. setTexture(name: string, texture: Texture): ProceduralTexture;
  12025. /**
  12026. * Set a float in the shader.
  12027. * @param name Define the name of the uniform as defined in the shader
  12028. * @param value Define the value to give to the uniform
  12029. * @return the texture itself allowing "fluent" like uniform updates
  12030. */
  12031. setFloat(name: string, value: number): ProceduralTexture;
  12032. /**
  12033. * Set a int in the shader.
  12034. * @param name Define the name of the uniform as defined in the shader
  12035. * @param value Define the value to give to the uniform
  12036. * @return the texture itself allowing "fluent" like uniform updates
  12037. */
  12038. setInt(name: string, value: number): ProceduralTexture;
  12039. /**
  12040. * Set an array of floats in the shader.
  12041. * @param name Define the name of the uniform as defined in the shader
  12042. * @param value Define the value to give to the uniform
  12043. * @return the texture itself allowing "fluent" like uniform updates
  12044. */
  12045. setFloats(name: string, value: number[]): ProceduralTexture;
  12046. /**
  12047. * Set a vec3 in the shader from a Color3.
  12048. * @param name Define the name of the uniform as defined in the shader
  12049. * @param value Define the value to give to the uniform
  12050. * @return the texture itself allowing "fluent" like uniform updates
  12051. */
  12052. setColor3(name: string, value: Color3): ProceduralTexture;
  12053. /**
  12054. * Set a vec4 in the shader from a Color4.
  12055. * @param name Define the name of the uniform as defined in the shader
  12056. * @param value Define the value to give to the uniform
  12057. * @return the texture itself allowing "fluent" like uniform updates
  12058. */
  12059. setColor4(name: string, value: Color4): ProceduralTexture;
  12060. /**
  12061. * Set a vec2 in the shader from a Vector2.
  12062. * @param name Define the name of the uniform as defined in the shader
  12063. * @param value Define the value to give to the uniform
  12064. * @return the texture itself allowing "fluent" like uniform updates
  12065. */
  12066. setVector2(name: string, value: Vector2): ProceduralTexture;
  12067. /**
  12068. * Set a vec3 in the shader from a Vector3.
  12069. * @param name Define the name of the uniform as defined in the shader
  12070. * @param value Define the value to give to the uniform
  12071. * @return the texture itself allowing "fluent" like uniform updates
  12072. */
  12073. setVector3(name: string, value: Vector3): ProceduralTexture;
  12074. /**
  12075. * Set a mat4 in the shader from a MAtrix.
  12076. * @param name Define the name of the uniform as defined in the shader
  12077. * @param value Define the value to give to the uniform
  12078. * @return the texture itself allowing "fluent" like uniform updates
  12079. */
  12080. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12081. /**
  12082. * Render the texture to its associated render target.
  12083. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12084. */
  12085. render(useCameraPostProcess?: boolean): void;
  12086. /**
  12087. * Clone the texture.
  12088. * @returns the cloned texture
  12089. */
  12090. clone(): ProceduralTexture;
  12091. /**
  12092. * Dispose the texture and release its asoociated resources.
  12093. */
  12094. dispose(): void;
  12095. }
  12096. }
  12097. declare module "babylonjs/Particles/baseParticleSystem" {
  12098. import { Nullable } from "babylonjs/types";
  12099. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12101. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12102. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12103. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12104. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12105. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12106. import { Texture } from "babylonjs/Materials/Textures/texture";
  12107. import { Color4 } from "babylonjs/Maths/math.color";
  12108. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12109. import { Animation } from "babylonjs/Animations/animation";
  12110. import { Scene } from "babylonjs/scene";
  12111. /**
  12112. * This represents the base class for particle system in Babylon.
  12113. * 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.
  12114. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12115. * @example https://doc.babylonjs.com/babylon101/particles
  12116. */
  12117. export class BaseParticleSystem {
  12118. /**
  12119. * Source color is added to the destination color without alpha affecting the result
  12120. */
  12121. static BLENDMODE_ONEONE: number;
  12122. /**
  12123. * Blend current color and particle color using particle’s alpha
  12124. */
  12125. static BLENDMODE_STANDARD: number;
  12126. /**
  12127. * Add current color and particle color multiplied by particle’s alpha
  12128. */
  12129. static BLENDMODE_ADD: number;
  12130. /**
  12131. * Multiply current color with particle color
  12132. */
  12133. static BLENDMODE_MULTIPLY: number;
  12134. /**
  12135. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12136. */
  12137. static BLENDMODE_MULTIPLYADD: number;
  12138. /**
  12139. * List of animations used by the particle system.
  12140. */
  12141. animations: Animation[];
  12142. /**
  12143. * Gets or sets the unique id of the particle system
  12144. */
  12145. uniqueId: number;
  12146. /**
  12147. * The id of the Particle system.
  12148. */
  12149. id: string;
  12150. /**
  12151. * The friendly name of the Particle system.
  12152. */
  12153. name: string;
  12154. /**
  12155. * Snippet ID if the particle system was created from the snippet server
  12156. */
  12157. snippetId: string;
  12158. /**
  12159. * The rendering group used by the Particle system to chose when to render.
  12160. */
  12161. renderingGroupId: number;
  12162. /**
  12163. * The emitter represents the Mesh or position we are attaching the particle system to.
  12164. */
  12165. emitter: Nullable<AbstractMesh | Vector3>;
  12166. /**
  12167. * The maximum number of particles to emit per frame
  12168. */
  12169. emitRate: number;
  12170. /**
  12171. * If you want to launch only a few particles at once, that can be done, as well.
  12172. */
  12173. manualEmitCount: number;
  12174. /**
  12175. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12176. */
  12177. updateSpeed: number;
  12178. /**
  12179. * The amount of time the particle system is running (depends of the overall update speed).
  12180. */
  12181. targetStopDuration: number;
  12182. /**
  12183. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12184. */
  12185. disposeOnStop: boolean;
  12186. /**
  12187. * Minimum power of emitting particles.
  12188. */
  12189. minEmitPower: number;
  12190. /**
  12191. * Maximum power of emitting particles.
  12192. */
  12193. maxEmitPower: number;
  12194. /**
  12195. * Minimum life time of emitting particles.
  12196. */
  12197. minLifeTime: number;
  12198. /**
  12199. * Maximum life time of emitting particles.
  12200. */
  12201. maxLifeTime: number;
  12202. /**
  12203. * Minimum Size of emitting particles.
  12204. */
  12205. minSize: number;
  12206. /**
  12207. * Maximum Size of emitting particles.
  12208. */
  12209. maxSize: number;
  12210. /**
  12211. * Minimum scale of emitting particles on X axis.
  12212. */
  12213. minScaleX: number;
  12214. /**
  12215. * Maximum scale of emitting particles on X axis.
  12216. */
  12217. maxScaleX: number;
  12218. /**
  12219. * Minimum scale of emitting particles on Y axis.
  12220. */
  12221. minScaleY: number;
  12222. /**
  12223. * Maximum scale of emitting particles on Y axis.
  12224. */
  12225. maxScaleY: number;
  12226. /**
  12227. * Gets or sets the minimal initial rotation in radians.
  12228. */
  12229. minInitialRotation: number;
  12230. /**
  12231. * Gets or sets the maximal initial rotation in radians.
  12232. */
  12233. maxInitialRotation: number;
  12234. /**
  12235. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12236. */
  12237. minAngularSpeed: number;
  12238. /**
  12239. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12240. */
  12241. maxAngularSpeed: number;
  12242. /**
  12243. * The texture used to render each particle. (this can be a spritesheet)
  12244. */
  12245. particleTexture: Nullable<Texture>;
  12246. /**
  12247. * The layer mask we are rendering the particles through.
  12248. */
  12249. layerMask: number;
  12250. /**
  12251. * This can help using your own shader to render the particle system.
  12252. * The according effect will be created
  12253. */
  12254. customShader: any;
  12255. /**
  12256. * By default particle system starts as soon as they are created. This prevents the
  12257. * automatic start to happen and let you decide when to start emitting particles.
  12258. */
  12259. preventAutoStart: boolean;
  12260. private _noiseTexture;
  12261. /**
  12262. * Gets or sets a texture used to add random noise to particle positions
  12263. */
  12264. get noiseTexture(): Nullable<ProceduralTexture>;
  12265. set noiseTexture(value: Nullable<ProceduralTexture>);
  12266. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12267. noiseStrength: Vector3;
  12268. /**
  12269. * Callback triggered when the particle animation is ending.
  12270. */
  12271. onAnimationEnd: Nullable<() => void>;
  12272. /**
  12273. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12274. */
  12275. blendMode: number;
  12276. /**
  12277. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12278. * to override the particles.
  12279. */
  12280. forceDepthWrite: boolean;
  12281. /** 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 */
  12282. preWarmCycles: number;
  12283. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12284. preWarmStepOffset: number;
  12285. /**
  12286. * 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)
  12287. */
  12288. spriteCellChangeSpeed: number;
  12289. /**
  12290. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12291. */
  12292. startSpriteCellID: number;
  12293. /**
  12294. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12295. */
  12296. endSpriteCellID: number;
  12297. /**
  12298. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12299. */
  12300. spriteCellWidth: number;
  12301. /**
  12302. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12303. */
  12304. spriteCellHeight: number;
  12305. /**
  12306. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12307. */
  12308. spriteRandomStartCell: boolean;
  12309. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12310. translationPivot: Vector2;
  12311. /** @hidden */
  12312. protected _isAnimationSheetEnabled: boolean;
  12313. /**
  12314. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12315. */
  12316. beginAnimationOnStart: boolean;
  12317. /**
  12318. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12319. */
  12320. beginAnimationFrom: number;
  12321. /**
  12322. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12323. */
  12324. beginAnimationTo: number;
  12325. /**
  12326. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12327. */
  12328. beginAnimationLoop: boolean;
  12329. /**
  12330. * Gets or sets a world offset applied to all particles
  12331. */
  12332. worldOffset: Vector3;
  12333. /**
  12334. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12335. */
  12336. get isAnimationSheetEnabled(): boolean;
  12337. set isAnimationSheetEnabled(value: boolean);
  12338. /**
  12339. * Get hosting scene
  12340. * @returns the scene
  12341. */
  12342. getScene(): Nullable<Scene>;
  12343. /**
  12344. * You can use gravity if you want to give an orientation to your particles.
  12345. */
  12346. gravity: Vector3;
  12347. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12348. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12349. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12350. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12351. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12352. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12353. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12354. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12355. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12356. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12357. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12358. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12359. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12360. /**
  12361. * Defines the delay in milliseconds before starting the system (0 by default)
  12362. */
  12363. startDelay: number;
  12364. /**
  12365. * Gets the current list of drag gradients.
  12366. * You must use addDragGradient and removeDragGradient to udpate this list
  12367. * @returns the list of drag gradients
  12368. */
  12369. getDragGradients(): Nullable<Array<FactorGradient>>;
  12370. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12371. limitVelocityDamping: number;
  12372. /**
  12373. * Gets the current list of limit velocity gradients.
  12374. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12375. * @returns the list of limit velocity gradients
  12376. */
  12377. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12378. /**
  12379. * Gets the current list of color gradients.
  12380. * You must use addColorGradient and removeColorGradient to udpate this list
  12381. * @returns the list of color gradients
  12382. */
  12383. getColorGradients(): Nullable<Array<ColorGradient>>;
  12384. /**
  12385. * Gets the current list of size gradients.
  12386. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12387. * @returns the list of size gradients
  12388. */
  12389. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12390. /**
  12391. * Gets the current list of color remap gradients.
  12392. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12393. * @returns the list of color remap gradients
  12394. */
  12395. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12396. /**
  12397. * Gets the current list of alpha remap gradients.
  12398. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12399. * @returns the list of alpha remap gradients
  12400. */
  12401. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12402. /**
  12403. * Gets the current list of life time gradients.
  12404. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12405. * @returns the list of life time gradients
  12406. */
  12407. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12408. /**
  12409. * Gets the current list of angular speed gradients.
  12410. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12411. * @returns the list of angular speed gradients
  12412. */
  12413. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12414. /**
  12415. * Gets the current list of velocity gradients.
  12416. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12417. * @returns the list of velocity gradients
  12418. */
  12419. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12420. /**
  12421. * Gets the current list of start size gradients.
  12422. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12423. * @returns the list of start size gradients
  12424. */
  12425. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12426. /**
  12427. * Gets the current list of emit rate gradients.
  12428. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12429. * @returns the list of emit rate gradients
  12430. */
  12431. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12432. /**
  12433. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12434. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12435. */
  12436. get direction1(): Vector3;
  12437. set direction1(value: Vector3);
  12438. /**
  12439. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12440. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12441. */
  12442. get direction2(): Vector3;
  12443. set direction2(value: Vector3);
  12444. /**
  12445. * 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.
  12446. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12447. */
  12448. get minEmitBox(): Vector3;
  12449. set minEmitBox(value: Vector3);
  12450. /**
  12451. * 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.
  12452. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12453. */
  12454. get maxEmitBox(): Vector3;
  12455. set maxEmitBox(value: Vector3);
  12456. /**
  12457. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12458. */
  12459. color1: Color4;
  12460. /**
  12461. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12462. */
  12463. color2: Color4;
  12464. /**
  12465. * Color the particle will have at the end of its lifetime
  12466. */
  12467. colorDead: Color4;
  12468. /**
  12469. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12470. */
  12471. textureMask: Color4;
  12472. /**
  12473. * The particle emitter type defines the emitter used by the particle system.
  12474. * It can be for example box, sphere, or cone...
  12475. */
  12476. particleEmitterType: IParticleEmitterType;
  12477. /** @hidden */
  12478. _isSubEmitter: boolean;
  12479. /**
  12480. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12481. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12482. */
  12483. billboardMode: number;
  12484. protected _isBillboardBased: boolean;
  12485. /**
  12486. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12487. */
  12488. get isBillboardBased(): boolean;
  12489. set isBillboardBased(value: boolean);
  12490. /**
  12491. * The scene the particle system belongs to.
  12492. */
  12493. protected _scene: Nullable<Scene>;
  12494. /**
  12495. * The engine the particle system belongs to.
  12496. */
  12497. protected _engine: ThinEngine;
  12498. /**
  12499. * Local cache of defines for image processing.
  12500. */
  12501. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12502. /**
  12503. * Default configuration related to image processing available in the standard Material.
  12504. */
  12505. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12506. /**
  12507. * Gets the image processing configuration used either in this material.
  12508. */
  12509. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12510. /**
  12511. * Sets the Default image processing configuration used either in the this material.
  12512. *
  12513. * If sets to null, the scene one is in use.
  12514. */
  12515. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12516. /**
  12517. * Attaches a new image processing configuration to the Standard Material.
  12518. * @param configuration
  12519. */
  12520. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12521. /** @hidden */
  12522. protected _reset(): void;
  12523. /** @hidden */
  12524. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12525. /**
  12526. * Instantiates a particle system.
  12527. * 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.
  12528. * @param name The name of the particle system
  12529. */
  12530. constructor(name: string);
  12531. /**
  12532. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12533. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12534. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12535. * @returns the emitter
  12536. */
  12537. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12538. /**
  12539. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12540. * @param radius The radius of the hemisphere to emit from
  12541. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12542. * @returns the emitter
  12543. */
  12544. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12545. /**
  12546. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12547. * @param radius The radius of the sphere to emit from
  12548. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12549. * @returns the emitter
  12550. */
  12551. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12552. /**
  12553. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12554. * @param radius The radius of the sphere to emit from
  12555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12557. * @returns the emitter
  12558. */
  12559. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12560. /**
  12561. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12562. * @param radius The radius of the emission cylinder
  12563. * @param height The height of the emission cylinder
  12564. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12565. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12566. * @returns the emitter
  12567. */
  12568. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12569. /**
  12570. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12571. * @param radius The radius of the cylinder to emit from
  12572. * @param height The height of the emission cylinder
  12573. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12574. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12575. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12576. * @returns the emitter
  12577. */
  12578. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12579. /**
  12580. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12581. * @param radius The radius of the cone to emit from
  12582. * @param angle The base angle of the cone
  12583. * @returns the emitter
  12584. */
  12585. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12586. /**
  12587. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12590. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12591. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12592. * @returns the emitter
  12593. */
  12594. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12595. }
  12596. }
  12597. declare module "babylonjs/Particles/subEmitter" {
  12598. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12599. import { Scene } from "babylonjs/scene";
  12600. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12601. /**
  12602. * Type of sub emitter
  12603. */
  12604. export enum SubEmitterType {
  12605. /**
  12606. * Attached to the particle over it's lifetime
  12607. */
  12608. ATTACHED = 0,
  12609. /**
  12610. * Created when the particle dies
  12611. */
  12612. END = 1
  12613. }
  12614. /**
  12615. * Sub emitter class used to emit particles from an existing particle
  12616. */
  12617. export class SubEmitter {
  12618. /**
  12619. * the particle system to be used by the sub emitter
  12620. */
  12621. particleSystem: ParticleSystem;
  12622. /**
  12623. * Type of the submitter (Default: END)
  12624. */
  12625. type: SubEmitterType;
  12626. /**
  12627. * 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)
  12628. * Note: This only is supported when using an emitter of type Mesh
  12629. */
  12630. inheritDirection: boolean;
  12631. /**
  12632. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12633. */
  12634. inheritedVelocityAmount: number;
  12635. /**
  12636. * Creates a sub emitter
  12637. * @param particleSystem the particle system to be used by the sub emitter
  12638. */
  12639. constructor(
  12640. /**
  12641. * the particle system to be used by the sub emitter
  12642. */
  12643. particleSystem: ParticleSystem);
  12644. /**
  12645. * Clones the sub emitter
  12646. * @returns the cloned sub emitter
  12647. */
  12648. clone(): SubEmitter;
  12649. /**
  12650. * Serialize current object to a JSON object
  12651. * @returns the serialized object
  12652. */
  12653. serialize(): any;
  12654. /** @hidden */
  12655. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12656. /**
  12657. * Creates a new SubEmitter from a serialized JSON version
  12658. * @param serializationObject defines the JSON object to read from
  12659. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12660. * @param rootUrl defines the rootUrl for data loading
  12661. * @returns a new SubEmitter
  12662. */
  12663. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12664. /** Release associated resources */
  12665. dispose(): void;
  12666. }
  12667. }
  12668. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12669. /** @hidden */
  12670. export var imageProcessingDeclaration: {
  12671. name: string;
  12672. shader: string;
  12673. };
  12674. }
  12675. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12676. /** @hidden */
  12677. export var imageProcessingFunctions: {
  12678. name: string;
  12679. shader: string;
  12680. };
  12681. }
  12682. declare module "babylonjs/Shaders/particles.fragment" {
  12683. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12684. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12685. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12686. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12687. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12688. /** @hidden */
  12689. export var particlesPixelShader: {
  12690. name: string;
  12691. shader: string;
  12692. };
  12693. }
  12694. declare module "babylonjs/Shaders/particles.vertex" {
  12695. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12696. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12697. /** @hidden */
  12698. export var particlesVertexShader: {
  12699. name: string;
  12700. shader: string;
  12701. };
  12702. }
  12703. declare module "babylonjs/Particles/particleSystem" {
  12704. import { Nullable } from "babylonjs/types";
  12705. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12706. import { Observable } from "babylonjs/Misc/observable";
  12707. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12708. import { Effect } from "babylonjs/Materials/effect";
  12709. import { IDisposable } from "babylonjs/scene";
  12710. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12711. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12712. import { Particle } from "babylonjs/Particles/particle";
  12713. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12714. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12715. import "babylonjs/Shaders/particles.fragment";
  12716. import "babylonjs/Shaders/particles.vertex";
  12717. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12718. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12719. import { Scene } from "babylonjs/scene";
  12720. /**
  12721. * This represents a particle system in Babylon.
  12722. * 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.
  12723. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12724. * @example https://doc.babylonjs.com/babylon101/particles
  12725. */
  12726. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12727. /**
  12728. * Billboard mode will only apply to Y axis
  12729. */
  12730. static readonly BILLBOARDMODE_Y: number;
  12731. /**
  12732. * Billboard mode will apply to all axes
  12733. */
  12734. static readonly BILLBOARDMODE_ALL: number;
  12735. /**
  12736. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12737. */
  12738. static readonly BILLBOARDMODE_STRETCHED: number;
  12739. /**
  12740. * This function can be defined to provide custom update for active particles.
  12741. * This function will be called instead of regular update (age, position, color, etc.).
  12742. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12743. */
  12744. updateFunction: (particles: Particle[]) => void;
  12745. private _emitterWorldMatrix;
  12746. /**
  12747. * This function can be defined to specify initial direction for every new particle.
  12748. * It by default use the emitterType defined function
  12749. */
  12750. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12751. /**
  12752. * This function can be defined to specify initial position for every new particle.
  12753. * It by default use the emitterType defined function
  12754. */
  12755. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12756. /**
  12757. * @hidden
  12758. */
  12759. _inheritedVelocityOffset: Vector3;
  12760. /**
  12761. * An event triggered when the system is disposed
  12762. */
  12763. onDisposeObservable: Observable<IParticleSystem>;
  12764. private _onDisposeObserver;
  12765. /**
  12766. * Sets a callback that will be triggered when the system is disposed
  12767. */
  12768. set onDispose(callback: () => void);
  12769. private _particles;
  12770. private _epsilon;
  12771. private _capacity;
  12772. private _stockParticles;
  12773. private _newPartsExcess;
  12774. private _vertexData;
  12775. private _vertexBuffer;
  12776. private _vertexBuffers;
  12777. private _spriteBuffer;
  12778. private _indexBuffer;
  12779. private _effect;
  12780. private _customEffect;
  12781. private _cachedDefines;
  12782. private _scaledColorStep;
  12783. private _colorDiff;
  12784. private _scaledDirection;
  12785. private _scaledGravity;
  12786. private _currentRenderId;
  12787. private _alive;
  12788. private _useInstancing;
  12789. private _started;
  12790. private _stopped;
  12791. private _actualFrame;
  12792. private _scaledUpdateSpeed;
  12793. private _vertexBufferSize;
  12794. /** @hidden */
  12795. _currentEmitRateGradient: Nullable<FactorGradient>;
  12796. /** @hidden */
  12797. _currentEmitRate1: number;
  12798. /** @hidden */
  12799. _currentEmitRate2: number;
  12800. /** @hidden */
  12801. _currentStartSizeGradient: Nullable<FactorGradient>;
  12802. /** @hidden */
  12803. _currentStartSize1: number;
  12804. /** @hidden */
  12805. _currentStartSize2: number;
  12806. private readonly _rawTextureWidth;
  12807. private _rampGradientsTexture;
  12808. private _useRampGradients;
  12809. /** Gets or sets a matrix to use to compute projection */
  12810. defaultProjectionMatrix: Matrix;
  12811. /** Gets or sets a boolean indicating that ramp gradients must be used
  12812. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12813. */
  12814. get useRampGradients(): boolean;
  12815. set useRampGradients(value: boolean);
  12816. /**
  12817. * 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.
  12818. * 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: [])
  12819. */
  12820. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12821. private _subEmitters;
  12822. /**
  12823. * @hidden
  12824. * If the particle systems emitter should be disposed when the particle system is disposed
  12825. */
  12826. _disposeEmitterOnDispose: boolean;
  12827. /**
  12828. * The current active Sub-systems, this property is used by the root particle system only.
  12829. */
  12830. activeSubSystems: Array<ParticleSystem>;
  12831. /**
  12832. * Specifies if the particles are updated in emitter local space or world space
  12833. */
  12834. isLocal: boolean;
  12835. private _rootParticleSystem;
  12836. /**
  12837. * Gets the current list of active particles
  12838. */
  12839. get particles(): Particle[];
  12840. /**
  12841. * Gets the number of particles active at the same time.
  12842. * @returns The number of active particles.
  12843. */
  12844. getActiveCount(): number;
  12845. /**
  12846. * Returns the string "ParticleSystem"
  12847. * @returns a string containing the class name
  12848. */
  12849. getClassName(): string;
  12850. /**
  12851. * Gets a boolean indicating that the system is stopping
  12852. * @returns true if the system is currently stopping
  12853. */
  12854. isStopping(): boolean;
  12855. /**
  12856. * Gets the custom effect used to render the particles
  12857. * @param blendMode Blend mode for which the effect should be retrieved
  12858. * @returns The effect
  12859. */
  12860. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12861. /**
  12862. * Sets the custom effect used to render the particles
  12863. * @param effect The effect to set
  12864. * @param blendMode Blend mode for which the effect should be set
  12865. */
  12866. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12867. /** @hidden */
  12868. private _onBeforeDrawParticlesObservable;
  12869. /**
  12870. * Observable that will be called just before the particles are drawn
  12871. */
  12872. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12873. /**
  12874. * Gets the name of the particle vertex shader
  12875. */
  12876. get vertexShaderName(): string;
  12877. /**
  12878. * Instantiates a particle system.
  12879. * 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.
  12880. * @param name The name of the particle system
  12881. * @param capacity The max number of particles alive at the same time
  12882. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12883. * @param customEffect a custom effect used to change the way particles are rendered by default
  12884. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12885. * @param epsilon Offset used to render the particles
  12886. */
  12887. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12888. private _addFactorGradient;
  12889. private _removeFactorGradient;
  12890. /**
  12891. * Adds a new life time gradient
  12892. * @param gradient defines the gradient to use (between 0 and 1)
  12893. * @param factor defines the life time factor to affect to the specified gradient
  12894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12895. * @returns the current particle system
  12896. */
  12897. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12898. /**
  12899. * Remove a specific life time gradient
  12900. * @param gradient defines the gradient to remove
  12901. * @returns the current particle system
  12902. */
  12903. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12904. /**
  12905. * Adds a new size gradient
  12906. * @param gradient defines the gradient to use (between 0 and 1)
  12907. * @param factor defines the size factor to affect to the specified gradient
  12908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12909. * @returns the current particle system
  12910. */
  12911. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12912. /**
  12913. * Remove a specific size gradient
  12914. * @param gradient defines the gradient to remove
  12915. * @returns the current particle system
  12916. */
  12917. removeSizeGradient(gradient: number): IParticleSystem;
  12918. /**
  12919. * Adds a new color remap gradient
  12920. * @param gradient defines the gradient to use (between 0 and 1)
  12921. * @param min defines the color remap minimal range
  12922. * @param max defines the color remap maximal range
  12923. * @returns the current particle system
  12924. */
  12925. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12926. /**
  12927. * Remove a specific color remap gradient
  12928. * @param gradient defines the gradient to remove
  12929. * @returns the current particle system
  12930. */
  12931. removeColorRemapGradient(gradient: number): IParticleSystem;
  12932. /**
  12933. * Adds a new alpha remap gradient
  12934. * @param gradient defines the gradient to use (between 0 and 1)
  12935. * @param min defines the alpha remap minimal range
  12936. * @param max defines the alpha remap maximal range
  12937. * @returns the current particle system
  12938. */
  12939. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12940. /**
  12941. * Remove a specific alpha remap gradient
  12942. * @param gradient defines the gradient to remove
  12943. * @returns the current particle system
  12944. */
  12945. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12946. /**
  12947. * Adds a new angular speed gradient
  12948. * @param gradient defines the gradient to use (between 0 and 1)
  12949. * @param factor defines the angular speed to affect to the specified gradient
  12950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12951. * @returns the current particle system
  12952. */
  12953. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12954. /**
  12955. * Remove a specific angular speed gradient
  12956. * @param gradient defines the gradient to remove
  12957. * @returns the current particle system
  12958. */
  12959. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12960. /**
  12961. * Adds a new velocity gradient
  12962. * @param gradient defines the gradient to use (between 0 and 1)
  12963. * @param factor defines the velocity to affect to the specified gradient
  12964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12965. * @returns the current particle system
  12966. */
  12967. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12968. /**
  12969. * Remove a specific velocity gradient
  12970. * @param gradient defines the gradient to remove
  12971. * @returns the current particle system
  12972. */
  12973. removeVelocityGradient(gradient: number): IParticleSystem;
  12974. /**
  12975. * Adds a new limit velocity gradient
  12976. * @param gradient defines the gradient to use (between 0 and 1)
  12977. * @param factor defines the limit velocity value to affect to the specified gradient
  12978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12979. * @returns the current particle system
  12980. */
  12981. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12982. /**
  12983. * Remove a specific limit velocity gradient
  12984. * @param gradient defines the gradient to remove
  12985. * @returns the current particle system
  12986. */
  12987. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12988. /**
  12989. * Adds a new drag gradient
  12990. * @param gradient defines the gradient to use (between 0 and 1)
  12991. * @param factor defines the drag value to affect to the specified gradient
  12992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12993. * @returns the current particle system
  12994. */
  12995. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12996. /**
  12997. * Remove a specific drag gradient
  12998. * @param gradient defines the gradient to remove
  12999. * @returns the current particle system
  13000. */
  13001. removeDragGradient(gradient: number): IParticleSystem;
  13002. /**
  13003. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13004. * @param gradient defines the gradient to use (between 0 and 1)
  13005. * @param factor defines the emit rate value to affect to the specified gradient
  13006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13007. * @returns the current particle system
  13008. */
  13009. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13010. /**
  13011. * Remove a specific emit rate gradient
  13012. * @param gradient defines the gradient to remove
  13013. * @returns the current particle system
  13014. */
  13015. removeEmitRateGradient(gradient: number): IParticleSystem;
  13016. /**
  13017. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13018. * @param gradient defines the gradient to use (between 0 and 1)
  13019. * @param factor defines the start size value to affect to the specified gradient
  13020. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13021. * @returns the current particle system
  13022. */
  13023. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13024. /**
  13025. * Remove a specific start size gradient
  13026. * @param gradient defines the gradient to remove
  13027. * @returns the current particle system
  13028. */
  13029. removeStartSizeGradient(gradient: number): IParticleSystem;
  13030. private _createRampGradientTexture;
  13031. /**
  13032. * Gets the current list of ramp gradients.
  13033. * You must use addRampGradient and removeRampGradient to udpate this list
  13034. * @returns the list of ramp gradients
  13035. */
  13036. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13037. /** Force the system to rebuild all gradients that need to be resync */
  13038. forceRefreshGradients(): void;
  13039. private _syncRampGradientTexture;
  13040. /**
  13041. * Adds a new ramp gradient used to remap particle colors
  13042. * @param gradient defines the gradient to use (between 0 and 1)
  13043. * @param color defines the color to affect to the specified gradient
  13044. * @returns the current particle system
  13045. */
  13046. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13047. /**
  13048. * Remove a specific ramp gradient
  13049. * @param gradient defines the gradient to remove
  13050. * @returns the current particle system
  13051. */
  13052. removeRampGradient(gradient: number): ParticleSystem;
  13053. /**
  13054. * Adds a new color gradient
  13055. * @param gradient defines the gradient to use (between 0 and 1)
  13056. * @param color1 defines the color to affect to the specified gradient
  13057. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13058. * @returns this particle system
  13059. */
  13060. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13061. /**
  13062. * Remove a specific color gradient
  13063. * @param gradient defines the gradient to remove
  13064. * @returns this particle system
  13065. */
  13066. removeColorGradient(gradient: number): IParticleSystem;
  13067. private _fetchR;
  13068. protected _reset(): void;
  13069. private _resetEffect;
  13070. private _createVertexBuffers;
  13071. private _createIndexBuffer;
  13072. /**
  13073. * Gets the maximum number of particles active at the same time.
  13074. * @returns The max number of active particles.
  13075. */
  13076. getCapacity(): number;
  13077. /**
  13078. * Gets whether there are still active particles in the system.
  13079. * @returns True if it is alive, otherwise false.
  13080. */
  13081. isAlive(): boolean;
  13082. /**
  13083. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13084. * @returns True if it has been started, otherwise false.
  13085. */
  13086. isStarted(): boolean;
  13087. private _prepareSubEmitterInternalArray;
  13088. /**
  13089. * Starts the particle system and begins to emit
  13090. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13091. */
  13092. start(delay?: number): void;
  13093. /**
  13094. * Stops the particle system.
  13095. * @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.
  13096. */
  13097. stop(stopSubEmitters?: boolean): void;
  13098. /**
  13099. * Remove all active particles
  13100. */
  13101. reset(): void;
  13102. /**
  13103. * @hidden (for internal use only)
  13104. */
  13105. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13106. /**
  13107. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13108. * Its lifetime will start back at 0.
  13109. */
  13110. recycleParticle: (particle: Particle) => void;
  13111. private _stopSubEmitters;
  13112. private _createParticle;
  13113. private _removeFromRoot;
  13114. private _emitFromParticle;
  13115. private _update;
  13116. /** @hidden */
  13117. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13118. /** @hidden */
  13119. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13120. /**
  13121. * Fill the defines array according to the current settings of the particle system
  13122. * @param defines Array to be updated
  13123. * @param blendMode blend mode to take into account when updating the array
  13124. */
  13125. fillDefines(defines: Array<string>, blendMode: number): void;
  13126. /**
  13127. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13128. * @param uniforms Uniforms array to fill
  13129. * @param attributes Attributes array to fill
  13130. * @param samplers Samplers array to fill
  13131. */
  13132. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13133. /** @hidden */
  13134. private _getEffect;
  13135. /**
  13136. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13137. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13138. */
  13139. animate(preWarmOnly?: boolean): void;
  13140. private _appendParticleVertices;
  13141. /**
  13142. * Rebuilds the particle system.
  13143. */
  13144. rebuild(): void;
  13145. /**
  13146. * Is this system ready to be used/rendered
  13147. * @return true if the system is ready
  13148. */
  13149. isReady(): boolean;
  13150. private _render;
  13151. /**
  13152. * Renders the particle system in its current state.
  13153. * @returns the current number of particles
  13154. */
  13155. render(): number;
  13156. /**
  13157. * Disposes the particle system and free the associated resources
  13158. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13159. */
  13160. dispose(disposeTexture?: boolean): void;
  13161. /**
  13162. * Clones the particle system.
  13163. * @param name The name of the cloned object
  13164. * @param newEmitter The new emitter to use
  13165. * @returns the cloned particle system
  13166. */
  13167. clone(name: string, newEmitter: any): ParticleSystem;
  13168. /**
  13169. * Serializes the particle system to a JSON object
  13170. * @param serializeTexture defines if the texture must be serialized as well
  13171. * @returns the JSON object
  13172. */
  13173. serialize(serializeTexture?: boolean): any;
  13174. /** @hidden */
  13175. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13176. /** @hidden */
  13177. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13178. /**
  13179. * Parses a JSON object to create a particle system.
  13180. * @param parsedParticleSystem The JSON object to parse
  13181. * @param sceneOrEngine The scene or the engine to create the particle system in
  13182. * @param rootUrl The root url to use to load external dependencies like texture
  13183. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13184. * @returns the Parsed particle system
  13185. */
  13186. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13187. }
  13188. }
  13189. declare module "babylonjs/Particles/particle" {
  13190. import { Nullable } from "babylonjs/types";
  13191. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13192. import { Color4 } from "babylonjs/Maths/math.color";
  13193. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13194. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13195. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13196. /**
  13197. * A particle represents one of the element emitted by a particle system.
  13198. * This is mainly define by its coordinates, direction, velocity and age.
  13199. */
  13200. export class Particle {
  13201. /**
  13202. * The particle system the particle belongs to.
  13203. */
  13204. particleSystem: ParticleSystem;
  13205. private static _Count;
  13206. /**
  13207. * Unique ID of the particle
  13208. */
  13209. id: number;
  13210. /**
  13211. * The world position of the particle in the scene.
  13212. */
  13213. position: Vector3;
  13214. /**
  13215. * The world direction of the particle in the scene.
  13216. */
  13217. direction: Vector3;
  13218. /**
  13219. * The color of the particle.
  13220. */
  13221. color: Color4;
  13222. /**
  13223. * The color change of the particle per step.
  13224. */
  13225. colorStep: Color4;
  13226. /**
  13227. * Defines how long will the life of the particle be.
  13228. */
  13229. lifeTime: number;
  13230. /**
  13231. * The current age of the particle.
  13232. */
  13233. age: number;
  13234. /**
  13235. * The current size of the particle.
  13236. */
  13237. size: number;
  13238. /**
  13239. * The current scale of the particle.
  13240. */
  13241. scale: Vector2;
  13242. /**
  13243. * The current angle of the particle.
  13244. */
  13245. angle: number;
  13246. /**
  13247. * Defines how fast is the angle changing.
  13248. */
  13249. angularSpeed: number;
  13250. /**
  13251. * Defines the cell index used by the particle to be rendered from a sprite.
  13252. */
  13253. cellIndex: number;
  13254. /**
  13255. * The information required to support color remapping
  13256. */
  13257. remapData: Vector4;
  13258. /** @hidden */
  13259. _randomCellOffset?: number;
  13260. /** @hidden */
  13261. _initialDirection: Nullable<Vector3>;
  13262. /** @hidden */
  13263. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13264. /** @hidden */
  13265. _initialStartSpriteCellID: number;
  13266. /** @hidden */
  13267. _initialEndSpriteCellID: number;
  13268. /** @hidden */
  13269. _currentColorGradient: Nullable<ColorGradient>;
  13270. /** @hidden */
  13271. _currentColor1: Color4;
  13272. /** @hidden */
  13273. _currentColor2: Color4;
  13274. /** @hidden */
  13275. _currentSizeGradient: Nullable<FactorGradient>;
  13276. /** @hidden */
  13277. _currentSize1: number;
  13278. /** @hidden */
  13279. _currentSize2: number;
  13280. /** @hidden */
  13281. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13282. /** @hidden */
  13283. _currentAngularSpeed1: number;
  13284. /** @hidden */
  13285. _currentAngularSpeed2: number;
  13286. /** @hidden */
  13287. _currentVelocityGradient: Nullable<FactorGradient>;
  13288. /** @hidden */
  13289. _currentVelocity1: number;
  13290. /** @hidden */
  13291. _currentVelocity2: number;
  13292. /** @hidden */
  13293. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13294. /** @hidden */
  13295. _currentLimitVelocity1: number;
  13296. /** @hidden */
  13297. _currentLimitVelocity2: number;
  13298. /** @hidden */
  13299. _currentDragGradient: Nullable<FactorGradient>;
  13300. /** @hidden */
  13301. _currentDrag1: number;
  13302. /** @hidden */
  13303. _currentDrag2: number;
  13304. /** @hidden */
  13305. _randomNoiseCoordinates1: Vector3;
  13306. /** @hidden */
  13307. _randomNoiseCoordinates2: Vector3;
  13308. /** @hidden */
  13309. _localPosition?: Vector3;
  13310. /**
  13311. * Creates a new instance Particle
  13312. * @param particleSystem the particle system the particle belongs to
  13313. */
  13314. constructor(
  13315. /**
  13316. * The particle system the particle belongs to.
  13317. */
  13318. particleSystem: ParticleSystem);
  13319. private updateCellInfoFromSystem;
  13320. /**
  13321. * Defines how the sprite cell index is updated for the particle
  13322. */
  13323. updateCellIndex(): void;
  13324. /** @hidden */
  13325. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13326. /** @hidden */
  13327. _inheritParticleInfoToSubEmitters(): void;
  13328. /** @hidden */
  13329. _reset(): void;
  13330. /**
  13331. * Copy the properties of particle to another one.
  13332. * @param other the particle to copy the information to.
  13333. */
  13334. copyTo(other: Particle): void;
  13335. }
  13336. }
  13337. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13338. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13339. import { Effect } from "babylonjs/Materials/effect";
  13340. import { Particle } from "babylonjs/Particles/particle";
  13341. import { Nullable } from "babylonjs/types";
  13342. import { Scene } from "babylonjs/scene";
  13343. /**
  13344. * Particle emitter represents a volume emitting particles.
  13345. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13346. */
  13347. export interface IParticleEmitterType {
  13348. /**
  13349. * Called by the particle System when the direction is computed for the created particle.
  13350. * @param worldMatrix is the world matrix of the particle system
  13351. * @param directionToUpdate is the direction vector to update with the result
  13352. * @param particle is the particle we are computed the direction for
  13353. * @param isLocal defines if the direction should be set in local space
  13354. */
  13355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13356. /**
  13357. * Called by the particle System when the position is computed for the created particle.
  13358. * @param worldMatrix is the world matrix of the particle system
  13359. * @param positionToUpdate is the position vector to update with the result
  13360. * @param particle is the particle we are computed the position for
  13361. * @param isLocal defines if the position should be set in local space
  13362. */
  13363. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13364. /**
  13365. * Clones the current emitter and returns a copy of it
  13366. * @returns the new emitter
  13367. */
  13368. clone(): IParticleEmitterType;
  13369. /**
  13370. * Called by the GPUParticleSystem to setup the update shader
  13371. * @param effect defines the update shader
  13372. */
  13373. applyToShader(effect: Effect): void;
  13374. /**
  13375. * Returns a string to use to update the GPU particles update shader
  13376. * @returns the effect defines string
  13377. */
  13378. getEffectDefines(): string;
  13379. /**
  13380. * Returns a string representing the class name
  13381. * @returns a string containing the class name
  13382. */
  13383. getClassName(): string;
  13384. /**
  13385. * Serializes the particle system to a JSON object.
  13386. * @returns the JSON object
  13387. */
  13388. serialize(): any;
  13389. /**
  13390. * Parse properties from a JSON object
  13391. * @param serializationObject defines the JSON object
  13392. * @param scene defines the hosting scene
  13393. */
  13394. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13395. }
  13396. }
  13397. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13398. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13399. import { Effect } from "babylonjs/Materials/effect";
  13400. import { Particle } from "babylonjs/Particles/particle";
  13401. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13402. /**
  13403. * Particle emitter emitting particles from the inside of a box.
  13404. * It emits the particles randomly between 2 given directions.
  13405. */
  13406. export class BoxParticleEmitter implements IParticleEmitterType {
  13407. /**
  13408. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13409. */
  13410. direction1: Vector3;
  13411. /**
  13412. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13413. */
  13414. direction2: Vector3;
  13415. /**
  13416. * 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.
  13417. */
  13418. minEmitBox: Vector3;
  13419. /**
  13420. * 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.
  13421. */
  13422. maxEmitBox: Vector3;
  13423. /**
  13424. * Creates a new instance BoxParticleEmitter
  13425. */
  13426. constructor();
  13427. /**
  13428. * Called by the particle System when the direction is computed for the created particle.
  13429. * @param worldMatrix is the world matrix of the particle system
  13430. * @param directionToUpdate is the direction vector to update with the result
  13431. * @param particle is the particle we are computed the direction for
  13432. * @param isLocal defines if the direction should be set in local space
  13433. */
  13434. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13435. /**
  13436. * Called by the particle System when the position is computed for the created particle.
  13437. * @param worldMatrix is the world matrix of the particle system
  13438. * @param positionToUpdate is the position vector to update with the result
  13439. * @param particle is the particle we are computed the position for
  13440. * @param isLocal defines if the position should be set in local space
  13441. */
  13442. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13443. /**
  13444. * Clones the current emitter and returns a copy of it
  13445. * @returns the new emitter
  13446. */
  13447. clone(): BoxParticleEmitter;
  13448. /**
  13449. * Called by the GPUParticleSystem to setup the update shader
  13450. * @param effect defines the update shader
  13451. */
  13452. applyToShader(effect: Effect): void;
  13453. /**
  13454. * Returns a string to use to update the GPU particles update shader
  13455. * @returns a string containng the defines string
  13456. */
  13457. getEffectDefines(): string;
  13458. /**
  13459. * Returns the string "BoxParticleEmitter"
  13460. * @returns a string containing the class name
  13461. */
  13462. getClassName(): string;
  13463. /**
  13464. * Serializes the particle system to a JSON object.
  13465. * @returns the JSON object
  13466. */
  13467. serialize(): any;
  13468. /**
  13469. * Parse properties from a JSON object
  13470. * @param serializationObject defines the JSON object
  13471. */
  13472. parse(serializationObject: any): void;
  13473. }
  13474. }
  13475. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13476. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13477. import { Effect } from "babylonjs/Materials/effect";
  13478. import { Particle } from "babylonjs/Particles/particle";
  13479. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13480. /**
  13481. * Particle emitter emitting particles from the inside of a cone.
  13482. * It emits the particles alongside the cone volume from the base to the particle.
  13483. * The emission direction might be randomized.
  13484. */
  13485. export class ConeParticleEmitter implements IParticleEmitterType {
  13486. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13487. directionRandomizer: number;
  13488. private _radius;
  13489. private _angle;
  13490. private _height;
  13491. /**
  13492. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13493. */
  13494. radiusRange: number;
  13495. /**
  13496. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13497. */
  13498. heightRange: number;
  13499. /**
  13500. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13501. */
  13502. emitFromSpawnPointOnly: boolean;
  13503. /**
  13504. * Gets or sets the radius of the emission cone
  13505. */
  13506. get radius(): number;
  13507. set radius(value: number);
  13508. /**
  13509. * Gets or sets the angle of the emission cone
  13510. */
  13511. get angle(): number;
  13512. set angle(value: number);
  13513. private _buildHeight;
  13514. /**
  13515. * Creates a new instance ConeParticleEmitter
  13516. * @param radius the radius of the emission cone (1 by default)
  13517. * @param angle the cone base angle (PI by default)
  13518. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13519. */
  13520. constructor(radius?: number, angle?: number,
  13521. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13522. directionRandomizer?: number);
  13523. /**
  13524. * Called by the particle System when the direction is computed for the created particle.
  13525. * @param worldMatrix is the world matrix of the particle system
  13526. * @param directionToUpdate is the direction vector to update with the result
  13527. * @param particle is the particle we are computed the direction for
  13528. * @param isLocal defines if the direction should be set in local space
  13529. */
  13530. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13531. /**
  13532. * Called by the particle System when the position is computed for the created particle.
  13533. * @param worldMatrix is the world matrix of the particle system
  13534. * @param positionToUpdate is the position vector to update with the result
  13535. * @param particle is the particle we are computed the position for
  13536. * @param isLocal defines if the position should be set in local space
  13537. */
  13538. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13539. /**
  13540. * Clones the current emitter and returns a copy of it
  13541. * @returns the new emitter
  13542. */
  13543. clone(): ConeParticleEmitter;
  13544. /**
  13545. * Called by the GPUParticleSystem to setup the update shader
  13546. * @param effect defines the update shader
  13547. */
  13548. applyToShader(effect: Effect): void;
  13549. /**
  13550. * Returns a string to use to update the GPU particles update shader
  13551. * @returns a string containng the defines string
  13552. */
  13553. getEffectDefines(): string;
  13554. /**
  13555. * Returns the string "ConeParticleEmitter"
  13556. * @returns a string containing the class name
  13557. */
  13558. getClassName(): string;
  13559. /**
  13560. * Serializes the particle system to a JSON object.
  13561. * @returns the JSON object
  13562. */
  13563. serialize(): any;
  13564. /**
  13565. * Parse properties from a JSON object
  13566. * @param serializationObject defines the JSON object
  13567. */
  13568. parse(serializationObject: any): void;
  13569. }
  13570. }
  13571. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13572. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13573. import { Effect } from "babylonjs/Materials/effect";
  13574. import { Particle } from "babylonjs/Particles/particle";
  13575. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13576. /**
  13577. * Particle emitter emitting particles from the inside of a cylinder.
  13578. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13579. */
  13580. export class CylinderParticleEmitter implements IParticleEmitterType {
  13581. /**
  13582. * The radius of the emission cylinder.
  13583. */
  13584. radius: number;
  13585. /**
  13586. * The height of the emission cylinder.
  13587. */
  13588. height: number;
  13589. /**
  13590. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13591. */
  13592. radiusRange: number;
  13593. /**
  13594. * How much to randomize the particle direction [0-1].
  13595. */
  13596. directionRandomizer: number;
  13597. /**
  13598. * Creates a new instance CylinderParticleEmitter
  13599. * @param radius the radius of the emission cylinder (1 by default)
  13600. * @param height the height of the emission cylinder (1 by default)
  13601. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13602. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13603. */
  13604. constructor(
  13605. /**
  13606. * The radius of the emission cylinder.
  13607. */
  13608. radius?: number,
  13609. /**
  13610. * The height of the emission cylinder.
  13611. */
  13612. height?: number,
  13613. /**
  13614. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13615. */
  13616. radiusRange?: number,
  13617. /**
  13618. * How much to randomize the particle direction [0-1].
  13619. */
  13620. directionRandomizer?: number);
  13621. /**
  13622. * Called by the particle System when the direction is computed for the created particle.
  13623. * @param worldMatrix is the world matrix of the particle system
  13624. * @param directionToUpdate is the direction vector to update with the result
  13625. * @param particle is the particle we are computed the direction for
  13626. * @param isLocal defines if the direction should be set in local space
  13627. */
  13628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13629. /**
  13630. * Called by the particle System when the position is computed for the created particle.
  13631. * @param worldMatrix is the world matrix of the particle system
  13632. * @param positionToUpdate is the position vector to update with the result
  13633. * @param particle is the particle we are computed the position for
  13634. * @param isLocal defines if the position should be set in local space
  13635. */
  13636. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13637. /**
  13638. * Clones the current emitter and returns a copy of it
  13639. * @returns the new emitter
  13640. */
  13641. clone(): CylinderParticleEmitter;
  13642. /**
  13643. * Called by the GPUParticleSystem to setup the update shader
  13644. * @param effect defines the update shader
  13645. */
  13646. applyToShader(effect: Effect): void;
  13647. /**
  13648. * Returns a string to use to update the GPU particles update shader
  13649. * @returns a string containng the defines string
  13650. */
  13651. getEffectDefines(): string;
  13652. /**
  13653. * Returns the string "CylinderParticleEmitter"
  13654. * @returns a string containing the class name
  13655. */
  13656. getClassName(): string;
  13657. /**
  13658. * Serializes the particle system to a JSON object.
  13659. * @returns the JSON object
  13660. */
  13661. serialize(): any;
  13662. /**
  13663. * Parse properties from a JSON object
  13664. * @param serializationObject defines the JSON object
  13665. */
  13666. parse(serializationObject: any): void;
  13667. }
  13668. /**
  13669. * Particle emitter emitting particles from the inside of a cylinder.
  13670. * It emits the particles randomly between two vectors.
  13671. */
  13672. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13673. /**
  13674. * The min limit of the emission direction.
  13675. */
  13676. direction1: Vector3;
  13677. /**
  13678. * The max limit of the emission direction.
  13679. */
  13680. direction2: Vector3;
  13681. /**
  13682. * Creates a new instance CylinderDirectedParticleEmitter
  13683. * @param radius the radius of the emission cylinder (1 by default)
  13684. * @param height the height of the emission cylinder (1 by default)
  13685. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13686. * @param direction1 the min limit of the emission direction (up vector by default)
  13687. * @param direction2 the max limit of the emission direction (up vector by default)
  13688. */
  13689. constructor(radius?: number, height?: number, radiusRange?: number,
  13690. /**
  13691. * The min limit of the emission direction.
  13692. */
  13693. direction1?: Vector3,
  13694. /**
  13695. * The max limit of the emission direction.
  13696. */
  13697. direction2?: Vector3);
  13698. /**
  13699. * Called by the particle System when the direction is computed for the created particle.
  13700. * @param worldMatrix is the world matrix of the particle system
  13701. * @param directionToUpdate is the direction vector to update with the result
  13702. * @param particle is the particle we are computed the direction for
  13703. */
  13704. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13705. /**
  13706. * Clones the current emitter and returns a copy of it
  13707. * @returns the new emitter
  13708. */
  13709. clone(): CylinderDirectedParticleEmitter;
  13710. /**
  13711. * Called by the GPUParticleSystem to setup the update shader
  13712. * @param effect defines the update shader
  13713. */
  13714. applyToShader(effect: Effect): void;
  13715. /**
  13716. * Returns a string to use to update the GPU particles update shader
  13717. * @returns a string containng the defines string
  13718. */
  13719. getEffectDefines(): string;
  13720. /**
  13721. * Returns the string "CylinderDirectedParticleEmitter"
  13722. * @returns a string containing the class name
  13723. */
  13724. getClassName(): string;
  13725. /**
  13726. * Serializes the particle system to a JSON object.
  13727. * @returns the JSON object
  13728. */
  13729. serialize(): any;
  13730. /**
  13731. * Parse properties from a JSON object
  13732. * @param serializationObject defines the JSON object
  13733. */
  13734. parse(serializationObject: any): void;
  13735. }
  13736. }
  13737. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13738. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13739. import { Effect } from "babylonjs/Materials/effect";
  13740. import { Particle } from "babylonjs/Particles/particle";
  13741. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13742. /**
  13743. * Particle emitter emitting particles from the inside of a hemisphere.
  13744. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13745. */
  13746. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13747. /**
  13748. * The radius of the emission hemisphere.
  13749. */
  13750. radius: number;
  13751. /**
  13752. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13753. */
  13754. radiusRange: number;
  13755. /**
  13756. * How much to randomize the particle direction [0-1].
  13757. */
  13758. directionRandomizer: number;
  13759. /**
  13760. * Creates a new instance HemisphericParticleEmitter
  13761. * @param radius the radius of the emission hemisphere (1 by default)
  13762. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13763. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13764. */
  13765. constructor(
  13766. /**
  13767. * The radius of the emission hemisphere.
  13768. */
  13769. radius?: number,
  13770. /**
  13771. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13772. */
  13773. radiusRange?: number,
  13774. /**
  13775. * How much to randomize the particle direction [0-1].
  13776. */
  13777. directionRandomizer?: number);
  13778. /**
  13779. * Called by the particle System when the direction is computed for the created particle.
  13780. * @param worldMatrix is the world matrix of the particle system
  13781. * @param directionToUpdate is the direction vector to update with the result
  13782. * @param particle is the particle we are computed the direction for
  13783. * @param isLocal defines if the direction should be set in local space
  13784. */
  13785. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13786. /**
  13787. * Called by the particle System when the position is computed for the created particle.
  13788. * @param worldMatrix is the world matrix of the particle system
  13789. * @param positionToUpdate is the position vector to update with the result
  13790. * @param particle is the particle we are computed the position for
  13791. * @param isLocal defines if the position should be set in local space
  13792. */
  13793. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13794. /**
  13795. * Clones the current emitter and returns a copy of it
  13796. * @returns the new emitter
  13797. */
  13798. clone(): HemisphericParticleEmitter;
  13799. /**
  13800. * Called by the GPUParticleSystem to setup the update shader
  13801. * @param effect defines the update shader
  13802. */
  13803. applyToShader(effect: Effect): void;
  13804. /**
  13805. * Returns a string to use to update the GPU particles update shader
  13806. * @returns a string containng the defines string
  13807. */
  13808. getEffectDefines(): string;
  13809. /**
  13810. * Returns the string "HemisphericParticleEmitter"
  13811. * @returns a string containing the class name
  13812. */
  13813. getClassName(): string;
  13814. /**
  13815. * Serializes the particle system to a JSON object.
  13816. * @returns the JSON object
  13817. */
  13818. serialize(): any;
  13819. /**
  13820. * Parse properties from a JSON object
  13821. * @param serializationObject defines the JSON object
  13822. */
  13823. parse(serializationObject: any): void;
  13824. }
  13825. }
  13826. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13827. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13828. import { Effect } from "babylonjs/Materials/effect";
  13829. import { Particle } from "babylonjs/Particles/particle";
  13830. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13831. /**
  13832. * Particle emitter emitting particles from a point.
  13833. * It emits the particles randomly between 2 given directions.
  13834. */
  13835. export class PointParticleEmitter implements IParticleEmitterType {
  13836. /**
  13837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13838. */
  13839. direction1: Vector3;
  13840. /**
  13841. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13842. */
  13843. direction2: Vector3;
  13844. /**
  13845. * Creates a new instance PointParticleEmitter
  13846. */
  13847. constructor();
  13848. /**
  13849. * Called by the particle System when the direction is computed for the created particle.
  13850. * @param worldMatrix is the world matrix of the particle system
  13851. * @param directionToUpdate is the direction vector to update with the result
  13852. * @param particle is the particle we are computed the direction for
  13853. * @param isLocal defines if the direction should be set in local space
  13854. */
  13855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13856. /**
  13857. * Called by the particle System when the position is computed for the created particle.
  13858. * @param worldMatrix is the world matrix of the particle system
  13859. * @param positionToUpdate is the position vector to update with the result
  13860. * @param particle is the particle we are computed the position for
  13861. * @param isLocal defines if the position should be set in local space
  13862. */
  13863. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13864. /**
  13865. * Clones the current emitter and returns a copy of it
  13866. * @returns the new emitter
  13867. */
  13868. clone(): PointParticleEmitter;
  13869. /**
  13870. * Called by the GPUParticleSystem to setup the update shader
  13871. * @param effect defines the update shader
  13872. */
  13873. applyToShader(effect: Effect): void;
  13874. /**
  13875. * Returns a string to use to update the GPU particles update shader
  13876. * @returns a string containng the defines string
  13877. */
  13878. getEffectDefines(): string;
  13879. /**
  13880. * Returns the string "PointParticleEmitter"
  13881. * @returns a string containing the class name
  13882. */
  13883. getClassName(): string;
  13884. /**
  13885. * Serializes the particle system to a JSON object.
  13886. * @returns the JSON object
  13887. */
  13888. serialize(): any;
  13889. /**
  13890. * Parse properties from a JSON object
  13891. * @param serializationObject defines the JSON object
  13892. */
  13893. parse(serializationObject: any): void;
  13894. }
  13895. }
  13896. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13897. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13898. import { Effect } from "babylonjs/Materials/effect";
  13899. import { Particle } from "babylonjs/Particles/particle";
  13900. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13901. /**
  13902. * Particle emitter emitting particles from the inside of a sphere.
  13903. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13904. */
  13905. export class SphereParticleEmitter implements IParticleEmitterType {
  13906. /**
  13907. * The radius of the emission sphere.
  13908. */
  13909. radius: number;
  13910. /**
  13911. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13912. */
  13913. radiusRange: number;
  13914. /**
  13915. * How much to randomize the particle direction [0-1].
  13916. */
  13917. directionRandomizer: number;
  13918. /**
  13919. * Creates a new instance SphereParticleEmitter
  13920. * @param radius the radius of the emission sphere (1 by default)
  13921. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13922. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13923. */
  13924. constructor(
  13925. /**
  13926. * The radius of the emission sphere.
  13927. */
  13928. radius?: number,
  13929. /**
  13930. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13931. */
  13932. radiusRange?: number,
  13933. /**
  13934. * How much to randomize the particle direction [0-1].
  13935. */
  13936. directionRandomizer?: number);
  13937. /**
  13938. * Called by the particle System when the direction is computed for the created particle.
  13939. * @param worldMatrix is the world matrix of the particle system
  13940. * @param directionToUpdate is the direction vector to update with the result
  13941. * @param particle is the particle we are computed the direction for
  13942. * @param isLocal defines if the direction should be set in local space
  13943. */
  13944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13945. /**
  13946. * Called by the particle System when the position is computed for the created particle.
  13947. * @param worldMatrix is the world matrix of the particle system
  13948. * @param positionToUpdate is the position vector to update with the result
  13949. * @param particle is the particle we are computed the position for
  13950. * @param isLocal defines if the position should be set in local space
  13951. */
  13952. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13953. /**
  13954. * Clones the current emitter and returns a copy of it
  13955. * @returns the new emitter
  13956. */
  13957. clone(): SphereParticleEmitter;
  13958. /**
  13959. * Called by the GPUParticleSystem to setup the update shader
  13960. * @param effect defines the update shader
  13961. */
  13962. applyToShader(effect: Effect): void;
  13963. /**
  13964. * Returns a string to use to update the GPU particles update shader
  13965. * @returns a string containng the defines string
  13966. */
  13967. getEffectDefines(): string;
  13968. /**
  13969. * Returns the string "SphereParticleEmitter"
  13970. * @returns a string containing the class name
  13971. */
  13972. getClassName(): string;
  13973. /**
  13974. * Serializes the particle system to a JSON object.
  13975. * @returns the JSON object
  13976. */
  13977. serialize(): any;
  13978. /**
  13979. * Parse properties from a JSON object
  13980. * @param serializationObject defines the JSON object
  13981. */
  13982. parse(serializationObject: any): void;
  13983. }
  13984. /**
  13985. * Particle emitter emitting particles from the inside of a sphere.
  13986. * It emits the particles randomly between two vectors.
  13987. */
  13988. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13989. /**
  13990. * The min limit of the emission direction.
  13991. */
  13992. direction1: Vector3;
  13993. /**
  13994. * The max limit of the emission direction.
  13995. */
  13996. direction2: Vector3;
  13997. /**
  13998. * Creates a new instance SphereDirectedParticleEmitter
  13999. * @param radius the radius of the emission sphere (1 by default)
  14000. * @param direction1 the min limit of the emission direction (up vector by default)
  14001. * @param direction2 the max limit of the emission direction (up vector by default)
  14002. */
  14003. constructor(radius?: number,
  14004. /**
  14005. * The min limit of the emission direction.
  14006. */
  14007. direction1?: Vector3,
  14008. /**
  14009. * The max limit of the emission direction.
  14010. */
  14011. direction2?: Vector3);
  14012. /**
  14013. * Called by the particle System when the direction is computed for the created particle.
  14014. * @param worldMatrix is the world matrix of the particle system
  14015. * @param directionToUpdate is the direction vector to update with the result
  14016. * @param particle is the particle we are computed the direction for
  14017. */
  14018. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14019. /**
  14020. * Clones the current emitter and returns a copy of it
  14021. * @returns the new emitter
  14022. */
  14023. clone(): SphereDirectedParticleEmitter;
  14024. /**
  14025. * Called by the GPUParticleSystem to setup the update shader
  14026. * @param effect defines the update shader
  14027. */
  14028. applyToShader(effect: Effect): void;
  14029. /**
  14030. * Returns a string to use to update the GPU particles update shader
  14031. * @returns a string containng the defines string
  14032. */
  14033. getEffectDefines(): string;
  14034. /**
  14035. * Returns the string "SphereDirectedParticleEmitter"
  14036. * @returns a string containing the class name
  14037. */
  14038. getClassName(): string;
  14039. /**
  14040. * Serializes the particle system to a JSON object.
  14041. * @returns the JSON object
  14042. */
  14043. serialize(): any;
  14044. /**
  14045. * Parse properties from a JSON object
  14046. * @param serializationObject defines the JSON object
  14047. */
  14048. parse(serializationObject: any): void;
  14049. }
  14050. }
  14051. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14052. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14053. import { Effect } from "babylonjs/Materials/effect";
  14054. import { Particle } from "babylonjs/Particles/particle";
  14055. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14056. import { Nullable } from "babylonjs/types";
  14057. /**
  14058. * Particle emitter emitting particles from a custom list of positions.
  14059. */
  14060. export class CustomParticleEmitter implements IParticleEmitterType {
  14061. /**
  14062. * Gets or sets the position generator that will create the inital position of each particle.
  14063. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14064. */
  14065. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14066. /**
  14067. * Gets or sets the destination generator that will create the final destination of each particle.
  14068. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14069. */
  14070. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14071. /**
  14072. * Creates a new instance CustomParticleEmitter
  14073. */
  14074. constructor();
  14075. /**
  14076. * Called by the particle System when the direction is computed for the created particle.
  14077. * @param worldMatrix is the world matrix of the particle system
  14078. * @param directionToUpdate is the direction vector to update with the result
  14079. * @param particle is the particle we are computed the direction for
  14080. * @param isLocal defines if the direction should be set in local space
  14081. */
  14082. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14083. /**
  14084. * Called by the particle System when the position is computed for the created particle.
  14085. * @param worldMatrix is the world matrix of the particle system
  14086. * @param positionToUpdate is the position vector to update with the result
  14087. * @param particle is the particle we are computed the position for
  14088. * @param isLocal defines if the position should be set in local space
  14089. */
  14090. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14091. /**
  14092. * Clones the current emitter and returns a copy of it
  14093. * @returns the new emitter
  14094. */
  14095. clone(): CustomParticleEmitter;
  14096. /**
  14097. * Called by the GPUParticleSystem to setup the update shader
  14098. * @param effect defines the update shader
  14099. */
  14100. applyToShader(effect: Effect): void;
  14101. /**
  14102. * Returns a string to use to update the GPU particles update shader
  14103. * @returns a string containng the defines string
  14104. */
  14105. getEffectDefines(): string;
  14106. /**
  14107. * Returns the string "PointParticleEmitter"
  14108. * @returns a string containing the class name
  14109. */
  14110. getClassName(): string;
  14111. /**
  14112. * Serializes the particle system to a JSON object.
  14113. * @returns the JSON object
  14114. */
  14115. serialize(): any;
  14116. /**
  14117. * Parse properties from a JSON object
  14118. * @param serializationObject defines the JSON object
  14119. */
  14120. parse(serializationObject: any): void;
  14121. }
  14122. }
  14123. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14124. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14125. import { Effect } from "babylonjs/Materials/effect";
  14126. import { Particle } from "babylonjs/Particles/particle";
  14127. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14128. import { Nullable } from "babylonjs/types";
  14129. import { Scene } from "babylonjs/scene";
  14130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14131. /**
  14132. * Particle emitter emitting particles from the inside of a box.
  14133. * It emits the particles randomly between 2 given directions.
  14134. */
  14135. export class MeshParticleEmitter implements IParticleEmitterType {
  14136. private _indices;
  14137. private _positions;
  14138. private _normals;
  14139. private _storedNormal;
  14140. private _mesh;
  14141. /**
  14142. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14143. */
  14144. direction1: Vector3;
  14145. /**
  14146. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14147. */
  14148. direction2: Vector3;
  14149. /**
  14150. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14151. */
  14152. useMeshNormalsForDirection: boolean;
  14153. /** Defines the mesh to use as source */
  14154. get mesh(): Nullable<AbstractMesh>;
  14155. set mesh(value: Nullable<AbstractMesh>);
  14156. /**
  14157. * Creates a new instance MeshParticleEmitter
  14158. * @param mesh defines the mesh to use as source
  14159. */
  14160. constructor(mesh?: Nullable<AbstractMesh>);
  14161. /**
  14162. * Called by the particle System when the direction is computed for the created particle.
  14163. * @param worldMatrix is the world matrix of the particle system
  14164. * @param directionToUpdate is the direction vector to update with the result
  14165. * @param particle is the particle we are computed the direction for
  14166. * @param isLocal defines if the direction should be set in local space
  14167. */
  14168. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14169. /**
  14170. * Called by the particle System when the position is computed for the created particle.
  14171. * @param worldMatrix is the world matrix of the particle system
  14172. * @param positionToUpdate is the position vector to update with the result
  14173. * @param particle is the particle we are computed the position for
  14174. * @param isLocal defines if the position should be set in local space
  14175. */
  14176. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14177. /**
  14178. * Clones the current emitter and returns a copy of it
  14179. * @returns the new emitter
  14180. */
  14181. clone(): MeshParticleEmitter;
  14182. /**
  14183. * Called by the GPUParticleSystem to setup the update shader
  14184. * @param effect defines the update shader
  14185. */
  14186. applyToShader(effect: Effect): void;
  14187. /**
  14188. * Returns a string to use to update the GPU particles update shader
  14189. * @returns a string containng the defines string
  14190. */
  14191. getEffectDefines(): string;
  14192. /**
  14193. * Returns the string "BoxParticleEmitter"
  14194. * @returns a string containing the class name
  14195. */
  14196. getClassName(): string;
  14197. /**
  14198. * Serializes the particle system to a JSON object.
  14199. * @returns the JSON object
  14200. */
  14201. serialize(): any;
  14202. /**
  14203. * Parse properties from a JSON object
  14204. * @param serializationObject defines the JSON object
  14205. * @param scene defines the hosting scene
  14206. */
  14207. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14208. }
  14209. }
  14210. declare module "babylonjs/Particles/EmitterTypes/index" {
  14211. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14212. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14213. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14214. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14215. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14216. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14217. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14218. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14219. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14220. }
  14221. declare module "babylonjs/Particles/IParticleSystem" {
  14222. import { Nullable } from "babylonjs/types";
  14223. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14224. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14226. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14227. import { Scene } from "babylonjs/scene";
  14228. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14229. import { Effect } from "babylonjs/Materials/effect";
  14230. import { Observable } from "babylonjs/Misc/observable";
  14231. import { Animation } from "babylonjs/Animations/animation";
  14232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14233. /**
  14234. * Interface representing a particle system in Babylon.js.
  14235. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14236. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14237. */
  14238. export interface IParticleSystem {
  14239. /**
  14240. * List of animations used by the particle system.
  14241. */
  14242. animations: Animation[];
  14243. /**
  14244. * The id of the Particle system.
  14245. */
  14246. id: string;
  14247. /**
  14248. * The name of the Particle system.
  14249. */
  14250. name: string;
  14251. /**
  14252. * The emitter represents the Mesh or position we are attaching the particle system to.
  14253. */
  14254. emitter: Nullable<AbstractMesh | Vector3>;
  14255. /**
  14256. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14257. */
  14258. isBillboardBased: boolean;
  14259. /**
  14260. * The rendering group used by the Particle system to chose when to render.
  14261. */
  14262. renderingGroupId: number;
  14263. /**
  14264. * The layer mask we are rendering the particles through.
  14265. */
  14266. layerMask: number;
  14267. /**
  14268. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14269. */
  14270. updateSpeed: number;
  14271. /**
  14272. * The amount of time the particle system is running (depends of the overall update speed).
  14273. */
  14274. targetStopDuration: number;
  14275. /**
  14276. * The texture used to render each particle. (this can be a spritesheet)
  14277. */
  14278. particleTexture: Nullable<BaseTexture>;
  14279. /**
  14280. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14281. */
  14282. blendMode: number;
  14283. /**
  14284. * Minimum life time of emitting particles.
  14285. */
  14286. minLifeTime: number;
  14287. /**
  14288. * Maximum life time of emitting particles.
  14289. */
  14290. maxLifeTime: number;
  14291. /**
  14292. * Minimum Size of emitting particles.
  14293. */
  14294. minSize: number;
  14295. /**
  14296. * Maximum Size of emitting particles.
  14297. */
  14298. maxSize: number;
  14299. /**
  14300. * Minimum scale of emitting particles on X axis.
  14301. */
  14302. minScaleX: number;
  14303. /**
  14304. * Maximum scale of emitting particles on X axis.
  14305. */
  14306. maxScaleX: number;
  14307. /**
  14308. * Minimum scale of emitting particles on Y axis.
  14309. */
  14310. minScaleY: number;
  14311. /**
  14312. * Maximum scale of emitting particles on Y axis.
  14313. */
  14314. maxScaleY: number;
  14315. /**
  14316. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14317. */
  14318. color1: Color4;
  14319. /**
  14320. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14321. */
  14322. color2: Color4;
  14323. /**
  14324. * Color the particle will have at the end of its lifetime.
  14325. */
  14326. colorDead: Color4;
  14327. /**
  14328. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14329. */
  14330. emitRate: number;
  14331. /**
  14332. * You can use gravity if you want to give an orientation to your particles.
  14333. */
  14334. gravity: Vector3;
  14335. /**
  14336. * Minimum power of emitting particles.
  14337. */
  14338. minEmitPower: number;
  14339. /**
  14340. * Maximum power of emitting particles.
  14341. */
  14342. maxEmitPower: number;
  14343. /**
  14344. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14345. */
  14346. minAngularSpeed: number;
  14347. /**
  14348. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14349. */
  14350. maxAngularSpeed: number;
  14351. /**
  14352. * Gets or sets the minimal initial rotation in radians.
  14353. */
  14354. minInitialRotation: number;
  14355. /**
  14356. * Gets or sets the maximal initial rotation in radians.
  14357. */
  14358. maxInitialRotation: number;
  14359. /**
  14360. * The particle emitter type defines the emitter used by the particle system.
  14361. * It can be for example box, sphere, or cone...
  14362. */
  14363. particleEmitterType: Nullable<IParticleEmitterType>;
  14364. /**
  14365. * Defines the delay in milliseconds before starting the system (0 by default)
  14366. */
  14367. startDelay: number;
  14368. /**
  14369. * 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
  14370. */
  14371. preWarmCycles: number;
  14372. /**
  14373. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14374. */
  14375. preWarmStepOffset: number;
  14376. /**
  14377. * 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)
  14378. */
  14379. spriteCellChangeSpeed: number;
  14380. /**
  14381. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14382. */
  14383. startSpriteCellID: number;
  14384. /**
  14385. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14386. */
  14387. endSpriteCellID: number;
  14388. /**
  14389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14390. */
  14391. spriteCellWidth: number;
  14392. /**
  14393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14394. */
  14395. spriteCellHeight: number;
  14396. /**
  14397. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14398. */
  14399. spriteRandomStartCell: boolean;
  14400. /**
  14401. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14402. */
  14403. isAnimationSheetEnabled: boolean;
  14404. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14405. translationPivot: Vector2;
  14406. /**
  14407. * Gets or sets a texture used to add random noise to particle positions
  14408. */
  14409. noiseTexture: Nullable<BaseTexture>;
  14410. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14411. noiseStrength: Vector3;
  14412. /**
  14413. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14414. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14415. */
  14416. billboardMode: number;
  14417. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14418. limitVelocityDamping: number;
  14419. /**
  14420. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14421. */
  14422. beginAnimationOnStart: boolean;
  14423. /**
  14424. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14425. */
  14426. beginAnimationFrom: number;
  14427. /**
  14428. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14429. */
  14430. beginAnimationTo: number;
  14431. /**
  14432. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14433. */
  14434. beginAnimationLoop: boolean;
  14435. /**
  14436. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14437. */
  14438. disposeOnStop: boolean;
  14439. /**
  14440. * Specifies if the particles are updated in emitter local space or world space
  14441. */
  14442. isLocal: boolean;
  14443. /** Snippet ID if the particle system was created from the snippet server */
  14444. snippetId: string;
  14445. /** Gets or sets a matrix to use to compute projection */
  14446. defaultProjectionMatrix: Matrix;
  14447. /**
  14448. * Gets the maximum number of particles active at the same time.
  14449. * @returns The max number of active particles.
  14450. */
  14451. getCapacity(): number;
  14452. /**
  14453. * Gets the number of particles active at the same time.
  14454. * @returns The number of active particles.
  14455. */
  14456. getActiveCount(): number;
  14457. /**
  14458. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14459. * @returns True if it has been started, otherwise false.
  14460. */
  14461. isStarted(): boolean;
  14462. /**
  14463. * Animates the particle system for this frame.
  14464. */
  14465. animate(): void;
  14466. /**
  14467. * Renders the particle system in its current state.
  14468. * @returns the current number of particles
  14469. */
  14470. render(): number;
  14471. /**
  14472. * Dispose the particle system and frees its associated resources.
  14473. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14474. */
  14475. dispose(disposeTexture?: boolean): void;
  14476. /**
  14477. * An event triggered when the system is disposed
  14478. */
  14479. onDisposeObservable: Observable<IParticleSystem>;
  14480. /**
  14481. * Clones the particle system.
  14482. * @param name The name of the cloned object
  14483. * @param newEmitter The new emitter to use
  14484. * @returns the cloned particle system
  14485. */
  14486. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14487. /**
  14488. * Serializes the particle system to a JSON object
  14489. * @param serializeTexture defines if the texture must be serialized as well
  14490. * @returns the JSON object
  14491. */
  14492. serialize(serializeTexture: boolean): any;
  14493. /**
  14494. * Rebuild the particle system
  14495. */
  14496. rebuild(): void;
  14497. /** Force the system to rebuild all gradients that need to be resync */
  14498. forceRefreshGradients(): void;
  14499. /**
  14500. * Starts the particle system and begins to emit
  14501. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14502. */
  14503. start(delay?: number): void;
  14504. /**
  14505. * Stops the particle system.
  14506. */
  14507. stop(): void;
  14508. /**
  14509. * Remove all active particles
  14510. */
  14511. reset(): void;
  14512. /**
  14513. * Gets a boolean indicating that the system is stopping
  14514. * @returns true if the system is currently stopping
  14515. */
  14516. isStopping(): boolean;
  14517. /**
  14518. * Is this system ready to be used/rendered
  14519. * @return true if the system is ready
  14520. */
  14521. isReady(): boolean;
  14522. /**
  14523. * Returns the string "ParticleSystem"
  14524. * @returns a string containing the class name
  14525. */
  14526. getClassName(): string;
  14527. /**
  14528. * Gets the custom effect used to render the particles
  14529. * @param blendMode Blend mode for which the effect should be retrieved
  14530. * @returns The effect
  14531. */
  14532. getCustomEffect(blendMode: number): Nullable<Effect>;
  14533. /**
  14534. * Sets the custom effect used to render the particles
  14535. * @param effect The effect to set
  14536. * @param blendMode Blend mode for which the effect should be set
  14537. */
  14538. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14539. /**
  14540. * Fill the defines array according to the current settings of the particle system
  14541. * @param defines Array to be updated
  14542. * @param blendMode blend mode to take into account when updating the array
  14543. */
  14544. fillDefines(defines: Array<string>, blendMode: number): void;
  14545. /**
  14546. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14547. * @param uniforms Uniforms array to fill
  14548. * @param attributes Attributes array to fill
  14549. * @param samplers Samplers array to fill
  14550. */
  14551. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14552. /**
  14553. * Observable that will be called just before the particles are drawn
  14554. */
  14555. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14556. /**
  14557. * Gets the name of the particle vertex shader
  14558. */
  14559. vertexShaderName: string;
  14560. /**
  14561. * Adds a new color gradient
  14562. * @param gradient defines the gradient to use (between 0 and 1)
  14563. * @param color1 defines the color to affect to the specified gradient
  14564. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14565. * @returns the current particle system
  14566. */
  14567. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14568. /**
  14569. * Remove a specific color gradient
  14570. * @param gradient defines the gradient to remove
  14571. * @returns the current particle system
  14572. */
  14573. removeColorGradient(gradient: number): IParticleSystem;
  14574. /**
  14575. * Adds a new size gradient
  14576. * @param gradient defines the gradient to use (between 0 and 1)
  14577. * @param factor defines the size factor to affect to the specified gradient
  14578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14579. * @returns the current particle system
  14580. */
  14581. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14582. /**
  14583. * Remove a specific size gradient
  14584. * @param gradient defines the gradient to remove
  14585. * @returns the current particle system
  14586. */
  14587. removeSizeGradient(gradient: number): IParticleSystem;
  14588. /**
  14589. * Gets the current list of color gradients.
  14590. * You must use addColorGradient and removeColorGradient to udpate this list
  14591. * @returns the list of color gradients
  14592. */
  14593. getColorGradients(): Nullable<Array<ColorGradient>>;
  14594. /**
  14595. * Gets the current list of size gradients.
  14596. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14597. * @returns the list of size gradients
  14598. */
  14599. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14600. /**
  14601. * Gets the current list of angular speed gradients.
  14602. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14603. * @returns the list of angular speed gradients
  14604. */
  14605. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14606. /**
  14607. * Adds a new angular speed gradient
  14608. * @param gradient defines the gradient to use (between 0 and 1)
  14609. * @param factor defines the angular speed to affect to the specified gradient
  14610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14611. * @returns the current particle system
  14612. */
  14613. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14614. /**
  14615. * Remove a specific angular speed gradient
  14616. * @param gradient defines the gradient to remove
  14617. * @returns the current particle system
  14618. */
  14619. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14620. /**
  14621. * Gets the current list of velocity gradients.
  14622. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14623. * @returns the list of velocity gradients
  14624. */
  14625. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14626. /**
  14627. * Adds a new velocity gradient
  14628. * @param gradient defines the gradient to use (between 0 and 1)
  14629. * @param factor defines the velocity to affect to the specified gradient
  14630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14631. * @returns the current particle system
  14632. */
  14633. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14634. /**
  14635. * Remove a specific velocity gradient
  14636. * @param gradient defines the gradient to remove
  14637. * @returns the current particle system
  14638. */
  14639. removeVelocityGradient(gradient: number): IParticleSystem;
  14640. /**
  14641. * Gets the current list of limit velocity gradients.
  14642. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14643. * @returns the list of limit velocity gradients
  14644. */
  14645. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14646. /**
  14647. * Adds a new limit velocity gradient
  14648. * @param gradient defines the gradient to use (between 0 and 1)
  14649. * @param factor defines the limit velocity to affect to the specified gradient
  14650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14651. * @returns the current particle system
  14652. */
  14653. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14654. /**
  14655. * Remove a specific limit velocity gradient
  14656. * @param gradient defines the gradient to remove
  14657. * @returns the current particle system
  14658. */
  14659. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14660. /**
  14661. * Adds a new drag gradient
  14662. * @param gradient defines the gradient to use (between 0 and 1)
  14663. * @param factor defines the drag to affect to the specified gradient
  14664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14665. * @returns the current particle system
  14666. */
  14667. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14668. /**
  14669. * Remove a specific drag gradient
  14670. * @param gradient defines the gradient to remove
  14671. * @returns the current particle system
  14672. */
  14673. removeDragGradient(gradient: number): IParticleSystem;
  14674. /**
  14675. * Gets the current list of drag gradients.
  14676. * You must use addDragGradient and removeDragGradient to udpate this list
  14677. * @returns the list of drag gradients
  14678. */
  14679. getDragGradients(): Nullable<Array<FactorGradient>>;
  14680. /**
  14681. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14682. * @param gradient defines the gradient to use (between 0 and 1)
  14683. * @param factor defines the emit rate to affect to the specified gradient
  14684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14685. * @returns the current particle system
  14686. */
  14687. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14688. /**
  14689. * Remove a specific emit rate gradient
  14690. * @param gradient defines the gradient to remove
  14691. * @returns the current particle system
  14692. */
  14693. removeEmitRateGradient(gradient: number): IParticleSystem;
  14694. /**
  14695. * Gets the current list of emit rate gradients.
  14696. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14697. * @returns the list of emit rate gradients
  14698. */
  14699. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14700. /**
  14701. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14702. * @param gradient defines the gradient to use (between 0 and 1)
  14703. * @param factor defines the start size to affect to the specified gradient
  14704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14705. * @returns the current particle system
  14706. */
  14707. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14708. /**
  14709. * Remove a specific start size gradient
  14710. * @param gradient defines the gradient to remove
  14711. * @returns the current particle system
  14712. */
  14713. removeStartSizeGradient(gradient: number): IParticleSystem;
  14714. /**
  14715. * Gets the current list of start size gradients.
  14716. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14717. * @returns the list of start size gradients
  14718. */
  14719. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14720. /**
  14721. * Adds a new life time gradient
  14722. * @param gradient defines the gradient to use (between 0 and 1)
  14723. * @param factor defines the life time factor to affect to the specified gradient
  14724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14725. * @returns the current particle system
  14726. */
  14727. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14728. /**
  14729. * Remove a specific life time gradient
  14730. * @param gradient defines the gradient to remove
  14731. * @returns the current particle system
  14732. */
  14733. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14734. /**
  14735. * Gets the current list of life time gradients.
  14736. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14737. * @returns the list of life time gradients
  14738. */
  14739. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14740. /**
  14741. * Gets the current list of color gradients.
  14742. * You must use addColorGradient and removeColorGradient to udpate this list
  14743. * @returns the list of color gradients
  14744. */
  14745. getColorGradients(): Nullable<Array<ColorGradient>>;
  14746. /**
  14747. * Adds a new ramp gradient used to remap particle colors
  14748. * @param gradient defines the gradient to use (between 0 and 1)
  14749. * @param color defines the color to affect to the specified gradient
  14750. * @returns the current particle system
  14751. */
  14752. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14753. /**
  14754. * Gets the current list of ramp gradients.
  14755. * You must use addRampGradient and removeRampGradient to udpate this list
  14756. * @returns the list of ramp gradients
  14757. */
  14758. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14759. /** Gets or sets a boolean indicating that ramp gradients must be used
  14760. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14761. */
  14762. useRampGradients: boolean;
  14763. /**
  14764. * Adds a new color remap gradient
  14765. * @param gradient defines the gradient to use (between 0 and 1)
  14766. * @param min defines the color remap minimal range
  14767. * @param max defines the color remap maximal range
  14768. * @returns the current particle system
  14769. */
  14770. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14771. /**
  14772. * Gets the current list of color remap gradients.
  14773. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14774. * @returns the list of color remap gradients
  14775. */
  14776. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14777. /**
  14778. * Adds a new alpha remap gradient
  14779. * @param gradient defines the gradient to use (between 0 and 1)
  14780. * @param min defines the alpha remap minimal range
  14781. * @param max defines the alpha remap maximal range
  14782. * @returns the current particle system
  14783. */
  14784. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14785. /**
  14786. * Gets the current list of alpha remap gradients.
  14787. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14788. * @returns the list of alpha remap gradients
  14789. */
  14790. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14791. /**
  14792. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14793. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14794. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14795. * @returns the emitter
  14796. */
  14797. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14798. /**
  14799. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14800. * @param radius The radius of the hemisphere to emit from
  14801. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14802. * @returns the emitter
  14803. */
  14804. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14805. /**
  14806. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14807. * @param radius The radius of the sphere to emit from
  14808. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14809. * @returns the emitter
  14810. */
  14811. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14812. /**
  14813. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14814. * @param radius The radius of the sphere to emit from
  14815. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14816. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14817. * @returns the emitter
  14818. */
  14819. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14820. /**
  14821. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14822. * @param radius The radius of the emission cylinder
  14823. * @param height The height of the emission cylinder
  14824. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14825. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14826. * @returns the emitter
  14827. */
  14828. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14829. /**
  14830. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14831. * @param radius The radius of the cylinder to emit from
  14832. * @param height The height of the emission cylinder
  14833. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14834. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14835. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14836. * @returns the emitter
  14837. */
  14838. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14839. /**
  14840. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14841. * @param radius The radius of the cone to emit from
  14842. * @param angle The base angle of the cone
  14843. * @returns the emitter
  14844. */
  14845. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14846. /**
  14847. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14848. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14849. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14850. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14851. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14852. * @returns the emitter
  14853. */
  14854. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14855. /**
  14856. * Get hosting scene
  14857. * @returns the scene
  14858. */
  14859. getScene(): Nullable<Scene>;
  14860. }
  14861. }
  14862. declare module "babylonjs/Meshes/transformNode" {
  14863. import { DeepImmutable } from "babylonjs/types";
  14864. import { Observable } from "babylonjs/Misc/observable";
  14865. import { Nullable } from "babylonjs/types";
  14866. import { Camera } from "babylonjs/Cameras/camera";
  14867. import { Scene } from "babylonjs/scene";
  14868. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14869. import { Node } from "babylonjs/node";
  14870. import { Bone } from "babylonjs/Bones/bone";
  14871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14872. import { Space } from "babylonjs/Maths/math.axis";
  14873. /**
  14874. * 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.
  14875. * @see https://doc.babylonjs.com/how_to/transformnode
  14876. */
  14877. export class TransformNode extends Node {
  14878. /**
  14879. * Object will not rotate to face the camera
  14880. */
  14881. static BILLBOARDMODE_NONE: number;
  14882. /**
  14883. * Object will rotate to face the camera but only on the x axis
  14884. */
  14885. static BILLBOARDMODE_X: number;
  14886. /**
  14887. * Object will rotate to face the camera but only on the y axis
  14888. */
  14889. static BILLBOARDMODE_Y: number;
  14890. /**
  14891. * Object will rotate to face the camera but only on the z axis
  14892. */
  14893. static BILLBOARDMODE_Z: number;
  14894. /**
  14895. * Object will rotate to face the camera
  14896. */
  14897. static BILLBOARDMODE_ALL: number;
  14898. /**
  14899. * Object will rotate to face the camera's position instead of orientation
  14900. */
  14901. static BILLBOARDMODE_USE_POSITION: number;
  14902. private static _TmpRotation;
  14903. private static _TmpScaling;
  14904. private static _TmpTranslation;
  14905. private _forward;
  14906. private _forwardInverted;
  14907. private _up;
  14908. private _right;
  14909. private _rightInverted;
  14910. private _position;
  14911. private _rotation;
  14912. private _rotationQuaternion;
  14913. protected _scaling: Vector3;
  14914. protected _isDirty: boolean;
  14915. private _transformToBoneReferal;
  14916. private _isAbsoluteSynced;
  14917. private _billboardMode;
  14918. /**
  14919. * Gets or sets the billboard mode. Default is 0.
  14920. *
  14921. * | Value | Type | Description |
  14922. * | --- | --- | --- |
  14923. * | 0 | BILLBOARDMODE_NONE | |
  14924. * | 1 | BILLBOARDMODE_X | |
  14925. * | 2 | BILLBOARDMODE_Y | |
  14926. * | 4 | BILLBOARDMODE_Z | |
  14927. * | 7 | BILLBOARDMODE_ALL | |
  14928. *
  14929. */
  14930. get billboardMode(): number;
  14931. set billboardMode(value: number);
  14932. private _preserveParentRotationForBillboard;
  14933. /**
  14934. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14935. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14936. */
  14937. get preserveParentRotationForBillboard(): boolean;
  14938. set preserveParentRotationForBillboard(value: boolean);
  14939. /**
  14940. * 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
  14941. */
  14942. scalingDeterminant: number;
  14943. private _infiniteDistance;
  14944. /**
  14945. * Gets or sets the distance of the object to max, often used by skybox
  14946. */
  14947. get infiniteDistance(): boolean;
  14948. set infiniteDistance(value: boolean);
  14949. /**
  14950. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14951. * By default the system will update normals to compensate
  14952. */
  14953. ignoreNonUniformScaling: boolean;
  14954. /**
  14955. * 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
  14956. */
  14957. reIntegrateRotationIntoRotationQuaternion: boolean;
  14958. /** @hidden */
  14959. _poseMatrix: Nullable<Matrix>;
  14960. /** @hidden */
  14961. _localMatrix: Matrix;
  14962. private _usePivotMatrix;
  14963. private _absolutePosition;
  14964. private _absoluteScaling;
  14965. private _absoluteRotationQuaternion;
  14966. private _pivotMatrix;
  14967. private _pivotMatrixInverse;
  14968. protected _postMultiplyPivotMatrix: boolean;
  14969. protected _isWorldMatrixFrozen: boolean;
  14970. /** @hidden */
  14971. _indexInSceneTransformNodesArray: number;
  14972. /**
  14973. * An event triggered after the world matrix is updated
  14974. */
  14975. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14976. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14977. /**
  14978. * Gets a string identifying the name of the class
  14979. * @returns "TransformNode" string
  14980. */
  14981. getClassName(): string;
  14982. /**
  14983. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14984. */
  14985. get position(): Vector3;
  14986. set position(newPosition: Vector3);
  14987. /**
  14988. * 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)).
  14989. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14990. */
  14991. get rotation(): Vector3;
  14992. set rotation(newRotation: Vector3);
  14993. /**
  14994. * 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)).
  14995. */
  14996. get scaling(): Vector3;
  14997. set scaling(newScaling: Vector3);
  14998. /**
  14999. * 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).
  15000. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15001. */
  15002. get rotationQuaternion(): Nullable<Quaternion>;
  15003. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15004. /**
  15005. * The forward direction of that transform in world space.
  15006. */
  15007. get forward(): Vector3;
  15008. /**
  15009. * The up direction of that transform in world space.
  15010. */
  15011. get up(): Vector3;
  15012. /**
  15013. * The right direction of that transform in world space.
  15014. */
  15015. get right(): Vector3;
  15016. /**
  15017. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15018. * @param matrix the matrix to copy the pose from
  15019. * @returns this TransformNode.
  15020. */
  15021. updatePoseMatrix(matrix: Matrix): TransformNode;
  15022. /**
  15023. * Returns the mesh Pose matrix.
  15024. * @returns the pose matrix
  15025. */
  15026. getPoseMatrix(): Matrix;
  15027. /** @hidden */
  15028. _isSynchronized(): boolean;
  15029. /** @hidden */
  15030. _initCache(): void;
  15031. /**
  15032. * Flag the transform node as dirty (Forcing it to update everything)
  15033. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15034. * @returns this transform node
  15035. */
  15036. markAsDirty(property: string): TransformNode;
  15037. /**
  15038. * Returns the current mesh absolute position.
  15039. * Returns a Vector3.
  15040. */
  15041. get absolutePosition(): Vector3;
  15042. /**
  15043. * Returns the current mesh absolute scaling.
  15044. * Returns a Vector3.
  15045. */
  15046. get absoluteScaling(): Vector3;
  15047. /**
  15048. * Returns the current mesh absolute rotation.
  15049. * Returns a Quaternion.
  15050. */
  15051. get absoluteRotationQuaternion(): Quaternion;
  15052. /**
  15053. * Sets a new matrix to apply before all other transformation
  15054. * @param matrix defines the transform matrix
  15055. * @returns the current TransformNode
  15056. */
  15057. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15058. /**
  15059. * Sets a new pivot matrix to the current node
  15060. * @param matrix defines the new pivot matrix to use
  15061. * @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
  15062. * @returns the current TransformNode
  15063. */
  15064. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15065. /**
  15066. * Returns the mesh pivot matrix.
  15067. * Default : Identity.
  15068. * @returns the matrix
  15069. */
  15070. getPivotMatrix(): Matrix;
  15071. /**
  15072. * Instantiate (when possible) or clone that node with its hierarchy
  15073. * @param newParent defines the new parent to use for the instance (or clone)
  15074. * @param options defines options to configure how copy is done
  15075. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15076. * @returns an instance (or a clone) of the current node with its hiearchy
  15077. */
  15078. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15079. doNotInstantiate: boolean;
  15080. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15081. /**
  15082. * Prevents the World matrix to be computed any longer
  15083. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15084. * @returns the TransformNode.
  15085. */
  15086. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15087. /**
  15088. * Allows back the World matrix computation.
  15089. * @returns the TransformNode.
  15090. */
  15091. unfreezeWorldMatrix(): this;
  15092. /**
  15093. * True if the World matrix has been frozen.
  15094. */
  15095. get isWorldMatrixFrozen(): boolean;
  15096. /**
  15097. * Retuns the mesh absolute position in the World.
  15098. * @returns a Vector3.
  15099. */
  15100. getAbsolutePosition(): Vector3;
  15101. /**
  15102. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15103. * @param absolutePosition the absolute position to set
  15104. * @returns the TransformNode.
  15105. */
  15106. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15107. /**
  15108. * Sets the mesh position in its local space.
  15109. * @param vector3 the position to set in localspace
  15110. * @returns the TransformNode.
  15111. */
  15112. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15113. /**
  15114. * Returns the mesh position in the local space from the current World matrix values.
  15115. * @returns a new Vector3.
  15116. */
  15117. getPositionExpressedInLocalSpace(): Vector3;
  15118. /**
  15119. * Translates the mesh along the passed Vector3 in its local space.
  15120. * @param vector3 the distance to translate in localspace
  15121. * @returns the TransformNode.
  15122. */
  15123. locallyTranslate(vector3: Vector3): TransformNode;
  15124. private static _lookAtVectorCache;
  15125. /**
  15126. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15127. * @param targetPoint the position (must be in same space as current mesh) to look at
  15128. * @param yawCor optional yaw (y-axis) correction in radians
  15129. * @param pitchCor optional pitch (x-axis) correction in radians
  15130. * @param rollCor optional roll (z-axis) correction in radians
  15131. * @param space the choosen space of the target
  15132. * @returns the TransformNode.
  15133. */
  15134. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15135. /**
  15136. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15137. * This Vector3 is expressed in the World space.
  15138. * @param localAxis axis to rotate
  15139. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15140. */
  15141. getDirection(localAxis: Vector3): Vector3;
  15142. /**
  15143. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15144. * localAxis is expressed in the mesh local space.
  15145. * result is computed in the Wordl space from the mesh World matrix.
  15146. * @param localAxis axis to rotate
  15147. * @param result the resulting transformnode
  15148. * @returns this TransformNode.
  15149. */
  15150. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15151. /**
  15152. * Sets this transform node rotation to the given local axis.
  15153. * @param localAxis the axis in local space
  15154. * @param yawCor optional yaw (y-axis) correction in radians
  15155. * @param pitchCor optional pitch (x-axis) correction in radians
  15156. * @param rollCor optional roll (z-axis) correction in radians
  15157. * @returns this TransformNode
  15158. */
  15159. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15160. /**
  15161. * Sets a new pivot point to the current node
  15162. * @param point defines the new pivot point to use
  15163. * @param space defines if the point is in world or local space (local by default)
  15164. * @returns the current TransformNode
  15165. */
  15166. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15167. /**
  15168. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15169. * @returns the pivot point
  15170. */
  15171. getPivotPoint(): Vector3;
  15172. /**
  15173. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15174. * @param result the vector3 to store the result
  15175. * @returns this TransformNode.
  15176. */
  15177. getPivotPointToRef(result: Vector3): TransformNode;
  15178. /**
  15179. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15180. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15181. */
  15182. getAbsolutePivotPoint(): Vector3;
  15183. /**
  15184. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15185. * @param result vector3 to store the result
  15186. * @returns this TransformNode.
  15187. */
  15188. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15189. /**
  15190. * Defines the passed node as the parent of the current node.
  15191. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15192. * @see https://doc.babylonjs.com/how_to/parenting
  15193. * @param node the node ot set as the parent
  15194. * @returns this TransformNode.
  15195. */
  15196. setParent(node: Nullable<Node>): TransformNode;
  15197. private _nonUniformScaling;
  15198. /**
  15199. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15200. */
  15201. get nonUniformScaling(): boolean;
  15202. /** @hidden */
  15203. _updateNonUniformScalingState(value: boolean): boolean;
  15204. /**
  15205. * Attach the current TransformNode to another TransformNode associated with a bone
  15206. * @param bone Bone affecting the TransformNode
  15207. * @param affectedTransformNode TransformNode associated with the bone
  15208. * @returns this object
  15209. */
  15210. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15211. /**
  15212. * Detach the transform node if its associated with a bone
  15213. * @returns this object
  15214. */
  15215. detachFromBone(): TransformNode;
  15216. private static _rotationAxisCache;
  15217. /**
  15218. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15219. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15220. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15221. * The passed axis is also normalized.
  15222. * @param axis the axis to rotate around
  15223. * @param amount the amount to rotate in radians
  15224. * @param space Space to rotate in (Default: local)
  15225. * @returns the TransformNode.
  15226. */
  15227. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15228. /**
  15229. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15230. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15231. * The passed axis is also normalized. .
  15232. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15233. * @param point the point to rotate around
  15234. * @param axis the axis to rotate around
  15235. * @param amount the amount to rotate in radians
  15236. * @returns the TransformNode
  15237. */
  15238. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15239. /**
  15240. * Translates the mesh along the axis vector for the passed distance in the given space.
  15241. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15242. * @param axis the axis to translate in
  15243. * @param distance the distance to translate
  15244. * @param space Space to rotate in (Default: local)
  15245. * @returns the TransformNode.
  15246. */
  15247. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15248. /**
  15249. * Adds a rotation step to the mesh current rotation.
  15250. * x, y, z are Euler angles expressed in radians.
  15251. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15252. * This means this rotation is made in the mesh local space only.
  15253. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15254. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15255. * ```javascript
  15256. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15257. * ```
  15258. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15259. * 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.
  15260. * @param x Rotation to add
  15261. * @param y Rotation to add
  15262. * @param z Rotation to add
  15263. * @returns the TransformNode.
  15264. */
  15265. addRotation(x: number, y: number, z: number): TransformNode;
  15266. /**
  15267. * @hidden
  15268. */
  15269. protected _getEffectiveParent(): Nullable<Node>;
  15270. /**
  15271. * Computes the world matrix of the node
  15272. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15273. * @returns the world matrix
  15274. */
  15275. computeWorldMatrix(force?: boolean): Matrix;
  15276. /**
  15277. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15278. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15279. */
  15280. resetLocalMatrix(independentOfChildren?: boolean): void;
  15281. protected _afterComputeWorldMatrix(): void;
  15282. /**
  15283. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15284. * @param func callback function to add
  15285. *
  15286. * @returns the TransformNode.
  15287. */
  15288. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15289. /**
  15290. * Removes a registered callback function.
  15291. * @param func callback function to remove
  15292. * @returns the TransformNode.
  15293. */
  15294. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15295. /**
  15296. * Gets the position of the current mesh in camera space
  15297. * @param camera defines the camera to use
  15298. * @returns a position
  15299. */
  15300. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15301. /**
  15302. * Returns the distance from the mesh to the active camera
  15303. * @param camera defines the camera to use
  15304. * @returns the distance
  15305. */
  15306. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15307. /**
  15308. * Clone the current transform node
  15309. * @param name Name of the new clone
  15310. * @param newParent New parent for the clone
  15311. * @param doNotCloneChildren Do not clone children hierarchy
  15312. * @returns the new transform node
  15313. */
  15314. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15315. /**
  15316. * Serializes the objects information.
  15317. * @param currentSerializationObject defines the object to serialize in
  15318. * @returns the serialized object
  15319. */
  15320. serialize(currentSerializationObject?: any): any;
  15321. /**
  15322. * Returns a new TransformNode object parsed from the source provided.
  15323. * @param parsedTransformNode is the source.
  15324. * @param scene the scne the object belongs to
  15325. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15326. * @returns a new TransformNode object parsed from the source provided.
  15327. */
  15328. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15329. /**
  15330. * Get all child-transformNodes of this node
  15331. * @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
  15332. * @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
  15333. * @returns an array of TransformNode
  15334. */
  15335. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15336. /**
  15337. * Releases resources associated with this transform node.
  15338. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15339. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15340. */
  15341. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15342. /**
  15343. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15344. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15345. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15346. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15347. * @returns the current mesh
  15348. */
  15349. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15350. private _syncAbsoluteScalingAndRotation;
  15351. }
  15352. }
  15353. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15354. /**
  15355. * Class used to override all child animations of a given target
  15356. */
  15357. export class AnimationPropertiesOverride {
  15358. /**
  15359. * Gets or sets a value indicating if animation blending must be used
  15360. */
  15361. enableBlending: boolean;
  15362. /**
  15363. * Gets or sets the blending speed to use when enableBlending is true
  15364. */
  15365. blendingSpeed: number;
  15366. /**
  15367. * Gets or sets the default loop mode to use
  15368. */
  15369. loopMode: number;
  15370. }
  15371. }
  15372. declare module "babylonjs/Bones/bone" {
  15373. import { Skeleton } from "babylonjs/Bones/skeleton";
  15374. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15375. import { Nullable } from "babylonjs/types";
  15376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15377. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15378. import { Node } from "babylonjs/node";
  15379. import { Space } from "babylonjs/Maths/math.axis";
  15380. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15381. /**
  15382. * Class used to store bone information
  15383. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15384. */
  15385. export class Bone extends Node {
  15386. /**
  15387. * defines the bone name
  15388. */
  15389. name: string;
  15390. private static _tmpVecs;
  15391. private static _tmpQuat;
  15392. private static _tmpMats;
  15393. /**
  15394. * Gets the list of child bones
  15395. */
  15396. children: Bone[];
  15397. /** Gets the animations associated with this bone */
  15398. animations: import("babylonjs/Animations/animation").Animation[];
  15399. /**
  15400. * Gets or sets bone length
  15401. */
  15402. length: number;
  15403. /**
  15404. * @hidden Internal only
  15405. * Set this value to map this bone to a different index in the transform matrices
  15406. * Set this value to -1 to exclude the bone from the transform matrices
  15407. */
  15408. _index: Nullable<number>;
  15409. private _skeleton;
  15410. private _localMatrix;
  15411. private _restPose;
  15412. private _bindPose;
  15413. private _baseMatrix;
  15414. private _absoluteTransform;
  15415. private _invertedAbsoluteTransform;
  15416. private _parent;
  15417. private _scalingDeterminant;
  15418. private _worldTransform;
  15419. private _localScaling;
  15420. private _localRotation;
  15421. private _localPosition;
  15422. private _needToDecompose;
  15423. private _needToCompose;
  15424. /** @hidden */
  15425. _linkedTransformNode: Nullable<TransformNode>;
  15426. /** @hidden */
  15427. _waitingTransformNodeId: Nullable<string>;
  15428. /** @hidden */
  15429. get _matrix(): Matrix;
  15430. /** @hidden */
  15431. set _matrix(value: Matrix);
  15432. /**
  15433. * Create a new bone
  15434. * @param name defines the bone name
  15435. * @param skeleton defines the parent skeleton
  15436. * @param parentBone defines the parent (can be null if the bone is the root)
  15437. * @param localMatrix defines the local matrix
  15438. * @param restPose defines the rest pose matrix
  15439. * @param baseMatrix defines the base matrix
  15440. * @param index defines index of the bone in the hiearchy
  15441. */
  15442. constructor(
  15443. /**
  15444. * defines the bone name
  15445. */
  15446. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15447. /**
  15448. * Gets the current object class name.
  15449. * @return the class name
  15450. */
  15451. getClassName(): string;
  15452. /**
  15453. * Gets the parent skeleton
  15454. * @returns a skeleton
  15455. */
  15456. getSkeleton(): Skeleton;
  15457. /**
  15458. * Gets parent bone
  15459. * @returns a bone or null if the bone is the root of the bone hierarchy
  15460. */
  15461. getParent(): Nullable<Bone>;
  15462. /**
  15463. * Returns an array containing the root bones
  15464. * @returns an array containing the root bones
  15465. */
  15466. getChildren(): Array<Bone>;
  15467. /**
  15468. * Gets the node index in matrix array generated for rendering
  15469. * @returns the node index
  15470. */
  15471. getIndex(): number;
  15472. /**
  15473. * Sets the parent bone
  15474. * @param parent defines the parent (can be null if the bone is the root)
  15475. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15476. */
  15477. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15478. /**
  15479. * Gets the local matrix
  15480. * @returns a matrix
  15481. */
  15482. getLocalMatrix(): Matrix;
  15483. /**
  15484. * Gets the base matrix (initial matrix which remains unchanged)
  15485. * @returns a matrix
  15486. */
  15487. getBaseMatrix(): Matrix;
  15488. /**
  15489. * Gets the rest pose matrix
  15490. * @returns a matrix
  15491. */
  15492. getRestPose(): Matrix;
  15493. /**
  15494. * Sets the rest pose matrix
  15495. * @param matrix the local-space rest pose to set for this bone
  15496. */
  15497. setRestPose(matrix: Matrix): void;
  15498. /**
  15499. * Gets the bind pose matrix
  15500. * @returns the bind pose matrix
  15501. */
  15502. getBindPose(): Matrix;
  15503. /**
  15504. * Sets the bind pose matrix
  15505. * @param matrix the local-space bind pose to set for this bone
  15506. */
  15507. setBindPose(matrix: Matrix): void;
  15508. /**
  15509. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15510. */
  15511. getWorldMatrix(): Matrix;
  15512. /**
  15513. * Sets the local matrix to rest pose matrix
  15514. */
  15515. returnToRest(): void;
  15516. /**
  15517. * Gets the inverse of the absolute transform matrix.
  15518. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15519. * @returns a matrix
  15520. */
  15521. getInvertedAbsoluteTransform(): Matrix;
  15522. /**
  15523. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15524. * @returns a matrix
  15525. */
  15526. getAbsoluteTransform(): Matrix;
  15527. /**
  15528. * Links with the given transform node.
  15529. * The local matrix of this bone is copied from the transform node every frame.
  15530. * @param transformNode defines the transform node to link to
  15531. */
  15532. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15533. /**
  15534. * Gets the node used to drive the bone's transformation
  15535. * @returns a transform node or null
  15536. */
  15537. getTransformNode(): Nullable<TransformNode>;
  15538. /** Gets or sets current position (in local space) */
  15539. get position(): Vector3;
  15540. set position(newPosition: Vector3);
  15541. /** Gets or sets current rotation (in local space) */
  15542. get rotation(): Vector3;
  15543. set rotation(newRotation: Vector3);
  15544. /** Gets or sets current rotation quaternion (in local space) */
  15545. get rotationQuaternion(): Quaternion;
  15546. set rotationQuaternion(newRotation: Quaternion);
  15547. /** Gets or sets current scaling (in local space) */
  15548. get scaling(): Vector3;
  15549. set scaling(newScaling: Vector3);
  15550. /**
  15551. * Gets the animation properties override
  15552. */
  15553. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15554. private _decompose;
  15555. private _compose;
  15556. /**
  15557. * Update the base and local matrices
  15558. * @param matrix defines the new base or local matrix
  15559. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15560. * @param updateLocalMatrix defines if the local matrix should be updated
  15561. */
  15562. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15563. /** @hidden */
  15564. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15565. /**
  15566. * Flag the bone as dirty (Forcing it to update everything)
  15567. */
  15568. markAsDirty(): void;
  15569. /** @hidden */
  15570. _markAsDirtyAndCompose(): void;
  15571. private _markAsDirtyAndDecompose;
  15572. /**
  15573. * Translate the bone in local or world space
  15574. * @param vec The amount to translate the bone
  15575. * @param space The space that the translation is in
  15576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15577. */
  15578. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15579. /**
  15580. * Set the postion of the bone in local or world space
  15581. * @param position The position to set the bone
  15582. * @param space The space that the position is in
  15583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15584. */
  15585. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15586. /**
  15587. * Set the absolute position of the bone (world space)
  15588. * @param position The position to set the bone
  15589. * @param mesh The mesh that this bone is attached to
  15590. */
  15591. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15592. /**
  15593. * Scale the bone on the x, y and z axes (in local space)
  15594. * @param x The amount to scale the bone on the x axis
  15595. * @param y The amount to scale the bone on the y axis
  15596. * @param z The amount to scale the bone on the z axis
  15597. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15598. */
  15599. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15600. /**
  15601. * Set the bone scaling in local space
  15602. * @param scale defines the scaling vector
  15603. */
  15604. setScale(scale: Vector3): void;
  15605. /**
  15606. * Gets the current scaling in local space
  15607. * @returns the current scaling vector
  15608. */
  15609. getScale(): Vector3;
  15610. /**
  15611. * Gets the current scaling in local space and stores it in a target vector
  15612. * @param result defines the target vector
  15613. */
  15614. getScaleToRef(result: Vector3): void;
  15615. /**
  15616. * Set the yaw, pitch, and roll of the bone in local or world space
  15617. * @param yaw The rotation of the bone on the y axis
  15618. * @param pitch The rotation of the bone on the x axis
  15619. * @param roll The rotation of the bone on the z axis
  15620. * @param space The space that the axes of rotation are in
  15621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15622. */
  15623. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15624. /**
  15625. * Add a rotation to the bone on an axis in local or world space
  15626. * @param axis The axis to rotate the bone on
  15627. * @param amount The amount to rotate the bone
  15628. * @param space The space that the axis is in
  15629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15630. */
  15631. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15632. /**
  15633. * Set the rotation of the bone to a particular axis angle in local or world space
  15634. * @param axis The axis to rotate the bone on
  15635. * @param angle The angle that the bone should be rotated to
  15636. * @param space The space that the axis is in
  15637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15638. */
  15639. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15640. /**
  15641. * Set the euler rotation of the bone in local of world space
  15642. * @param rotation The euler rotation that the bone should be set to
  15643. * @param space The space that the rotation is in
  15644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15645. */
  15646. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15647. /**
  15648. * Set the quaternion rotation of the bone in local of world space
  15649. * @param quat The quaternion rotation that the bone should be set to
  15650. * @param space The space that the rotation is in
  15651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15652. */
  15653. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15654. /**
  15655. * Set the rotation matrix of the bone in local of world space
  15656. * @param rotMat The rotation matrix that the bone should be set to
  15657. * @param space The space that the rotation is in
  15658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15659. */
  15660. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15661. private _rotateWithMatrix;
  15662. private _getNegativeRotationToRef;
  15663. /**
  15664. * Get the position of the bone in local or world space
  15665. * @param space The space that the returned position is in
  15666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15667. * @returns The position of the bone
  15668. */
  15669. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15670. /**
  15671. * Copy the position of the bone to a vector3 in local or world space
  15672. * @param space The space that the returned position is in
  15673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15674. * @param result The vector3 to copy the position to
  15675. */
  15676. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15677. /**
  15678. * Get the absolute position of the bone (world space)
  15679. * @param mesh The mesh that this bone is attached to
  15680. * @returns The absolute position of the bone
  15681. */
  15682. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15683. /**
  15684. * Copy the absolute position of the bone (world space) to the result param
  15685. * @param mesh The mesh that this bone is attached to
  15686. * @param result The vector3 to copy the absolute position to
  15687. */
  15688. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15689. /**
  15690. * Compute the absolute transforms of this bone and its children
  15691. */
  15692. computeAbsoluteTransforms(): void;
  15693. /**
  15694. * Get the world direction from an axis that is in the local space of the bone
  15695. * @param localAxis The local direction that is used to compute the world direction
  15696. * @param mesh The mesh that this bone is attached to
  15697. * @returns The world direction
  15698. */
  15699. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15700. /**
  15701. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15702. * @param localAxis The local direction that is used to compute the world direction
  15703. * @param mesh The mesh that this bone is attached to
  15704. * @param result The vector3 that the world direction will be copied to
  15705. */
  15706. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15707. /**
  15708. * Get the euler rotation of the bone in local or world space
  15709. * @param space The space that the rotation should be in
  15710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15711. * @returns The euler rotation
  15712. */
  15713. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15714. /**
  15715. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15716. * @param space The space that the rotation should be in
  15717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15718. * @param result The vector3 that the rotation should be copied to
  15719. */
  15720. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15721. /**
  15722. * Get the quaternion rotation of the bone in either local or world space
  15723. * @param space The space that the rotation should be in
  15724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15725. * @returns The quaternion rotation
  15726. */
  15727. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15728. /**
  15729. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15730. * @param space The space that the rotation should be in
  15731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15732. * @param result The quaternion that the rotation should be copied to
  15733. */
  15734. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15735. /**
  15736. * Get the rotation matrix of the bone in local or world space
  15737. * @param space The space that the rotation should be in
  15738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15739. * @returns The rotation matrix
  15740. */
  15741. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15742. /**
  15743. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15744. * @param space The space that the rotation should be in
  15745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15746. * @param result The quaternion that the rotation should be copied to
  15747. */
  15748. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15749. /**
  15750. * Get the world position of a point that is in the local space of the bone
  15751. * @param position The local position
  15752. * @param mesh The mesh that this bone is attached to
  15753. * @returns The world position
  15754. */
  15755. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15756. /**
  15757. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15758. * @param position The local position
  15759. * @param mesh The mesh that this bone is attached to
  15760. * @param result The vector3 that the world position should be copied to
  15761. */
  15762. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15763. /**
  15764. * Get the local position of a point that is in world space
  15765. * @param position The world position
  15766. * @param mesh The mesh that this bone is attached to
  15767. * @returns The local position
  15768. */
  15769. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15770. /**
  15771. * Get the local position of a point that is in world space and copy it to the result param
  15772. * @param position The world position
  15773. * @param mesh The mesh that this bone is attached to
  15774. * @param result The vector3 that the local position should be copied to
  15775. */
  15776. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15777. }
  15778. }
  15779. declare module "babylonjs/Animations/runtimeAnimation" {
  15780. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15781. import { Animatable } from "babylonjs/Animations/animatable";
  15782. import { Scene } from "babylonjs/scene";
  15783. /**
  15784. * Defines a runtime animation
  15785. */
  15786. export class RuntimeAnimation {
  15787. private _events;
  15788. /**
  15789. * The current frame of the runtime animation
  15790. */
  15791. private _currentFrame;
  15792. /**
  15793. * The animation used by the runtime animation
  15794. */
  15795. private _animation;
  15796. /**
  15797. * The target of the runtime animation
  15798. */
  15799. private _target;
  15800. /**
  15801. * The initiating animatable
  15802. */
  15803. private _host;
  15804. /**
  15805. * The original value of the runtime animation
  15806. */
  15807. private _originalValue;
  15808. /**
  15809. * The original blend value of the runtime animation
  15810. */
  15811. private _originalBlendValue;
  15812. /**
  15813. * The offsets cache of the runtime animation
  15814. */
  15815. private _offsetsCache;
  15816. /**
  15817. * The high limits cache of the runtime animation
  15818. */
  15819. private _highLimitsCache;
  15820. /**
  15821. * Specifies if the runtime animation has been stopped
  15822. */
  15823. private _stopped;
  15824. /**
  15825. * The blending factor of the runtime animation
  15826. */
  15827. private _blendingFactor;
  15828. /**
  15829. * The BabylonJS scene
  15830. */
  15831. private _scene;
  15832. /**
  15833. * The current value of the runtime animation
  15834. */
  15835. private _currentValue;
  15836. /** @hidden */
  15837. _animationState: _IAnimationState;
  15838. /**
  15839. * The active target of the runtime animation
  15840. */
  15841. private _activeTargets;
  15842. private _currentActiveTarget;
  15843. private _directTarget;
  15844. /**
  15845. * The target path of the runtime animation
  15846. */
  15847. private _targetPath;
  15848. /**
  15849. * The weight of the runtime animation
  15850. */
  15851. private _weight;
  15852. /**
  15853. * The ratio offset of the runtime animation
  15854. */
  15855. private _ratioOffset;
  15856. /**
  15857. * The previous delay of the runtime animation
  15858. */
  15859. private _previousDelay;
  15860. /**
  15861. * The previous ratio of the runtime animation
  15862. */
  15863. private _previousRatio;
  15864. private _enableBlending;
  15865. private _keys;
  15866. private _minFrame;
  15867. private _maxFrame;
  15868. private _minValue;
  15869. private _maxValue;
  15870. private _targetIsArray;
  15871. /**
  15872. * Gets the current frame of the runtime animation
  15873. */
  15874. get currentFrame(): number;
  15875. /**
  15876. * Gets the weight of the runtime animation
  15877. */
  15878. get weight(): number;
  15879. /**
  15880. * Gets the current value of the runtime animation
  15881. */
  15882. get currentValue(): any;
  15883. /**
  15884. * Gets the target path of the runtime animation
  15885. */
  15886. get targetPath(): string;
  15887. /**
  15888. * Gets the actual target of the runtime animation
  15889. */
  15890. get target(): any;
  15891. /**
  15892. * Gets the additive state of the runtime animation
  15893. */
  15894. get isAdditive(): boolean;
  15895. /** @hidden */
  15896. _onLoop: () => void;
  15897. /**
  15898. * Create a new RuntimeAnimation object
  15899. * @param target defines the target of the animation
  15900. * @param animation defines the source animation object
  15901. * @param scene defines the hosting scene
  15902. * @param host defines the initiating Animatable
  15903. */
  15904. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15905. private _preparePath;
  15906. /**
  15907. * Gets the animation from the runtime animation
  15908. */
  15909. get animation(): Animation;
  15910. /**
  15911. * Resets the runtime animation to the beginning
  15912. * @param restoreOriginal defines whether to restore the target property to the original value
  15913. */
  15914. reset(restoreOriginal?: boolean): void;
  15915. /**
  15916. * Specifies if the runtime animation is stopped
  15917. * @returns Boolean specifying if the runtime animation is stopped
  15918. */
  15919. isStopped(): boolean;
  15920. /**
  15921. * Disposes of the runtime animation
  15922. */
  15923. dispose(): void;
  15924. /**
  15925. * Apply the interpolated value to the target
  15926. * @param currentValue defines the value computed by the animation
  15927. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15928. */
  15929. setValue(currentValue: any, weight: number): void;
  15930. private _getOriginalValues;
  15931. private _setValue;
  15932. /**
  15933. * Gets the loop pmode of the runtime animation
  15934. * @returns Loop Mode
  15935. */
  15936. private _getCorrectLoopMode;
  15937. /**
  15938. * Move the current animation to a given frame
  15939. * @param frame defines the frame to move to
  15940. */
  15941. goToFrame(frame: number): void;
  15942. /**
  15943. * @hidden Internal use only
  15944. */
  15945. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15946. /**
  15947. * Execute the current animation
  15948. * @param delay defines the delay to add to the current frame
  15949. * @param from defines the lower bound of the animation range
  15950. * @param to defines the upper bound of the animation range
  15951. * @param loop defines if the current animation must loop
  15952. * @param speedRatio defines the current speed ratio
  15953. * @param weight defines the weight of the animation (default is -1 so no weight)
  15954. * @param onLoop optional callback called when animation loops
  15955. * @returns a boolean indicating if the animation is running
  15956. */
  15957. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15958. }
  15959. }
  15960. declare module "babylonjs/Animations/animatable" {
  15961. import { Animation } from "babylonjs/Animations/animation";
  15962. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15963. import { Nullable } from "babylonjs/types";
  15964. import { Observable } from "babylonjs/Misc/observable";
  15965. import { Scene } from "babylonjs/scene";
  15966. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15967. import { Node } from "babylonjs/node";
  15968. /**
  15969. * Class used to store an actual running animation
  15970. */
  15971. export class Animatable {
  15972. /** defines the target object */
  15973. target: any;
  15974. /** defines the starting frame number (default is 0) */
  15975. fromFrame: number;
  15976. /** defines the ending frame number (default is 100) */
  15977. toFrame: number;
  15978. /** defines if the animation must loop (default is false) */
  15979. loopAnimation: boolean;
  15980. /** defines a callback to call when animation ends if it is not looping */
  15981. onAnimationEnd?: (() => void) | null | undefined;
  15982. /** defines a callback to call when animation loops */
  15983. onAnimationLoop?: (() => void) | null | undefined;
  15984. /** defines whether the animation should be evaluated additively */
  15985. isAdditive: boolean;
  15986. private _localDelayOffset;
  15987. private _pausedDelay;
  15988. private _runtimeAnimations;
  15989. private _paused;
  15990. private _scene;
  15991. private _speedRatio;
  15992. private _weight;
  15993. private _syncRoot;
  15994. /**
  15995. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15996. * This will only apply for non looping animation (default is true)
  15997. */
  15998. disposeOnEnd: boolean;
  15999. /**
  16000. * Gets a boolean indicating if the animation has started
  16001. */
  16002. animationStarted: boolean;
  16003. /**
  16004. * Observer raised when the animation ends
  16005. */
  16006. onAnimationEndObservable: Observable<Animatable>;
  16007. /**
  16008. * Observer raised when the animation loops
  16009. */
  16010. onAnimationLoopObservable: Observable<Animatable>;
  16011. /**
  16012. * Gets the root Animatable used to synchronize and normalize animations
  16013. */
  16014. get syncRoot(): Nullable<Animatable>;
  16015. /**
  16016. * Gets the current frame of the first RuntimeAnimation
  16017. * Used to synchronize Animatables
  16018. */
  16019. get masterFrame(): number;
  16020. /**
  16021. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16022. */
  16023. get weight(): number;
  16024. set weight(value: number);
  16025. /**
  16026. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16027. */
  16028. get speedRatio(): number;
  16029. set speedRatio(value: number);
  16030. /**
  16031. * Creates a new Animatable
  16032. * @param scene defines the hosting scene
  16033. * @param target defines the target object
  16034. * @param fromFrame defines the starting frame number (default is 0)
  16035. * @param toFrame defines the ending frame number (default is 100)
  16036. * @param loopAnimation defines if the animation must loop (default is false)
  16037. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16038. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16039. * @param animations defines a group of animation to add to the new Animatable
  16040. * @param onAnimationLoop defines a callback to call when animation loops
  16041. * @param isAdditive defines whether the animation should be evaluated additively
  16042. */
  16043. constructor(scene: Scene,
  16044. /** defines the target object */
  16045. target: any,
  16046. /** defines the starting frame number (default is 0) */
  16047. fromFrame?: number,
  16048. /** defines the ending frame number (default is 100) */
  16049. toFrame?: number,
  16050. /** defines if the animation must loop (default is false) */
  16051. loopAnimation?: boolean, speedRatio?: number,
  16052. /** defines a callback to call when animation ends if it is not looping */
  16053. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16054. /** defines a callback to call when animation loops */
  16055. onAnimationLoop?: (() => void) | null | undefined,
  16056. /** defines whether the animation should be evaluated additively */
  16057. isAdditive?: boolean);
  16058. /**
  16059. * Synchronize and normalize current Animatable with a source Animatable
  16060. * This is useful when using animation weights and when animations are not of the same length
  16061. * @param root defines the root Animatable to synchronize with
  16062. * @returns the current Animatable
  16063. */
  16064. syncWith(root: Animatable): Animatable;
  16065. /**
  16066. * Gets the list of runtime animations
  16067. * @returns an array of RuntimeAnimation
  16068. */
  16069. getAnimations(): RuntimeAnimation[];
  16070. /**
  16071. * Adds more animations to the current animatable
  16072. * @param target defines the target of the animations
  16073. * @param animations defines the new animations to add
  16074. */
  16075. appendAnimations(target: any, animations: Animation[]): void;
  16076. /**
  16077. * Gets the source animation for a specific property
  16078. * @param property defines the propertyu to look for
  16079. * @returns null or the source animation for the given property
  16080. */
  16081. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16082. /**
  16083. * Gets the runtime animation for a specific property
  16084. * @param property defines the propertyu to look for
  16085. * @returns null or the runtime animation for the given property
  16086. */
  16087. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16088. /**
  16089. * Resets the animatable to its original state
  16090. */
  16091. reset(): void;
  16092. /**
  16093. * Allows the animatable to blend with current running animations
  16094. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16095. * @param blendingSpeed defines the blending speed to use
  16096. */
  16097. enableBlending(blendingSpeed: number): void;
  16098. /**
  16099. * Disable animation blending
  16100. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16101. */
  16102. disableBlending(): void;
  16103. /**
  16104. * Jump directly to a given frame
  16105. * @param frame defines the frame to jump to
  16106. */
  16107. goToFrame(frame: number): void;
  16108. /**
  16109. * Pause the animation
  16110. */
  16111. pause(): void;
  16112. /**
  16113. * Restart the animation
  16114. */
  16115. restart(): void;
  16116. private _raiseOnAnimationEnd;
  16117. /**
  16118. * Stop and delete the current animation
  16119. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16120. * @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)
  16121. */
  16122. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16123. /**
  16124. * Wait asynchronously for the animation to end
  16125. * @returns a promise which will be fullfilled when the animation ends
  16126. */
  16127. waitAsync(): Promise<Animatable>;
  16128. /** @hidden */
  16129. _animate(delay: number): boolean;
  16130. }
  16131. module "babylonjs/scene" {
  16132. interface Scene {
  16133. /** @hidden */
  16134. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16135. /** @hidden */
  16136. _processLateAnimationBindingsForMatrices(holder: {
  16137. totalWeight: number;
  16138. totalAdditiveWeight: number;
  16139. animations: RuntimeAnimation[];
  16140. additiveAnimations: RuntimeAnimation[];
  16141. originalValue: Matrix;
  16142. }): any;
  16143. /** @hidden */
  16144. _processLateAnimationBindingsForQuaternions(holder: {
  16145. totalWeight: number;
  16146. totalAdditiveWeight: number;
  16147. animations: RuntimeAnimation[];
  16148. additiveAnimations: RuntimeAnimation[];
  16149. originalValue: Quaternion;
  16150. }, refQuaternion: Quaternion): Quaternion;
  16151. /** @hidden */
  16152. _processLateAnimationBindings(): void;
  16153. /**
  16154. * Will start the animation sequence of a given target
  16155. * @param target defines the target
  16156. * @param from defines from which frame should animation start
  16157. * @param to defines until which frame should animation run.
  16158. * @param weight defines the weight to apply to the animation (1.0 by default)
  16159. * @param loop defines if the animation loops
  16160. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16161. * @param onAnimationEnd defines the function to be executed when the animation ends
  16162. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16163. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16164. * @param onAnimationLoop defines the callback to call when an animation loops
  16165. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16166. * @returns the animatable object created for this animation
  16167. */
  16168. 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;
  16169. /**
  16170. * Will start the animation sequence of a given target
  16171. * @param target defines the target
  16172. * @param from defines from which frame should animation start
  16173. * @param to defines until which frame should animation run.
  16174. * @param loop defines if the animation loops
  16175. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16176. * @param onAnimationEnd defines the function to be executed when the animation ends
  16177. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16178. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16179. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16180. * @param onAnimationLoop defines the callback to call when an animation loops
  16181. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16182. * @returns the animatable object created for this animation
  16183. */
  16184. 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;
  16185. /**
  16186. * Will start the animation sequence of a given target and its hierarchy
  16187. * @param target defines the target
  16188. * @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.
  16189. * @param from defines from which frame should animation start
  16190. * @param to defines until which frame should animation run.
  16191. * @param loop defines if the animation loops
  16192. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16193. * @param onAnimationEnd defines the function to be executed when the animation ends
  16194. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16195. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16196. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16197. * @param onAnimationLoop defines the callback to call when an animation loops
  16198. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16199. * @returns the list of created animatables
  16200. */
  16201. 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[];
  16202. /**
  16203. * Begin a new animation on a given node
  16204. * @param target defines the target where the animation will take place
  16205. * @param animations defines the list of animations to start
  16206. * @param from defines the initial value
  16207. * @param to defines the final value
  16208. * @param loop defines if you want animation to loop (off by default)
  16209. * @param speedRatio defines the speed ratio to apply to all animations
  16210. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16211. * @param onAnimationLoop defines the callback to call when an animation loops
  16212. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16213. * @returns the list of created animatables
  16214. */
  16215. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16216. /**
  16217. * Begin a new animation on a given node and its hierarchy
  16218. * @param target defines the root node where the animation will take place
  16219. * @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.
  16220. * @param animations defines the list of animations to start
  16221. * @param from defines the initial value
  16222. * @param to defines the final value
  16223. * @param loop defines if you want animation to loop (off by default)
  16224. * @param speedRatio defines the speed ratio to apply to all animations
  16225. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16226. * @param onAnimationLoop defines the callback to call when an animation loops
  16227. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16228. * @returns the list of animatables created for all nodes
  16229. */
  16230. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16231. /**
  16232. * Gets the animatable associated with a specific target
  16233. * @param target defines the target of the animatable
  16234. * @returns the required animatable if found
  16235. */
  16236. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16237. /**
  16238. * Gets all animatables associated with a given target
  16239. * @param target defines the target to look animatables for
  16240. * @returns an array of Animatables
  16241. */
  16242. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16243. /**
  16244. * Stops and removes all animations that have been applied to the scene
  16245. */
  16246. stopAllAnimations(): void;
  16247. /**
  16248. * Gets the current delta time used by animation engine
  16249. */
  16250. deltaTime: number;
  16251. }
  16252. }
  16253. module "babylonjs/Bones/bone" {
  16254. interface Bone {
  16255. /**
  16256. * Copy an animation range from another bone
  16257. * @param source defines the source bone
  16258. * @param rangeName defines the range name to copy
  16259. * @param frameOffset defines the frame offset
  16260. * @param rescaleAsRequired defines if rescaling must be applied if required
  16261. * @param skelDimensionsRatio defines the scaling ratio
  16262. * @returns true if operation was successful
  16263. */
  16264. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16265. }
  16266. }
  16267. }
  16268. declare module "babylonjs/Bones/skeleton" {
  16269. import { Bone } from "babylonjs/Bones/bone";
  16270. import { Observable } from "babylonjs/Misc/observable";
  16271. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16272. import { Scene } from "babylonjs/scene";
  16273. import { Nullable } from "babylonjs/types";
  16274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16275. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16276. import { Animatable } from "babylonjs/Animations/animatable";
  16277. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16278. import { Animation } from "babylonjs/Animations/animation";
  16279. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16280. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16281. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16282. /**
  16283. * Class used to handle skinning animations
  16284. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16285. */
  16286. export class Skeleton implements IAnimatable {
  16287. /** defines the skeleton name */
  16288. name: string;
  16289. /** defines the skeleton Id */
  16290. id: string;
  16291. /**
  16292. * Defines the list of child bones
  16293. */
  16294. bones: Bone[];
  16295. /**
  16296. * Defines an estimate of the dimension of the skeleton at rest
  16297. */
  16298. dimensionsAtRest: Vector3;
  16299. /**
  16300. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16301. */
  16302. needInitialSkinMatrix: boolean;
  16303. /**
  16304. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16305. */
  16306. overrideMesh: Nullable<AbstractMesh>;
  16307. /**
  16308. * Gets the list of animations attached to this skeleton
  16309. */
  16310. animations: Array<Animation>;
  16311. private _scene;
  16312. private _isDirty;
  16313. private _transformMatrices;
  16314. private _transformMatrixTexture;
  16315. private _meshesWithPoseMatrix;
  16316. private _animatables;
  16317. private _identity;
  16318. private _synchronizedWithMesh;
  16319. private _ranges;
  16320. private _lastAbsoluteTransformsUpdateId;
  16321. private _canUseTextureForBones;
  16322. private _uniqueId;
  16323. /** @hidden */
  16324. _numBonesWithLinkedTransformNode: number;
  16325. /** @hidden */
  16326. _hasWaitingData: Nullable<boolean>;
  16327. /**
  16328. * Specifies if the skeleton should be serialized
  16329. */
  16330. doNotSerialize: boolean;
  16331. private _useTextureToStoreBoneMatrices;
  16332. /**
  16333. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16334. * Please note that this option is not available if the hardware does not support it
  16335. */
  16336. get useTextureToStoreBoneMatrices(): boolean;
  16337. set useTextureToStoreBoneMatrices(value: boolean);
  16338. private _animationPropertiesOverride;
  16339. /**
  16340. * Gets or sets the animation properties override
  16341. */
  16342. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16343. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16344. /**
  16345. * List of inspectable custom properties (used by the Inspector)
  16346. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16347. */
  16348. inspectableCustomProperties: IInspectable[];
  16349. /**
  16350. * An observable triggered before computing the skeleton's matrices
  16351. */
  16352. onBeforeComputeObservable: Observable<Skeleton>;
  16353. /**
  16354. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16355. */
  16356. get isUsingTextureForMatrices(): boolean;
  16357. /**
  16358. * Gets the unique ID of this skeleton
  16359. */
  16360. get uniqueId(): number;
  16361. /**
  16362. * Creates a new skeleton
  16363. * @param name defines the skeleton name
  16364. * @param id defines the skeleton Id
  16365. * @param scene defines the hosting scene
  16366. */
  16367. constructor(
  16368. /** defines the skeleton name */
  16369. name: string,
  16370. /** defines the skeleton Id */
  16371. id: string, scene: Scene);
  16372. /**
  16373. * Gets the current object class name.
  16374. * @return the class name
  16375. */
  16376. getClassName(): string;
  16377. /**
  16378. * Returns an array containing the root bones
  16379. * @returns an array containing the root bones
  16380. */
  16381. getChildren(): Array<Bone>;
  16382. /**
  16383. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16384. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16385. * @returns a Float32Array containing matrices data
  16386. */
  16387. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16388. /**
  16389. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16390. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16391. * @returns a raw texture containing the data
  16392. */
  16393. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16394. /**
  16395. * Gets the current hosting scene
  16396. * @returns a scene object
  16397. */
  16398. getScene(): Scene;
  16399. /**
  16400. * Gets a string representing the current skeleton data
  16401. * @param fullDetails defines a boolean indicating if we want a verbose version
  16402. * @returns a string representing the current skeleton data
  16403. */
  16404. toString(fullDetails?: boolean): string;
  16405. /**
  16406. * Get bone's index searching by name
  16407. * @param name defines bone's name to search for
  16408. * @return the indice of the bone. Returns -1 if not found
  16409. */
  16410. getBoneIndexByName(name: string): number;
  16411. /**
  16412. * Creater a new animation range
  16413. * @param name defines the name of the range
  16414. * @param from defines the start key
  16415. * @param to defines the end key
  16416. */
  16417. createAnimationRange(name: string, from: number, to: number): void;
  16418. /**
  16419. * Delete a specific animation range
  16420. * @param name defines the name of the range
  16421. * @param deleteFrames defines if frames must be removed as well
  16422. */
  16423. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16424. /**
  16425. * Gets a specific animation range
  16426. * @param name defines the name of the range to look for
  16427. * @returns the requested animation range or null if not found
  16428. */
  16429. getAnimationRange(name: string): Nullable<AnimationRange>;
  16430. /**
  16431. * Gets the list of all animation ranges defined on this skeleton
  16432. * @returns an array
  16433. */
  16434. getAnimationRanges(): Nullable<AnimationRange>[];
  16435. /**
  16436. * Copy animation range from a source skeleton.
  16437. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16438. * @param source defines the source skeleton
  16439. * @param name defines the name of the range to copy
  16440. * @param rescaleAsRequired defines if rescaling must be applied if required
  16441. * @returns true if operation was successful
  16442. */
  16443. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16444. /**
  16445. * Forces the skeleton to go to rest pose
  16446. */
  16447. returnToRest(): void;
  16448. private _getHighestAnimationFrame;
  16449. /**
  16450. * Begin a specific animation range
  16451. * @param name defines the name of the range to start
  16452. * @param loop defines if looping must be turned on (false by default)
  16453. * @param speedRatio defines the speed ratio to apply (1 by default)
  16454. * @param onAnimationEnd defines a callback which will be called when animation will end
  16455. * @returns a new animatable
  16456. */
  16457. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16458. /**
  16459. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16460. * @param skeleton defines the Skeleton containing the animation range to convert
  16461. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16462. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16463. * @returns the original skeleton
  16464. */
  16465. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16466. /** @hidden */
  16467. _markAsDirty(): void;
  16468. /** @hidden */
  16469. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16470. /** @hidden */
  16471. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16472. private _computeTransformMatrices;
  16473. /**
  16474. * Build all resources required to render a skeleton
  16475. */
  16476. prepare(): void;
  16477. /**
  16478. * Gets the list of animatables currently running for this skeleton
  16479. * @returns an array of animatables
  16480. */
  16481. getAnimatables(): IAnimatable[];
  16482. /**
  16483. * Clone the current skeleton
  16484. * @param name defines the name of the new skeleton
  16485. * @param id defines the id of the new skeleton
  16486. * @returns the new skeleton
  16487. */
  16488. clone(name: string, id?: string): Skeleton;
  16489. /**
  16490. * Enable animation blending for this skeleton
  16491. * @param blendingSpeed defines the blending speed to apply
  16492. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16493. */
  16494. enableBlending(blendingSpeed?: number): void;
  16495. /**
  16496. * Releases all resources associated with the current skeleton
  16497. */
  16498. dispose(): void;
  16499. /**
  16500. * Serialize the skeleton in a JSON object
  16501. * @returns a JSON object
  16502. */
  16503. serialize(): any;
  16504. /**
  16505. * Creates a new skeleton from serialized data
  16506. * @param parsedSkeleton defines the serialized data
  16507. * @param scene defines the hosting scene
  16508. * @returns a new skeleton
  16509. */
  16510. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16511. /**
  16512. * Compute all node absolute transforms
  16513. * @param forceUpdate defines if computation must be done even if cache is up to date
  16514. */
  16515. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16516. /**
  16517. * Gets the root pose matrix
  16518. * @returns a matrix
  16519. */
  16520. getPoseMatrix(): Nullable<Matrix>;
  16521. /**
  16522. * Sorts bones per internal index
  16523. */
  16524. sortBones(): void;
  16525. private _sortBones;
  16526. }
  16527. }
  16528. declare module "babylonjs/Meshes/instancedMesh" {
  16529. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16530. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16531. import { Camera } from "babylonjs/Cameras/camera";
  16532. import { Node } from "babylonjs/node";
  16533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16534. import { Mesh } from "babylonjs/Meshes/mesh";
  16535. import { Material } from "babylonjs/Materials/material";
  16536. import { Skeleton } from "babylonjs/Bones/skeleton";
  16537. import { Light } from "babylonjs/Lights/light";
  16538. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16539. /**
  16540. * Creates an instance based on a source mesh.
  16541. */
  16542. export class InstancedMesh extends AbstractMesh {
  16543. private _sourceMesh;
  16544. private _currentLOD;
  16545. /** @hidden */
  16546. _indexInSourceMeshInstanceArray: number;
  16547. constructor(name: string, source: Mesh);
  16548. /**
  16549. * Returns the string "InstancedMesh".
  16550. */
  16551. getClassName(): string;
  16552. /** Gets the list of lights affecting that mesh */
  16553. get lightSources(): Light[];
  16554. _resyncLightSources(): void;
  16555. _resyncLightSource(light: Light): void;
  16556. _removeLightSource(light: Light, dispose: boolean): void;
  16557. /**
  16558. * If the source mesh receives shadows
  16559. */
  16560. get receiveShadows(): boolean;
  16561. /**
  16562. * The material of the source mesh
  16563. */
  16564. get material(): Nullable<Material>;
  16565. /**
  16566. * Visibility of the source mesh
  16567. */
  16568. get visibility(): number;
  16569. /**
  16570. * Skeleton of the source mesh
  16571. */
  16572. get skeleton(): Nullable<Skeleton>;
  16573. /**
  16574. * Rendering ground id of the source mesh
  16575. */
  16576. get renderingGroupId(): number;
  16577. set renderingGroupId(value: number);
  16578. /**
  16579. * Returns the total number of vertices (integer).
  16580. */
  16581. getTotalVertices(): number;
  16582. /**
  16583. * Returns a positive integer : the total number of indices in this mesh geometry.
  16584. * @returns the numner of indices or zero if the mesh has no geometry.
  16585. */
  16586. getTotalIndices(): number;
  16587. /**
  16588. * The source mesh of the instance
  16589. */
  16590. get sourceMesh(): Mesh;
  16591. /**
  16592. * Creates a new InstancedMesh object from the mesh model.
  16593. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16594. * @param name defines the name of the new instance
  16595. * @returns a new InstancedMesh
  16596. */
  16597. createInstance(name: string): InstancedMesh;
  16598. /**
  16599. * Is this node ready to be used/rendered
  16600. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16601. * @return {boolean} is it ready
  16602. */
  16603. isReady(completeCheck?: boolean): boolean;
  16604. /**
  16605. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16606. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16607. * @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.
  16608. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16609. */
  16610. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16611. /**
  16612. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16613. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16614. * The `data` are either a numeric array either a Float32Array.
  16615. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16616. * 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).
  16617. * Note that a new underlying VertexBuffer object is created each call.
  16618. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16619. *
  16620. * Possible `kind` values :
  16621. * - VertexBuffer.PositionKind
  16622. * - VertexBuffer.UVKind
  16623. * - VertexBuffer.UV2Kind
  16624. * - VertexBuffer.UV3Kind
  16625. * - VertexBuffer.UV4Kind
  16626. * - VertexBuffer.UV5Kind
  16627. * - VertexBuffer.UV6Kind
  16628. * - VertexBuffer.ColorKind
  16629. * - VertexBuffer.MatricesIndicesKind
  16630. * - VertexBuffer.MatricesIndicesExtraKind
  16631. * - VertexBuffer.MatricesWeightsKind
  16632. * - VertexBuffer.MatricesWeightsExtraKind
  16633. *
  16634. * Returns the Mesh.
  16635. */
  16636. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16637. /**
  16638. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16639. * If the mesh has no geometry, it is simply returned as it is.
  16640. * The `data` are either a numeric array either a Float32Array.
  16641. * No new underlying VertexBuffer object is created.
  16642. * 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.
  16643. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16644. *
  16645. * Possible `kind` values :
  16646. * - VertexBuffer.PositionKind
  16647. * - VertexBuffer.UVKind
  16648. * - VertexBuffer.UV2Kind
  16649. * - VertexBuffer.UV3Kind
  16650. * - VertexBuffer.UV4Kind
  16651. * - VertexBuffer.UV5Kind
  16652. * - VertexBuffer.UV6Kind
  16653. * - VertexBuffer.ColorKind
  16654. * - VertexBuffer.MatricesIndicesKind
  16655. * - VertexBuffer.MatricesIndicesExtraKind
  16656. * - VertexBuffer.MatricesWeightsKind
  16657. * - VertexBuffer.MatricesWeightsExtraKind
  16658. *
  16659. * Returns the Mesh.
  16660. */
  16661. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16662. /**
  16663. * Sets the mesh indices.
  16664. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16665. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16666. * This method creates a new index buffer each call.
  16667. * Returns the Mesh.
  16668. */
  16669. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16670. /**
  16671. * Boolean : True if the mesh owns the requested kind of data.
  16672. */
  16673. isVerticesDataPresent(kind: string): boolean;
  16674. /**
  16675. * Returns an array of indices (IndicesArray).
  16676. */
  16677. getIndices(): Nullable<IndicesArray>;
  16678. get _positions(): Nullable<Vector3[]>;
  16679. /**
  16680. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16681. * This means the mesh underlying bounding box and sphere are recomputed.
  16682. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16683. * @returns the current mesh
  16684. */
  16685. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16686. /** @hidden */
  16687. _preActivate(): InstancedMesh;
  16688. /** @hidden */
  16689. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16690. /** @hidden */
  16691. _postActivate(): void;
  16692. getWorldMatrix(): Matrix;
  16693. get isAnInstance(): boolean;
  16694. /**
  16695. * Returns the current associated LOD AbstractMesh.
  16696. */
  16697. getLOD(camera: Camera): AbstractMesh;
  16698. /** @hidden */
  16699. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16700. /** @hidden */
  16701. _syncSubMeshes(): InstancedMesh;
  16702. /** @hidden */
  16703. _generatePointsArray(): boolean;
  16704. /**
  16705. * Creates a new InstancedMesh from the current mesh.
  16706. * - name (string) : the cloned mesh name
  16707. * - newParent (optional Node) : the optional Node to parent the clone to.
  16708. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16709. *
  16710. * Returns the clone.
  16711. */
  16712. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16713. /**
  16714. * Disposes the InstancedMesh.
  16715. * Returns nothing.
  16716. */
  16717. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16718. }
  16719. module "babylonjs/Meshes/mesh" {
  16720. interface Mesh {
  16721. /**
  16722. * Register a custom buffer that will be instanced
  16723. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16724. * @param kind defines the buffer kind
  16725. * @param stride defines the stride in floats
  16726. */
  16727. registerInstancedBuffer(kind: string, stride: number): void;
  16728. /**
  16729. * true to use the edge renderer for all instances of this mesh
  16730. */
  16731. edgesShareWithInstances: boolean;
  16732. /** @hidden */
  16733. _userInstancedBuffersStorage: {
  16734. data: {
  16735. [key: string]: Float32Array;
  16736. };
  16737. sizes: {
  16738. [key: string]: number;
  16739. };
  16740. vertexBuffers: {
  16741. [key: string]: Nullable<VertexBuffer>;
  16742. };
  16743. strides: {
  16744. [key: string]: number;
  16745. };
  16746. };
  16747. }
  16748. }
  16749. module "babylonjs/Meshes/abstractMesh" {
  16750. interface AbstractMesh {
  16751. /**
  16752. * Object used to store instanced buffers defined by user
  16753. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16754. */
  16755. instancedBuffers: {
  16756. [key: string]: any;
  16757. };
  16758. }
  16759. }
  16760. }
  16761. declare module "babylonjs/Materials/shaderMaterial" {
  16762. import { Nullable } from "babylonjs/types";
  16763. import { Scene } from "babylonjs/scene";
  16764. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16766. import { Mesh } from "babylonjs/Meshes/mesh";
  16767. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16768. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16769. import { Effect } from "babylonjs/Materials/effect";
  16770. import { Material } from "babylonjs/Materials/material";
  16771. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16772. /**
  16773. * Defines the options associated with the creation of a shader material.
  16774. */
  16775. export interface IShaderMaterialOptions {
  16776. /**
  16777. * Does the material work in alpha blend mode
  16778. */
  16779. needAlphaBlending: boolean;
  16780. /**
  16781. * Does the material work in alpha test mode
  16782. */
  16783. needAlphaTesting: boolean;
  16784. /**
  16785. * The list of attribute names used in the shader
  16786. */
  16787. attributes: string[];
  16788. /**
  16789. * The list of unifrom names used in the shader
  16790. */
  16791. uniforms: string[];
  16792. /**
  16793. * The list of UBO names used in the shader
  16794. */
  16795. uniformBuffers: string[];
  16796. /**
  16797. * The list of sampler names used in the shader
  16798. */
  16799. samplers: string[];
  16800. /**
  16801. * The list of defines used in the shader
  16802. */
  16803. defines: string[];
  16804. }
  16805. /**
  16806. * 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.
  16807. *
  16808. * This returned material effects how the mesh will look based on the code in the shaders.
  16809. *
  16810. * @see https://doc.babylonjs.com/how_to/shader_material
  16811. */
  16812. export class ShaderMaterial extends Material {
  16813. private _shaderPath;
  16814. private _options;
  16815. private _textures;
  16816. private _textureArrays;
  16817. private _floats;
  16818. private _ints;
  16819. private _floatsArrays;
  16820. private _colors3;
  16821. private _colors3Arrays;
  16822. private _colors4;
  16823. private _colors4Arrays;
  16824. private _vectors2;
  16825. private _vectors3;
  16826. private _vectors4;
  16827. private _matrices;
  16828. private _matrixArrays;
  16829. private _matrices3x3;
  16830. private _matrices2x2;
  16831. private _vectors2Arrays;
  16832. private _vectors3Arrays;
  16833. private _vectors4Arrays;
  16834. private _cachedWorldViewMatrix;
  16835. private _cachedWorldViewProjectionMatrix;
  16836. private _renderId;
  16837. private _multiview;
  16838. private _cachedDefines;
  16839. /** Define the Url to load snippets */
  16840. static SnippetUrl: string;
  16841. /** Snippet ID if the material was created from the snippet server */
  16842. snippetId: string;
  16843. /**
  16844. * Instantiate a new shader material.
  16845. * 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.
  16846. * This returned material effects how the mesh will look based on the code in the shaders.
  16847. * @see https://doc.babylonjs.com/how_to/shader_material
  16848. * @param name Define the name of the material in the scene
  16849. * @param scene Define the scene the material belongs to
  16850. * @param shaderPath Defines the route to the shader code in one of three ways:
  16851. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16852. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16853. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16854. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16855. * @param options Define the options used to create the shader
  16856. */
  16857. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16858. /**
  16859. * Gets the shader path used to define the shader code
  16860. * It can be modified to trigger a new compilation
  16861. */
  16862. get shaderPath(): any;
  16863. /**
  16864. * Sets the shader path used to define the shader code
  16865. * It can be modified to trigger a new compilation
  16866. */
  16867. set shaderPath(shaderPath: any);
  16868. /**
  16869. * Gets the options used to compile the shader.
  16870. * They can be modified to trigger a new compilation
  16871. */
  16872. get options(): IShaderMaterialOptions;
  16873. /**
  16874. * Gets the current class name of the material e.g. "ShaderMaterial"
  16875. * Mainly use in serialization.
  16876. * @returns the class name
  16877. */
  16878. getClassName(): string;
  16879. /**
  16880. * Specifies if the material will require alpha blending
  16881. * @returns a boolean specifying if alpha blending is needed
  16882. */
  16883. needAlphaBlending(): boolean;
  16884. /**
  16885. * Specifies if this material should be rendered in alpha test mode
  16886. * @returns a boolean specifying if an alpha test is needed.
  16887. */
  16888. needAlphaTesting(): boolean;
  16889. private _checkUniform;
  16890. /**
  16891. * Set a texture in the shader.
  16892. * @param name Define the name of the uniform samplers as defined in the shader
  16893. * @param texture Define the texture to bind to this sampler
  16894. * @return the material itself allowing "fluent" like uniform updates
  16895. */
  16896. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16897. /**
  16898. * Set a texture array in the shader.
  16899. * @param name Define the name of the uniform sampler array as defined in the shader
  16900. * @param textures Define the list of textures to bind to this sampler
  16901. * @return the material itself allowing "fluent" like uniform updates
  16902. */
  16903. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16904. /**
  16905. * Set a float in the shader.
  16906. * @param name Define the name of the uniform as defined in the shader
  16907. * @param value Define the value to give to the uniform
  16908. * @return the material itself allowing "fluent" like uniform updates
  16909. */
  16910. setFloat(name: string, value: number): ShaderMaterial;
  16911. /**
  16912. * Set a int in the shader.
  16913. * @param name Define the name of the uniform as defined in the shader
  16914. * @param value Define the value to give to the uniform
  16915. * @return the material itself allowing "fluent" like uniform updates
  16916. */
  16917. setInt(name: string, value: number): ShaderMaterial;
  16918. /**
  16919. * Set an array of floats in the shader.
  16920. * @param name Define the name of the uniform as defined in the shader
  16921. * @param value Define the value to give to the uniform
  16922. * @return the material itself allowing "fluent" like uniform updates
  16923. */
  16924. setFloats(name: string, value: number[]): ShaderMaterial;
  16925. /**
  16926. * Set a vec3 in the shader from a Color3.
  16927. * @param name Define the name of the uniform as defined in the shader
  16928. * @param value Define the value to give to the uniform
  16929. * @return the material itself allowing "fluent" like uniform updates
  16930. */
  16931. setColor3(name: string, value: Color3): ShaderMaterial;
  16932. /**
  16933. * Set a vec3 array in the shader from a Color3 array.
  16934. * @param name Define the name of the uniform as defined in the shader
  16935. * @param value Define the value to give to the uniform
  16936. * @return the material itself allowing "fluent" like uniform updates
  16937. */
  16938. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16939. /**
  16940. * Set a vec4 in the shader from a Color4.
  16941. * @param name Define the name of the uniform as defined in the shader
  16942. * @param value Define the value to give to the uniform
  16943. * @return the material itself allowing "fluent" like uniform updates
  16944. */
  16945. setColor4(name: string, value: Color4): ShaderMaterial;
  16946. /**
  16947. * Set a vec4 array in the shader from a Color4 array.
  16948. * @param name Define the name of the uniform as defined in the shader
  16949. * @param value Define the value to give to the uniform
  16950. * @return the material itself allowing "fluent" like uniform updates
  16951. */
  16952. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16953. /**
  16954. * Set a vec2 in the shader from a Vector2.
  16955. * @param name Define the name of the uniform as defined in the shader
  16956. * @param value Define the value to give to the uniform
  16957. * @return the material itself allowing "fluent" like uniform updates
  16958. */
  16959. setVector2(name: string, value: Vector2): ShaderMaterial;
  16960. /**
  16961. * Set a vec3 in the shader from a Vector3.
  16962. * @param name Define the name of the uniform as defined in the shader
  16963. * @param value Define the value to give to the uniform
  16964. * @return the material itself allowing "fluent" like uniform updates
  16965. */
  16966. setVector3(name: string, value: Vector3): ShaderMaterial;
  16967. /**
  16968. * Set a vec4 in the shader from a Vector4.
  16969. * @param name Define the name of the uniform as defined in the shader
  16970. * @param value Define the value to give to the uniform
  16971. * @return the material itself allowing "fluent" like uniform updates
  16972. */
  16973. setVector4(name: string, value: Vector4): ShaderMaterial;
  16974. /**
  16975. * Set a mat4 in the shader from a Matrix.
  16976. * @param name Define the name of the uniform as defined in the shader
  16977. * @param value Define the value to give to the uniform
  16978. * @return the material itself allowing "fluent" like uniform updates
  16979. */
  16980. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16981. /**
  16982. * Set a float32Array in the shader from a matrix array.
  16983. * @param name Define the name of the uniform as defined in the shader
  16984. * @param value Define the value to give to the uniform
  16985. * @return the material itself allowing "fluent" like uniform updates
  16986. */
  16987. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16988. /**
  16989. * Set a mat3 in the shader from a Float32Array.
  16990. * @param name Define the name of the uniform as defined in the shader
  16991. * @param value Define the value to give to the uniform
  16992. * @return the material itself allowing "fluent" like uniform updates
  16993. */
  16994. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16995. /**
  16996. * Set a mat2 in the shader from a Float32Array.
  16997. * @param name Define the name of the uniform as defined in the shader
  16998. * @param value Define the value to give to the uniform
  16999. * @return the material itself allowing "fluent" like uniform updates
  17000. */
  17001. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17002. /**
  17003. * Set a vec2 array in the shader from a number array.
  17004. * @param name Define the name of the uniform as defined in the shader
  17005. * @param value Define the value to give to the uniform
  17006. * @return the material itself allowing "fluent" like uniform updates
  17007. */
  17008. setArray2(name: string, value: number[]): ShaderMaterial;
  17009. /**
  17010. * Set a vec3 array in the shader from a number array.
  17011. * @param name Define the name of the uniform as defined in the shader
  17012. * @param value Define the value to give to the uniform
  17013. * @return the material itself allowing "fluent" like uniform updates
  17014. */
  17015. setArray3(name: string, value: number[]): ShaderMaterial;
  17016. /**
  17017. * Set a vec4 array in the shader from a number array.
  17018. * @param name Define the name of the uniform as defined in the shader
  17019. * @param value Define the value to give to the uniform
  17020. * @return the material itself allowing "fluent" like uniform updates
  17021. */
  17022. setArray4(name: string, value: number[]): ShaderMaterial;
  17023. private _checkCache;
  17024. /**
  17025. * Specifies that the submesh is ready to be used
  17026. * @param mesh defines the mesh to check
  17027. * @param subMesh defines which submesh to check
  17028. * @param useInstances specifies that instances should be used
  17029. * @returns a boolean indicating that the submesh is ready or not
  17030. */
  17031. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17032. /**
  17033. * Checks if the material is ready to render the requested mesh
  17034. * @param mesh Define the mesh to render
  17035. * @param useInstances Define whether or not the material is used with instances
  17036. * @returns true if ready, otherwise false
  17037. */
  17038. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17039. /**
  17040. * Binds the world matrix to the material
  17041. * @param world defines the world transformation matrix
  17042. * @param effectOverride - If provided, use this effect instead of internal effect
  17043. */
  17044. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17045. /**
  17046. * Binds the submesh to this material by preparing the effect and shader to draw
  17047. * @param world defines the world transformation matrix
  17048. * @param mesh defines the mesh containing the submesh
  17049. * @param subMesh defines the submesh to bind the material to
  17050. */
  17051. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17052. /**
  17053. * Binds the material to the mesh
  17054. * @param world defines the world transformation matrix
  17055. * @param mesh defines the mesh to bind the material to
  17056. * @param effectOverride - If provided, use this effect instead of internal effect
  17057. */
  17058. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17059. protected _afterBind(mesh?: Mesh): void;
  17060. /**
  17061. * Gets the active textures from the material
  17062. * @returns an array of textures
  17063. */
  17064. getActiveTextures(): BaseTexture[];
  17065. /**
  17066. * Specifies if the material uses a texture
  17067. * @param texture defines the texture to check against the material
  17068. * @returns a boolean specifying if the material uses the texture
  17069. */
  17070. hasTexture(texture: BaseTexture): boolean;
  17071. /**
  17072. * Makes a duplicate of the material, and gives it a new name
  17073. * @param name defines the new name for the duplicated material
  17074. * @returns the cloned material
  17075. */
  17076. clone(name: string): ShaderMaterial;
  17077. /**
  17078. * Disposes the material
  17079. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17080. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17081. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17082. */
  17083. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17084. /**
  17085. * Serializes this material in a JSON representation
  17086. * @returns the serialized material object
  17087. */
  17088. serialize(): any;
  17089. /**
  17090. * Creates a shader material from parsed shader material data
  17091. * @param source defines the JSON represnetation of the material
  17092. * @param scene defines the hosting scene
  17093. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17094. * @returns a new material
  17095. */
  17096. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17097. /**
  17098. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17099. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17100. * @param url defines the url to load from
  17101. * @param scene defines the hosting scene
  17102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17103. * @returns a promise that will resolve to the new ShaderMaterial
  17104. */
  17105. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17106. /**
  17107. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17108. * @param snippetId defines the snippet to load
  17109. * @param scene defines the hosting scene
  17110. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17111. * @returns a promise that will resolve to the new ShaderMaterial
  17112. */
  17113. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17114. }
  17115. }
  17116. declare module "babylonjs/Shaders/color.fragment" {
  17117. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17118. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17119. /** @hidden */
  17120. export var colorPixelShader: {
  17121. name: string;
  17122. shader: string;
  17123. };
  17124. }
  17125. declare module "babylonjs/Shaders/color.vertex" {
  17126. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17127. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17128. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17129. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17130. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17131. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17132. /** @hidden */
  17133. export var colorVertexShader: {
  17134. name: string;
  17135. shader: string;
  17136. };
  17137. }
  17138. declare module "babylonjs/Meshes/linesMesh" {
  17139. import { Nullable } from "babylonjs/types";
  17140. import { Scene } from "babylonjs/scene";
  17141. import { Color3 } from "babylonjs/Maths/math.color";
  17142. import { Node } from "babylonjs/node";
  17143. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17144. import { Mesh } from "babylonjs/Meshes/mesh";
  17145. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17146. import { Effect } from "babylonjs/Materials/effect";
  17147. import { Material } from "babylonjs/Materials/material";
  17148. import "babylonjs/Shaders/color.fragment";
  17149. import "babylonjs/Shaders/color.vertex";
  17150. /**
  17151. * Line mesh
  17152. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17153. */
  17154. export class LinesMesh extends Mesh {
  17155. /**
  17156. * If vertex color should be applied to the mesh
  17157. */
  17158. readonly useVertexColor?: boolean | undefined;
  17159. /**
  17160. * If vertex alpha should be applied to the mesh
  17161. */
  17162. readonly useVertexAlpha?: boolean | undefined;
  17163. /**
  17164. * Color of the line (Default: White)
  17165. */
  17166. color: Color3;
  17167. /**
  17168. * Alpha of the line (Default: 1)
  17169. */
  17170. alpha: number;
  17171. /**
  17172. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17173. * This margin is expressed in world space coordinates, so its value may vary.
  17174. * Default value is 0.1
  17175. */
  17176. intersectionThreshold: number;
  17177. private _colorShader;
  17178. private color4;
  17179. /**
  17180. * Creates a new LinesMesh
  17181. * @param name defines the name
  17182. * @param scene defines the hosting scene
  17183. * @param parent defines the parent mesh if any
  17184. * @param source defines the optional source LinesMesh used to clone data from
  17185. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17186. * When false, achieved by calling a clone(), also passing False.
  17187. * This will make creation of children, recursive.
  17188. * @param useVertexColor defines if this LinesMesh supports vertex color
  17189. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17190. */
  17191. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17192. /**
  17193. * If vertex color should be applied to the mesh
  17194. */
  17195. useVertexColor?: boolean | undefined,
  17196. /**
  17197. * If vertex alpha should be applied to the mesh
  17198. */
  17199. useVertexAlpha?: boolean | undefined);
  17200. private _addClipPlaneDefine;
  17201. private _removeClipPlaneDefine;
  17202. isReady(): boolean;
  17203. /**
  17204. * Returns the string "LineMesh"
  17205. */
  17206. getClassName(): string;
  17207. /**
  17208. * @hidden
  17209. */
  17210. get material(): Material;
  17211. /**
  17212. * @hidden
  17213. */
  17214. set material(value: Material);
  17215. /**
  17216. * @hidden
  17217. */
  17218. get checkCollisions(): boolean;
  17219. /** @hidden */
  17220. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17221. /** @hidden */
  17222. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17223. /**
  17224. * Disposes of the line mesh
  17225. * @param doNotRecurse If children should be disposed
  17226. */
  17227. dispose(doNotRecurse?: boolean): void;
  17228. /**
  17229. * Returns a new LineMesh object cloned from the current one.
  17230. */
  17231. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17232. /**
  17233. * Creates a new InstancedLinesMesh object from the mesh model.
  17234. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17235. * @param name defines the name of the new instance
  17236. * @returns a new InstancedLinesMesh
  17237. */
  17238. createInstance(name: string): InstancedLinesMesh;
  17239. }
  17240. /**
  17241. * Creates an instance based on a source LinesMesh
  17242. */
  17243. export class InstancedLinesMesh extends InstancedMesh {
  17244. /**
  17245. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17246. * This margin is expressed in world space coordinates, so its value may vary.
  17247. * Initilized with the intersectionThreshold value of the source LinesMesh
  17248. */
  17249. intersectionThreshold: number;
  17250. constructor(name: string, source: LinesMesh);
  17251. /**
  17252. * Returns the string "InstancedLinesMesh".
  17253. */
  17254. getClassName(): string;
  17255. }
  17256. }
  17257. declare module "babylonjs/Shaders/line.fragment" {
  17258. /** @hidden */
  17259. export var linePixelShader: {
  17260. name: string;
  17261. shader: string;
  17262. };
  17263. }
  17264. declare module "babylonjs/Shaders/line.vertex" {
  17265. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17266. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17267. /** @hidden */
  17268. export var lineVertexShader: {
  17269. name: string;
  17270. shader: string;
  17271. };
  17272. }
  17273. declare module "babylonjs/Rendering/edgesRenderer" {
  17274. import { Nullable } from "babylonjs/types";
  17275. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17277. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17278. import { IDisposable } from "babylonjs/scene";
  17279. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17280. import "babylonjs/Shaders/line.fragment";
  17281. import "babylonjs/Shaders/line.vertex";
  17282. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17283. import { SmartArray } from "babylonjs/Misc/smartArray";
  17284. module "babylonjs/scene" {
  17285. interface Scene {
  17286. /** @hidden */
  17287. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17288. }
  17289. }
  17290. module "babylonjs/Meshes/abstractMesh" {
  17291. interface AbstractMesh {
  17292. /**
  17293. * Gets the edgesRenderer associated with the mesh
  17294. */
  17295. edgesRenderer: Nullable<EdgesRenderer>;
  17296. }
  17297. }
  17298. module "babylonjs/Meshes/linesMesh" {
  17299. interface LinesMesh {
  17300. /**
  17301. * Enables the edge rendering mode on the mesh.
  17302. * This mode makes the mesh edges visible
  17303. * @param epsilon defines the maximal distance between two angles to detect a face
  17304. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17305. * @returns the currentAbstractMesh
  17306. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17307. */
  17308. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17309. }
  17310. }
  17311. module "babylonjs/Meshes/linesMesh" {
  17312. interface InstancedLinesMesh {
  17313. /**
  17314. * Enables the edge rendering mode on the mesh.
  17315. * This mode makes the mesh edges visible
  17316. * @param epsilon defines the maximal distance between two angles to detect a face
  17317. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17318. * @returns the current InstancedLinesMesh
  17319. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17320. */
  17321. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17322. }
  17323. }
  17324. /**
  17325. * Defines the minimum contract an Edges renderer should follow.
  17326. */
  17327. export interface IEdgesRenderer extends IDisposable {
  17328. /**
  17329. * Gets or sets a boolean indicating if the edgesRenderer is active
  17330. */
  17331. isEnabled: boolean;
  17332. /**
  17333. * Renders the edges of the attached mesh,
  17334. */
  17335. render(): void;
  17336. /**
  17337. * Checks wether or not the edges renderer is ready to render.
  17338. * @return true if ready, otherwise false.
  17339. */
  17340. isReady(): boolean;
  17341. /**
  17342. * List of instances to render in case the source mesh has instances
  17343. */
  17344. customInstances: SmartArray<Matrix>;
  17345. }
  17346. /**
  17347. * Defines the additional options of the edges renderer
  17348. */
  17349. export interface IEdgesRendererOptions {
  17350. /**
  17351. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17352. * If not defined, the default value is true
  17353. */
  17354. useAlternateEdgeFinder?: boolean;
  17355. /**
  17356. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17357. * If not defined, the default value is true.
  17358. * 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)
  17359. * This option is used only if useAlternateEdgeFinder = true
  17360. */
  17361. useFastVertexMerger?: boolean;
  17362. /**
  17363. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17364. * The default value is 1e-6
  17365. * This option is used only if useAlternateEdgeFinder = true
  17366. */
  17367. epsilonVertexMerge?: number;
  17368. /**
  17369. * 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
  17370. * 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.
  17371. * This option is used only if useAlternateEdgeFinder = true
  17372. */
  17373. applyTessellation?: boolean;
  17374. /**
  17375. * 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
  17376. * The default value is 1e-6
  17377. * This option is used only if useAlternateEdgeFinder = true
  17378. */
  17379. epsilonVertexAligned?: number;
  17380. }
  17381. /**
  17382. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17383. */
  17384. export class EdgesRenderer implements IEdgesRenderer {
  17385. /**
  17386. * Define the size of the edges with an orthographic camera
  17387. */
  17388. edgesWidthScalerForOrthographic: number;
  17389. /**
  17390. * Define the size of the edges with a perspective camera
  17391. */
  17392. edgesWidthScalerForPerspective: number;
  17393. protected _source: AbstractMesh;
  17394. protected _linesPositions: number[];
  17395. protected _linesNormals: number[];
  17396. protected _linesIndices: number[];
  17397. protected _epsilon: number;
  17398. protected _indicesCount: number;
  17399. protected _lineShader: ShaderMaterial;
  17400. protected _ib: DataBuffer;
  17401. protected _buffers: {
  17402. [key: string]: Nullable<VertexBuffer>;
  17403. };
  17404. protected _buffersForInstances: {
  17405. [key: string]: Nullable<VertexBuffer>;
  17406. };
  17407. protected _checkVerticesInsteadOfIndices: boolean;
  17408. protected _options: Nullable<IEdgesRendererOptions>;
  17409. private _meshRebuildObserver;
  17410. private _meshDisposeObserver;
  17411. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17412. isEnabled: boolean;
  17413. /**
  17414. * List of instances to render in case the source mesh has instances
  17415. */
  17416. customInstances: SmartArray<Matrix>;
  17417. private static GetShader;
  17418. /**
  17419. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17420. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17421. * @param source Mesh used to create edges
  17422. * @param epsilon sum of angles in adjacency to check for edge
  17423. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17424. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17425. * @param options The options to apply when generating the edges
  17426. */
  17427. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17428. protected _prepareRessources(): void;
  17429. /** @hidden */
  17430. _rebuild(): void;
  17431. /**
  17432. * Releases the required resources for the edges renderer
  17433. */
  17434. dispose(): void;
  17435. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17436. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17437. /**
  17438. * Checks if the pair of p0 and p1 is en edge
  17439. * @param faceIndex
  17440. * @param edge
  17441. * @param faceNormals
  17442. * @param p0
  17443. * @param p1
  17444. * @private
  17445. */
  17446. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17447. /**
  17448. * push line into the position, normal and index buffer
  17449. * @protected
  17450. */
  17451. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17452. /**
  17453. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17454. */
  17455. private _tessellateTriangle;
  17456. private _generateEdgesLinesAlternate;
  17457. /**
  17458. * Generates lines edges from adjacencjes
  17459. * @private
  17460. */
  17461. _generateEdgesLines(): void;
  17462. /**
  17463. * Checks wether or not the edges renderer is ready to render.
  17464. * @return true if ready, otherwise false.
  17465. */
  17466. isReady(): boolean;
  17467. /**
  17468. * Renders the edges of the attached mesh,
  17469. */
  17470. render(): void;
  17471. }
  17472. /**
  17473. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17474. */
  17475. export class LineEdgesRenderer extends EdgesRenderer {
  17476. /**
  17477. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17478. * @param source LineMesh used to generate edges
  17479. * @param epsilon not important (specified angle for edge detection)
  17480. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17481. */
  17482. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17483. /**
  17484. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17485. */
  17486. _generateEdgesLines(): void;
  17487. }
  17488. }
  17489. declare module "babylonjs/Rendering/renderingGroup" {
  17490. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17491. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17493. import { Nullable } from "babylonjs/types";
  17494. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17495. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17496. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17497. import { Material } from "babylonjs/Materials/material";
  17498. import { Scene } from "babylonjs/scene";
  17499. /**
  17500. * This represents the object necessary to create a rendering group.
  17501. * This is exclusively used and created by the rendering manager.
  17502. * To modify the behavior, you use the available helpers in your scene or meshes.
  17503. * @hidden
  17504. */
  17505. export class RenderingGroup {
  17506. index: number;
  17507. private static _zeroVector;
  17508. private _scene;
  17509. private _opaqueSubMeshes;
  17510. private _transparentSubMeshes;
  17511. private _alphaTestSubMeshes;
  17512. private _depthOnlySubMeshes;
  17513. private _particleSystems;
  17514. private _spriteManagers;
  17515. private _opaqueSortCompareFn;
  17516. private _alphaTestSortCompareFn;
  17517. private _transparentSortCompareFn;
  17518. private _renderOpaque;
  17519. private _renderAlphaTest;
  17520. private _renderTransparent;
  17521. /** @hidden */
  17522. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17523. onBeforeTransparentRendering: () => void;
  17524. /**
  17525. * Set the opaque sort comparison function.
  17526. * If null the sub meshes will be render in the order they were created
  17527. */
  17528. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17529. /**
  17530. * Set the alpha test sort comparison function.
  17531. * If null the sub meshes will be render in the order they were created
  17532. */
  17533. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17534. /**
  17535. * Set the transparent sort comparison function.
  17536. * If null the sub meshes will be render in the order they were created
  17537. */
  17538. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17539. /**
  17540. * Creates a new rendering group.
  17541. * @param index The rendering group index
  17542. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17543. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17544. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17545. */
  17546. 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>);
  17547. /**
  17548. * Render all the sub meshes contained in the group.
  17549. * @param customRenderFunction Used to override the default render behaviour of the group.
  17550. * @returns true if rendered some submeshes.
  17551. */
  17552. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17553. /**
  17554. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17555. * @param subMeshes The submeshes to render
  17556. */
  17557. private renderOpaqueSorted;
  17558. /**
  17559. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17560. * @param subMeshes The submeshes to render
  17561. */
  17562. private renderAlphaTestSorted;
  17563. /**
  17564. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17565. * @param subMeshes The submeshes to render
  17566. */
  17567. private renderTransparentSorted;
  17568. /**
  17569. * Renders the submeshes in a specified order.
  17570. * @param subMeshes The submeshes to sort before render
  17571. * @param sortCompareFn The comparison function use to sort
  17572. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17573. * @param transparent Specifies to activate blending if true
  17574. */
  17575. private static renderSorted;
  17576. /**
  17577. * Renders the submeshes in the order they were dispatched (no sort applied).
  17578. * @param subMeshes The submeshes to render
  17579. */
  17580. private static renderUnsorted;
  17581. /**
  17582. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17583. * are rendered back to front if in the same alpha index.
  17584. *
  17585. * @param a The first submesh
  17586. * @param b The second submesh
  17587. * @returns The result of the comparison
  17588. */
  17589. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17590. /**
  17591. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17592. * are rendered back to front.
  17593. *
  17594. * @param a The first submesh
  17595. * @param b The second submesh
  17596. * @returns The result of the comparison
  17597. */
  17598. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17599. /**
  17600. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17601. * are rendered front to back (prevent overdraw).
  17602. *
  17603. * @param a The first submesh
  17604. * @param b The second submesh
  17605. * @returns The result of the comparison
  17606. */
  17607. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17608. /**
  17609. * Resets the different lists of submeshes to prepare a new frame.
  17610. */
  17611. prepare(): void;
  17612. dispose(): void;
  17613. /**
  17614. * Inserts the submesh in its correct queue depending on its material.
  17615. * @param subMesh The submesh to dispatch
  17616. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17617. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17618. */
  17619. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17620. dispatchSprites(spriteManager: ISpriteManager): void;
  17621. dispatchParticles(particleSystem: IParticleSystem): void;
  17622. private _renderParticles;
  17623. private _renderSprites;
  17624. }
  17625. }
  17626. declare module "babylonjs/Rendering/renderingManager" {
  17627. import { Nullable } from "babylonjs/types";
  17628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17629. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17630. import { SmartArray } from "babylonjs/Misc/smartArray";
  17631. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17632. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17633. import { Material } from "babylonjs/Materials/material";
  17634. import { Scene } from "babylonjs/scene";
  17635. import { Camera } from "babylonjs/Cameras/camera";
  17636. /**
  17637. * Interface describing the different options available in the rendering manager
  17638. * regarding Auto Clear between groups.
  17639. */
  17640. export interface IRenderingManagerAutoClearSetup {
  17641. /**
  17642. * Defines whether or not autoclear is enable.
  17643. */
  17644. autoClear: boolean;
  17645. /**
  17646. * Defines whether or not to autoclear the depth buffer.
  17647. */
  17648. depth: boolean;
  17649. /**
  17650. * Defines whether or not to autoclear the stencil buffer.
  17651. */
  17652. stencil: boolean;
  17653. }
  17654. /**
  17655. * This class is used by the onRenderingGroupObservable
  17656. */
  17657. export class RenderingGroupInfo {
  17658. /**
  17659. * The Scene that being rendered
  17660. */
  17661. scene: Scene;
  17662. /**
  17663. * The camera currently used for the rendering pass
  17664. */
  17665. camera: Nullable<Camera>;
  17666. /**
  17667. * The ID of the renderingGroup being processed
  17668. */
  17669. renderingGroupId: number;
  17670. }
  17671. /**
  17672. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17673. * It is enable to manage the different groups as well as the different necessary sort functions.
  17674. * This should not be used directly aside of the few static configurations
  17675. */
  17676. export class RenderingManager {
  17677. /**
  17678. * The max id used for rendering groups (not included)
  17679. */
  17680. static MAX_RENDERINGGROUPS: number;
  17681. /**
  17682. * The min id used for rendering groups (included)
  17683. */
  17684. static MIN_RENDERINGGROUPS: number;
  17685. /**
  17686. * Used to globally prevent autoclearing scenes.
  17687. */
  17688. static AUTOCLEAR: boolean;
  17689. /**
  17690. * @hidden
  17691. */
  17692. _useSceneAutoClearSetup: boolean;
  17693. private _scene;
  17694. private _renderingGroups;
  17695. private _depthStencilBufferAlreadyCleaned;
  17696. private _autoClearDepthStencil;
  17697. private _customOpaqueSortCompareFn;
  17698. private _customAlphaTestSortCompareFn;
  17699. private _customTransparentSortCompareFn;
  17700. private _renderingGroupInfo;
  17701. /**
  17702. * Instantiates a new rendering group for a particular scene
  17703. * @param scene Defines the scene the groups belongs to
  17704. */
  17705. constructor(scene: Scene);
  17706. private _clearDepthStencilBuffer;
  17707. /**
  17708. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17709. * @hidden
  17710. */
  17711. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17712. /**
  17713. * Resets the different information of the group to prepare a new frame
  17714. * @hidden
  17715. */
  17716. reset(): void;
  17717. /**
  17718. * Dispose and release the group and its associated resources.
  17719. * @hidden
  17720. */
  17721. dispose(): void;
  17722. /**
  17723. * Clear the info related to rendering groups preventing retention points during dispose.
  17724. */
  17725. freeRenderingGroups(): void;
  17726. private _prepareRenderingGroup;
  17727. /**
  17728. * Add a sprite manager to the rendering manager in order to render it this frame.
  17729. * @param spriteManager Define the sprite manager to render
  17730. */
  17731. dispatchSprites(spriteManager: ISpriteManager): void;
  17732. /**
  17733. * Add a particle system to the rendering manager in order to render it this frame.
  17734. * @param particleSystem Define the particle system to render
  17735. */
  17736. dispatchParticles(particleSystem: IParticleSystem): void;
  17737. /**
  17738. * Add a submesh to the manager in order to render it this frame
  17739. * @param subMesh The submesh to dispatch
  17740. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17741. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17742. */
  17743. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17744. /**
  17745. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17746. * This allowed control for front to back rendering or reversly depending of the special needs.
  17747. *
  17748. * @param renderingGroupId The rendering group id corresponding to its index
  17749. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17750. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17751. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17752. */
  17753. 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;
  17754. /**
  17755. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17756. *
  17757. * @param renderingGroupId The rendering group id corresponding to its index
  17758. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17759. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17760. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17761. */
  17762. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17763. /**
  17764. * Gets the current auto clear configuration for one rendering group of the rendering
  17765. * manager.
  17766. * @param index the rendering group index to get the information for
  17767. * @returns The auto clear setup for the requested rendering group
  17768. */
  17769. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17770. }
  17771. }
  17772. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17773. import { SmartArray } from "babylonjs/Misc/smartArray";
  17774. import { Nullable } from "babylonjs/types";
  17775. import { Scene } from "babylonjs/scene";
  17776. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17777. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17779. import { Mesh } from "babylonjs/Meshes/mesh";
  17780. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17781. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17782. import { Effect } from "babylonjs/Materials/effect";
  17783. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17784. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17785. import "babylonjs/Shaders/shadowMap.fragment";
  17786. import "babylonjs/Shaders/shadowMap.vertex";
  17787. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17788. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17789. import { Observable } from "babylonjs/Misc/observable";
  17790. /**
  17791. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17792. */
  17793. export interface ICustomShaderOptions {
  17794. /**
  17795. * Gets or sets the custom shader name to use
  17796. */
  17797. shaderName: string;
  17798. /**
  17799. * The list of attribute names used in the shader
  17800. */
  17801. attributes?: string[];
  17802. /**
  17803. * The list of unifrom names used in the shader
  17804. */
  17805. uniforms?: string[];
  17806. /**
  17807. * The list of sampler names used in the shader
  17808. */
  17809. samplers?: string[];
  17810. /**
  17811. * The list of defines used in the shader
  17812. */
  17813. defines?: string[];
  17814. }
  17815. /**
  17816. * Interface to implement to create a shadow generator compatible with BJS.
  17817. */
  17818. export interface IShadowGenerator {
  17819. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17820. id: string;
  17821. /**
  17822. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17823. * @returns The render target texture if present otherwise, null
  17824. */
  17825. getShadowMap(): Nullable<RenderTargetTexture>;
  17826. /**
  17827. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17828. * @param subMesh The submesh we want to render in the shadow map
  17829. * @param useInstances Defines wether will draw in the map using instances
  17830. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17831. * @returns true if ready otherwise, false
  17832. */
  17833. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17834. /**
  17835. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17836. * @param defines Defines of the material we want to update
  17837. * @param lightIndex Index of the light in the enabled light list of the material
  17838. */
  17839. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17840. /**
  17841. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17842. * defined in the generator but impacting the effect).
  17843. * It implies the unifroms available on the materials are the standard BJS ones.
  17844. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17845. * @param effect The effect we are binfing the information for
  17846. */
  17847. bindShadowLight(lightIndex: string, effect: Effect): void;
  17848. /**
  17849. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17850. * (eq to shadow prjection matrix * light transform matrix)
  17851. * @returns The transform matrix used to create the shadow map
  17852. */
  17853. getTransformMatrix(): Matrix;
  17854. /**
  17855. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17856. * Cube and 2D textures for instance.
  17857. */
  17858. recreateShadowMap(): void;
  17859. /**
  17860. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17861. * @param onCompiled Callback triggered at the and of the effects compilation
  17862. * @param options Sets of optional options forcing the compilation with different modes
  17863. */
  17864. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17865. useInstances: boolean;
  17866. }>): void;
  17867. /**
  17868. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17869. * @param options Sets of optional options forcing the compilation with different modes
  17870. * @returns A promise that resolves when the compilation completes
  17871. */
  17872. forceCompilationAsync(options?: Partial<{
  17873. useInstances: boolean;
  17874. }>): Promise<void>;
  17875. /**
  17876. * Serializes the shadow generator setup to a json object.
  17877. * @returns The serialized JSON object
  17878. */
  17879. serialize(): any;
  17880. /**
  17881. * Disposes the Shadow map and related Textures and effects.
  17882. */
  17883. dispose(): void;
  17884. }
  17885. /**
  17886. * Default implementation IShadowGenerator.
  17887. * This is the main object responsible of generating shadows in the framework.
  17888. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17889. */
  17890. export class ShadowGenerator implements IShadowGenerator {
  17891. /**
  17892. * Name of the shadow generator class
  17893. */
  17894. static CLASSNAME: string;
  17895. /**
  17896. * Shadow generator mode None: no filtering applied.
  17897. */
  17898. static readonly FILTER_NONE: number;
  17899. /**
  17900. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17901. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17902. */
  17903. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17904. /**
  17905. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17906. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17907. */
  17908. static readonly FILTER_POISSONSAMPLING: number;
  17909. /**
  17910. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17911. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17912. */
  17913. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17914. /**
  17915. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17916. * edge artifacts on steep falloff.
  17917. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17918. */
  17919. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17920. /**
  17921. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17922. * edge artifacts on steep falloff.
  17923. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17924. */
  17925. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17926. /**
  17927. * Shadow generator mode PCF: Percentage Closer Filtering
  17928. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17929. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17930. */
  17931. static readonly FILTER_PCF: number;
  17932. /**
  17933. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17934. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17935. * Contact Hardening
  17936. */
  17937. static readonly FILTER_PCSS: number;
  17938. /**
  17939. * Reserved for PCF and PCSS
  17940. * Highest Quality.
  17941. *
  17942. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17943. *
  17944. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17945. */
  17946. static readonly QUALITY_HIGH: number;
  17947. /**
  17948. * Reserved for PCF and PCSS
  17949. * Good tradeoff for quality/perf cross devices
  17950. *
  17951. * Execute PCF on a 3*3 kernel.
  17952. *
  17953. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17954. */
  17955. static readonly QUALITY_MEDIUM: number;
  17956. /**
  17957. * Reserved for PCF and PCSS
  17958. * The lowest quality but the fastest.
  17959. *
  17960. * Execute PCF on a 1*1 kernel.
  17961. *
  17962. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17963. */
  17964. static readonly QUALITY_LOW: number;
  17965. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17966. id: string;
  17967. /** Gets or sets the custom shader name to use */
  17968. customShaderOptions: ICustomShaderOptions;
  17969. /**
  17970. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17971. */
  17972. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17973. /**
  17974. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17975. */
  17976. onAfterShadowMapRenderObservable: Observable<Effect>;
  17977. /**
  17978. * Observable triggered before a mesh is rendered in the shadow map.
  17979. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17980. */
  17981. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17982. /**
  17983. * Observable triggered after a mesh is rendered in the shadow map.
  17984. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17985. */
  17986. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17987. protected _bias: number;
  17988. /**
  17989. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17990. */
  17991. get bias(): number;
  17992. /**
  17993. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17994. */
  17995. set bias(bias: number);
  17996. protected _normalBias: number;
  17997. /**
  17998. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17999. */
  18000. get normalBias(): number;
  18001. /**
  18002. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18003. */
  18004. set normalBias(normalBias: number);
  18005. protected _blurBoxOffset: number;
  18006. /**
  18007. * Gets the blur box offset: offset applied during the blur pass.
  18008. * Only useful if useKernelBlur = false
  18009. */
  18010. get blurBoxOffset(): number;
  18011. /**
  18012. * Sets the blur box offset: offset applied during the blur pass.
  18013. * Only useful if useKernelBlur = false
  18014. */
  18015. set blurBoxOffset(value: number);
  18016. protected _blurScale: number;
  18017. /**
  18018. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18019. * 2 means half of the size.
  18020. */
  18021. get blurScale(): number;
  18022. /**
  18023. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18024. * 2 means half of the size.
  18025. */
  18026. set blurScale(value: number);
  18027. protected _blurKernel: number;
  18028. /**
  18029. * Gets the blur kernel: kernel size of the blur pass.
  18030. * Only useful if useKernelBlur = true
  18031. */
  18032. get blurKernel(): number;
  18033. /**
  18034. * Sets the blur kernel: kernel size of the blur pass.
  18035. * Only useful if useKernelBlur = true
  18036. */
  18037. set blurKernel(value: number);
  18038. protected _useKernelBlur: boolean;
  18039. /**
  18040. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18041. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18042. */
  18043. get useKernelBlur(): boolean;
  18044. /**
  18045. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18046. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18047. */
  18048. set useKernelBlur(value: boolean);
  18049. protected _depthScale: number;
  18050. /**
  18051. * Gets the depth scale used in ESM mode.
  18052. */
  18053. get depthScale(): number;
  18054. /**
  18055. * Sets the depth scale used in ESM mode.
  18056. * This can override the scale stored on the light.
  18057. */
  18058. set depthScale(value: number);
  18059. protected _validateFilter(filter: number): number;
  18060. protected _filter: number;
  18061. /**
  18062. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18063. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18064. */
  18065. get filter(): number;
  18066. /**
  18067. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18068. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18069. */
  18070. set filter(value: number);
  18071. /**
  18072. * Gets if the current filter is set to Poisson Sampling.
  18073. */
  18074. get usePoissonSampling(): boolean;
  18075. /**
  18076. * Sets the current filter to Poisson Sampling.
  18077. */
  18078. set usePoissonSampling(value: boolean);
  18079. /**
  18080. * Gets if the current filter is set to ESM.
  18081. */
  18082. get useExponentialShadowMap(): boolean;
  18083. /**
  18084. * Sets the current filter is to ESM.
  18085. */
  18086. set useExponentialShadowMap(value: boolean);
  18087. /**
  18088. * Gets if the current filter is set to filtered ESM.
  18089. */
  18090. get useBlurExponentialShadowMap(): boolean;
  18091. /**
  18092. * Gets if the current filter is set to filtered ESM.
  18093. */
  18094. set useBlurExponentialShadowMap(value: boolean);
  18095. /**
  18096. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18097. * exponential to prevent steep falloff artifacts).
  18098. */
  18099. get useCloseExponentialShadowMap(): boolean;
  18100. /**
  18101. * Sets the current filter to "close ESM" (using the inverse of the
  18102. * exponential to prevent steep falloff artifacts).
  18103. */
  18104. set useCloseExponentialShadowMap(value: boolean);
  18105. /**
  18106. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18107. * exponential to prevent steep falloff artifacts).
  18108. */
  18109. get useBlurCloseExponentialShadowMap(): boolean;
  18110. /**
  18111. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18112. * exponential to prevent steep falloff artifacts).
  18113. */
  18114. set useBlurCloseExponentialShadowMap(value: boolean);
  18115. /**
  18116. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18117. */
  18118. get usePercentageCloserFiltering(): boolean;
  18119. /**
  18120. * Sets the current filter to "PCF" (percentage closer filtering).
  18121. */
  18122. set usePercentageCloserFiltering(value: boolean);
  18123. protected _filteringQuality: number;
  18124. /**
  18125. * Gets the PCF or PCSS Quality.
  18126. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18127. */
  18128. get filteringQuality(): number;
  18129. /**
  18130. * Sets the PCF or PCSS Quality.
  18131. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18132. */
  18133. set filteringQuality(filteringQuality: number);
  18134. /**
  18135. * Gets if the current filter is set to "PCSS" (contact hardening).
  18136. */
  18137. get useContactHardeningShadow(): boolean;
  18138. /**
  18139. * Sets the current filter to "PCSS" (contact hardening).
  18140. */
  18141. set useContactHardeningShadow(value: boolean);
  18142. protected _contactHardeningLightSizeUVRatio: number;
  18143. /**
  18144. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18145. * Using a ratio helps keeping shape stability independently of the map size.
  18146. *
  18147. * It does not account for the light projection as it was having too much
  18148. * instability during the light setup or during light position changes.
  18149. *
  18150. * Only valid if useContactHardeningShadow is true.
  18151. */
  18152. get contactHardeningLightSizeUVRatio(): number;
  18153. /**
  18154. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18155. * Using a ratio helps keeping shape stability independently of the map size.
  18156. *
  18157. * It does not account for the light projection as it was having too much
  18158. * instability during the light setup or during light position changes.
  18159. *
  18160. * Only valid if useContactHardeningShadow is true.
  18161. */
  18162. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18163. protected _darkness: number;
  18164. /** Gets or sets the actual darkness of a shadow */
  18165. get darkness(): number;
  18166. set darkness(value: number);
  18167. /**
  18168. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18169. * 0 means strongest and 1 would means no shadow.
  18170. * @returns the darkness.
  18171. */
  18172. getDarkness(): number;
  18173. /**
  18174. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18175. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18176. * @returns the shadow generator allowing fluent coding.
  18177. */
  18178. setDarkness(darkness: number): ShadowGenerator;
  18179. protected _transparencyShadow: boolean;
  18180. /** Gets or sets the ability to have transparent shadow */
  18181. get transparencyShadow(): boolean;
  18182. set transparencyShadow(value: boolean);
  18183. /**
  18184. * Sets the ability to have transparent shadow (boolean).
  18185. * @param transparent True if transparent else False
  18186. * @returns the shadow generator allowing fluent coding
  18187. */
  18188. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18189. /**
  18190. * Enables or disables shadows with varying strength based on the transparency
  18191. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18192. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18193. * mesh.visibility * alphaTexture.a
  18194. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18195. */
  18196. enableSoftTransparentShadow: boolean;
  18197. protected _shadowMap: Nullable<RenderTargetTexture>;
  18198. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18199. /**
  18200. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18201. * @returns The render target texture if present otherwise, null
  18202. */
  18203. getShadowMap(): Nullable<RenderTargetTexture>;
  18204. /**
  18205. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18206. * @returns The render target texture if the shadow map is present otherwise, null
  18207. */
  18208. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18209. /**
  18210. * Gets the class name of that object
  18211. * @returns "ShadowGenerator"
  18212. */
  18213. getClassName(): string;
  18214. /**
  18215. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18216. * @param mesh Mesh to add
  18217. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18218. * @returns the Shadow Generator itself
  18219. */
  18220. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18221. /**
  18222. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18223. * @param mesh Mesh to remove
  18224. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18225. * @returns the Shadow Generator itself
  18226. */
  18227. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18228. /**
  18229. * Controls the extent to which the shadows fade out at the edge of the frustum
  18230. */
  18231. frustumEdgeFalloff: number;
  18232. protected _light: IShadowLight;
  18233. /**
  18234. * Returns the associated light object.
  18235. * @returns the light generating the shadow
  18236. */
  18237. getLight(): IShadowLight;
  18238. /**
  18239. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18240. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18241. * It might on the other hand introduce peter panning.
  18242. */
  18243. forceBackFacesOnly: boolean;
  18244. protected _scene: Scene;
  18245. protected _lightDirection: Vector3;
  18246. protected _effect: Effect;
  18247. protected _viewMatrix: Matrix;
  18248. protected _projectionMatrix: Matrix;
  18249. protected _transformMatrix: Matrix;
  18250. protected _cachedPosition: Vector3;
  18251. protected _cachedDirection: Vector3;
  18252. protected _cachedDefines: string;
  18253. protected _currentRenderID: number;
  18254. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18255. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18256. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18257. protected _blurPostProcesses: PostProcess[];
  18258. protected _mapSize: number;
  18259. protected _currentFaceIndex: number;
  18260. protected _currentFaceIndexCache: number;
  18261. protected _textureType: number;
  18262. protected _defaultTextureMatrix: Matrix;
  18263. protected _storedUniqueId: Nullable<number>;
  18264. /** @hidden */
  18265. static _SceneComponentInitialization: (scene: Scene) => void;
  18266. /**
  18267. * Creates a ShadowGenerator object.
  18268. * A ShadowGenerator is the required tool to use the shadows.
  18269. * Each light casting shadows needs to use its own ShadowGenerator.
  18270. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18271. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18272. * @param light The light object generating the shadows.
  18273. * @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.
  18274. */
  18275. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18276. protected _initializeGenerator(): void;
  18277. protected _createTargetRenderTexture(): void;
  18278. protected _initializeShadowMap(): void;
  18279. protected _initializeBlurRTTAndPostProcesses(): void;
  18280. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18281. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18282. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18283. protected _applyFilterValues(): void;
  18284. /**
  18285. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18286. * @param onCompiled Callback triggered at the and of the effects compilation
  18287. * @param options Sets of optional options forcing the compilation with different modes
  18288. */
  18289. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18290. useInstances: boolean;
  18291. }>): void;
  18292. /**
  18293. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18294. * @param options Sets of optional options forcing the compilation with different modes
  18295. * @returns A promise that resolves when the compilation completes
  18296. */
  18297. forceCompilationAsync(options?: Partial<{
  18298. useInstances: boolean;
  18299. }>): Promise<void>;
  18300. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18301. private _prepareShadowDefines;
  18302. /**
  18303. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18304. * @param subMesh The submesh we want to render in the shadow map
  18305. * @param useInstances Defines wether will draw in the map using instances
  18306. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18307. * @returns true if ready otherwise, false
  18308. */
  18309. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18310. /**
  18311. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18312. * @param defines Defines of the material we want to update
  18313. * @param lightIndex Index of the light in the enabled light list of the material
  18314. */
  18315. prepareDefines(defines: any, lightIndex: number): void;
  18316. /**
  18317. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18318. * defined in the generator but impacting the effect).
  18319. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18320. * @param effect The effect we are binfing the information for
  18321. */
  18322. bindShadowLight(lightIndex: string, effect: Effect): void;
  18323. /**
  18324. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18325. * (eq to shadow prjection matrix * light transform matrix)
  18326. * @returns The transform matrix used to create the shadow map
  18327. */
  18328. getTransformMatrix(): Matrix;
  18329. /**
  18330. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18331. * Cube and 2D textures for instance.
  18332. */
  18333. recreateShadowMap(): void;
  18334. protected _disposeBlurPostProcesses(): void;
  18335. protected _disposeRTTandPostProcesses(): void;
  18336. /**
  18337. * Disposes the ShadowGenerator.
  18338. * Returns nothing.
  18339. */
  18340. dispose(): void;
  18341. /**
  18342. * Serializes the shadow generator setup to a json object.
  18343. * @returns The serialized JSON object
  18344. */
  18345. serialize(): any;
  18346. /**
  18347. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18348. * @param parsedShadowGenerator The JSON object to parse
  18349. * @param scene The scene to create the shadow map for
  18350. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18351. * @returns The parsed shadow generator
  18352. */
  18353. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18354. }
  18355. }
  18356. declare module "babylonjs/Lights/light" {
  18357. import { Nullable } from "babylonjs/types";
  18358. import { Scene } from "babylonjs/scene";
  18359. import { Vector3 } from "babylonjs/Maths/math.vector";
  18360. import { Color3 } from "babylonjs/Maths/math.color";
  18361. import { Node } from "babylonjs/node";
  18362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18363. import { Effect } from "babylonjs/Materials/effect";
  18364. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18365. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18366. /**
  18367. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18368. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18369. * 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.
  18370. */
  18371. export abstract class Light extends Node {
  18372. /**
  18373. * Falloff Default: light is falling off following the material specification:
  18374. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18375. */
  18376. static readonly FALLOFF_DEFAULT: number;
  18377. /**
  18378. * Falloff Physical: light is falling off following the inverse squared distance law.
  18379. */
  18380. static readonly FALLOFF_PHYSICAL: number;
  18381. /**
  18382. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18383. * to enhance interoperability with other engines.
  18384. */
  18385. static readonly FALLOFF_GLTF: number;
  18386. /**
  18387. * Falloff Standard: light is falling off like in the standard material
  18388. * to enhance interoperability with other materials.
  18389. */
  18390. static readonly FALLOFF_STANDARD: number;
  18391. /**
  18392. * If every light affecting the material is in this lightmapMode,
  18393. * material.lightmapTexture adds or multiplies
  18394. * (depends on material.useLightmapAsShadowmap)
  18395. * after every other light calculations.
  18396. */
  18397. static readonly LIGHTMAP_DEFAULT: number;
  18398. /**
  18399. * material.lightmapTexture as only diffuse lighting from this light
  18400. * adds only specular lighting from this light
  18401. * adds dynamic shadows
  18402. */
  18403. static readonly LIGHTMAP_SPECULAR: number;
  18404. /**
  18405. * material.lightmapTexture as only lighting
  18406. * no light calculation from this light
  18407. * only adds dynamic shadows from this light
  18408. */
  18409. static readonly LIGHTMAP_SHADOWSONLY: number;
  18410. /**
  18411. * Each light type uses the default quantity according to its type:
  18412. * point/spot lights use luminous intensity
  18413. * directional lights use illuminance
  18414. */
  18415. static readonly INTENSITYMODE_AUTOMATIC: number;
  18416. /**
  18417. * lumen (lm)
  18418. */
  18419. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18420. /**
  18421. * candela (lm/sr)
  18422. */
  18423. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18424. /**
  18425. * lux (lm/m^2)
  18426. */
  18427. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18428. /**
  18429. * nit (cd/m^2)
  18430. */
  18431. static readonly INTENSITYMODE_LUMINANCE: number;
  18432. /**
  18433. * Light type const id of the point light.
  18434. */
  18435. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18436. /**
  18437. * Light type const id of the directional light.
  18438. */
  18439. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18440. /**
  18441. * Light type const id of the spot light.
  18442. */
  18443. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18444. /**
  18445. * Light type const id of the hemispheric light.
  18446. */
  18447. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18448. /**
  18449. * Diffuse gives the basic color to an object.
  18450. */
  18451. diffuse: Color3;
  18452. /**
  18453. * Specular produces a highlight color on an object.
  18454. * Note: This is note affecting PBR materials.
  18455. */
  18456. specular: Color3;
  18457. /**
  18458. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18459. * falling off base on range or angle.
  18460. * This can be set to any values in Light.FALLOFF_x.
  18461. *
  18462. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18463. * other types of materials.
  18464. */
  18465. falloffType: number;
  18466. /**
  18467. * Strength of the light.
  18468. * Note: By default it is define in the framework own unit.
  18469. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18470. */
  18471. intensity: number;
  18472. private _range;
  18473. protected _inverseSquaredRange: number;
  18474. /**
  18475. * Defines how far from the source the light is impacting in scene units.
  18476. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18477. */
  18478. get range(): number;
  18479. /**
  18480. * Defines how far from the source the light is impacting in scene units.
  18481. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18482. */
  18483. set range(value: number);
  18484. /**
  18485. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18486. * of light.
  18487. */
  18488. private _photometricScale;
  18489. private _intensityMode;
  18490. /**
  18491. * Gets the photometric scale used to interpret the intensity.
  18492. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18493. */
  18494. get intensityMode(): number;
  18495. /**
  18496. * Sets the photometric scale used to interpret the intensity.
  18497. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18498. */
  18499. set intensityMode(value: number);
  18500. private _radius;
  18501. /**
  18502. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18503. */
  18504. get radius(): number;
  18505. /**
  18506. * sets the light radius used by PBR Materials to simulate soft area lights.
  18507. */
  18508. set radius(value: number);
  18509. private _renderPriority;
  18510. /**
  18511. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18512. * exceeding the number allowed of the materials.
  18513. */
  18514. renderPriority: number;
  18515. private _shadowEnabled;
  18516. /**
  18517. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18518. * the current shadow generator.
  18519. */
  18520. get shadowEnabled(): boolean;
  18521. /**
  18522. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18523. * the current shadow generator.
  18524. */
  18525. set shadowEnabled(value: boolean);
  18526. private _includedOnlyMeshes;
  18527. /**
  18528. * Gets the only meshes impacted by this light.
  18529. */
  18530. get includedOnlyMeshes(): AbstractMesh[];
  18531. /**
  18532. * Sets the only meshes impacted by this light.
  18533. */
  18534. set includedOnlyMeshes(value: AbstractMesh[]);
  18535. private _excludedMeshes;
  18536. /**
  18537. * Gets the meshes not impacted by this light.
  18538. */
  18539. get excludedMeshes(): AbstractMesh[];
  18540. /**
  18541. * Sets the meshes not impacted by this light.
  18542. */
  18543. set excludedMeshes(value: AbstractMesh[]);
  18544. private _excludeWithLayerMask;
  18545. /**
  18546. * Gets the layer id use to find what meshes are not impacted by the light.
  18547. * Inactive if 0
  18548. */
  18549. get excludeWithLayerMask(): number;
  18550. /**
  18551. * Sets the layer id use to find what meshes are not impacted by the light.
  18552. * Inactive if 0
  18553. */
  18554. set excludeWithLayerMask(value: number);
  18555. private _includeOnlyWithLayerMask;
  18556. /**
  18557. * Gets the layer id use to find what meshes are impacted by the light.
  18558. * Inactive if 0
  18559. */
  18560. get includeOnlyWithLayerMask(): number;
  18561. /**
  18562. * Sets the layer id use to find what meshes are impacted by the light.
  18563. * Inactive if 0
  18564. */
  18565. set includeOnlyWithLayerMask(value: number);
  18566. private _lightmapMode;
  18567. /**
  18568. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18569. */
  18570. get lightmapMode(): number;
  18571. /**
  18572. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18573. */
  18574. set lightmapMode(value: number);
  18575. /**
  18576. * Shadow generator associted to the light.
  18577. * @hidden Internal use only.
  18578. */
  18579. _shadowGenerator: Nullable<IShadowGenerator>;
  18580. /**
  18581. * @hidden Internal use only.
  18582. */
  18583. _excludedMeshesIds: string[];
  18584. /**
  18585. * @hidden Internal use only.
  18586. */
  18587. _includedOnlyMeshesIds: string[];
  18588. /**
  18589. * The current light unifom buffer.
  18590. * @hidden Internal use only.
  18591. */
  18592. _uniformBuffer: UniformBuffer;
  18593. /** @hidden */
  18594. _renderId: number;
  18595. /**
  18596. * Creates a Light object in the scene.
  18597. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18598. * @param name The firendly name of the light
  18599. * @param scene The scene the light belongs too
  18600. */
  18601. constructor(name: string, scene: Scene);
  18602. protected abstract _buildUniformLayout(): void;
  18603. /**
  18604. * Sets the passed Effect "effect" with the Light information.
  18605. * @param effect The effect to update
  18606. * @param lightIndex The index of the light in the effect to update
  18607. * @returns The light
  18608. */
  18609. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18610. /**
  18611. * Sets the passed Effect "effect" with the Light textures.
  18612. * @param effect The effect to update
  18613. * @param lightIndex The index of the light in the effect to update
  18614. * @returns The light
  18615. */
  18616. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18617. /**
  18618. * Binds the lights information from the scene to the effect for the given mesh.
  18619. * @param lightIndex Light index
  18620. * @param scene The scene where the light belongs to
  18621. * @param effect The effect we are binding the data to
  18622. * @param useSpecular Defines if specular is supported
  18623. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18624. */
  18625. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18626. /**
  18627. * Sets the passed Effect "effect" with the Light information.
  18628. * @param effect The effect to update
  18629. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18630. * @returns The light
  18631. */
  18632. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18633. /**
  18634. * Returns the string "Light".
  18635. * @returns the class name
  18636. */
  18637. getClassName(): string;
  18638. /** @hidden */
  18639. readonly _isLight: boolean;
  18640. /**
  18641. * Converts the light information to a readable string for debug purpose.
  18642. * @param fullDetails Supports for multiple levels of logging within scene loading
  18643. * @returns the human readable light info
  18644. */
  18645. toString(fullDetails?: boolean): string;
  18646. /** @hidden */
  18647. protected _syncParentEnabledState(): void;
  18648. /**
  18649. * Set the enabled state of this node.
  18650. * @param value - the new enabled state
  18651. */
  18652. setEnabled(value: boolean): void;
  18653. /**
  18654. * Returns the Light associated shadow generator if any.
  18655. * @return the associated shadow generator.
  18656. */
  18657. getShadowGenerator(): Nullable<IShadowGenerator>;
  18658. /**
  18659. * Returns a Vector3, the absolute light position in the World.
  18660. * @returns the world space position of the light
  18661. */
  18662. getAbsolutePosition(): Vector3;
  18663. /**
  18664. * Specifies if the light will affect the passed mesh.
  18665. * @param mesh The mesh to test against the light
  18666. * @return true the mesh is affected otherwise, false.
  18667. */
  18668. canAffectMesh(mesh: AbstractMesh): boolean;
  18669. /**
  18670. * Sort function to order lights for rendering.
  18671. * @param a First Light object to compare to second.
  18672. * @param b Second Light object to compare first.
  18673. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18674. */
  18675. static CompareLightsPriority(a: Light, b: Light): number;
  18676. /**
  18677. * Releases resources associated with this node.
  18678. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18679. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18680. */
  18681. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18682. /**
  18683. * Returns the light type ID (integer).
  18684. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18685. */
  18686. getTypeID(): number;
  18687. /**
  18688. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18689. * @returns the scaled intensity in intensity mode unit
  18690. */
  18691. getScaledIntensity(): number;
  18692. /**
  18693. * Returns a new Light object, named "name", from the current one.
  18694. * @param name The name of the cloned light
  18695. * @param newParent The parent of this light, if it has one
  18696. * @returns the new created light
  18697. */
  18698. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18699. /**
  18700. * Serializes the current light into a Serialization object.
  18701. * @returns the serialized object.
  18702. */
  18703. serialize(): any;
  18704. /**
  18705. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18706. * This new light is named "name" and added to the passed scene.
  18707. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18708. * @param name The friendly name of the light
  18709. * @param scene The scene the new light will belong to
  18710. * @returns the constructor function
  18711. */
  18712. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18713. /**
  18714. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18715. * @param parsedLight The JSON representation of the light
  18716. * @param scene The scene to create the parsed light in
  18717. * @returns the created light after parsing
  18718. */
  18719. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18720. private _hookArrayForExcluded;
  18721. private _hookArrayForIncludedOnly;
  18722. private _resyncMeshes;
  18723. /**
  18724. * Forces the meshes to update their light related information in their rendering used effects
  18725. * @hidden Internal Use Only
  18726. */
  18727. _markMeshesAsLightDirty(): void;
  18728. /**
  18729. * Recomputes the cached photometric scale if needed.
  18730. */
  18731. private _computePhotometricScale;
  18732. /**
  18733. * Returns the Photometric Scale according to the light type and intensity mode.
  18734. */
  18735. private _getPhotometricScale;
  18736. /**
  18737. * Reorder the light in the scene according to their defined priority.
  18738. * @hidden Internal Use Only
  18739. */
  18740. _reorderLightsInScene(): void;
  18741. /**
  18742. * Prepares the list of defines specific to the light type.
  18743. * @param defines the list of defines
  18744. * @param lightIndex defines the index of the light for the effect
  18745. */
  18746. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18747. }
  18748. }
  18749. declare module "babylonjs/Cameras/targetCamera" {
  18750. import { Nullable } from "babylonjs/types";
  18751. import { Camera } from "babylonjs/Cameras/camera";
  18752. import { Scene } from "babylonjs/scene";
  18753. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18754. /**
  18755. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18756. * This is the base of the follow, arc rotate cameras and Free camera
  18757. * @see https://doc.babylonjs.com/features/cameras
  18758. */
  18759. export class TargetCamera extends Camera {
  18760. private static _RigCamTransformMatrix;
  18761. private static _TargetTransformMatrix;
  18762. private static _TargetFocalPoint;
  18763. private _tmpUpVector;
  18764. private _tmpTargetVector;
  18765. /**
  18766. * Define the current direction the camera is moving to
  18767. */
  18768. cameraDirection: Vector3;
  18769. /**
  18770. * Define the current rotation the camera is rotating to
  18771. */
  18772. cameraRotation: Vector2;
  18773. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18774. ignoreParentScaling: boolean;
  18775. /**
  18776. * When set, the up vector of the camera will be updated by the rotation of the camera
  18777. */
  18778. updateUpVectorFromRotation: boolean;
  18779. private _tmpQuaternion;
  18780. /**
  18781. * Define the current rotation of the camera
  18782. */
  18783. rotation: Vector3;
  18784. /**
  18785. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18786. */
  18787. rotationQuaternion: Quaternion;
  18788. /**
  18789. * Define the current speed of the camera
  18790. */
  18791. speed: number;
  18792. /**
  18793. * Add constraint to the camera to prevent it to move freely in all directions and
  18794. * around all axis.
  18795. */
  18796. noRotationConstraint: boolean;
  18797. /**
  18798. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18799. * panning
  18800. */
  18801. invertRotation: boolean;
  18802. /**
  18803. * Speed multiplier for inverse camera panning
  18804. */
  18805. inverseRotationSpeed: number;
  18806. /**
  18807. * Define the current target of the camera as an object or a position.
  18808. */
  18809. lockedTarget: any;
  18810. /** @hidden */
  18811. _currentTarget: Vector3;
  18812. /** @hidden */
  18813. _initialFocalDistance: number;
  18814. /** @hidden */
  18815. _viewMatrix: Matrix;
  18816. /** @hidden */
  18817. _camMatrix: Matrix;
  18818. /** @hidden */
  18819. _cameraTransformMatrix: Matrix;
  18820. /** @hidden */
  18821. _cameraRotationMatrix: Matrix;
  18822. /** @hidden */
  18823. _referencePoint: Vector3;
  18824. /** @hidden */
  18825. _transformedReferencePoint: Vector3;
  18826. /** @hidden */
  18827. _reset: () => void;
  18828. private _defaultUp;
  18829. /**
  18830. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18831. * This is the base of the follow, arc rotate cameras and Free camera
  18832. * @see https://doc.babylonjs.com/features/cameras
  18833. * @param name Defines the name of the camera in the scene
  18834. * @param position Defines the start position of the camera in the scene
  18835. * @param scene Defines the scene the camera belongs to
  18836. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18837. */
  18838. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18839. /**
  18840. * Gets the position in front of the camera at a given distance.
  18841. * @param distance The distance from the camera we want the position to be
  18842. * @returns the position
  18843. */
  18844. getFrontPosition(distance: number): Vector3;
  18845. /** @hidden */
  18846. _getLockedTargetPosition(): Nullable<Vector3>;
  18847. private _storedPosition;
  18848. private _storedRotation;
  18849. private _storedRotationQuaternion;
  18850. /**
  18851. * Store current camera state of the camera (fov, position, rotation, etc..)
  18852. * @returns the camera
  18853. */
  18854. storeState(): Camera;
  18855. /**
  18856. * Restored camera state. You must call storeState() first
  18857. * @returns whether it was successful or not
  18858. * @hidden
  18859. */
  18860. _restoreStateValues(): boolean;
  18861. /** @hidden */
  18862. _initCache(): void;
  18863. /** @hidden */
  18864. _updateCache(ignoreParentClass?: boolean): void;
  18865. /** @hidden */
  18866. _isSynchronizedViewMatrix(): boolean;
  18867. /** @hidden */
  18868. _computeLocalCameraSpeed(): number;
  18869. /**
  18870. * Defines the target the camera should look at.
  18871. * @param target Defines the new target as a Vector or a mesh
  18872. */
  18873. setTarget(target: Vector3): void;
  18874. /**
  18875. * Defines the target point of the camera.
  18876. * The camera looks towards it form the radius distance.
  18877. */
  18878. get target(): Vector3;
  18879. set target(value: Vector3);
  18880. /**
  18881. * Return the current target position of the camera. This value is expressed in local space.
  18882. * @returns the target position
  18883. */
  18884. getTarget(): Vector3;
  18885. /** @hidden */
  18886. _decideIfNeedsToMove(): boolean;
  18887. /** @hidden */
  18888. _updatePosition(): void;
  18889. /** @hidden */
  18890. _checkInputs(): void;
  18891. protected _updateCameraRotationMatrix(): void;
  18892. /**
  18893. * 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)
  18894. * @returns the current camera
  18895. */
  18896. private _rotateUpVectorWithCameraRotationMatrix;
  18897. private _cachedRotationZ;
  18898. private _cachedQuaternionRotationZ;
  18899. /** @hidden */
  18900. _getViewMatrix(): Matrix;
  18901. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18902. /**
  18903. * @hidden
  18904. */
  18905. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18906. /**
  18907. * @hidden
  18908. */
  18909. _updateRigCameras(): void;
  18910. private _getRigCamPositionAndTarget;
  18911. /**
  18912. * Gets the current object class name.
  18913. * @return the class name
  18914. */
  18915. getClassName(): string;
  18916. }
  18917. }
  18918. declare module "babylonjs/Events/keyboardEvents" {
  18919. /**
  18920. * Gather the list of keyboard event types as constants.
  18921. */
  18922. export class KeyboardEventTypes {
  18923. /**
  18924. * The keydown event is fired when a key becomes active (pressed).
  18925. */
  18926. static readonly KEYDOWN: number;
  18927. /**
  18928. * The keyup event is fired when a key has been released.
  18929. */
  18930. static readonly KEYUP: number;
  18931. }
  18932. /**
  18933. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18934. */
  18935. export class KeyboardInfo {
  18936. /**
  18937. * Defines the type of event (KeyboardEventTypes)
  18938. */
  18939. type: number;
  18940. /**
  18941. * Defines the related dom event
  18942. */
  18943. event: KeyboardEvent;
  18944. /**
  18945. * Instantiates a new keyboard info.
  18946. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18947. * @param type Defines the type of event (KeyboardEventTypes)
  18948. * @param event Defines the related dom event
  18949. */
  18950. constructor(
  18951. /**
  18952. * Defines the type of event (KeyboardEventTypes)
  18953. */
  18954. type: number,
  18955. /**
  18956. * Defines the related dom event
  18957. */
  18958. event: KeyboardEvent);
  18959. }
  18960. /**
  18961. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18962. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18963. */
  18964. export class KeyboardInfoPre extends KeyboardInfo {
  18965. /**
  18966. * Defines the type of event (KeyboardEventTypes)
  18967. */
  18968. type: number;
  18969. /**
  18970. * Defines the related dom event
  18971. */
  18972. event: KeyboardEvent;
  18973. /**
  18974. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18975. */
  18976. skipOnPointerObservable: boolean;
  18977. /**
  18978. * Instantiates a new keyboard pre info.
  18979. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18980. * @param type Defines the type of event (KeyboardEventTypes)
  18981. * @param event Defines the related dom event
  18982. */
  18983. constructor(
  18984. /**
  18985. * Defines the type of event (KeyboardEventTypes)
  18986. */
  18987. type: number,
  18988. /**
  18989. * Defines the related dom event
  18990. */
  18991. event: KeyboardEvent);
  18992. }
  18993. }
  18994. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18995. import { Nullable } from "babylonjs/types";
  18996. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18997. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18998. /**
  18999. * Manage the keyboard inputs to control the movement of a free camera.
  19000. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19001. */
  19002. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19003. /**
  19004. * Defines the camera the input is attached to.
  19005. */
  19006. camera: FreeCamera;
  19007. /**
  19008. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19009. */
  19010. keysUp: number[];
  19011. /**
  19012. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19013. */
  19014. keysUpward: number[];
  19015. /**
  19016. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19017. */
  19018. keysDown: number[];
  19019. /**
  19020. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19021. */
  19022. keysDownward: number[];
  19023. /**
  19024. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19025. */
  19026. keysLeft: number[];
  19027. /**
  19028. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19029. */
  19030. keysRight: number[];
  19031. private _keys;
  19032. private _onCanvasBlurObserver;
  19033. private _onKeyboardObserver;
  19034. private _engine;
  19035. private _scene;
  19036. /**
  19037. * Attach the input controls to a specific dom element to get the input from.
  19038. * @param element Defines the element the controls should be listened from
  19039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19040. */
  19041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19042. /**
  19043. * Detach the current controls from the specified dom element.
  19044. * @param element Defines the element to stop listening the inputs from
  19045. */
  19046. detachControl(element: Nullable<HTMLElement>): void;
  19047. /**
  19048. * Update the current camera state depending on the inputs that have been used this frame.
  19049. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19050. */
  19051. checkInputs(): void;
  19052. /**
  19053. * Gets the class name of the current intput.
  19054. * @returns the class name
  19055. */
  19056. getClassName(): string;
  19057. /** @hidden */
  19058. _onLostFocus(): void;
  19059. /**
  19060. * Get the friendly name associated with the input class.
  19061. * @returns the input friendly name
  19062. */
  19063. getSimpleName(): string;
  19064. }
  19065. }
  19066. declare module "babylonjs/Events/pointerEvents" {
  19067. import { Nullable } from "babylonjs/types";
  19068. import { Vector2 } from "babylonjs/Maths/math.vector";
  19069. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19070. import { Ray } from "babylonjs/Culling/ray";
  19071. /**
  19072. * Gather the list of pointer event types as constants.
  19073. */
  19074. export class PointerEventTypes {
  19075. /**
  19076. * 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.
  19077. */
  19078. static readonly POINTERDOWN: number;
  19079. /**
  19080. * The pointerup event is fired when a pointer is no longer active.
  19081. */
  19082. static readonly POINTERUP: number;
  19083. /**
  19084. * The pointermove event is fired when a pointer changes coordinates.
  19085. */
  19086. static readonly POINTERMOVE: number;
  19087. /**
  19088. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19089. */
  19090. static readonly POINTERWHEEL: number;
  19091. /**
  19092. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19093. */
  19094. static readonly POINTERPICK: number;
  19095. /**
  19096. * The pointertap event is fired when a the object has been touched and released without drag.
  19097. */
  19098. static readonly POINTERTAP: number;
  19099. /**
  19100. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19101. */
  19102. static readonly POINTERDOUBLETAP: number;
  19103. }
  19104. /**
  19105. * Base class of pointer info types.
  19106. */
  19107. export class PointerInfoBase {
  19108. /**
  19109. * Defines the type of event (PointerEventTypes)
  19110. */
  19111. type: number;
  19112. /**
  19113. * Defines the related dom event
  19114. */
  19115. event: PointerEvent | MouseWheelEvent;
  19116. /**
  19117. * Instantiates the base class of pointers info.
  19118. * @param type Defines the type of event (PointerEventTypes)
  19119. * @param event Defines the related dom event
  19120. */
  19121. constructor(
  19122. /**
  19123. * Defines the type of event (PointerEventTypes)
  19124. */
  19125. type: number,
  19126. /**
  19127. * Defines the related dom event
  19128. */
  19129. event: PointerEvent | MouseWheelEvent);
  19130. }
  19131. /**
  19132. * This class is used to store pointer related info for the onPrePointerObservable event.
  19133. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19134. */
  19135. export class PointerInfoPre extends PointerInfoBase {
  19136. /**
  19137. * Ray from a pointer if availible (eg. 6dof controller)
  19138. */
  19139. ray: Nullable<Ray>;
  19140. /**
  19141. * Defines the local position of the pointer on the canvas.
  19142. */
  19143. localPosition: Vector2;
  19144. /**
  19145. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19146. */
  19147. skipOnPointerObservable: boolean;
  19148. /**
  19149. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19150. * @param type Defines the type of event (PointerEventTypes)
  19151. * @param event Defines the related dom event
  19152. * @param localX Defines the local x coordinates of the pointer when the event occured
  19153. * @param localY Defines the local y coordinates of the pointer when the event occured
  19154. */
  19155. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19156. }
  19157. /**
  19158. * This type contains all the data related to a pointer event in Babylon.js.
  19159. * 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.
  19160. */
  19161. export class PointerInfo extends PointerInfoBase {
  19162. /**
  19163. * Defines the picking info associated to the info (if any)\
  19164. */
  19165. pickInfo: Nullable<PickingInfo>;
  19166. /**
  19167. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19168. * @param type Defines the type of event (PointerEventTypes)
  19169. * @param event Defines the related dom event
  19170. * @param pickInfo Defines the picking info associated to the info (if any)\
  19171. */
  19172. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19173. /**
  19174. * Defines the picking info associated to the info (if any)\
  19175. */
  19176. pickInfo: Nullable<PickingInfo>);
  19177. }
  19178. /**
  19179. * Data relating to a touch event on the screen.
  19180. */
  19181. export interface PointerTouch {
  19182. /**
  19183. * X coordinate of touch.
  19184. */
  19185. x: number;
  19186. /**
  19187. * Y coordinate of touch.
  19188. */
  19189. y: number;
  19190. /**
  19191. * Id of touch. Unique for each finger.
  19192. */
  19193. pointerId: number;
  19194. /**
  19195. * Event type passed from DOM.
  19196. */
  19197. type: any;
  19198. }
  19199. }
  19200. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19201. import { Observable } from "babylonjs/Misc/observable";
  19202. import { Nullable } from "babylonjs/types";
  19203. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19205. /**
  19206. * Manage the mouse inputs to control the movement of a free camera.
  19207. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19208. */
  19209. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19210. /**
  19211. * Define if touch is enabled in the mouse input
  19212. */
  19213. touchEnabled: boolean;
  19214. /**
  19215. * Defines the camera the input is attached to.
  19216. */
  19217. camera: FreeCamera;
  19218. /**
  19219. * Defines the buttons associated with the input to handle camera move.
  19220. */
  19221. buttons: number[];
  19222. /**
  19223. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19224. */
  19225. angularSensibility: number;
  19226. private _pointerInput;
  19227. private _onMouseMove;
  19228. private _observer;
  19229. private previousPosition;
  19230. /**
  19231. * Observable for when a pointer move event occurs containing the move offset
  19232. */
  19233. onPointerMovedObservable: Observable<{
  19234. offsetX: number;
  19235. offsetY: number;
  19236. }>;
  19237. /**
  19238. * @hidden
  19239. * If the camera should be rotated automatically based on pointer movement
  19240. */
  19241. _allowCameraRotation: boolean;
  19242. /**
  19243. * Manage the mouse inputs to control the movement of a free camera.
  19244. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19245. * @param touchEnabled Defines if touch is enabled or not
  19246. */
  19247. constructor(
  19248. /**
  19249. * Define if touch is enabled in the mouse input
  19250. */
  19251. touchEnabled?: boolean);
  19252. /**
  19253. * Attach the input controls to a specific dom element to get the input from.
  19254. * @param element Defines the element the controls should be listened from
  19255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19256. */
  19257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19258. /**
  19259. * Called on JS contextmenu event.
  19260. * Override this method to provide functionality.
  19261. */
  19262. protected onContextMenu(evt: PointerEvent): void;
  19263. /**
  19264. * Detach the current controls from the specified dom element.
  19265. * @param element Defines the element to stop listening the inputs from
  19266. */
  19267. detachControl(element: Nullable<HTMLElement>): void;
  19268. /**
  19269. * Gets the class name of the current intput.
  19270. * @returns the class name
  19271. */
  19272. getClassName(): string;
  19273. /**
  19274. * Get the friendly name associated with the input class.
  19275. * @returns the input friendly name
  19276. */
  19277. getSimpleName(): string;
  19278. }
  19279. }
  19280. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19281. import { Nullable } from "babylonjs/types";
  19282. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19283. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19284. /**
  19285. * Manage the touch inputs to control the movement of a free camera.
  19286. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19287. */
  19288. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19289. /**
  19290. * Defines the camera the input is attached to.
  19291. */
  19292. camera: FreeCamera;
  19293. /**
  19294. * Defines the touch sensibility for rotation.
  19295. * The higher the faster.
  19296. */
  19297. touchAngularSensibility: number;
  19298. /**
  19299. * Defines the touch sensibility for move.
  19300. * The higher the faster.
  19301. */
  19302. touchMoveSensibility: number;
  19303. private _offsetX;
  19304. private _offsetY;
  19305. private _pointerPressed;
  19306. private _pointerInput;
  19307. private _observer;
  19308. private _onLostFocus;
  19309. /**
  19310. * Attach the input controls to a specific dom element to get the input from.
  19311. * @param element Defines the element the controls should be listened from
  19312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19313. */
  19314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19315. /**
  19316. * Detach the current controls from the specified dom element.
  19317. * @param element Defines the element to stop listening the inputs from
  19318. */
  19319. detachControl(element: Nullable<HTMLElement>): void;
  19320. /**
  19321. * Update the current camera state depending on the inputs that have been used this frame.
  19322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19323. */
  19324. checkInputs(): void;
  19325. /**
  19326. * Gets the class name of the current intput.
  19327. * @returns the class name
  19328. */
  19329. getClassName(): string;
  19330. /**
  19331. * Get the friendly name associated with the input class.
  19332. * @returns the input friendly name
  19333. */
  19334. getSimpleName(): string;
  19335. }
  19336. }
  19337. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19338. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19339. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19340. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19341. import { Nullable } from "babylonjs/types";
  19342. /**
  19343. * Default Inputs manager for the FreeCamera.
  19344. * It groups all the default supported inputs for ease of use.
  19345. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19346. */
  19347. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19348. /**
  19349. * @hidden
  19350. */
  19351. _mouseInput: Nullable<FreeCameraMouseInput>;
  19352. /**
  19353. * Instantiates a new FreeCameraInputsManager.
  19354. * @param camera Defines the camera the inputs belong to
  19355. */
  19356. constructor(camera: FreeCamera);
  19357. /**
  19358. * Add keyboard input support to the input manager.
  19359. * @returns the current input manager
  19360. */
  19361. addKeyboard(): FreeCameraInputsManager;
  19362. /**
  19363. * Add mouse input support to the input manager.
  19364. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19365. * @returns the current input manager
  19366. */
  19367. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19368. /**
  19369. * Removes the mouse input support from the manager
  19370. * @returns the current input manager
  19371. */
  19372. removeMouse(): FreeCameraInputsManager;
  19373. /**
  19374. * Add touch input support to the input manager.
  19375. * @returns the current input manager
  19376. */
  19377. addTouch(): FreeCameraInputsManager;
  19378. /**
  19379. * Remove all attached input methods from a camera
  19380. */
  19381. clear(): void;
  19382. }
  19383. }
  19384. declare module "babylonjs/Cameras/freeCamera" {
  19385. import { Vector3 } from "babylonjs/Maths/math.vector";
  19386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19387. import { Scene } from "babylonjs/scene";
  19388. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19389. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19390. /**
  19391. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19392. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19393. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19394. */
  19395. export class FreeCamera extends TargetCamera {
  19396. /**
  19397. * Define the collision ellipsoid of the camera.
  19398. * This is helpful to simulate a camera body like the player body around the camera
  19399. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19400. */
  19401. ellipsoid: Vector3;
  19402. /**
  19403. * Define an offset for the position of the ellipsoid around the camera.
  19404. * This can be helpful to determine the center of the body near the gravity center of the body
  19405. * instead of its head.
  19406. */
  19407. ellipsoidOffset: Vector3;
  19408. /**
  19409. * Enable or disable collisions of the camera with the rest of the scene objects.
  19410. */
  19411. checkCollisions: boolean;
  19412. /**
  19413. * Enable or disable gravity on the camera.
  19414. */
  19415. applyGravity: boolean;
  19416. /**
  19417. * Define the input manager associated to the camera.
  19418. */
  19419. inputs: FreeCameraInputsManager;
  19420. /**
  19421. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19422. * Higher values reduce sensitivity.
  19423. */
  19424. get angularSensibility(): number;
  19425. /**
  19426. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19427. * Higher values reduce sensitivity.
  19428. */
  19429. set angularSensibility(value: number);
  19430. /**
  19431. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19432. */
  19433. get keysUp(): number[];
  19434. set keysUp(value: number[]);
  19435. /**
  19436. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19437. */
  19438. get keysUpward(): number[];
  19439. set keysUpward(value: number[]);
  19440. /**
  19441. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19442. */
  19443. get keysDown(): number[];
  19444. set keysDown(value: number[]);
  19445. /**
  19446. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19447. */
  19448. get keysDownward(): number[];
  19449. set keysDownward(value: number[]);
  19450. /**
  19451. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19452. */
  19453. get keysLeft(): number[];
  19454. set keysLeft(value: number[]);
  19455. /**
  19456. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19457. */
  19458. get keysRight(): number[];
  19459. set keysRight(value: number[]);
  19460. /**
  19461. * Event raised when the camera collide with a mesh in the scene.
  19462. */
  19463. onCollide: (collidedMesh: AbstractMesh) => void;
  19464. private _collider;
  19465. private _needMoveForGravity;
  19466. private _oldPosition;
  19467. private _diffPosition;
  19468. private _newPosition;
  19469. /** @hidden */
  19470. _localDirection: Vector3;
  19471. /** @hidden */
  19472. _transformedDirection: Vector3;
  19473. /**
  19474. * Instantiates a Free Camera.
  19475. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19476. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19477. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19478. * @param name Define the name of the camera in the scene
  19479. * @param position Define the start position of the camera in the scene
  19480. * @param scene Define the scene the camera belongs to
  19481. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19482. */
  19483. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19484. /**
  19485. * Attached controls to the current camera.
  19486. * @param element Defines the element the controls should be listened from
  19487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19488. */
  19489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19490. /**
  19491. * Detach the current controls from the camera.
  19492. * The camera will stop reacting to inputs.
  19493. * @param element Defines the element to stop listening the inputs from
  19494. */
  19495. detachControl(element: HTMLElement): void;
  19496. private _collisionMask;
  19497. /**
  19498. * Define a collision mask to limit the list of object the camera can collide with
  19499. */
  19500. get collisionMask(): number;
  19501. set collisionMask(mask: number);
  19502. /** @hidden */
  19503. _collideWithWorld(displacement: Vector3): void;
  19504. private _onCollisionPositionChange;
  19505. /** @hidden */
  19506. _checkInputs(): void;
  19507. /** @hidden */
  19508. _decideIfNeedsToMove(): boolean;
  19509. /** @hidden */
  19510. _updatePosition(): void;
  19511. /**
  19512. * Destroy the camera and release the current resources hold by it.
  19513. */
  19514. dispose(): void;
  19515. /**
  19516. * Gets the current object class name.
  19517. * @return the class name
  19518. */
  19519. getClassName(): string;
  19520. }
  19521. }
  19522. declare module "babylonjs/Gamepads/gamepad" {
  19523. import { Observable } from "babylonjs/Misc/observable";
  19524. /**
  19525. * Represents a gamepad control stick position
  19526. */
  19527. export class StickValues {
  19528. /**
  19529. * The x component of the control stick
  19530. */
  19531. x: number;
  19532. /**
  19533. * The y component of the control stick
  19534. */
  19535. y: number;
  19536. /**
  19537. * Initializes the gamepad x and y control stick values
  19538. * @param x The x component of the gamepad control stick value
  19539. * @param y The y component of the gamepad control stick value
  19540. */
  19541. constructor(
  19542. /**
  19543. * The x component of the control stick
  19544. */
  19545. x: number,
  19546. /**
  19547. * The y component of the control stick
  19548. */
  19549. y: number);
  19550. }
  19551. /**
  19552. * An interface which manages callbacks for gamepad button changes
  19553. */
  19554. export interface GamepadButtonChanges {
  19555. /**
  19556. * Called when a gamepad has been changed
  19557. */
  19558. changed: boolean;
  19559. /**
  19560. * Called when a gamepad press event has been triggered
  19561. */
  19562. pressChanged: boolean;
  19563. /**
  19564. * Called when a touch event has been triggered
  19565. */
  19566. touchChanged: boolean;
  19567. /**
  19568. * Called when a value has changed
  19569. */
  19570. valueChanged: boolean;
  19571. }
  19572. /**
  19573. * Represents a gamepad
  19574. */
  19575. export class Gamepad {
  19576. /**
  19577. * The id of the gamepad
  19578. */
  19579. id: string;
  19580. /**
  19581. * The index of the gamepad
  19582. */
  19583. index: number;
  19584. /**
  19585. * The browser gamepad
  19586. */
  19587. browserGamepad: any;
  19588. /**
  19589. * Specifies what type of gamepad this represents
  19590. */
  19591. type: number;
  19592. private _leftStick;
  19593. private _rightStick;
  19594. /** @hidden */
  19595. _isConnected: boolean;
  19596. private _leftStickAxisX;
  19597. private _leftStickAxisY;
  19598. private _rightStickAxisX;
  19599. private _rightStickAxisY;
  19600. /**
  19601. * Triggered when the left control stick has been changed
  19602. */
  19603. private _onleftstickchanged;
  19604. /**
  19605. * Triggered when the right control stick has been changed
  19606. */
  19607. private _onrightstickchanged;
  19608. /**
  19609. * Represents a gamepad controller
  19610. */
  19611. static GAMEPAD: number;
  19612. /**
  19613. * Represents a generic controller
  19614. */
  19615. static GENERIC: number;
  19616. /**
  19617. * Represents an XBox controller
  19618. */
  19619. static XBOX: number;
  19620. /**
  19621. * Represents a pose-enabled controller
  19622. */
  19623. static POSE_ENABLED: number;
  19624. /**
  19625. * Represents an Dual Shock controller
  19626. */
  19627. static DUALSHOCK: number;
  19628. /**
  19629. * Specifies whether the left control stick should be Y-inverted
  19630. */
  19631. protected _invertLeftStickY: boolean;
  19632. /**
  19633. * Specifies if the gamepad has been connected
  19634. */
  19635. get isConnected(): boolean;
  19636. /**
  19637. * Initializes the gamepad
  19638. * @param id The id of the gamepad
  19639. * @param index The index of the gamepad
  19640. * @param browserGamepad The browser gamepad
  19641. * @param leftStickX The x component of the left joystick
  19642. * @param leftStickY The y component of the left joystick
  19643. * @param rightStickX The x component of the right joystick
  19644. * @param rightStickY The y component of the right joystick
  19645. */
  19646. constructor(
  19647. /**
  19648. * The id of the gamepad
  19649. */
  19650. id: string,
  19651. /**
  19652. * The index of the gamepad
  19653. */
  19654. index: number,
  19655. /**
  19656. * The browser gamepad
  19657. */
  19658. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19659. /**
  19660. * Callback triggered when the left joystick has changed
  19661. * @param callback
  19662. */
  19663. onleftstickchanged(callback: (values: StickValues) => void): void;
  19664. /**
  19665. * Callback triggered when the right joystick has changed
  19666. * @param callback
  19667. */
  19668. onrightstickchanged(callback: (values: StickValues) => void): void;
  19669. /**
  19670. * Gets the left joystick
  19671. */
  19672. get leftStick(): StickValues;
  19673. /**
  19674. * Sets the left joystick values
  19675. */
  19676. set leftStick(newValues: StickValues);
  19677. /**
  19678. * Gets the right joystick
  19679. */
  19680. get rightStick(): StickValues;
  19681. /**
  19682. * Sets the right joystick value
  19683. */
  19684. set rightStick(newValues: StickValues);
  19685. /**
  19686. * Updates the gamepad joystick positions
  19687. */
  19688. update(): void;
  19689. /**
  19690. * Disposes the gamepad
  19691. */
  19692. dispose(): void;
  19693. }
  19694. /**
  19695. * Represents a generic gamepad
  19696. */
  19697. export class GenericPad extends Gamepad {
  19698. private _buttons;
  19699. private _onbuttondown;
  19700. private _onbuttonup;
  19701. /**
  19702. * Observable triggered when a button has been pressed
  19703. */
  19704. onButtonDownObservable: Observable<number>;
  19705. /**
  19706. * Observable triggered when a button has been released
  19707. */
  19708. onButtonUpObservable: Observable<number>;
  19709. /**
  19710. * Callback triggered when a button has been pressed
  19711. * @param callback Called when a button has been pressed
  19712. */
  19713. onbuttondown(callback: (buttonPressed: number) => void): void;
  19714. /**
  19715. * Callback triggered when a button has been released
  19716. * @param callback Called when a button has been released
  19717. */
  19718. onbuttonup(callback: (buttonReleased: number) => void): void;
  19719. /**
  19720. * Initializes the generic gamepad
  19721. * @param id The id of the generic gamepad
  19722. * @param index The index of the generic gamepad
  19723. * @param browserGamepad The browser gamepad
  19724. */
  19725. constructor(id: string, index: number, browserGamepad: any);
  19726. private _setButtonValue;
  19727. /**
  19728. * Updates the generic gamepad
  19729. */
  19730. update(): void;
  19731. /**
  19732. * Disposes the generic gamepad
  19733. */
  19734. dispose(): void;
  19735. }
  19736. }
  19737. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19738. import { Observable } from "babylonjs/Misc/observable";
  19739. import { Nullable } from "babylonjs/types";
  19740. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19741. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19743. import { Ray } from "babylonjs/Culling/ray";
  19744. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19745. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19746. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19747. /**
  19748. * Defines the types of pose enabled controllers that are supported
  19749. */
  19750. export enum PoseEnabledControllerType {
  19751. /**
  19752. * HTC Vive
  19753. */
  19754. VIVE = 0,
  19755. /**
  19756. * Oculus Rift
  19757. */
  19758. OCULUS = 1,
  19759. /**
  19760. * Windows mixed reality
  19761. */
  19762. WINDOWS = 2,
  19763. /**
  19764. * Samsung gear VR
  19765. */
  19766. GEAR_VR = 3,
  19767. /**
  19768. * Google Daydream
  19769. */
  19770. DAYDREAM = 4,
  19771. /**
  19772. * Generic
  19773. */
  19774. GENERIC = 5
  19775. }
  19776. /**
  19777. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19778. */
  19779. export interface MutableGamepadButton {
  19780. /**
  19781. * Value of the button/trigger
  19782. */
  19783. value: number;
  19784. /**
  19785. * If the button/trigger is currently touched
  19786. */
  19787. touched: boolean;
  19788. /**
  19789. * If the button/trigger is currently pressed
  19790. */
  19791. pressed: boolean;
  19792. }
  19793. /**
  19794. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19795. * @hidden
  19796. */
  19797. export interface ExtendedGamepadButton extends GamepadButton {
  19798. /**
  19799. * If the button/trigger is currently pressed
  19800. */
  19801. readonly pressed: boolean;
  19802. /**
  19803. * If the button/trigger is currently touched
  19804. */
  19805. readonly touched: boolean;
  19806. /**
  19807. * Value of the button/trigger
  19808. */
  19809. readonly value: number;
  19810. }
  19811. /** @hidden */
  19812. export interface _GamePadFactory {
  19813. /**
  19814. * Returns whether or not the current gamepad can be created for this type of controller.
  19815. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19816. * @returns true if it can be created, otherwise false
  19817. */
  19818. canCreate(gamepadInfo: any): boolean;
  19819. /**
  19820. * Creates a new instance of the Gamepad.
  19821. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19822. * @returns the new gamepad instance
  19823. */
  19824. create(gamepadInfo: any): Gamepad;
  19825. }
  19826. /**
  19827. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19828. */
  19829. export class PoseEnabledControllerHelper {
  19830. /** @hidden */
  19831. static _ControllerFactories: _GamePadFactory[];
  19832. /** @hidden */
  19833. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19834. /**
  19835. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19836. * @param vrGamepad the gamepad to initialized
  19837. * @returns a vr controller of the type the gamepad identified as
  19838. */
  19839. static InitiateController(vrGamepad: any): Gamepad;
  19840. }
  19841. /**
  19842. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19843. */
  19844. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19845. /**
  19846. * If the controller is used in a webXR session
  19847. */
  19848. isXR: boolean;
  19849. private _deviceRoomPosition;
  19850. private _deviceRoomRotationQuaternion;
  19851. /**
  19852. * The device position in babylon space
  19853. */
  19854. devicePosition: Vector3;
  19855. /**
  19856. * The device rotation in babylon space
  19857. */
  19858. deviceRotationQuaternion: Quaternion;
  19859. /**
  19860. * The scale factor of the device in babylon space
  19861. */
  19862. deviceScaleFactor: number;
  19863. /**
  19864. * (Likely devicePosition should be used instead) The device position in its room space
  19865. */
  19866. position: Vector3;
  19867. /**
  19868. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19869. */
  19870. rotationQuaternion: Quaternion;
  19871. /**
  19872. * The type of controller (Eg. Windows mixed reality)
  19873. */
  19874. controllerType: PoseEnabledControllerType;
  19875. protected _calculatedPosition: Vector3;
  19876. private _calculatedRotation;
  19877. /**
  19878. * The raw pose from the device
  19879. */
  19880. rawPose: DevicePose;
  19881. private _trackPosition;
  19882. private _maxRotationDistFromHeadset;
  19883. private _draggedRoomRotation;
  19884. /**
  19885. * @hidden
  19886. */
  19887. _disableTrackPosition(fixedPosition: Vector3): void;
  19888. /**
  19889. * Internal, the mesh attached to the controller
  19890. * @hidden
  19891. */
  19892. _mesh: Nullable<AbstractMesh>;
  19893. private _poseControlledCamera;
  19894. private _leftHandSystemQuaternion;
  19895. /**
  19896. * Internal, matrix used to convert room space to babylon space
  19897. * @hidden
  19898. */
  19899. _deviceToWorld: Matrix;
  19900. /**
  19901. * Node to be used when casting a ray from the controller
  19902. * @hidden
  19903. */
  19904. _pointingPoseNode: Nullable<TransformNode>;
  19905. /**
  19906. * Name of the child mesh that can be used to cast a ray from the controller
  19907. */
  19908. static readonly POINTING_POSE: string;
  19909. /**
  19910. * Creates a new PoseEnabledController from a gamepad
  19911. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19912. */
  19913. constructor(browserGamepad: any);
  19914. private _workingMatrix;
  19915. /**
  19916. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19917. */
  19918. update(): void;
  19919. /**
  19920. * Updates only the pose device and mesh without doing any button event checking
  19921. */
  19922. protected _updatePoseAndMesh(): void;
  19923. /**
  19924. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19925. * @param poseData raw pose fromthe device
  19926. */
  19927. updateFromDevice(poseData: DevicePose): void;
  19928. /**
  19929. * @hidden
  19930. */
  19931. _meshAttachedObservable: Observable<AbstractMesh>;
  19932. /**
  19933. * Attaches a mesh to the controller
  19934. * @param mesh the mesh to be attached
  19935. */
  19936. attachToMesh(mesh: AbstractMesh): void;
  19937. /**
  19938. * Attaches the controllers mesh to a camera
  19939. * @param camera the camera the mesh should be attached to
  19940. */
  19941. attachToPoseControlledCamera(camera: TargetCamera): void;
  19942. /**
  19943. * Disposes of the controller
  19944. */
  19945. dispose(): void;
  19946. /**
  19947. * The mesh that is attached to the controller
  19948. */
  19949. get mesh(): Nullable<AbstractMesh>;
  19950. /**
  19951. * Gets the ray of the controller in the direction the controller is pointing
  19952. * @param length the length the resulting ray should be
  19953. * @returns a ray in the direction the controller is pointing
  19954. */
  19955. getForwardRay(length?: number): Ray;
  19956. }
  19957. }
  19958. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19959. import { Observable } from "babylonjs/Misc/observable";
  19960. import { Scene } from "babylonjs/scene";
  19961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19962. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19963. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19964. import { Nullable } from "babylonjs/types";
  19965. /**
  19966. * Defines the WebVRController object that represents controllers tracked in 3D space
  19967. */
  19968. export abstract class WebVRController extends PoseEnabledController {
  19969. /**
  19970. * Internal, the default controller model for the controller
  19971. */
  19972. protected _defaultModel: Nullable<AbstractMesh>;
  19973. /**
  19974. * Fired when the trigger state has changed
  19975. */
  19976. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19977. /**
  19978. * Fired when the main button state has changed
  19979. */
  19980. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19981. /**
  19982. * Fired when the secondary button state has changed
  19983. */
  19984. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19985. /**
  19986. * Fired when the pad state has changed
  19987. */
  19988. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19989. /**
  19990. * Fired when controllers stick values have changed
  19991. */
  19992. onPadValuesChangedObservable: Observable<StickValues>;
  19993. /**
  19994. * Array of button availible on the controller
  19995. */
  19996. protected _buttons: Array<MutableGamepadButton>;
  19997. private _onButtonStateChange;
  19998. /**
  19999. * Fired when a controller button's state has changed
  20000. * @param callback the callback containing the button that was modified
  20001. */
  20002. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20003. /**
  20004. * X and Y axis corresponding to the controllers joystick
  20005. */
  20006. pad: StickValues;
  20007. /**
  20008. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20009. */
  20010. hand: string;
  20011. /**
  20012. * The default controller model for the controller
  20013. */
  20014. get defaultModel(): Nullable<AbstractMesh>;
  20015. /**
  20016. * Creates a new WebVRController from a gamepad
  20017. * @param vrGamepad the gamepad that the WebVRController should be created from
  20018. */
  20019. constructor(vrGamepad: any);
  20020. /**
  20021. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20022. */
  20023. update(): void;
  20024. /**
  20025. * Function to be called when a button is modified
  20026. */
  20027. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20028. /**
  20029. * Loads a mesh and attaches it to the controller
  20030. * @param scene the scene the mesh should be added to
  20031. * @param meshLoaded callback for when the mesh has been loaded
  20032. */
  20033. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20034. private _setButtonValue;
  20035. private _changes;
  20036. private _checkChanges;
  20037. /**
  20038. * Disposes of th webVRCOntroller
  20039. */
  20040. dispose(): void;
  20041. }
  20042. }
  20043. declare module "babylonjs/Lights/hemisphericLight" {
  20044. import { Nullable } from "babylonjs/types";
  20045. import { Scene } from "babylonjs/scene";
  20046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20047. import { Color3 } from "babylonjs/Maths/math.color";
  20048. import { Effect } from "babylonjs/Materials/effect";
  20049. import { Light } from "babylonjs/Lights/light";
  20050. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20051. /**
  20052. * The HemisphericLight simulates the ambient environment light,
  20053. * so the passed direction is the light reflection direction, not the incoming direction.
  20054. */
  20055. export class HemisphericLight extends Light {
  20056. /**
  20057. * The groundColor is the light in the opposite direction to the one specified during creation.
  20058. * 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.
  20059. */
  20060. groundColor: Color3;
  20061. /**
  20062. * The light reflection direction, not the incoming direction.
  20063. */
  20064. direction: Vector3;
  20065. /**
  20066. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20067. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20068. * The HemisphericLight can't cast shadows.
  20069. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20070. * @param name The friendly name of the light
  20071. * @param direction The direction of the light reflection
  20072. * @param scene The scene the light belongs to
  20073. */
  20074. constructor(name: string, direction: Vector3, scene: Scene);
  20075. protected _buildUniformLayout(): void;
  20076. /**
  20077. * Returns the string "HemisphericLight".
  20078. * @return The class name
  20079. */
  20080. getClassName(): string;
  20081. /**
  20082. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20083. * Returns the updated direction.
  20084. * @param target The target the direction should point to
  20085. * @return The computed direction
  20086. */
  20087. setDirectionToTarget(target: Vector3): Vector3;
  20088. /**
  20089. * Returns the shadow generator associated to the light.
  20090. * @returns Always null for hemispheric lights because it does not support shadows.
  20091. */
  20092. getShadowGenerator(): Nullable<IShadowGenerator>;
  20093. /**
  20094. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20095. * @param effect The effect to update
  20096. * @param lightIndex The index of the light in the effect to update
  20097. * @returns The hemispheric light
  20098. */
  20099. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20100. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20101. /**
  20102. * Computes the world matrix of the node
  20103. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20104. * @param useWasUpdatedFlag defines a reserved property
  20105. * @returns the world matrix
  20106. */
  20107. computeWorldMatrix(): Matrix;
  20108. /**
  20109. * Returns the integer 3.
  20110. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20111. */
  20112. getTypeID(): number;
  20113. /**
  20114. * Prepares the list of defines specific to the light type.
  20115. * @param defines the list of defines
  20116. * @param lightIndex defines the index of the light for the effect
  20117. */
  20118. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20119. }
  20120. }
  20121. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20122. /** @hidden */
  20123. export var vrMultiviewToSingleviewPixelShader: {
  20124. name: string;
  20125. shader: string;
  20126. };
  20127. }
  20128. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20129. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20130. import { Scene } from "babylonjs/scene";
  20131. /**
  20132. * Renders to multiple views with a single draw call
  20133. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20134. */
  20135. export class MultiviewRenderTarget extends RenderTargetTexture {
  20136. /**
  20137. * Creates a multiview render target
  20138. * @param scene scene used with the render target
  20139. * @param size the size of the render target (used for each view)
  20140. */
  20141. constructor(scene: Scene, size?: number | {
  20142. width: number;
  20143. height: number;
  20144. } | {
  20145. ratio: number;
  20146. });
  20147. /**
  20148. * @hidden
  20149. * @param faceIndex the face index, if its a cube texture
  20150. */
  20151. _bindFrameBuffer(faceIndex?: number): void;
  20152. /**
  20153. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20154. * @returns the view count
  20155. */
  20156. getViewCount(): number;
  20157. }
  20158. }
  20159. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20160. import { Camera } from "babylonjs/Cameras/camera";
  20161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20162. import { Nullable } from "babylonjs/types";
  20163. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20164. import { Matrix } from "babylonjs/Maths/math.vector";
  20165. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20166. module "babylonjs/Engines/engine" {
  20167. interface Engine {
  20168. /**
  20169. * Creates a new multiview render target
  20170. * @param width defines the width of the texture
  20171. * @param height defines the height of the texture
  20172. * @returns the created multiview texture
  20173. */
  20174. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20175. /**
  20176. * Binds a multiview framebuffer to be drawn to
  20177. * @param multiviewTexture texture to bind
  20178. */
  20179. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20180. }
  20181. }
  20182. module "babylonjs/Cameras/camera" {
  20183. interface Camera {
  20184. /**
  20185. * @hidden
  20186. * 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)
  20187. */
  20188. _useMultiviewToSingleView: boolean;
  20189. /**
  20190. * @hidden
  20191. * 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)
  20192. */
  20193. _multiviewTexture: Nullable<RenderTargetTexture>;
  20194. /**
  20195. * @hidden
  20196. * ensures the multiview texture of the camera exists and has the specified width/height
  20197. * @param width height to set on the multiview texture
  20198. * @param height width to set on the multiview texture
  20199. */
  20200. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20201. }
  20202. }
  20203. module "babylonjs/scene" {
  20204. interface Scene {
  20205. /** @hidden */
  20206. _transformMatrixR: Matrix;
  20207. /** @hidden */
  20208. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20209. /** @hidden */
  20210. _createMultiviewUbo(): void;
  20211. /** @hidden */
  20212. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20213. /** @hidden */
  20214. _renderMultiviewToSingleView(camera: Camera): void;
  20215. }
  20216. }
  20217. }
  20218. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20219. import { Camera } from "babylonjs/Cameras/camera";
  20220. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20221. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20222. import "babylonjs/Engines/Extensions/engine.multiview";
  20223. /**
  20224. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20225. * This will not be used for webXR as it supports displaying texture arrays directly
  20226. */
  20227. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20228. /**
  20229. * Initializes a VRMultiviewToSingleview
  20230. * @param name name of the post process
  20231. * @param camera camera to be applied to
  20232. * @param scaleFactor scaling factor to the size of the output texture
  20233. */
  20234. constructor(name: string, camera: Camera, scaleFactor: number);
  20235. }
  20236. }
  20237. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20238. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20239. import { Nullable } from "babylonjs/types";
  20240. import { Size } from "babylonjs/Maths/math.size";
  20241. import { Observable } from "babylonjs/Misc/observable";
  20242. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20243. /**
  20244. * Interface used to define additional presentation attributes
  20245. */
  20246. export interface IVRPresentationAttributes {
  20247. /**
  20248. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20249. */
  20250. highRefreshRate: boolean;
  20251. /**
  20252. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20253. */
  20254. foveationLevel: number;
  20255. }
  20256. module "babylonjs/Engines/engine" {
  20257. interface Engine {
  20258. /** @hidden */
  20259. _vrDisplay: any;
  20260. /** @hidden */
  20261. _vrSupported: boolean;
  20262. /** @hidden */
  20263. _oldSize: Size;
  20264. /** @hidden */
  20265. _oldHardwareScaleFactor: number;
  20266. /** @hidden */
  20267. _vrExclusivePointerMode: boolean;
  20268. /** @hidden */
  20269. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20270. /** @hidden */
  20271. _onVRDisplayPointerRestricted: () => void;
  20272. /** @hidden */
  20273. _onVRDisplayPointerUnrestricted: () => void;
  20274. /** @hidden */
  20275. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20276. /** @hidden */
  20277. _onVrDisplayDisconnect: Nullable<() => void>;
  20278. /** @hidden */
  20279. _onVrDisplayPresentChange: Nullable<() => void>;
  20280. /**
  20281. * Observable signaled when VR display mode changes
  20282. */
  20283. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20284. /**
  20285. * Observable signaled when VR request present is complete
  20286. */
  20287. onVRRequestPresentComplete: Observable<boolean>;
  20288. /**
  20289. * Observable signaled when VR request present starts
  20290. */
  20291. onVRRequestPresentStart: Observable<Engine>;
  20292. /**
  20293. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20294. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20295. */
  20296. isInVRExclusivePointerMode: boolean;
  20297. /**
  20298. * Gets a boolean indicating if a webVR device was detected
  20299. * @returns true if a webVR device was detected
  20300. */
  20301. isVRDevicePresent(): boolean;
  20302. /**
  20303. * Gets the current webVR device
  20304. * @returns the current webVR device (or null)
  20305. */
  20306. getVRDevice(): any;
  20307. /**
  20308. * Initializes a webVR display and starts listening to display change events
  20309. * The onVRDisplayChangedObservable will be notified upon these changes
  20310. * @returns A promise containing a VRDisplay and if vr is supported
  20311. */
  20312. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20313. /** @hidden */
  20314. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20315. /**
  20316. * Gets or sets the presentation attributes used to configure VR rendering
  20317. */
  20318. vrPresentationAttributes?: IVRPresentationAttributes;
  20319. /**
  20320. * Call this function to switch to webVR mode
  20321. * Will do nothing if webVR is not supported or if there is no webVR device
  20322. * @param options the webvr options provided to the camera. mainly used for multiview
  20323. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20324. */
  20325. enableVR(options: WebVROptions): void;
  20326. /** @hidden */
  20327. _onVRFullScreenTriggered(): void;
  20328. }
  20329. }
  20330. }
  20331. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20332. import { Nullable } from "babylonjs/types";
  20333. import { Observable } from "babylonjs/Misc/observable";
  20334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20335. import { Scene } from "babylonjs/scene";
  20336. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20337. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20338. import { Node } from "babylonjs/node";
  20339. import { Ray } from "babylonjs/Culling/ray";
  20340. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20341. import "babylonjs/Engines/Extensions/engine.webVR";
  20342. /**
  20343. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20344. * IMPORTANT!! The data is right-hand data.
  20345. * @export
  20346. * @interface DevicePose
  20347. */
  20348. export interface DevicePose {
  20349. /**
  20350. * The position of the device, values in array are [x,y,z].
  20351. */
  20352. readonly position: Nullable<Float32Array>;
  20353. /**
  20354. * The linearVelocity of the device, values in array are [x,y,z].
  20355. */
  20356. readonly linearVelocity: Nullable<Float32Array>;
  20357. /**
  20358. * The linearAcceleration of the device, values in array are [x,y,z].
  20359. */
  20360. readonly linearAcceleration: Nullable<Float32Array>;
  20361. /**
  20362. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20363. */
  20364. readonly orientation: Nullable<Float32Array>;
  20365. /**
  20366. * The angularVelocity of the device, values in array are [x,y,z].
  20367. */
  20368. readonly angularVelocity: Nullable<Float32Array>;
  20369. /**
  20370. * The angularAcceleration of the device, values in array are [x,y,z].
  20371. */
  20372. readonly angularAcceleration: Nullable<Float32Array>;
  20373. }
  20374. /**
  20375. * Interface representing a pose controlled object in Babylon.
  20376. * A pose controlled object has both regular pose values as well as pose values
  20377. * from an external device such as a VR head mounted display
  20378. */
  20379. export interface PoseControlled {
  20380. /**
  20381. * The position of the object in babylon space.
  20382. */
  20383. position: Vector3;
  20384. /**
  20385. * The rotation quaternion of the object in babylon space.
  20386. */
  20387. rotationQuaternion: Quaternion;
  20388. /**
  20389. * The position of the device in babylon space.
  20390. */
  20391. devicePosition?: Vector3;
  20392. /**
  20393. * The rotation quaternion of the device in babylon space.
  20394. */
  20395. deviceRotationQuaternion: Quaternion;
  20396. /**
  20397. * The raw pose coming from the device.
  20398. */
  20399. rawPose: Nullable<DevicePose>;
  20400. /**
  20401. * The scale of the device to be used when translating from device space to babylon space.
  20402. */
  20403. deviceScaleFactor: number;
  20404. /**
  20405. * Updates the poseControlled values based on the input device pose.
  20406. * @param poseData the pose data to update the object with
  20407. */
  20408. updateFromDevice(poseData: DevicePose): void;
  20409. }
  20410. /**
  20411. * Set of options to customize the webVRCamera
  20412. */
  20413. export interface WebVROptions {
  20414. /**
  20415. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20416. */
  20417. trackPosition?: boolean;
  20418. /**
  20419. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20420. */
  20421. positionScale?: number;
  20422. /**
  20423. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20424. */
  20425. displayName?: string;
  20426. /**
  20427. * Should the native controller meshes be initialized. (default: true)
  20428. */
  20429. controllerMeshes?: boolean;
  20430. /**
  20431. * Creating a default HemiLight only on controllers. (default: true)
  20432. */
  20433. defaultLightingOnControllers?: boolean;
  20434. /**
  20435. * If you don't want to use the default VR button of the helper. (default: false)
  20436. */
  20437. useCustomVRButton?: boolean;
  20438. /**
  20439. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20440. */
  20441. customVRButton?: HTMLButtonElement;
  20442. /**
  20443. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20444. */
  20445. rayLength?: number;
  20446. /**
  20447. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20448. */
  20449. defaultHeight?: number;
  20450. /**
  20451. * If multiview should be used if availible (default: false)
  20452. */
  20453. useMultiview?: boolean;
  20454. }
  20455. /**
  20456. * This represents a WebVR camera.
  20457. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20458. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20459. */
  20460. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20461. private webVROptions;
  20462. /**
  20463. * @hidden
  20464. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20465. */
  20466. _vrDevice: any;
  20467. /**
  20468. * The rawPose of the vrDevice.
  20469. */
  20470. rawPose: Nullable<DevicePose>;
  20471. private _onVREnabled;
  20472. private _specsVersion;
  20473. private _attached;
  20474. private _frameData;
  20475. protected _descendants: Array<Node>;
  20476. private _deviceRoomPosition;
  20477. /** @hidden */
  20478. _deviceRoomRotationQuaternion: Quaternion;
  20479. private _standingMatrix;
  20480. /**
  20481. * Represents device position in babylon space.
  20482. */
  20483. devicePosition: Vector3;
  20484. /**
  20485. * Represents device rotation in babylon space.
  20486. */
  20487. deviceRotationQuaternion: Quaternion;
  20488. /**
  20489. * The scale of the device to be used when translating from device space to babylon space.
  20490. */
  20491. deviceScaleFactor: number;
  20492. private _deviceToWorld;
  20493. private _worldToDevice;
  20494. /**
  20495. * References to the webVR controllers for the vrDevice.
  20496. */
  20497. controllers: Array<WebVRController>;
  20498. /**
  20499. * Emits an event when a controller is attached.
  20500. */
  20501. onControllersAttachedObservable: Observable<WebVRController[]>;
  20502. /**
  20503. * Emits an event when a controller's mesh has been loaded;
  20504. */
  20505. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20506. /**
  20507. * Emits an event when the HMD's pose has been updated.
  20508. */
  20509. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20510. private _poseSet;
  20511. /**
  20512. * If the rig cameras be used as parent instead of this camera.
  20513. */
  20514. rigParenting: boolean;
  20515. private _lightOnControllers;
  20516. private _defaultHeight?;
  20517. /**
  20518. * Instantiates a WebVRFreeCamera.
  20519. * @param name The name of the WebVRFreeCamera
  20520. * @param position The starting anchor position for the camera
  20521. * @param scene The scene the camera belongs to
  20522. * @param webVROptions a set of customizable options for the webVRCamera
  20523. */
  20524. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20525. /**
  20526. * Gets the device distance from the ground in meters.
  20527. * @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.
  20528. */
  20529. deviceDistanceToRoomGround(): number;
  20530. /**
  20531. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20532. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20533. */
  20534. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20535. /**
  20536. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20537. * @returns A promise with a boolean set to if the standing matrix is supported.
  20538. */
  20539. useStandingMatrixAsync(): Promise<boolean>;
  20540. /**
  20541. * Disposes the camera
  20542. */
  20543. dispose(): void;
  20544. /**
  20545. * Gets a vrController by name.
  20546. * @param name The name of the controller to retreive
  20547. * @returns the controller matching the name specified or null if not found
  20548. */
  20549. getControllerByName(name: string): Nullable<WebVRController>;
  20550. private _leftController;
  20551. /**
  20552. * The controller corresponding to the users left hand.
  20553. */
  20554. get leftController(): Nullable<WebVRController>;
  20555. private _rightController;
  20556. /**
  20557. * The controller corresponding to the users right hand.
  20558. */
  20559. get rightController(): Nullable<WebVRController>;
  20560. /**
  20561. * Casts a ray forward from the vrCamera's gaze.
  20562. * @param length Length of the ray (default: 100)
  20563. * @returns the ray corresponding to the gaze
  20564. */
  20565. getForwardRay(length?: number): Ray;
  20566. /**
  20567. * @hidden
  20568. * Updates the camera based on device's frame data
  20569. */
  20570. _checkInputs(): void;
  20571. /**
  20572. * Updates the poseControlled values based on the input device pose.
  20573. * @param poseData Pose coming from the device
  20574. */
  20575. updateFromDevice(poseData: DevicePose): void;
  20576. private _htmlElementAttached;
  20577. private _detachIfAttached;
  20578. /**
  20579. * WebVR's attach control will start broadcasting frames to the device.
  20580. * Note that in certain browsers (chrome for example) this function must be called
  20581. * within a user-interaction callback. Example:
  20582. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20583. *
  20584. * @param element html element to attach the vrDevice to
  20585. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20586. */
  20587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20588. /**
  20589. * Detaches the camera from the html element and disables VR
  20590. *
  20591. * @param element html element to detach from
  20592. */
  20593. detachControl(element: HTMLElement): void;
  20594. /**
  20595. * @returns the name of this class
  20596. */
  20597. getClassName(): string;
  20598. /**
  20599. * Calls resetPose on the vrDisplay
  20600. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20601. */
  20602. resetToCurrentRotation(): void;
  20603. /**
  20604. * @hidden
  20605. * Updates the rig cameras (left and right eye)
  20606. */
  20607. _updateRigCameras(): void;
  20608. private _workingVector;
  20609. private _oneVector;
  20610. private _workingMatrix;
  20611. private updateCacheCalled;
  20612. private _correctPositionIfNotTrackPosition;
  20613. /**
  20614. * @hidden
  20615. * Updates the cached values of the camera
  20616. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20617. */
  20618. _updateCache(ignoreParentClass?: boolean): void;
  20619. /**
  20620. * @hidden
  20621. * Get current device position in babylon world
  20622. */
  20623. _computeDevicePosition(): void;
  20624. /**
  20625. * Updates the current device position and rotation in the babylon world
  20626. */
  20627. update(): void;
  20628. /**
  20629. * @hidden
  20630. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20631. * @returns an identity matrix
  20632. */
  20633. _getViewMatrix(): Matrix;
  20634. private _tmpMatrix;
  20635. /**
  20636. * This function is called by the two RIG cameras.
  20637. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20638. * @hidden
  20639. */
  20640. _getWebVRViewMatrix(): Matrix;
  20641. /** @hidden */
  20642. _getWebVRProjectionMatrix(): Matrix;
  20643. private _onGamepadConnectedObserver;
  20644. private _onGamepadDisconnectedObserver;
  20645. private _updateCacheWhenTrackingDisabledObserver;
  20646. /**
  20647. * Initializes the controllers and their meshes
  20648. */
  20649. initControllers(): void;
  20650. }
  20651. }
  20652. declare module "babylonjs/Materials/materialHelper" {
  20653. import { Nullable } from "babylonjs/types";
  20654. import { Scene } from "babylonjs/scene";
  20655. import { Engine } from "babylonjs/Engines/engine";
  20656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20657. import { Light } from "babylonjs/Lights/light";
  20658. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20659. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20660. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20661. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20662. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20663. /**
  20664. * "Static Class" containing the most commonly used helper while dealing with material for
  20665. * rendering purpose.
  20666. *
  20667. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20668. *
  20669. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20670. */
  20671. export class MaterialHelper {
  20672. /**
  20673. * Bind the current view position to an effect.
  20674. * @param effect The effect to be bound
  20675. * @param scene The scene the eyes position is used from
  20676. * @param variableName name of the shader variable that will hold the eye position
  20677. */
  20678. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20679. /**
  20680. * Helps preparing the defines values about the UVs in used in the effect.
  20681. * UVs are shared as much as we can accross channels in the shaders.
  20682. * @param texture The texture we are preparing the UVs for
  20683. * @param defines The defines to update
  20684. * @param key The channel key "diffuse", "specular"... used in the shader
  20685. */
  20686. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20687. /**
  20688. * Binds a texture matrix value to its corrsponding uniform
  20689. * @param texture The texture to bind the matrix for
  20690. * @param uniformBuffer The uniform buffer receivin the data
  20691. * @param key The channel key "diffuse", "specular"... used in the shader
  20692. */
  20693. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20694. /**
  20695. * Gets the current status of the fog (should it be enabled?)
  20696. * @param mesh defines the mesh to evaluate for fog support
  20697. * @param scene defines the hosting scene
  20698. * @returns true if fog must be enabled
  20699. */
  20700. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20701. /**
  20702. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20703. * @param mesh defines the current mesh
  20704. * @param scene defines the current scene
  20705. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20706. * @param pointsCloud defines if point cloud rendering has to be turned on
  20707. * @param fogEnabled defines if fog has to be turned on
  20708. * @param alphaTest defines if alpha testing has to be turned on
  20709. * @param defines defines the current list of defines
  20710. */
  20711. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20712. /**
  20713. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20714. * @param scene defines the current scene
  20715. * @param engine defines the current engine
  20716. * @param defines specifies the list of active defines
  20717. * @param useInstances defines if instances have to be turned on
  20718. * @param useClipPlane defines if clip plane have to be turned on
  20719. * @param useInstances defines if instances have to be turned on
  20720. * @param useThinInstances defines if thin instances have to be turned on
  20721. */
  20722. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20723. /**
  20724. * Prepares the defines for bones
  20725. * @param mesh The mesh containing the geometry data we will draw
  20726. * @param defines The defines to update
  20727. */
  20728. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20729. /**
  20730. * Prepares the defines for morph targets
  20731. * @param mesh The mesh containing the geometry data we will draw
  20732. * @param defines The defines to update
  20733. */
  20734. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20735. /**
  20736. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20737. * @param mesh The mesh containing the geometry data we will draw
  20738. * @param defines The defines to update
  20739. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20740. * @param useBones Precise whether bones should be used or not (override mesh info)
  20741. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20742. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20743. * @returns false if defines are considered not dirty and have not been checked
  20744. */
  20745. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20746. /**
  20747. * Prepares the defines related to multiview
  20748. * @param scene The scene we are intending to draw
  20749. * @param defines The defines to update
  20750. */
  20751. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20752. /**
  20753. * Prepares the defines related to the prepass
  20754. * @param scene The scene we are intending to draw
  20755. * @param defines The defines to update
  20756. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20757. */
  20758. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20759. /**
  20760. * Prepares the defines related to the light information passed in parameter
  20761. * @param scene The scene we are intending to draw
  20762. * @param mesh The mesh the effect is compiling for
  20763. * @param light The light the effect is compiling for
  20764. * @param lightIndex The index of the light
  20765. * @param defines The defines to update
  20766. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20767. * @param state Defines the current state regarding what is needed (normals, etc...)
  20768. */
  20769. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20770. needNormals: boolean;
  20771. needRebuild: boolean;
  20772. shadowEnabled: boolean;
  20773. specularEnabled: boolean;
  20774. lightmapMode: boolean;
  20775. }): void;
  20776. /**
  20777. * Prepares the defines related to the light information passed in parameter
  20778. * @param scene The scene we are intending to draw
  20779. * @param mesh The mesh the effect is compiling for
  20780. * @param defines The defines to update
  20781. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20782. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20783. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20784. * @returns true if normals will be required for the rest of the effect
  20785. */
  20786. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20787. /**
  20788. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20789. * @param lightIndex defines the light index
  20790. * @param uniformsList The uniform list
  20791. * @param samplersList The sampler list
  20792. * @param projectedLightTexture defines if projected texture must be used
  20793. * @param uniformBuffersList defines an optional list of uniform buffers
  20794. */
  20795. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20796. /**
  20797. * Prepares the uniforms and samplers list to be used in the effect
  20798. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20799. * @param samplersList The sampler list
  20800. * @param defines The defines helping in the list generation
  20801. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20802. */
  20803. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20804. /**
  20805. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20806. * @param defines The defines to update while falling back
  20807. * @param fallbacks The authorized effect fallbacks
  20808. * @param maxSimultaneousLights The maximum number of lights allowed
  20809. * @param rank the current rank of the Effect
  20810. * @returns The newly affected rank
  20811. */
  20812. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20813. private static _TmpMorphInfluencers;
  20814. /**
  20815. * Prepares the list of attributes required for morph targets according to the effect defines.
  20816. * @param attribs The current list of supported attribs
  20817. * @param mesh The mesh to prepare the morph targets attributes for
  20818. * @param influencers The number of influencers
  20819. */
  20820. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20821. /**
  20822. * Prepares the list of attributes required for morph targets according to the effect defines.
  20823. * @param attribs The current list of supported attribs
  20824. * @param mesh The mesh to prepare the morph targets attributes for
  20825. * @param defines The current Defines of the effect
  20826. */
  20827. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20828. /**
  20829. * Prepares the list of attributes required for bones according to the effect defines.
  20830. * @param attribs The current list of supported attribs
  20831. * @param mesh The mesh to prepare the bones attributes for
  20832. * @param defines The current Defines of the effect
  20833. * @param fallbacks The current efffect fallback strategy
  20834. */
  20835. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20836. /**
  20837. * Check and prepare the list of attributes required for instances according to the effect defines.
  20838. * @param attribs The current list of supported attribs
  20839. * @param defines The current MaterialDefines of the effect
  20840. */
  20841. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20842. /**
  20843. * Add the list of attributes required for instances to the attribs array.
  20844. * @param attribs The current list of supported attribs
  20845. */
  20846. static PushAttributesForInstances(attribs: string[]): void;
  20847. /**
  20848. * Binds the light information to the effect.
  20849. * @param light The light containing the generator
  20850. * @param effect The effect we are binding the data to
  20851. * @param lightIndex The light index in the effect used to render
  20852. */
  20853. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20854. /**
  20855. * Binds the lights information from the scene to the effect for the given mesh.
  20856. * @param light Light to bind
  20857. * @param lightIndex Light index
  20858. * @param scene The scene where the light belongs to
  20859. * @param effect The effect we are binding the data to
  20860. * @param useSpecular Defines if specular is supported
  20861. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20862. */
  20863. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20864. /**
  20865. * Binds the lights information from the scene to the effect for the given mesh.
  20866. * @param scene The scene the lights belongs to
  20867. * @param mesh The mesh we are binding the information to render
  20868. * @param effect The effect we are binding the data to
  20869. * @param defines The generated defines for the effect
  20870. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20871. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20872. */
  20873. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20874. private static _tempFogColor;
  20875. /**
  20876. * Binds the fog information from the scene to the effect for the given mesh.
  20877. * @param scene The scene the lights belongs to
  20878. * @param mesh The mesh we are binding the information to render
  20879. * @param effect The effect we are binding the data to
  20880. * @param linearSpace Defines if the fog effect is applied in linear space
  20881. */
  20882. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20883. /**
  20884. * Binds the bones information from the mesh to the effect.
  20885. * @param mesh The mesh we are binding the information to render
  20886. * @param effect The effect we are binding the data to
  20887. */
  20888. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20889. /**
  20890. * Binds the morph targets information from the mesh to the effect.
  20891. * @param abstractMesh The mesh we are binding the information to render
  20892. * @param effect The effect we are binding the data to
  20893. */
  20894. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20895. /**
  20896. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20897. * @param defines The generated defines used in the effect
  20898. * @param effect The effect we are binding the data to
  20899. * @param scene The scene we are willing to render with logarithmic scale for
  20900. */
  20901. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20902. /**
  20903. * Binds the clip plane information from the scene to the effect.
  20904. * @param scene The scene the clip plane information are extracted from
  20905. * @param effect The effect we are binding the data to
  20906. */
  20907. static BindClipPlane(effect: Effect, scene: Scene): void;
  20908. }
  20909. }
  20910. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20911. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20912. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20913. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20914. import { Nullable } from "babylonjs/types";
  20915. import { Effect } from "babylonjs/Materials/effect";
  20916. import { Matrix } from "babylonjs/Maths/math.vector";
  20917. import { Scene } from "babylonjs/scene";
  20918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20920. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20921. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20922. import { Observable } from "babylonjs/Misc/observable";
  20923. /**
  20924. * Block used to expose an input value
  20925. */
  20926. export class InputBlock extends NodeMaterialBlock {
  20927. private _mode;
  20928. private _associatedVariableName;
  20929. private _storedValue;
  20930. private _valueCallback;
  20931. private _type;
  20932. private _animationType;
  20933. /** Gets or set a value used to limit the range of float values */
  20934. min: number;
  20935. /** Gets or set a value used to limit the range of float values */
  20936. max: number;
  20937. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20938. isBoolean: boolean;
  20939. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20940. matrixMode: number;
  20941. /** @hidden */
  20942. _systemValue: Nullable<NodeMaterialSystemValues>;
  20943. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20944. visibleInInspector: boolean;
  20945. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20946. isConstant: boolean;
  20947. /** Gets or sets the group to use to display this block in the Inspector */
  20948. groupInInspector: string;
  20949. /** Gets an observable raised when the value is changed */
  20950. onValueChangedObservable: Observable<InputBlock>;
  20951. /**
  20952. * Gets or sets the connection point type (default is float)
  20953. */
  20954. get type(): NodeMaterialBlockConnectionPointTypes;
  20955. /**
  20956. * Creates a new InputBlock
  20957. * @param name defines the block name
  20958. * @param target defines the target of that block (Vertex by default)
  20959. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20960. */
  20961. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20962. /**
  20963. * Validates if a name is a reserve word.
  20964. * @param newName the new name to be given to the node.
  20965. * @returns false if the name is a reserve word, else true.
  20966. */
  20967. validateBlockName(newName: string): boolean;
  20968. /**
  20969. * Gets the output component
  20970. */
  20971. get output(): NodeMaterialConnectionPoint;
  20972. /**
  20973. * Set the source of this connection point to a vertex attribute
  20974. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20975. * @returns the current connection point
  20976. */
  20977. setAsAttribute(attributeName?: string): InputBlock;
  20978. /**
  20979. * Set the source of this connection point to a system value
  20980. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20981. * @returns the current connection point
  20982. */
  20983. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20984. /**
  20985. * Gets or sets the value of that point.
  20986. * Please note that this value will be ignored if valueCallback is defined
  20987. */
  20988. get value(): any;
  20989. set value(value: any);
  20990. /**
  20991. * Gets or sets a callback used to get the value of that point.
  20992. * Please note that setting this value will force the connection point to ignore the value property
  20993. */
  20994. get valueCallback(): () => any;
  20995. set valueCallback(value: () => any);
  20996. /**
  20997. * Gets or sets the associated variable name in the shader
  20998. */
  20999. get associatedVariableName(): string;
  21000. set associatedVariableName(value: string);
  21001. /** Gets or sets the type of animation applied to the input */
  21002. get animationType(): AnimatedInputBlockTypes;
  21003. set animationType(value: AnimatedInputBlockTypes);
  21004. /**
  21005. * Gets a boolean indicating that this connection point not defined yet
  21006. */
  21007. get isUndefined(): boolean;
  21008. /**
  21009. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21010. * In this case the connection point name must be the name of the uniform to use.
  21011. * Can only be set on inputs
  21012. */
  21013. get isUniform(): boolean;
  21014. set isUniform(value: boolean);
  21015. /**
  21016. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21017. * In this case the connection point name must be the name of the attribute to use
  21018. * Can only be set on inputs
  21019. */
  21020. get isAttribute(): boolean;
  21021. set isAttribute(value: boolean);
  21022. /**
  21023. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21024. * Can only be set on exit points
  21025. */
  21026. get isVarying(): boolean;
  21027. set isVarying(value: boolean);
  21028. /**
  21029. * Gets a boolean indicating that the current connection point is a system value
  21030. */
  21031. get isSystemValue(): boolean;
  21032. /**
  21033. * Gets or sets the current well known value or null if not defined as a system value
  21034. */
  21035. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21036. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21037. /**
  21038. * Gets the current class name
  21039. * @returns the class name
  21040. */
  21041. getClassName(): string;
  21042. /**
  21043. * Animate the input if animationType !== None
  21044. * @param scene defines the rendering scene
  21045. */
  21046. animate(scene: Scene): void;
  21047. private _emitDefine;
  21048. initialize(state: NodeMaterialBuildState): void;
  21049. /**
  21050. * Set the input block to its default value (based on its type)
  21051. */
  21052. setDefaultValue(): void;
  21053. private _emitConstant;
  21054. /** @hidden */
  21055. get _noContextSwitch(): boolean;
  21056. private _emit;
  21057. /** @hidden */
  21058. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21059. /** @hidden */
  21060. _transmit(effect: Effect, scene: Scene): void;
  21061. protected _buildBlock(state: NodeMaterialBuildState): void;
  21062. protected _dumpPropertiesCode(): string;
  21063. dispose(): void;
  21064. serialize(): any;
  21065. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21066. }
  21067. }
  21068. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21069. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21070. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21071. import { Nullable } from "babylonjs/types";
  21072. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21073. import { Observable } from "babylonjs/Misc/observable";
  21074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21075. /**
  21076. * Enum used to define the compatibility state between two connection points
  21077. */
  21078. export enum NodeMaterialConnectionPointCompatibilityStates {
  21079. /** Points are compatibles */
  21080. Compatible = 0,
  21081. /** Points are incompatible because of their types */
  21082. TypeIncompatible = 1,
  21083. /** Points are incompatible because of their targets (vertex vs fragment) */
  21084. TargetIncompatible = 2
  21085. }
  21086. /**
  21087. * Defines the direction of a connection point
  21088. */
  21089. export enum NodeMaterialConnectionPointDirection {
  21090. /** Input */
  21091. Input = 0,
  21092. /** Output */
  21093. Output = 1
  21094. }
  21095. /**
  21096. * Defines a connection point for a block
  21097. */
  21098. export class NodeMaterialConnectionPoint {
  21099. /** @hidden */
  21100. _ownerBlock: NodeMaterialBlock;
  21101. /** @hidden */
  21102. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21103. private _endpoints;
  21104. private _associatedVariableName;
  21105. private _direction;
  21106. /** @hidden */
  21107. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21108. /** @hidden */
  21109. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21110. private _type;
  21111. /** @hidden */
  21112. _enforceAssociatedVariableName: boolean;
  21113. /** Gets the direction of the point */
  21114. get direction(): NodeMaterialConnectionPointDirection;
  21115. /** Indicates that this connection point needs dual validation before being connected to another point */
  21116. needDualDirectionValidation: boolean;
  21117. /**
  21118. * Gets or sets the additional types supported by this connection point
  21119. */
  21120. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21121. /**
  21122. * Gets or sets the additional types excluded by this connection point
  21123. */
  21124. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21125. /**
  21126. * Observable triggered when this point is connected
  21127. */
  21128. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21129. /**
  21130. * Gets or sets the associated variable name in the shader
  21131. */
  21132. get associatedVariableName(): string;
  21133. set associatedVariableName(value: string);
  21134. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21135. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21136. /**
  21137. * Gets or sets the connection point type (default is float)
  21138. */
  21139. get type(): NodeMaterialBlockConnectionPointTypes;
  21140. set type(value: NodeMaterialBlockConnectionPointTypes);
  21141. /**
  21142. * Gets or sets the connection point name
  21143. */
  21144. name: string;
  21145. /**
  21146. * Gets or sets the connection point name
  21147. */
  21148. displayName: string;
  21149. /**
  21150. * Gets or sets a boolean indicating that this connection point can be omitted
  21151. */
  21152. isOptional: boolean;
  21153. /**
  21154. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21155. */
  21156. isExposedOnFrame: boolean;
  21157. /**
  21158. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21159. */
  21160. define: string;
  21161. /** @hidden */
  21162. _prioritizeVertex: boolean;
  21163. private _target;
  21164. /** Gets or sets the target of that connection point */
  21165. get target(): NodeMaterialBlockTargets;
  21166. set target(value: NodeMaterialBlockTargets);
  21167. /**
  21168. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21169. */
  21170. get isConnected(): boolean;
  21171. /**
  21172. * Gets a boolean indicating that the current point is connected to an input block
  21173. */
  21174. get isConnectedToInputBlock(): boolean;
  21175. /**
  21176. * Gets a the connected input block (if any)
  21177. */
  21178. get connectInputBlock(): Nullable<InputBlock>;
  21179. /** Get the other side of the connection (if any) */
  21180. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21181. /** Get the block that owns this connection point */
  21182. get ownerBlock(): NodeMaterialBlock;
  21183. /** Get the block connected on the other side of this connection (if any) */
  21184. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21185. /** Get the block connected on the endpoints of this connection (if any) */
  21186. get connectedBlocks(): Array<NodeMaterialBlock>;
  21187. /** Gets the list of connected endpoints */
  21188. get endpoints(): NodeMaterialConnectionPoint[];
  21189. /** Gets a boolean indicating if that output point is connected to at least one input */
  21190. get hasEndpoints(): boolean;
  21191. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21192. get isConnectedInVertexShader(): boolean;
  21193. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21194. get isConnectedInFragmentShader(): boolean;
  21195. /**
  21196. * Creates a block suitable to be used as an input for this input point.
  21197. * If null is returned, a block based on the point type will be created.
  21198. * @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
  21199. */
  21200. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21201. /**
  21202. * Creates a new connection point
  21203. * @param name defines the connection point name
  21204. * @param ownerBlock defines the block hosting this connection point
  21205. * @param direction defines the direction of the connection point
  21206. */
  21207. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21208. /**
  21209. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21210. * @returns the class name
  21211. */
  21212. getClassName(): string;
  21213. /**
  21214. * Gets a boolean indicating if the current point can be connected to another point
  21215. * @param connectionPoint defines the other connection point
  21216. * @returns a boolean
  21217. */
  21218. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21219. /**
  21220. * Gets a number indicating if the current point can be connected to another point
  21221. * @param connectionPoint defines the other connection point
  21222. * @returns a number defining the compatibility state
  21223. */
  21224. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21225. /**
  21226. * Connect this point to another connection point
  21227. * @param connectionPoint defines the other connection point
  21228. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21229. * @returns the current connection point
  21230. */
  21231. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21232. /**
  21233. * Disconnect this point from one of his endpoint
  21234. * @param endpoint defines the other connection point
  21235. * @returns the current connection point
  21236. */
  21237. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21238. /**
  21239. * Serializes this point in a JSON representation
  21240. * @param isInput defines if the connection point is an input (default is true)
  21241. * @returns the serialized point object
  21242. */
  21243. serialize(isInput?: boolean): any;
  21244. /**
  21245. * Release resources
  21246. */
  21247. dispose(): void;
  21248. }
  21249. }
  21250. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21251. /**
  21252. * Enum used to define the material modes
  21253. */
  21254. export enum NodeMaterialModes {
  21255. /** Regular material */
  21256. Material = 0,
  21257. /** For post process */
  21258. PostProcess = 1,
  21259. /** For particle system */
  21260. Particle = 2
  21261. }
  21262. }
  21263. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21266. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21269. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21270. import { Effect } from "babylonjs/Materials/effect";
  21271. import { Mesh } from "babylonjs/Meshes/mesh";
  21272. import { Nullable } from "babylonjs/types";
  21273. import { Texture } from "babylonjs/Materials/Textures/texture";
  21274. import { Scene } from "babylonjs/scene";
  21275. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21276. /**
  21277. * Block used to read a texture from a sampler
  21278. */
  21279. export class TextureBlock extends NodeMaterialBlock {
  21280. private _defineName;
  21281. private _linearDefineName;
  21282. private _gammaDefineName;
  21283. private _tempTextureRead;
  21284. private _samplerName;
  21285. private _transformedUVName;
  21286. private _textureTransformName;
  21287. private _textureInfoName;
  21288. private _mainUVName;
  21289. private _mainUVDefineName;
  21290. private _fragmentOnly;
  21291. /**
  21292. * Gets or sets the texture associated with the node
  21293. */
  21294. texture: Nullable<Texture>;
  21295. /**
  21296. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21297. */
  21298. convertToGammaSpace: boolean;
  21299. /**
  21300. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21301. */
  21302. convertToLinearSpace: boolean;
  21303. /**
  21304. * Create a new TextureBlock
  21305. * @param name defines the block name
  21306. */
  21307. constructor(name: string, fragmentOnly?: boolean);
  21308. /**
  21309. * Gets the current class name
  21310. * @returns the class name
  21311. */
  21312. getClassName(): string;
  21313. /**
  21314. * Gets the uv input component
  21315. */
  21316. get uv(): NodeMaterialConnectionPoint;
  21317. /**
  21318. * Gets the rgba output component
  21319. */
  21320. get rgba(): NodeMaterialConnectionPoint;
  21321. /**
  21322. * Gets the rgb output component
  21323. */
  21324. get rgb(): NodeMaterialConnectionPoint;
  21325. /**
  21326. * Gets the r output component
  21327. */
  21328. get r(): NodeMaterialConnectionPoint;
  21329. /**
  21330. * Gets the g output component
  21331. */
  21332. get g(): NodeMaterialConnectionPoint;
  21333. /**
  21334. * Gets the b output component
  21335. */
  21336. get b(): NodeMaterialConnectionPoint;
  21337. /**
  21338. * Gets the a output component
  21339. */
  21340. get a(): NodeMaterialConnectionPoint;
  21341. get target(): NodeMaterialBlockTargets;
  21342. autoConfigure(material: NodeMaterial): void;
  21343. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21345. isReady(): boolean;
  21346. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21347. private get _isMixed();
  21348. private _injectVertexCode;
  21349. private _writeTextureRead;
  21350. private _writeOutput;
  21351. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21352. protected _dumpPropertiesCode(): string;
  21353. serialize(): any;
  21354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21355. }
  21356. }
  21357. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21358. /** @hidden */
  21359. export var reflectionFunction: {
  21360. name: string;
  21361. shader: string;
  21362. };
  21363. }
  21364. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21365. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21366. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21367. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21370. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21371. import { Effect } from "babylonjs/Materials/effect";
  21372. import { Mesh } from "babylonjs/Meshes/mesh";
  21373. import { Nullable } from "babylonjs/types";
  21374. import { Scene } from "babylonjs/scene";
  21375. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21376. /**
  21377. * Base block used to read a reflection texture from a sampler
  21378. */
  21379. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21380. /** @hidden */
  21381. _define3DName: string;
  21382. /** @hidden */
  21383. _defineCubicName: string;
  21384. /** @hidden */
  21385. _defineExplicitName: string;
  21386. /** @hidden */
  21387. _defineProjectionName: string;
  21388. /** @hidden */
  21389. _defineLocalCubicName: string;
  21390. /** @hidden */
  21391. _defineSphericalName: string;
  21392. /** @hidden */
  21393. _definePlanarName: string;
  21394. /** @hidden */
  21395. _defineEquirectangularName: string;
  21396. /** @hidden */
  21397. _defineMirroredEquirectangularFixedName: string;
  21398. /** @hidden */
  21399. _defineEquirectangularFixedName: string;
  21400. /** @hidden */
  21401. _defineSkyboxName: string;
  21402. /** @hidden */
  21403. _defineOppositeZ: string;
  21404. /** @hidden */
  21405. _cubeSamplerName: string;
  21406. /** @hidden */
  21407. _2DSamplerName: string;
  21408. protected _positionUVWName: string;
  21409. protected _directionWName: string;
  21410. protected _reflectionVectorName: string;
  21411. /** @hidden */
  21412. _reflectionCoordsName: string;
  21413. /** @hidden */
  21414. _reflectionMatrixName: string;
  21415. protected _reflectionColorName: string;
  21416. /**
  21417. * Gets or sets the texture associated with the node
  21418. */
  21419. texture: Nullable<BaseTexture>;
  21420. /**
  21421. * Create a new ReflectionTextureBaseBlock
  21422. * @param name defines the block name
  21423. */
  21424. constructor(name: string);
  21425. /**
  21426. * Gets the current class name
  21427. * @returns the class name
  21428. */
  21429. getClassName(): string;
  21430. /**
  21431. * Gets the world position input component
  21432. */
  21433. abstract get position(): NodeMaterialConnectionPoint;
  21434. /**
  21435. * Gets the world position input component
  21436. */
  21437. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21438. /**
  21439. * Gets the world normal input component
  21440. */
  21441. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21442. /**
  21443. * Gets the world input component
  21444. */
  21445. abstract get world(): NodeMaterialConnectionPoint;
  21446. /**
  21447. * Gets the camera (or eye) position component
  21448. */
  21449. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21450. /**
  21451. * Gets the view input component
  21452. */
  21453. abstract get view(): NodeMaterialConnectionPoint;
  21454. protected _getTexture(): Nullable<BaseTexture>;
  21455. autoConfigure(material: NodeMaterial): void;
  21456. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21457. isReady(): boolean;
  21458. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21459. /**
  21460. * Gets the code to inject in the vertex shader
  21461. * @param state current state of the node material building
  21462. * @returns the shader code
  21463. */
  21464. handleVertexSide(state: NodeMaterialBuildState): string;
  21465. /**
  21466. * Handles the inits for the fragment code path
  21467. * @param state node material build state
  21468. */
  21469. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21470. /**
  21471. * Generates the reflection coords code for the fragment code path
  21472. * @param worldNormalVarName name of the world normal variable
  21473. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21474. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21475. * @returns the shader code
  21476. */
  21477. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21478. /**
  21479. * Generates the reflection color code for the fragment code path
  21480. * @param lodVarName name of the lod variable
  21481. * @param swizzleLookupTexture swizzle to use for the final color variable
  21482. * @returns the shader code
  21483. */
  21484. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21485. /**
  21486. * Generates the code corresponding to the connected output points
  21487. * @param state node material build state
  21488. * @param varName name of the variable to output
  21489. * @returns the shader code
  21490. */
  21491. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21492. protected _buildBlock(state: NodeMaterialBuildState): this;
  21493. protected _dumpPropertiesCode(): string;
  21494. serialize(): any;
  21495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21496. }
  21497. }
  21498. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21500. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21501. import { Nullable } from "babylonjs/types";
  21502. /**
  21503. * Defines a connection point to be used for points with a custom object type
  21504. */
  21505. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21506. private _blockType;
  21507. private _blockName;
  21508. private _nameForCheking?;
  21509. /**
  21510. * Creates a new connection point
  21511. * @param name defines the connection point name
  21512. * @param ownerBlock defines the block hosting this connection point
  21513. * @param direction defines the direction of the connection point
  21514. */
  21515. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21516. /**
  21517. * Gets a number indicating if the current point can be connected to another point
  21518. * @param connectionPoint defines the other connection point
  21519. * @returns a number defining the compatibility state
  21520. */
  21521. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21522. /**
  21523. * Creates a block suitable to be used as an input for this input point.
  21524. * If null is returned, a block based on the point type will be created.
  21525. * @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
  21526. */
  21527. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21528. }
  21529. }
  21530. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21531. /**
  21532. * Enum defining the type of properties that can be edited in the property pages in the NME
  21533. */
  21534. export enum PropertyTypeForEdition {
  21535. /** property is a boolean */
  21536. Boolean = 0,
  21537. /** property is a float */
  21538. Float = 1,
  21539. /** property is a Vector2 */
  21540. Vector2 = 2,
  21541. /** property is a list of values */
  21542. List = 3
  21543. }
  21544. /**
  21545. * Interface that defines an option in a variable of type list
  21546. */
  21547. export interface IEditablePropertyListOption {
  21548. /** label of the option */
  21549. "label": string;
  21550. /** value of the option */
  21551. "value": number;
  21552. }
  21553. /**
  21554. * Interface that defines the options available for an editable property
  21555. */
  21556. export interface IEditablePropertyOption {
  21557. /** min value */
  21558. "min"?: number;
  21559. /** max value */
  21560. "max"?: number;
  21561. /** notifiers: indicates which actions to take when the property is changed */
  21562. "notifiers"?: {
  21563. /** the material should be rebuilt */
  21564. "rebuild"?: boolean;
  21565. /** the preview should be updated */
  21566. "update"?: boolean;
  21567. };
  21568. /** list of the options for a variable of type list */
  21569. "options"?: IEditablePropertyListOption[];
  21570. }
  21571. /**
  21572. * Interface that describes an editable property
  21573. */
  21574. export interface IPropertyDescriptionForEdition {
  21575. /** name of the property */
  21576. "propertyName": string;
  21577. /** display name of the property */
  21578. "displayName": string;
  21579. /** type of the property */
  21580. "type": PropertyTypeForEdition;
  21581. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21582. "groupName": string;
  21583. /** options for the property */
  21584. "options": IEditablePropertyOption;
  21585. }
  21586. /**
  21587. * Decorator that flags a property in a node material block as being editable
  21588. */
  21589. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21590. }
  21591. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21594. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21596. import { Nullable } from "babylonjs/types";
  21597. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21598. import { Mesh } from "babylonjs/Meshes/mesh";
  21599. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21600. import { Effect } from "babylonjs/Materials/effect";
  21601. import { Scene } from "babylonjs/scene";
  21602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21603. /**
  21604. * Block used to implement the refraction part of the sub surface module of the PBR material
  21605. */
  21606. export class RefractionBlock extends NodeMaterialBlock {
  21607. /** @hidden */
  21608. _define3DName: string;
  21609. /** @hidden */
  21610. _refractionMatrixName: string;
  21611. /** @hidden */
  21612. _defineLODRefractionAlpha: string;
  21613. /** @hidden */
  21614. _defineLinearSpecularRefraction: string;
  21615. /** @hidden */
  21616. _defineOppositeZ: string;
  21617. /** @hidden */
  21618. _cubeSamplerName: string;
  21619. /** @hidden */
  21620. _2DSamplerName: string;
  21621. /** @hidden */
  21622. _vRefractionMicrosurfaceInfosName: string;
  21623. /** @hidden */
  21624. _vRefractionInfosName: string;
  21625. private _scene;
  21626. /**
  21627. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21628. * Materials half opaque for instance using refraction could benefit from this control.
  21629. */
  21630. linkRefractionWithTransparency: boolean;
  21631. /**
  21632. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21633. */
  21634. invertRefractionY: boolean;
  21635. /**
  21636. * Gets or sets the texture associated with the node
  21637. */
  21638. texture: Nullable<BaseTexture>;
  21639. /**
  21640. * Create a new RefractionBlock
  21641. * @param name defines the block name
  21642. */
  21643. constructor(name: string);
  21644. /**
  21645. * Gets the current class name
  21646. * @returns the class name
  21647. */
  21648. getClassName(): string;
  21649. /**
  21650. * Gets the intensity input component
  21651. */
  21652. get intensity(): NodeMaterialConnectionPoint;
  21653. /**
  21654. * Gets the index of refraction input component
  21655. */
  21656. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21657. /**
  21658. * Gets the tint at distance input component
  21659. */
  21660. get tintAtDistance(): NodeMaterialConnectionPoint;
  21661. /**
  21662. * Gets the view input component
  21663. */
  21664. get view(): NodeMaterialConnectionPoint;
  21665. /**
  21666. * Gets the refraction object output component
  21667. */
  21668. get refraction(): NodeMaterialConnectionPoint;
  21669. /**
  21670. * Returns true if the block has a texture
  21671. */
  21672. get hasTexture(): boolean;
  21673. protected _getTexture(): Nullable<BaseTexture>;
  21674. autoConfigure(material: NodeMaterial): void;
  21675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21676. isReady(): boolean;
  21677. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21678. /**
  21679. * Gets the main code of the block (fragment side)
  21680. * @param state current state of the node material building
  21681. * @returns the shader code
  21682. */
  21683. getCode(state: NodeMaterialBuildState): string;
  21684. protected _buildBlock(state: NodeMaterialBuildState): this;
  21685. protected _dumpPropertiesCode(): string;
  21686. serialize(): any;
  21687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21688. }
  21689. }
  21690. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21693. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21696. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21697. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21698. import { Nullable } from "babylonjs/types";
  21699. import { Scene } from "babylonjs/scene";
  21700. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21701. /**
  21702. * Base block used as input for post process
  21703. */
  21704. export class CurrentScreenBlock extends NodeMaterialBlock {
  21705. private _samplerName;
  21706. private _linearDefineName;
  21707. private _gammaDefineName;
  21708. private _mainUVName;
  21709. private _tempTextureRead;
  21710. /**
  21711. * Gets or sets the texture associated with the node
  21712. */
  21713. texture: Nullable<BaseTexture>;
  21714. /**
  21715. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21716. */
  21717. convertToGammaSpace: boolean;
  21718. /**
  21719. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21720. */
  21721. convertToLinearSpace: boolean;
  21722. /**
  21723. * Create a new CurrentScreenBlock
  21724. * @param name defines the block name
  21725. */
  21726. constructor(name: string);
  21727. /**
  21728. * Gets the current class name
  21729. * @returns the class name
  21730. */
  21731. getClassName(): string;
  21732. /**
  21733. * Gets the uv input component
  21734. */
  21735. get uv(): NodeMaterialConnectionPoint;
  21736. /**
  21737. * Gets the rgba output component
  21738. */
  21739. get rgba(): NodeMaterialConnectionPoint;
  21740. /**
  21741. * Gets the rgb output component
  21742. */
  21743. get rgb(): NodeMaterialConnectionPoint;
  21744. /**
  21745. * Gets the r output component
  21746. */
  21747. get r(): NodeMaterialConnectionPoint;
  21748. /**
  21749. * Gets the g output component
  21750. */
  21751. get g(): NodeMaterialConnectionPoint;
  21752. /**
  21753. * Gets the b output component
  21754. */
  21755. get b(): NodeMaterialConnectionPoint;
  21756. /**
  21757. * Gets the a output component
  21758. */
  21759. get a(): NodeMaterialConnectionPoint;
  21760. /**
  21761. * Initialize the block and prepare the context for build
  21762. * @param state defines the state that will be used for the build
  21763. */
  21764. initialize(state: NodeMaterialBuildState): void;
  21765. get target(): NodeMaterialBlockTargets;
  21766. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21767. isReady(): boolean;
  21768. private _injectVertexCode;
  21769. private _writeTextureRead;
  21770. private _writeOutput;
  21771. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21772. serialize(): any;
  21773. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21774. }
  21775. }
  21776. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21777. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21778. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21779. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21780. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21781. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21782. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21783. import { Nullable } from "babylonjs/types";
  21784. import { Scene } from "babylonjs/scene";
  21785. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21786. /**
  21787. * Base block used for the particle texture
  21788. */
  21789. export class ParticleTextureBlock extends NodeMaterialBlock {
  21790. private _samplerName;
  21791. private _linearDefineName;
  21792. private _gammaDefineName;
  21793. private _tempTextureRead;
  21794. /**
  21795. * Gets or sets the texture associated with the node
  21796. */
  21797. texture: Nullable<BaseTexture>;
  21798. /**
  21799. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21800. */
  21801. convertToGammaSpace: boolean;
  21802. /**
  21803. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21804. */
  21805. convertToLinearSpace: boolean;
  21806. /**
  21807. * Create a new ParticleTextureBlock
  21808. * @param name defines the block name
  21809. */
  21810. constructor(name: string);
  21811. /**
  21812. * Gets the current class name
  21813. * @returns the class name
  21814. */
  21815. getClassName(): string;
  21816. /**
  21817. * Gets the uv input component
  21818. */
  21819. get uv(): NodeMaterialConnectionPoint;
  21820. /**
  21821. * Gets the rgba output component
  21822. */
  21823. get rgba(): NodeMaterialConnectionPoint;
  21824. /**
  21825. * Gets the rgb output component
  21826. */
  21827. get rgb(): NodeMaterialConnectionPoint;
  21828. /**
  21829. * Gets the r output component
  21830. */
  21831. get r(): NodeMaterialConnectionPoint;
  21832. /**
  21833. * Gets the g output component
  21834. */
  21835. get g(): NodeMaterialConnectionPoint;
  21836. /**
  21837. * Gets the b output component
  21838. */
  21839. get b(): NodeMaterialConnectionPoint;
  21840. /**
  21841. * Gets the a output component
  21842. */
  21843. get a(): NodeMaterialConnectionPoint;
  21844. /**
  21845. * Initialize the block and prepare the context for build
  21846. * @param state defines the state that will be used for the build
  21847. */
  21848. initialize(state: NodeMaterialBuildState): void;
  21849. autoConfigure(material: NodeMaterial): void;
  21850. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21851. isReady(): boolean;
  21852. private _writeOutput;
  21853. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21854. serialize(): any;
  21855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21856. }
  21857. }
  21858. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21861. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21862. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21863. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21864. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21865. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21866. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21867. import { Scene } from "babylonjs/scene";
  21868. /**
  21869. * Class used to store shared data between 2 NodeMaterialBuildState
  21870. */
  21871. export class NodeMaterialBuildStateSharedData {
  21872. /**
  21873. * Gets the list of emitted varyings
  21874. */
  21875. temps: string[];
  21876. /**
  21877. * Gets the list of emitted varyings
  21878. */
  21879. varyings: string[];
  21880. /**
  21881. * Gets the varying declaration string
  21882. */
  21883. varyingDeclaration: string;
  21884. /**
  21885. * Input blocks
  21886. */
  21887. inputBlocks: InputBlock[];
  21888. /**
  21889. * Input blocks
  21890. */
  21891. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21892. /**
  21893. * Bindable blocks (Blocks that need to set data to the effect)
  21894. */
  21895. bindableBlocks: NodeMaterialBlock[];
  21896. /**
  21897. * List of blocks that can provide a compilation fallback
  21898. */
  21899. blocksWithFallbacks: NodeMaterialBlock[];
  21900. /**
  21901. * List of blocks that can provide a define update
  21902. */
  21903. blocksWithDefines: NodeMaterialBlock[];
  21904. /**
  21905. * List of blocks that can provide a repeatable content
  21906. */
  21907. repeatableContentBlocks: NodeMaterialBlock[];
  21908. /**
  21909. * List of blocks that can provide a dynamic list of uniforms
  21910. */
  21911. dynamicUniformBlocks: NodeMaterialBlock[];
  21912. /**
  21913. * List of blocks that can block the isReady function for the material
  21914. */
  21915. blockingBlocks: NodeMaterialBlock[];
  21916. /**
  21917. * Gets the list of animated inputs
  21918. */
  21919. animatedInputs: InputBlock[];
  21920. /**
  21921. * Build Id used to avoid multiple recompilations
  21922. */
  21923. buildId: number;
  21924. /** List of emitted variables */
  21925. variableNames: {
  21926. [key: string]: number;
  21927. };
  21928. /** List of emitted defines */
  21929. defineNames: {
  21930. [key: string]: number;
  21931. };
  21932. /** Should emit comments? */
  21933. emitComments: boolean;
  21934. /** Emit build activity */
  21935. verbose: boolean;
  21936. /** Gets or sets the hosting scene */
  21937. scene: Scene;
  21938. /**
  21939. * Gets the compilation hints emitted at compilation time
  21940. */
  21941. hints: {
  21942. needWorldViewMatrix: boolean;
  21943. needWorldViewProjectionMatrix: boolean;
  21944. needAlphaBlending: boolean;
  21945. needAlphaTesting: boolean;
  21946. };
  21947. /**
  21948. * List of compilation checks
  21949. */
  21950. checks: {
  21951. emitVertex: boolean;
  21952. emitFragment: boolean;
  21953. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21954. };
  21955. /**
  21956. * Is vertex program allowed to be empty?
  21957. */
  21958. allowEmptyVertexProgram: boolean;
  21959. /** Creates a new shared data */
  21960. constructor();
  21961. /**
  21962. * Emits console errors and exceptions if there is a failing check
  21963. */
  21964. emitErrors(): void;
  21965. }
  21966. }
  21967. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21968. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21969. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21970. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21971. /**
  21972. * Class used to store node based material build state
  21973. */
  21974. export class NodeMaterialBuildState {
  21975. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21976. supportUniformBuffers: boolean;
  21977. /**
  21978. * Gets the list of emitted attributes
  21979. */
  21980. attributes: string[];
  21981. /**
  21982. * Gets the list of emitted uniforms
  21983. */
  21984. uniforms: string[];
  21985. /**
  21986. * Gets the list of emitted constants
  21987. */
  21988. constants: string[];
  21989. /**
  21990. * Gets the list of emitted samplers
  21991. */
  21992. samplers: string[];
  21993. /**
  21994. * Gets the list of emitted functions
  21995. */
  21996. functions: {
  21997. [key: string]: string;
  21998. };
  21999. /**
  22000. * Gets the list of emitted extensions
  22001. */
  22002. extensions: {
  22003. [key: string]: string;
  22004. };
  22005. /**
  22006. * Gets the target of the compilation state
  22007. */
  22008. target: NodeMaterialBlockTargets;
  22009. /**
  22010. * Gets the list of emitted counters
  22011. */
  22012. counters: {
  22013. [key: string]: number;
  22014. };
  22015. /**
  22016. * Shared data between multiple NodeMaterialBuildState instances
  22017. */
  22018. sharedData: NodeMaterialBuildStateSharedData;
  22019. /** @hidden */
  22020. _vertexState: NodeMaterialBuildState;
  22021. /** @hidden */
  22022. _attributeDeclaration: string;
  22023. /** @hidden */
  22024. _uniformDeclaration: string;
  22025. /** @hidden */
  22026. _constantDeclaration: string;
  22027. /** @hidden */
  22028. _samplerDeclaration: string;
  22029. /** @hidden */
  22030. _varyingTransfer: string;
  22031. /** @hidden */
  22032. _injectAtEnd: string;
  22033. private _repeatableContentAnchorIndex;
  22034. /** @hidden */
  22035. _builtCompilationString: string;
  22036. /**
  22037. * Gets the emitted compilation strings
  22038. */
  22039. compilationString: string;
  22040. /**
  22041. * Finalize the compilation strings
  22042. * @param state defines the current compilation state
  22043. */
  22044. finalize(state: NodeMaterialBuildState): void;
  22045. /** @hidden */
  22046. get _repeatableContentAnchor(): string;
  22047. /** @hidden */
  22048. _getFreeVariableName(prefix: string): string;
  22049. /** @hidden */
  22050. _getFreeDefineName(prefix: string): string;
  22051. /** @hidden */
  22052. _excludeVariableName(name: string): void;
  22053. /** @hidden */
  22054. _emit2DSampler(name: string): void;
  22055. /** @hidden */
  22056. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22057. /** @hidden */
  22058. _emitExtension(name: string, extension: string, define?: string): void;
  22059. /** @hidden */
  22060. _emitFunction(name: string, code: string, comments: string): void;
  22061. /** @hidden */
  22062. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22063. replaceStrings?: {
  22064. search: RegExp;
  22065. replace: string;
  22066. }[];
  22067. repeatKey?: string;
  22068. }): string;
  22069. /** @hidden */
  22070. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22071. repeatKey?: string;
  22072. removeAttributes?: boolean;
  22073. removeUniforms?: boolean;
  22074. removeVaryings?: boolean;
  22075. removeIfDef?: boolean;
  22076. replaceStrings?: {
  22077. search: RegExp;
  22078. replace: string;
  22079. }[];
  22080. }, storeKey?: string): void;
  22081. /** @hidden */
  22082. _registerTempVariable(name: string): boolean;
  22083. /** @hidden */
  22084. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22085. /** @hidden */
  22086. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22087. /** @hidden */
  22088. _emitFloat(value: number): string;
  22089. }
  22090. }
  22091. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22092. /**
  22093. * Helper class used to generate session unique ID
  22094. */
  22095. export class UniqueIdGenerator {
  22096. private static _UniqueIdCounter;
  22097. /**
  22098. * Gets an unique (relatively to the current scene) Id
  22099. */
  22100. static get UniqueId(): number;
  22101. }
  22102. }
  22103. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22104. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22106. import { Nullable } from "babylonjs/types";
  22107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22108. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22109. import { Effect } from "babylonjs/Materials/effect";
  22110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22111. import { Mesh } from "babylonjs/Meshes/mesh";
  22112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22113. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22114. import { Scene } from "babylonjs/scene";
  22115. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22116. /**
  22117. * Defines a block that can be used inside a node based material
  22118. */
  22119. export class NodeMaterialBlock {
  22120. private _buildId;
  22121. private _buildTarget;
  22122. private _target;
  22123. private _isFinalMerger;
  22124. private _isInput;
  22125. private _name;
  22126. protected _isUnique: boolean;
  22127. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22128. inputsAreExclusive: boolean;
  22129. /** @hidden */
  22130. _codeVariableName: string;
  22131. /** @hidden */
  22132. _inputs: NodeMaterialConnectionPoint[];
  22133. /** @hidden */
  22134. _outputs: NodeMaterialConnectionPoint[];
  22135. /** @hidden */
  22136. _preparationId: number;
  22137. /**
  22138. * Gets the name of the block
  22139. */
  22140. get name(): string;
  22141. /**
  22142. * Sets the name of the block. Will check if the name is valid.
  22143. */
  22144. set name(newName: string);
  22145. /**
  22146. * Gets or sets the unique id of the node
  22147. */
  22148. uniqueId: number;
  22149. /**
  22150. * Gets or sets the comments associated with this block
  22151. */
  22152. comments: string;
  22153. /**
  22154. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22155. */
  22156. get isUnique(): boolean;
  22157. /**
  22158. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22159. */
  22160. get isFinalMerger(): boolean;
  22161. /**
  22162. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22163. */
  22164. get isInput(): boolean;
  22165. /**
  22166. * Gets or sets the build Id
  22167. */
  22168. get buildId(): number;
  22169. set buildId(value: number);
  22170. /**
  22171. * Gets or sets the target of the block
  22172. */
  22173. get target(): NodeMaterialBlockTargets;
  22174. set target(value: NodeMaterialBlockTargets);
  22175. /**
  22176. * Gets the list of input points
  22177. */
  22178. get inputs(): NodeMaterialConnectionPoint[];
  22179. /** Gets the list of output points */
  22180. get outputs(): NodeMaterialConnectionPoint[];
  22181. /**
  22182. * Find an input by its name
  22183. * @param name defines the name of the input to look for
  22184. * @returns the input or null if not found
  22185. */
  22186. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22187. /**
  22188. * Find an output by its name
  22189. * @param name defines the name of the outputto look for
  22190. * @returns the output or null if not found
  22191. */
  22192. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22193. /**
  22194. * Creates a new NodeMaterialBlock
  22195. * @param name defines the block name
  22196. * @param target defines the target of that block (Vertex by default)
  22197. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22198. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22199. */
  22200. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22201. /**
  22202. * Initialize the block and prepare the context for build
  22203. * @param state defines the state that will be used for the build
  22204. */
  22205. initialize(state: NodeMaterialBuildState): void;
  22206. /**
  22207. * Bind data to effect. Will only be called for blocks with isBindable === true
  22208. * @param effect defines the effect to bind data to
  22209. * @param nodeMaterial defines the hosting NodeMaterial
  22210. * @param mesh defines the mesh that will be rendered
  22211. * @param subMesh defines the submesh that will be rendered
  22212. */
  22213. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22214. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22215. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22216. protected _writeFloat(value: number): string;
  22217. /**
  22218. * Gets the current class name e.g. "NodeMaterialBlock"
  22219. * @returns the class name
  22220. */
  22221. getClassName(): string;
  22222. /**
  22223. * Register a new input. Must be called inside a block constructor
  22224. * @param name defines the connection point name
  22225. * @param type defines the connection point type
  22226. * @param isOptional defines a boolean indicating that this input can be omitted
  22227. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22228. * @param point an already created connection point. If not provided, create a new one
  22229. * @returns the current block
  22230. */
  22231. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22232. /**
  22233. * Register a new output. Must be called inside a block constructor
  22234. * @param name defines the connection point name
  22235. * @param type defines the connection point type
  22236. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22237. * @param point an already created connection point. If not provided, create a new one
  22238. * @returns the current block
  22239. */
  22240. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22241. /**
  22242. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22243. * @param forOutput defines an optional connection point to check compatibility with
  22244. * @returns the first available input or null
  22245. */
  22246. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22247. /**
  22248. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22249. * @param forBlock defines an optional block to check compatibility with
  22250. * @returns the first available input or null
  22251. */
  22252. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22253. /**
  22254. * Gets the sibling of the given output
  22255. * @param current defines the current output
  22256. * @returns the next output in the list or null
  22257. */
  22258. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22259. /**
  22260. * Connect current block with another block
  22261. * @param other defines the block to connect with
  22262. * @param options define the various options to help pick the right connections
  22263. * @returns the current block
  22264. */
  22265. connectTo(other: NodeMaterialBlock, options?: {
  22266. input?: string;
  22267. output?: string;
  22268. outputSwizzle?: string;
  22269. }): this | undefined;
  22270. protected _buildBlock(state: NodeMaterialBuildState): void;
  22271. /**
  22272. * Add uniforms, samplers and uniform buffers at compilation time
  22273. * @param state defines the state to update
  22274. * @param nodeMaterial defines the node material requesting the update
  22275. * @param defines defines the material defines to update
  22276. * @param uniformBuffers defines the list of uniform buffer names
  22277. */
  22278. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22279. /**
  22280. * Add potential fallbacks if shader compilation fails
  22281. * @param mesh defines the mesh to be rendered
  22282. * @param fallbacks defines the current prioritized list of fallbacks
  22283. */
  22284. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22285. /**
  22286. * Initialize defines for shader compilation
  22287. * @param mesh defines the mesh to be rendered
  22288. * @param nodeMaterial defines the node material requesting the update
  22289. * @param defines defines the material defines to update
  22290. * @param useInstances specifies that instances should be used
  22291. */
  22292. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22293. /**
  22294. * Update defines for shader compilation
  22295. * @param mesh defines the mesh to be rendered
  22296. * @param nodeMaterial defines the node material requesting the update
  22297. * @param defines defines the material defines to update
  22298. * @param useInstances specifies that instances should be used
  22299. * @param subMesh defines which submesh to render
  22300. */
  22301. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22302. /**
  22303. * Lets the block try to connect some inputs automatically
  22304. * @param material defines the hosting NodeMaterial
  22305. */
  22306. autoConfigure(material: NodeMaterial): void;
  22307. /**
  22308. * Function called when a block is declared as repeatable content generator
  22309. * @param vertexShaderState defines the current compilation state for the vertex shader
  22310. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22311. * @param mesh defines the mesh to be rendered
  22312. * @param defines defines the material defines to update
  22313. */
  22314. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22315. /**
  22316. * Checks if the block is ready
  22317. * @param mesh defines the mesh to be rendered
  22318. * @param nodeMaterial defines the node material requesting the update
  22319. * @param defines defines the material defines to update
  22320. * @param useInstances specifies that instances should be used
  22321. * @returns true if the block is ready
  22322. */
  22323. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22324. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22325. private _processBuild;
  22326. /**
  22327. * Validates the new name for the block node.
  22328. * @param newName the new name to be given to the node.
  22329. * @returns false if the name is a reserve word, else true.
  22330. */
  22331. validateBlockName(newName: string): boolean;
  22332. /**
  22333. * Compile the current node and generate the shader code
  22334. * @param state defines the current compilation state (uniforms, samplers, current string)
  22335. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22336. * @returns true if already built
  22337. */
  22338. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22339. protected _inputRename(name: string): string;
  22340. protected _outputRename(name: string): string;
  22341. protected _dumpPropertiesCode(): string;
  22342. /** @hidden */
  22343. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22344. /** @hidden */
  22345. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22346. /**
  22347. * Clone the current block to a new identical block
  22348. * @param scene defines the hosting scene
  22349. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22350. * @returns a copy of the current block
  22351. */
  22352. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22353. /**
  22354. * Serializes this block in a JSON representation
  22355. * @returns the serialized block object
  22356. */
  22357. serialize(): any;
  22358. /** @hidden */
  22359. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22360. private _deserializePortDisplayNamesAndExposedOnFrame;
  22361. /**
  22362. * Release resources
  22363. */
  22364. dispose(): void;
  22365. }
  22366. }
  22367. declare module "babylonjs/Materials/pushMaterial" {
  22368. import { Nullable } from "babylonjs/types";
  22369. import { Scene } from "babylonjs/scene";
  22370. import { Matrix } from "babylonjs/Maths/math.vector";
  22371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22372. import { Mesh } from "babylonjs/Meshes/mesh";
  22373. import { Material } from "babylonjs/Materials/material";
  22374. import { Effect } from "babylonjs/Materials/effect";
  22375. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22376. /**
  22377. * Base class of materials working in push mode in babylon JS
  22378. * @hidden
  22379. */
  22380. export class PushMaterial extends Material {
  22381. protected _activeEffect: Effect;
  22382. protected _normalMatrix: Matrix;
  22383. constructor(name: string, scene: Scene);
  22384. getEffect(): Effect;
  22385. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22386. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22387. /**
  22388. * Binds the given world matrix to the active effect
  22389. *
  22390. * @param world the matrix to bind
  22391. */
  22392. bindOnlyWorldMatrix(world: Matrix): void;
  22393. /**
  22394. * Binds the given normal matrix to the active effect
  22395. *
  22396. * @param normalMatrix the matrix to bind
  22397. */
  22398. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22399. bind(world: Matrix, mesh?: Mesh): void;
  22400. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22401. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22402. }
  22403. }
  22404. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22406. /**
  22407. * Root class for all node material optimizers
  22408. */
  22409. export class NodeMaterialOptimizer {
  22410. /**
  22411. * Function used to optimize a NodeMaterial graph
  22412. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22413. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22414. */
  22415. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22416. }
  22417. }
  22418. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22422. import { Scene } from "babylonjs/scene";
  22423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22424. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22425. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22426. /**
  22427. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22428. */
  22429. export class TransformBlock extends NodeMaterialBlock {
  22430. /**
  22431. * Defines the value to use to complement W value to transform it to a Vector4
  22432. */
  22433. complementW: number;
  22434. /**
  22435. * Defines the value to use to complement z value to transform it to a Vector4
  22436. */
  22437. complementZ: number;
  22438. /**
  22439. * Creates a new TransformBlock
  22440. * @param name defines the block name
  22441. */
  22442. constructor(name: string);
  22443. /**
  22444. * Gets the current class name
  22445. * @returns the class name
  22446. */
  22447. getClassName(): string;
  22448. /**
  22449. * Gets the vector input
  22450. */
  22451. get vector(): NodeMaterialConnectionPoint;
  22452. /**
  22453. * Gets the output component
  22454. */
  22455. get output(): NodeMaterialConnectionPoint;
  22456. /**
  22457. * Gets the xyz output component
  22458. */
  22459. get xyz(): NodeMaterialConnectionPoint;
  22460. /**
  22461. * Gets the matrix transform input
  22462. */
  22463. get transform(): NodeMaterialConnectionPoint;
  22464. protected _buildBlock(state: NodeMaterialBuildState): this;
  22465. /**
  22466. * Update defines for shader compilation
  22467. * @param mesh defines the mesh to be rendered
  22468. * @param nodeMaterial defines the node material requesting the update
  22469. * @param defines defines the material defines to update
  22470. * @param useInstances specifies that instances should be used
  22471. * @param subMesh defines which submesh to render
  22472. */
  22473. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22474. serialize(): any;
  22475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22476. protected _dumpPropertiesCode(): string;
  22477. }
  22478. }
  22479. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22483. /**
  22484. * Block used to output the vertex position
  22485. */
  22486. export class VertexOutputBlock extends NodeMaterialBlock {
  22487. /**
  22488. * Creates a new VertexOutputBlock
  22489. * @param name defines the block name
  22490. */
  22491. constructor(name: string);
  22492. /**
  22493. * Gets the current class name
  22494. * @returns the class name
  22495. */
  22496. getClassName(): string;
  22497. /**
  22498. * Gets the vector input component
  22499. */
  22500. get vector(): NodeMaterialConnectionPoint;
  22501. protected _buildBlock(state: NodeMaterialBuildState): this;
  22502. }
  22503. }
  22504. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22508. /**
  22509. * Block used to output the final color
  22510. */
  22511. export class FragmentOutputBlock extends NodeMaterialBlock {
  22512. /**
  22513. * Create a new FragmentOutputBlock
  22514. * @param name defines the block name
  22515. */
  22516. constructor(name: string);
  22517. /**
  22518. * Gets the current class name
  22519. * @returns the class name
  22520. */
  22521. getClassName(): string;
  22522. /**
  22523. * Gets the rgba input component
  22524. */
  22525. get rgba(): NodeMaterialConnectionPoint;
  22526. /**
  22527. * Gets the rgb input component
  22528. */
  22529. get rgb(): NodeMaterialConnectionPoint;
  22530. /**
  22531. * Gets the a input component
  22532. */
  22533. get a(): NodeMaterialConnectionPoint;
  22534. protected _buildBlock(state: NodeMaterialBuildState): this;
  22535. }
  22536. }
  22537. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22541. /**
  22542. * Block used for the particle ramp gradient section
  22543. */
  22544. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22545. /**
  22546. * Create a new ParticleRampGradientBlock
  22547. * @param name defines the block name
  22548. */
  22549. constructor(name: string);
  22550. /**
  22551. * Gets the current class name
  22552. * @returns the class name
  22553. */
  22554. getClassName(): string;
  22555. /**
  22556. * Gets the color input component
  22557. */
  22558. get color(): NodeMaterialConnectionPoint;
  22559. /**
  22560. * Gets the rampColor output component
  22561. */
  22562. get rampColor(): NodeMaterialConnectionPoint;
  22563. /**
  22564. * Initialize the block and prepare the context for build
  22565. * @param state defines the state that will be used for the build
  22566. */
  22567. initialize(state: NodeMaterialBuildState): void;
  22568. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22569. }
  22570. }
  22571. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22575. /**
  22576. * Block used for the particle blend multiply section
  22577. */
  22578. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22579. /**
  22580. * Create a new ParticleBlendMultiplyBlock
  22581. * @param name defines the block name
  22582. */
  22583. constructor(name: string);
  22584. /**
  22585. * Gets the current class name
  22586. * @returns the class name
  22587. */
  22588. getClassName(): string;
  22589. /**
  22590. * Gets the color input component
  22591. */
  22592. get color(): NodeMaterialConnectionPoint;
  22593. /**
  22594. * Gets the alphaTexture input component
  22595. */
  22596. get alphaTexture(): NodeMaterialConnectionPoint;
  22597. /**
  22598. * Gets the alphaColor input component
  22599. */
  22600. get alphaColor(): NodeMaterialConnectionPoint;
  22601. /**
  22602. * Gets the blendColor output component
  22603. */
  22604. get blendColor(): NodeMaterialConnectionPoint;
  22605. /**
  22606. * Initialize the block and prepare the context for build
  22607. * @param state defines the state that will be used for the build
  22608. */
  22609. initialize(state: NodeMaterialBuildState): void;
  22610. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22611. }
  22612. }
  22613. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22614. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22615. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22616. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22617. /**
  22618. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22619. */
  22620. export class VectorMergerBlock extends NodeMaterialBlock {
  22621. /**
  22622. * Create a new VectorMergerBlock
  22623. * @param name defines the block name
  22624. */
  22625. constructor(name: string);
  22626. /**
  22627. * Gets the current class name
  22628. * @returns the class name
  22629. */
  22630. getClassName(): string;
  22631. /**
  22632. * Gets the xyz component (input)
  22633. */
  22634. get xyzIn(): NodeMaterialConnectionPoint;
  22635. /**
  22636. * Gets the xy component (input)
  22637. */
  22638. get xyIn(): NodeMaterialConnectionPoint;
  22639. /**
  22640. * Gets the x component (input)
  22641. */
  22642. get x(): NodeMaterialConnectionPoint;
  22643. /**
  22644. * Gets the y component (input)
  22645. */
  22646. get y(): NodeMaterialConnectionPoint;
  22647. /**
  22648. * Gets the z component (input)
  22649. */
  22650. get z(): NodeMaterialConnectionPoint;
  22651. /**
  22652. * Gets the w component (input)
  22653. */
  22654. get w(): NodeMaterialConnectionPoint;
  22655. /**
  22656. * Gets the xyzw component (output)
  22657. */
  22658. get xyzw(): NodeMaterialConnectionPoint;
  22659. /**
  22660. * Gets the xyz component (output)
  22661. */
  22662. get xyzOut(): NodeMaterialConnectionPoint;
  22663. /**
  22664. * Gets the xy component (output)
  22665. */
  22666. get xyOut(): NodeMaterialConnectionPoint;
  22667. /**
  22668. * Gets the xy component (output)
  22669. * @deprecated Please use xyOut instead.
  22670. */
  22671. get xy(): NodeMaterialConnectionPoint;
  22672. /**
  22673. * Gets the xyz component (output)
  22674. * @deprecated Please use xyzOut instead.
  22675. */
  22676. get xyz(): NodeMaterialConnectionPoint;
  22677. protected _buildBlock(state: NodeMaterialBuildState): this;
  22678. }
  22679. }
  22680. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22684. import { Vector2 } from "babylonjs/Maths/math.vector";
  22685. import { Scene } from "babylonjs/scene";
  22686. /**
  22687. * Block used to remap a float from a range to a new one
  22688. */
  22689. export class RemapBlock extends NodeMaterialBlock {
  22690. /**
  22691. * Gets or sets the source range
  22692. */
  22693. sourceRange: Vector2;
  22694. /**
  22695. * Gets or sets the target range
  22696. */
  22697. targetRange: Vector2;
  22698. /**
  22699. * Creates a new RemapBlock
  22700. * @param name defines the block name
  22701. */
  22702. constructor(name: string);
  22703. /**
  22704. * Gets the current class name
  22705. * @returns the class name
  22706. */
  22707. getClassName(): string;
  22708. /**
  22709. * Gets the input component
  22710. */
  22711. get input(): NodeMaterialConnectionPoint;
  22712. /**
  22713. * Gets the source min input component
  22714. */
  22715. get sourceMin(): NodeMaterialConnectionPoint;
  22716. /**
  22717. * Gets the source max input component
  22718. */
  22719. get sourceMax(): NodeMaterialConnectionPoint;
  22720. /**
  22721. * Gets the target min input component
  22722. */
  22723. get targetMin(): NodeMaterialConnectionPoint;
  22724. /**
  22725. * Gets the target max input component
  22726. */
  22727. get targetMax(): NodeMaterialConnectionPoint;
  22728. /**
  22729. * Gets the output component
  22730. */
  22731. get output(): NodeMaterialConnectionPoint;
  22732. protected _buildBlock(state: NodeMaterialBuildState): this;
  22733. protected _dumpPropertiesCode(): string;
  22734. serialize(): any;
  22735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22736. }
  22737. }
  22738. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22742. /**
  22743. * Block used to multiply 2 values
  22744. */
  22745. export class MultiplyBlock extends NodeMaterialBlock {
  22746. /**
  22747. * Creates a new MultiplyBlock
  22748. * @param name defines the block name
  22749. */
  22750. constructor(name: string);
  22751. /**
  22752. * Gets the current class name
  22753. * @returns the class name
  22754. */
  22755. getClassName(): string;
  22756. /**
  22757. * Gets the left operand input component
  22758. */
  22759. get left(): NodeMaterialConnectionPoint;
  22760. /**
  22761. * Gets the right operand input component
  22762. */
  22763. get right(): NodeMaterialConnectionPoint;
  22764. /**
  22765. * Gets the output component
  22766. */
  22767. get output(): NodeMaterialConnectionPoint;
  22768. protected _buildBlock(state: NodeMaterialBuildState): this;
  22769. }
  22770. }
  22771. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22775. /**
  22776. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22777. */
  22778. export class ColorSplitterBlock extends NodeMaterialBlock {
  22779. /**
  22780. * Create a new ColorSplitterBlock
  22781. * @param name defines the block name
  22782. */
  22783. constructor(name: string);
  22784. /**
  22785. * Gets the current class name
  22786. * @returns the class name
  22787. */
  22788. getClassName(): string;
  22789. /**
  22790. * Gets the rgba component (input)
  22791. */
  22792. get rgba(): NodeMaterialConnectionPoint;
  22793. /**
  22794. * Gets the rgb component (input)
  22795. */
  22796. get rgbIn(): NodeMaterialConnectionPoint;
  22797. /**
  22798. * Gets the rgb component (output)
  22799. */
  22800. get rgbOut(): NodeMaterialConnectionPoint;
  22801. /**
  22802. * Gets the r component (output)
  22803. */
  22804. get r(): NodeMaterialConnectionPoint;
  22805. /**
  22806. * Gets the g component (output)
  22807. */
  22808. get g(): NodeMaterialConnectionPoint;
  22809. /**
  22810. * Gets the b component (output)
  22811. */
  22812. get b(): NodeMaterialConnectionPoint;
  22813. /**
  22814. * Gets the a component (output)
  22815. */
  22816. get a(): NodeMaterialConnectionPoint;
  22817. protected _inputRename(name: string): string;
  22818. protected _outputRename(name: string): string;
  22819. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22820. }
  22821. }
  22822. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22824. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22825. import { Scene } from "babylonjs/scene";
  22826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22827. import { Matrix } from "babylonjs/Maths/math.vector";
  22828. import { Mesh } from "babylonjs/Meshes/mesh";
  22829. import { Engine } from "babylonjs/Engines/engine";
  22830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22831. import { Observable } from "babylonjs/Misc/observable";
  22832. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22833. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22834. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22835. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22836. import { Nullable } from "babylonjs/types";
  22837. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22838. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22839. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22840. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22841. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22842. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22843. import { Effect } from "babylonjs/Materials/effect";
  22844. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22845. import { Camera } from "babylonjs/Cameras/camera";
  22846. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22847. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22848. /**
  22849. * Interface used to configure the node material editor
  22850. */
  22851. export interface INodeMaterialEditorOptions {
  22852. /** Define the URl to load node editor script */
  22853. editorURL?: string;
  22854. }
  22855. /** @hidden */
  22856. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22857. NORMAL: boolean;
  22858. TANGENT: boolean;
  22859. UV1: boolean;
  22860. /** BONES */
  22861. NUM_BONE_INFLUENCERS: number;
  22862. BonesPerMesh: number;
  22863. BONETEXTURE: boolean;
  22864. /** MORPH TARGETS */
  22865. MORPHTARGETS: boolean;
  22866. MORPHTARGETS_NORMAL: boolean;
  22867. MORPHTARGETS_TANGENT: boolean;
  22868. MORPHTARGETS_UV: boolean;
  22869. NUM_MORPH_INFLUENCERS: number;
  22870. /** IMAGE PROCESSING */
  22871. IMAGEPROCESSING: boolean;
  22872. VIGNETTE: boolean;
  22873. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22874. VIGNETTEBLENDMODEOPAQUE: boolean;
  22875. TONEMAPPING: boolean;
  22876. TONEMAPPING_ACES: boolean;
  22877. CONTRAST: boolean;
  22878. EXPOSURE: boolean;
  22879. COLORCURVES: boolean;
  22880. COLORGRADING: boolean;
  22881. COLORGRADING3D: boolean;
  22882. SAMPLER3DGREENDEPTH: boolean;
  22883. SAMPLER3DBGRMAP: boolean;
  22884. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22885. /** MISC. */
  22886. BUMPDIRECTUV: number;
  22887. constructor();
  22888. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22889. }
  22890. /**
  22891. * Class used to configure NodeMaterial
  22892. */
  22893. export interface INodeMaterialOptions {
  22894. /**
  22895. * Defines if blocks should emit comments
  22896. */
  22897. emitComments: boolean;
  22898. }
  22899. /**
  22900. * Class used to create a node based material built by assembling shader blocks
  22901. */
  22902. export class NodeMaterial extends PushMaterial {
  22903. private static _BuildIdGenerator;
  22904. private _options;
  22905. private _vertexCompilationState;
  22906. private _fragmentCompilationState;
  22907. private _sharedData;
  22908. private _buildId;
  22909. private _buildWasSuccessful;
  22910. private _cachedWorldViewMatrix;
  22911. private _cachedWorldViewProjectionMatrix;
  22912. private _optimizers;
  22913. private _animationFrame;
  22914. /** Define the Url to load node editor script */
  22915. static EditorURL: string;
  22916. /** Define the Url to load snippets */
  22917. static SnippetUrl: string;
  22918. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22919. static IgnoreTexturesAtLoadTime: boolean;
  22920. private BJSNODEMATERIALEDITOR;
  22921. /** Get the inspector from bundle or global */
  22922. private _getGlobalNodeMaterialEditor;
  22923. /**
  22924. * Snippet ID if the material was created from the snippet server
  22925. */
  22926. snippetId: string;
  22927. /**
  22928. * Gets or sets data used by visual editor
  22929. * @see https://nme.babylonjs.com
  22930. */
  22931. editorData: any;
  22932. /**
  22933. * 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)
  22934. */
  22935. ignoreAlpha: boolean;
  22936. /**
  22937. * Defines the maximum number of lights that can be used in the material
  22938. */
  22939. maxSimultaneousLights: number;
  22940. /**
  22941. * Observable raised when the material is built
  22942. */
  22943. onBuildObservable: Observable<NodeMaterial>;
  22944. /**
  22945. * Gets or sets the root nodes of the material vertex shader
  22946. */
  22947. _vertexOutputNodes: NodeMaterialBlock[];
  22948. /**
  22949. * Gets or sets the root nodes of the material fragment (pixel) shader
  22950. */
  22951. _fragmentOutputNodes: NodeMaterialBlock[];
  22952. /** Gets or sets options to control the node material overall behavior */
  22953. get options(): INodeMaterialOptions;
  22954. set options(options: INodeMaterialOptions);
  22955. /**
  22956. * Default configuration related to image processing available in the standard Material.
  22957. */
  22958. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22959. /**
  22960. * Gets the image processing configuration used either in this material.
  22961. */
  22962. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22963. /**
  22964. * Sets the Default image processing configuration used either in the this material.
  22965. *
  22966. * If sets to null, the scene one is in use.
  22967. */
  22968. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22969. /**
  22970. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22971. */
  22972. attachedBlocks: NodeMaterialBlock[];
  22973. /**
  22974. * Specifies the mode of the node material
  22975. * @hidden
  22976. */
  22977. _mode: NodeMaterialModes;
  22978. /**
  22979. * Gets the mode property
  22980. */
  22981. get mode(): NodeMaterialModes;
  22982. /**
  22983. * Create a new node based material
  22984. * @param name defines the material name
  22985. * @param scene defines the hosting scene
  22986. * @param options defines creation option
  22987. */
  22988. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22989. /**
  22990. * Gets the current class name of the material e.g. "NodeMaterial"
  22991. * @returns the class name
  22992. */
  22993. getClassName(): string;
  22994. /**
  22995. * Keep track of the image processing observer to allow dispose and replace.
  22996. */
  22997. private _imageProcessingObserver;
  22998. /**
  22999. * Attaches a new image processing configuration to the Standard Material.
  23000. * @param configuration
  23001. */
  23002. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23003. /**
  23004. * Get a block by its name
  23005. * @param name defines the name of the block to retrieve
  23006. * @returns the required block or null if not found
  23007. */
  23008. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23009. /**
  23010. * Get a block by its name
  23011. * @param predicate defines the predicate used to find the good candidate
  23012. * @returns the required block or null if not found
  23013. */
  23014. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23015. /**
  23016. * Get an input block by its name
  23017. * @param predicate defines the predicate used to find the good candidate
  23018. * @returns the required input block or null if not found
  23019. */
  23020. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23021. /**
  23022. * Gets the list of input blocks attached to this material
  23023. * @returns an array of InputBlocks
  23024. */
  23025. getInputBlocks(): InputBlock[];
  23026. /**
  23027. * Adds a new optimizer to the list of optimizers
  23028. * @param optimizer defines the optimizers to add
  23029. * @returns the current material
  23030. */
  23031. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23032. /**
  23033. * Remove an optimizer from the list of optimizers
  23034. * @param optimizer defines the optimizers to remove
  23035. * @returns the current material
  23036. */
  23037. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23038. /**
  23039. * Add a new block to the list of output nodes
  23040. * @param node defines the node to add
  23041. * @returns the current material
  23042. */
  23043. addOutputNode(node: NodeMaterialBlock): this;
  23044. /**
  23045. * Remove a block from the list of root nodes
  23046. * @param node defines the node to remove
  23047. * @returns the current material
  23048. */
  23049. removeOutputNode(node: NodeMaterialBlock): this;
  23050. private _addVertexOutputNode;
  23051. private _removeVertexOutputNode;
  23052. private _addFragmentOutputNode;
  23053. private _removeFragmentOutputNode;
  23054. /**
  23055. * Specifies if the material will require alpha blending
  23056. * @returns a boolean specifying if alpha blending is needed
  23057. */
  23058. needAlphaBlending(): boolean;
  23059. /**
  23060. * Specifies if this material should be rendered in alpha test mode
  23061. * @returns a boolean specifying if an alpha test is needed.
  23062. */
  23063. needAlphaTesting(): boolean;
  23064. private _initializeBlock;
  23065. private _resetDualBlocks;
  23066. /**
  23067. * Remove a block from the current node material
  23068. * @param block defines the block to remove
  23069. */
  23070. removeBlock(block: NodeMaterialBlock): void;
  23071. /**
  23072. * Build the material and generates the inner effect
  23073. * @param verbose defines if the build should log activity
  23074. */
  23075. build(verbose?: boolean): void;
  23076. /**
  23077. * Runs an otpimization phase to try to improve the shader code
  23078. */
  23079. optimize(): void;
  23080. private _prepareDefinesForAttributes;
  23081. /**
  23082. * Create a post process from the material
  23083. * @param camera The camera to apply the render pass to.
  23084. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23086. * @param engine The engine which the post process will be applied. (default: current engine)
  23087. * @param reusable If the post process can be reused on the same frame. (default: false)
  23088. * @param textureType Type of textures used when performing the post process. (default: 0)
  23089. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23090. * @returns the post process created
  23091. */
  23092. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23093. /**
  23094. * Create the post process effect from the material
  23095. * @param postProcess The post process to create the effect for
  23096. */
  23097. createEffectForPostProcess(postProcess: PostProcess): void;
  23098. private _createEffectOrPostProcess;
  23099. private _createEffectForParticles;
  23100. /**
  23101. * Create the effect to be used as the custom effect for a particle system
  23102. * @param particleSystem Particle system to create the effect for
  23103. * @param onCompiled defines a function to call when the effect creation is successful
  23104. * @param onError defines a function to call when the effect creation has failed
  23105. */
  23106. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23107. private _processDefines;
  23108. /**
  23109. * Get if the submesh is ready to be used and all its information available.
  23110. * Child classes can use it to update shaders
  23111. * @param mesh defines the mesh to check
  23112. * @param subMesh defines which submesh to check
  23113. * @param useInstances specifies that instances should be used
  23114. * @returns a boolean indicating that the submesh is ready or not
  23115. */
  23116. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23117. /**
  23118. * Get a string representing the shaders built by the current node graph
  23119. */
  23120. get compiledShaders(): string;
  23121. /**
  23122. * Binds the world matrix to the material
  23123. * @param world defines the world transformation matrix
  23124. */
  23125. bindOnlyWorldMatrix(world: Matrix): void;
  23126. /**
  23127. * Binds the submesh to this material by preparing the effect and shader to draw
  23128. * @param world defines the world transformation matrix
  23129. * @param mesh defines the mesh containing the submesh
  23130. * @param subMesh defines the submesh to bind the material to
  23131. */
  23132. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23133. /**
  23134. * Gets the active textures from the material
  23135. * @returns an array of textures
  23136. */
  23137. getActiveTextures(): BaseTexture[];
  23138. /**
  23139. * Gets the list of texture blocks
  23140. * @returns an array of texture blocks
  23141. */
  23142. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23143. /**
  23144. * Specifies if the material uses a texture
  23145. * @param texture defines the texture to check against the material
  23146. * @returns a boolean specifying if the material uses the texture
  23147. */
  23148. hasTexture(texture: BaseTexture): boolean;
  23149. /**
  23150. * Disposes the material
  23151. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23152. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23153. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23154. */
  23155. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23156. /** Creates the node editor window. */
  23157. private _createNodeEditor;
  23158. /**
  23159. * Launch the node material editor
  23160. * @param config Define the configuration of the editor
  23161. * @return a promise fulfilled when the node editor is visible
  23162. */
  23163. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23164. /**
  23165. * Clear the current material
  23166. */
  23167. clear(): void;
  23168. /**
  23169. * Clear the current material and set it to a default state
  23170. */
  23171. setToDefault(): void;
  23172. /**
  23173. * Clear the current material and set it to a default state for post process
  23174. */
  23175. setToDefaultPostProcess(): void;
  23176. /**
  23177. * Clear the current material and set it to a default state for particle
  23178. */
  23179. setToDefaultParticle(): void;
  23180. /**
  23181. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23182. * @param url defines the url to load from
  23183. * @returns a promise that will fullfil when the material is fully loaded
  23184. */
  23185. loadAsync(url: string): Promise<void>;
  23186. private _gatherBlocks;
  23187. /**
  23188. * Generate a string containing the code declaration required to create an equivalent of this material
  23189. * @returns a string
  23190. */
  23191. generateCode(): string;
  23192. /**
  23193. * Serializes this material in a JSON representation
  23194. * @returns the serialized material object
  23195. */
  23196. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23197. private _restoreConnections;
  23198. /**
  23199. * Clear the current graph and load a new one from a serialization object
  23200. * @param source defines the JSON representation of the material
  23201. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23202. * @param merge defines whether or not the source must be merged or replace the current content
  23203. */
  23204. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23205. /**
  23206. * Makes a duplicate of the current material.
  23207. * @param name - name to use for the new material.
  23208. */
  23209. clone(name: string): NodeMaterial;
  23210. /**
  23211. * Creates a node material from parsed material data
  23212. * @param source defines the JSON representation of the material
  23213. * @param scene defines the hosting scene
  23214. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23215. * @returns a new node material
  23216. */
  23217. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23218. /**
  23219. * Creates a node material from a snippet saved in a remote file
  23220. * @param name defines the name of the material to create
  23221. * @param url defines the url to load from
  23222. * @param scene defines the hosting scene
  23223. * @returns a promise that will resolve to the new node material
  23224. */
  23225. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23226. /**
  23227. * Creates a node material from a snippet saved by the node material editor
  23228. * @param snippetId defines the snippet to load
  23229. * @param scene defines the hosting scene
  23230. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23231. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23232. * @returns a promise that will resolve to the new node material
  23233. */
  23234. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23235. /**
  23236. * Creates a new node material set to default basic configuration
  23237. * @param name defines the name of the material
  23238. * @param scene defines the hosting scene
  23239. * @returns a new NodeMaterial
  23240. */
  23241. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23242. }
  23243. }
  23244. declare module "babylonjs/PostProcesses/postProcess" {
  23245. import { Nullable } from "babylonjs/types";
  23246. import { SmartArray } from "babylonjs/Misc/smartArray";
  23247. import { Observable } from "babylonjs/Misc/observable";
  23248. import { Vector2 } from "babylonjs/Maths/math.vector";
  23249. import { Camera } from "babylonjs/Cameras/camera";
  23250. import { Effect } from "babylonjs/Materials/effect";
  23251. import "babylonjs/Shaders/postprocess.vertex";
  23252. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23253. import { Engine } from "babylonjs/Engines/engine";
  23254. import { Color4 } from "babylonjs/Maths/math.color";
  23255. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23256. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23257. import { Scene } from "babylonjs/scene";
  23258. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23259. /**
  23260. * Size options for a post process
  23261. */
  23262. export type PostProcessOptions = {
  23263. width: number;
  23264. height: number;
  23265. };
  23266. /**
  23267. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23268. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23269. */
  23270. export class PostProcess {
  23271. /** Name of the PostProcess. */
  23272. name: string;
  23273. /**
  23274. * Gets or sets the unique id of the post process
  23275. */
  23276. uniqueId: number;
  23277. /**
  23278. * Width of the texture to apply the post process on
  23279. */
  23280. width: number;
  23281. /**
  23282. * Height of the texture to apply the post process on
  23283. */
  23284. height: number;
  23285. /**
  23286. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23287. */
  23288. nodeMaterialSource: Nullable<NodeMaterial>;
  23289. /**
  23290. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23291. * @hidden
  23292. */
  23293. _outputTexture: Nullable<InternalTexture>;
  23294. /**
  23295. * Sampling mode used by the shader
  23296. * See https://doc.babylonjs.com/classes/3.1/texture
  23297. */
  23298. renderTargetSamplingMode: number;
  23299. /**
  23300. * Clear color to use when screen clearing
  23301. */
  23302. clearColor: Color4;
  23303. /**
  23304. * If the buffer needs to be cleared before applying the post process. (default: true)
  23305. * Should be set to false if shader will overwrite all previous pixels.
  23306. */
  23307. autoClear: boolean;
  23308. /**
  23309. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23310. */
  23311. alphaMode: number;
  23312. /**
  23313. * Sets the setAlphaBlendConstants of the babylon engine
  23314. */
  23315. alphaConstants: Color4;
  23316. /**
  23317. * Animations to be used for the post processing
  23318. */
  23319. animations: import("babylonjs/Animations/animation").Animation[];
  23320. /**
  23321. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23322. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23323. */
  23324. enablePixelPerfectMode: boolean;
  23325. /**
  23326. * Force the postprocess to be applied without taking in account viewport
  23327. */
  23328. forceFullscreenViewport: boolean;
  23329. /**
  23330. * List of inspectable custom properties (used by the Inspector)
  23331. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23332. */
  23333. inspectableCustomProperties: IInspectable[];
  23334. /**
  23335. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23336. *
  23337. * | Value | Type | Description |
  23338. * | ----- | ----------------------------------- | ----------- |
  23339. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23340. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23341. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23342. *
  23343. */
  23344. scaleMode: number;
  23345. /**
  23346. * Force textures to be a power of two (default: false)
  23347. */
  23348. alwaysForcePOT: boolean;
  23349. private _samples;
  23350. /**
  23351. * Number of sample textures (default: 1)
  23352. */
  23353. get samples(): number;
  23354. set samples(n: number);
  23355. /**
  23356. * Modify the scale of the post process to be the same as the viewport (default: false)
  23357. */
  23358. adaptScaleToCurrentViewport: boolean;
  23359. private _camera;
  23360. protected _scene: Scene;
  23361. private _engine;
  23362. private _options;
  23363. private _reusable;
  23364. private _textureType;
  23365. private _textureFormat;
  23366. /**
  23367. * Smart array of input and output textures for the post process.
  23368. * @hidden
  23369. */
  23370. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23371. /**
  23372. * The index in _textures that corresponds to the output texture.
  23373. * @hidden
  23374. */
  23375. _currentRenderTextureInd: number;
  23376. private _effect;
  23377. private _samplers;
  23378. private _fragmentUrl;
  23379. private _vertexUrl;
  23380. private _parameters;
  23381. private _scaleRatio;
  23382. protected _indexParameters: any;
  23383. private _shareOutputWithPostProcess;
  23384. private _texelSize;
  23385. private _forcedOutputTexture;
  23386. /**
  23387. * Returns the fragment url or shader name used in the post process.
  23388. * @returns the fragment url or name in the shader store.
  23389. */
  23390. getEffectName(): string;
  23391. /**
  23392. * An event triggered when the postprocess is activated.
  23393. */
  23394. onActivateObservable: Observable<Camera>;
  23395. private _onActivateObserver;
  23396. /**
  23397. * A function that is added to the onActivateObservable
  23398. */
  23399. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23400. /**
  23401. * An event triggered when the postprocess changes its size.
  23402. */
  23403. onSizeChangedObservable: Observable<PostProcess>;
  23404. private _onSizeChangedObserver;
  23405. /**
  23406. * A function that is added to the onSizeChangedObservable
  23407. */
  23408. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23409. /**
  23410. * An event triggered when the postprocess applies its effect.
  23411. */
  23412. onApplyObservable: Observable<Effect>;
  23413. private _onApplyObserver;
  23414. /**
  23415. * A function that is added to the onApplyObservable
  23416. */
  23417. set onApply(callback: (effect: Effect) => void);
  23418. /**
  23419. * An event triggered before rendering the postprocess
  23420. */
  23421. onBeforeRenderObservable: Observable<Effect>;
  23422. private _onBeforeRenderObserver;
  23423. /**
  23424. * A function that is added to the onBeforeRenderObservable
  23425. */
  23426. set onBeforeRender(callback: (effect: Effect) => void);
  23427. /**
  23428. * An event triggered after rendering the postprocess
  23429. */
  23430. onAfterRenderObservable: Observable<Effect>;
  23431. private _onAfterRenderObserver;
  23432. /**
  23433. * A function that is added to the onAfterRenderObservable
  23434. */
  23435. set onAfterRender(callback: (efect: Effect) => void);
  23436. /**
  23437. * 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
  23438. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23439. */
  23440. get inputTexture(): InternalTexture;
  23441. set inputTexture(value: InternalTexture);
  23442. /**
  23443. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23444. * the only way to unset it is to use this function to restore its internal state
  23445. */
  23446. restoreDefaultInputTexture(): void;
  23447. /**
  23448. * Gets the camera which post process is applied to.
  23449. * @returns The camera the post process is applied to.
  23450. */
  23451. getCamera(): Camera;
  23452. /**
  23453. * Gets the texel size of the postprocess.
  23454. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23455. */
  23456. get texelSize(): Vector2;
  23457. /**
  23458. * Creates a new instance PostProcess
  23459. * @param name The name of the PostProcess.
  23460. * @param fragmentUrl The url of the fragment shader to be used.
  23461. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23462. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23463. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23464. * @param camera The camera to apply the render pass to.
  23465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23466. * @param engine The engine which the post process will be applied. (default: current engine)
  23467. * @param reusable If the post process can be reused on the same frame. (default: false)
  23468. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23469. * @param textureType Type of textures used when performing the post process. (default: 0)
  23470. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23471. * @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
  23472. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23473. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23474. */
  23475. constructor(
  23476. /** Name of the PostProcess. */
  23477. 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);
  23478. /**
  23479. * Gets a string idenfifying the name of the class
  23480. * @returns "PostProcess" string
  23481. */
  23482. getClassName(): string;
  23483. /**
  23484. * Gets the engine which this post process belongs to.
  23485. * @returns The engine the post process was enabled with.
  23486. */
  23487. getEngine(): Engine;
  23488. /**
  23489. * The effect that is created when initializing the post process.
  23490. * @returns The created effect corresponding the the postprocess.
  23491. */
  23492. getEffect(): Effect;
  23493. /**
  23494. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23495. * @param postProcess The post process to share the output with.
  23496. * @returns This post process.
  23497. */
  23498. shareOutputWith(postProcess: PostProcess): PostProcess;
  23499. /**
  23500. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23501. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23502. */
  23503. useOwnOutput(): void;
  23504. /**
  23505. * Updates the effect with the current post process compile time values and recompiles the shader.
  23506. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23507. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23508. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23509. * @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
  23510. * @param onCompiled Called when the shader has been compiled.
  23511. * @param onError Called if there is an error when compiling a shader.
  23512. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23513. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23514. */
  23515. 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;
  23516. /**
  23517. * The post process is reusable if it can be used multiple times within one frame.
  23518. * @returns If the post process is reusable
  23519. */
  23520. isReusable(): boolean;
  23521. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23522. markTextureDirty(): void;
  23523. /**
  23524. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23525. * 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.
  23526. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23527. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23528. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23529. * @returns The target texture that was bound to be written to.
  23530. */
  23531. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23532. /**
  23533. * If the post process is supported.
  23534. */
  23535. get isSupported(): boolean;
  23536. /**
  23537. * The aspect ratio of the output texture.
  23538. */
  23539. get aspectRatio(): number;
  23540. /**
  23541. * Get a value indicating if the post-process is ready to be used
  23542. * @returns true if the post-process is ready (shader is compiled)
  23543. */
  23544. isReady(): boolean;
  23545. /**
  23546. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23547. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23548. */
  23549. apply(): Nullable<Effect>;
  23550. private _disposeTextures;
  23551. /**
  23552. * Disposes the post process.
  23553. * @param camera The camera to dispose the post process on.
  23554. */
  23555. dispose(camera?: Camera): void;
  23556. }
  23557. }
  23558. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23559. /** @hidden */
  23560. export var kernelBlurVaryingDeclaration: {
  23561. name: string;
  23562. shader: string;
  23563. };
  23564. }
  23565. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23566. /** @hidden */
  23567. export var kernelBlurFragment: {
  23568. name: string;
  23569. shader: string;
  23570. };
  23571. }
  23572. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23573. /** @hidden */
  23574. export var kernelBlurFragment2: {
  23575. name: string;
  23576. shader: string;
  23577. };
  23578. }
  23579. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23580. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23581. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23582. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23583. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23584. /** @hidden */
  23585. export var kernelBlurPixelShader: {
  23586. name: string;
  23587. shader: string;
  23588. };
  23589. }
  23590. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23591. /** @hidden */
  23592. export var kernelBlurVertex: {
  23593. name: string;
  23594. shader: string;
  23595. };
  23596. }
  23597. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23598. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23599. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23600. /** @hidden */
  23601. export var kernelBlurVertexShader: {
  23602. name: string;
  23603. shader: string;
  23604. };
  23605. }
  23606. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23607. import { Vector2 } from "babylonjs/Maths/math.vector";
  23608. import { Nullable } from "babylonjs/types";
  23609. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23610. import { Camera } from "babylonjs/Cameras/camera";
  23611. import { Effect } from "babylonjs/Materials/effect";
  23612. import { Engine } from "babylonjs/Engines/engine";
  23613. import "babylonjs/Shaders/kernelBlur.fragment";
  23614. import "babylonjs/Shaders/kernelBlur.vertex";
  23615. /**
  23616. * The Blur Post Process which blurs an image based on a kernel and direction.
  23617. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23618. */
  23619. export class BlurPostProcess extends PostProcess {
  23620. /** The direction in which to blur the image. */
  23621. direction: Vector2;
  23622. private blockCompilation;
  23623. protected _kernel: number;
  23624. protected _idealKernel: number;
  23625. protected _packedFloat: boolean;
  23626. private _staticDefines;
  23627. /**
  23628. * Sets the length in pixels of the blur sample region
  23629. */
  23630. set kernel(v: number);
  23631. /**
  23632. * Gets the length in pixels of the blur sample region
  23633. */
  23634. get kernel(): number;
  23635. /**
  23636. * Sets wether or not the blur needs to unpack/repack floats
  23637. */
  23638. set packedFloat(v: boolean);
  23639. /**
  23640. * Gets wether or not the blur is unpacking/repacking floats
  23641. */
  23642. get packedFloat(): boolean;
  23643. /**
  23644. * Creates a new instance BlurPostProcess
  23645. * @param name The name of the effect.
  23646. * @param direction The direction in which to blur the image.
  23647. * @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.
  23648. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23649. * @param camera The camera to apply the render pass to.
  23650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23651. * @param engine The engine which the post process will be applied. (default: current engine)
  23652. * @param reusable If the post process can be reused on the same frame. (default: false)
  23653. * @param textureType Type of textures used when performing the post process. (default: 0)
  23654. * @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)
  23655. */
  23656. constructor(name: string,
  23657. /** The direction in which to blur the image. */
  23658. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23659. /**
  23660. * Updates the effect with the current post process compile time values and recompiles the shader.
  23661. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23662. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23663. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23664. * @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
  23665. * @param onCompiled Called when the shader has been compiled.
  23666. * @param onError Called if there is an error when compiling a shader.
  23667. */
  23668. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23669. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23670. /**
  23671. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23672. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23673. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23674. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23675. * The gaps between physical kernels are compensated for in the weighting of the samples
  23676. * @param idealKernel Ideal blur kernel.
  23677. * @return Nearest best kernel.
  23678. */
  23679. protected _nearestBestKernel(idealKernel: number): number;
  23680. /**
  23681. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23682. * @param x The point on the Gaussian distribution to sample.
  23683. * @return the value of the Gaussian function at x.
  23684. */
  23685. protected _gaussianWeight(x: number): number;
  23686. /**
  23687. * Generates a string that can be used as a floating point number in GLSL.
  23688. * @param x Value to print.
  23689. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23690. * @return GLSL float string.
  23691. */
  23692. protected _glslFloat(x: number, decimalFigures?: number): string;
  23693. }
  23694. }
  23695. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23696. import { Scene } from "babylonjs/scene";
  23697. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23698. import { Plane } from "babylonjs/Maths/math.plane";
  23699. /**
  23700. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23701. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23702. * You can then easily use it as a reflectionTexture on a flat surface.
  23703. * In case the surface is not a plane, please consider relying on reflection probes.
  23704. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23705. */
  23706. export class MirrorTexture extends RenderTargetTexture {
  23707. private scene;
  23708. /**
  23709. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23710. * 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.
  23711. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23712. */
  23713. mirrorPlane: Plane;
  23714. /**
  23715. * Define the blur ratio used to blur the reflection if needed.
  23716. */
  23717. set blurRatio(value: number);
  23718. get blurRatio(): number;
  23719. /**
  23720. * Define the adaptive blur kernel used to blur the reflection if needed.
  23721. * This will autocompute the closest best match for the `blurKernel`
  23722. */
  23723. set adaptiveBlurKernel(value: number);
  23724. /**
  23725. * Define the blur kernel used to blur the reflection if needed.
  23726. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23727. */
  23728. set blurKernel(value: number);
  23729. /**
  23730. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23731. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23732. */
  23733. set blurKernelX(value: number);
  23734. get blurKernelX(): number;
  23735. /**
  23736. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23737. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23738. */
  23739. set blurKernelY(value: number);
  23740. get blurKernelY(): number;
  23741. private _autoComputeBlurKernel;
  23742. protected _onRatioRescale(): void;
  23743. private _updateGammaSpace;
  23744. private _imageProcessingConfigChangeObserver;
  23745. private _transformMatrix;
  23746. private _mirrorMatrix;
  23747. private _savedViewMatrix;
  23748. private _blurX;
  23749. private _blurY;
  23750. private _adaptiveBlurKernel;
  23751. private _blurKernelX;
  23752. private _blurKernelY;
  23753. private _blurRatio;
  23754. /**
  23755. * Instantiates a Mirror Texture.
  23756. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23757. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23758. * You can then easily use it as a reflectionTexture on a flat surface.
  23759. * In case the surface is not a plane, please consider relying on reflection probes.
  23760. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23761. * @param name
  23762. * @param size
  23763. * @param scene
  23764. * @param generateMipMaps
  23765. * @param type
  23766. * @param samplingMode
  23767. * @param generateDepthBuffer
  23768. */
  23769. constructor(name: string, size: number | {
  23770. width: number;
  23771. height: number;
  23772. } | {
  23773. ratio: number;
  23774. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23775. private _preparePostProcesses;
  23776. /**
  23777. * Clone the mirror texture.
  23778. * @returns the cloned texture
  23779. */
  23780. clone(): MirrorTexture;
  23781. /**
  23782. * Serialize the texture to a JSON representation you could use in Parse later on
  23783. * @returns the serialized JSON representation
  23784. */
  23785. serialize(): any;
  23786. /**
  23787. * Dispose the texture and release its associated resources.
  23788. */
  23789. dispose(): void;
  23790. }
  23791. }
  23792. declare module "babylonjs/Materials/Textures/texture" {
  23793. import { Observable } from "babylonjs/Misc/observable";
  23794. import { Nullable } from "babylonjs/types";
  23795. import { Matrix } from "babylonjs/Maths/math.vector";
  23796. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23797. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23798. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23799. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23800. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23801. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23802. import { Scene } from "babylonjs/scene";
  23803. /**
  23804. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23805. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23806. */
  23807. export class Texture extends BaseTexture {
  23808. /**
  23809. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23810. */
  23811. static SerializeBuffers: boolean;
  23812. /** @hidden */
  23813. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23814. /** @hidden */
  23815. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23816. /** @hidden */
  23817. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23818. /** nearest is mag = nearest and min = nearest and mip = linear */
  23819. static readonly NEAREST_SAMPLINGMODE: number;
  23820. /** nearest is mag = nearest and min = nearest and mip = linear */
  23821. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23822. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23823. static readonly BILINEAR_SAMPLINGMODE: number;
  23824. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23825. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23826. /** Trilinear is mag = linear and min = linear and mip = linear */
  23827. static readonly TRILINEAR_SAMPLINGMODE: number;
  23828. /** Trilinear is mag = linear and min = linear and mip = linear */
  23829. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23830. /** mag = nearest and min = nearest and mip = nearest */
  23831. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23832. /** mag = nearest and min = linear and mip = nearest */
  23833. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23834. /** mag = nearest and min = linear and mip = linear */
  23835. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23836. /** mag = nearest and min = linear and mip = none */
  23837. static readonly NEAREST_LINEAR: number;
  23838. /** mag = nearest and min = nearest and mip = none */
  23839. static readonly NEAREST_NEAREST: number;
  23840. /** mag = linear and min = nearest and mip = nearest */
  23841. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23842. /** mag = linear and min = nearest and mip = linear */
  23843. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23844. /** mag = linear and min = linear and mip = none */
  23845. static readonly LINEAR_LINEAR: number;
  23846. /** mag = linear and min = nearest and mip = none */
  23847. static readonly LINEAR_NEAREST: number;
  23848. /** Explicit coordinates mode */
  23849. static readonly EXPLICIT_MODE: number;
  23850. /** Spherical coordinates mode */
  23851. static readonly SPHERICAL_MODE: number;
  23852. /** Planar coordinates mode */
  23853. static readonly PLANAR_MODE: number;
  23854. /** Cubic coordinates mode */
  23855. static readonly CUBIC_MODE: number;
  23856. /** Projection coordinates mode */
  23857. static readonly PROJECTION_MODE: number;
  23858. /** Inverse Cubic coordinates mode */
  23859. static readonly SKYBOX_MODE: number;
  23860. /** Inverse Cubic coordinates mode */
  23861. static readonly INVCUBIC_MODE: number;
  23862. /** Equirectangular coordinates mode */
  23863. static readonly EQUIRECTANGULAR_MODE: number;
  23864. /** Equirectangular Fixed coordinates mode */
  23865. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23866. /** Equirectangular Fixed Mirrored coordinates mode */
  23867. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23868. /** Texture is not repeating outside of 0..1 UVs */
  23869. static readonly CLAMP_ADDRESSMODE: number;
  23870. /** Texture is repeating outside of 0..1 UVs */
  23871. static readonly WRAP_ADDRESSMODE: number;
  23872. /** Texture is repeating and mirrored */
  23873. static readonly MIRROR_ADDRESSMODE: number;
  23874. /**
  23875. * 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
  23876. */
  23877. static UseSerializedUrlIfAny: boolean;
  23878. /**
  23879. * Define the url of the texture.
  23880. */
  23881. url: Nullable<string>;
  23882. /**
  23883. * Define an offset on the texture to offset the u coordinates of the UVs
  23884. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23885. */
  23886. uOffset: number;
  23887. /**
  23888. * Define an offset on the texture to offset the v coordinates of the UVs
  23889. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23890. */
  23891. vOffset: number;
  23892. /**
  23893. * Define an offset on the texture to scale the u coordinates of the UVs
  23894. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23895. */
  23896. uScale: number;
  23897. /**
  23898. * Define an offset on the texture to scale the v coordinates of the UVs
  23899. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23900. */
  23901. vScale: number;
  23902. /**
  23903. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23904. * @see https://doc.babylonjs.com/how_to/more_materials
  23905. */
  23906. uAng: number;
  23907. /**
  23908. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23909. * @see https://doc.babylonjs.com/how_to/more_materials
  23910. */
  23911. vAng: number;
  23912. /**
  23913. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23914. * @see https://doc.babylonjs.com/how_to/more_materials
  23915. */
  23916. wAng: number;
  23917. /**
  23918. * Defines the center of rotation (U)
  23919. */
  23920. uRotationCenter: number;
  23921. /**
  23922. * Defines the center of rotation (V)
  23923. */
  23924. vRotationCenter: number;
  23925. /**
  23926. * Defines the center of rotation (W)
  23927. */
  23928. wRotationCenter: number;
  23929. /**
  23930. * Are mip maps generated for this texture or not.
  23931. */
  23932. get noMipmap(): boolean;
  23933. /**
  23934. * List of inspectable custom properties (used by the Inspector)
  23935. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23936. */
  23937. inspectableCustomProperties: Nullable<IInspectable[]>;
  23938. private _noMipmap;
  23939. /** @hidden */
  23940. _invertY: boolean;
  23941. private _rowGenerationMatrix;
  23942. private _cachedTextureMatrix;
  23943. private _projectionModeMatrix;
  23944. private _t0;
  23945. private _t1;
  23946. private _t2;
  23947. private _cachedUOffset;
  23948. private _cachedVOffset;
  23949. private _cachedUScale;
  23950. private _cachedVScale;
  23951. private _cachedUAng;
  23952. private _cachedVAng;
  23953. private _cachedWAng;
  23954. private _cachedProjectionMatrixId;
  23955. private _cachedCoordinatesMode;
  23956. /** @hidden */
  23957. protected _initialSamplingMode: number;
  23958. /** @hidden */
  23959. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23960. private _deleteBuffer;
  23961. protected _format: Nullable<number>;
  23962. private _delayedOnLoad;
  23963. private _delayedOnError;
  23964. private _mimeType?;
  23965. /**
  23966. * Observable triggered once the texture has been loaded.
  23967. */
  23968. onLoadObservable: Observable<Texture>;
  23969. protected _isBlocking: boolean;
  23970. /**
  23971. * Is the texture preventing material to render while loading.
  23972. * If false, a default texture will be used instead of the loading one during the preparation step.
  23973. */
  23974. set isBlocking(value: boolean);
  23975. get isBlocking(): boolean;
  23976. /**
  23977. * Get the current sampling mode associated with the texture.
  23978. */
  23979. get samplingMode(): number;
  23980. /**
  23981. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23982. */
  23983. get invertY(): boolean;
  23984. /**
  23985. * Instantiates a new texture.
  23986. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23987. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23988. * @param url defines the url of the picture to load as a texture
  23989. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23990. * @param noMipmap defines if the texture will require mip maps or not
  23991. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23992. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23993. * @param onLoad defines a callback triggered when the texture has been loaded
  23994. * @param onError defines a callback triggered when an error occurred during the loading session
  23995. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23996. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23997. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23998. * @param mimeType defines an optional mime type information
  23999. */
  24000. 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);
  24001. /**
  24002. * Update the url (and optional buffer) of this texture if url was null during construction.
  24003. * @param url the url of the texture
  24004. * @param buffer the buffer of the texture (defaults to null)
  24005. * @param onLoad callback called when the texture is loaded (defaults to null)
  24006. */
  24007. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24008. /**
  24009. * Finish the loading sequence of a texture flagged as delayed load.
  24010. * @hidden
  24011. */
  24012. delayLoad(): void;
  24013. private _prepareRowForTextureGeneration;
  24014. /**
  24015. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24016. * @returns the transform matrix of the texture.
  24017. */
  24018. getTextureMatrix(uBase?: number): Matrix;
  24019. /**
  24020. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24021. * @returns The reflection texture transform
  24022. */
  24023. getReflectionTextureMatrix(): Matrix;
  24024. /**
  24025. * Clones the texture.
  24026. * @returns the cloned texture
  24027. */
  24028. clone(): Texture;
  24029. /**
  24030. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24031. * @returns The JSON representation of the texture
  24032. */
  24033. serialize(): any;
  24034. /**
  24035. * Get the current class name of the texture useful for serialization or dynamic coding.
  24036. * @returns "Texture"
  24037. */
  24038. getClassName(): string;
  24039. /**
  24040. * Dispose the texture and release its associated resources.
  24041. */
  24042. dispose(): void;
  24043. /**
  24044. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24045. * @param parsedTexture Define the JSON representation of the texture
  24046. * @param scene Define the scene the parsed texture should be instantiated in
  24047. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24048. * @returns The parsed texture if successful
  24049. */
  24050. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24051. /**
  24052. * Creates a texture from its base 64 representation.
  24053. * @param data Define the base64 payload without the data: prefix
  24054. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24055. * @param scene Define the scene the texture should belong to
  24056. * @param noMipmap Forces the texture to not create mip map information if true
  24057. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24058. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24059. * @param onLoad define a callback triggered when the texture has been loaded
  24060. * @param onError define a callback triggered when an error occurred during the loading session
  24061. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24062. * @returns the created texture
  24063. */
  24064. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24065. /**
  24066. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24067. * @param data Define the base64 payload without the data: prefix
  24068. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24069. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24070. * @param scene Define the scene the texture should belong to
  24071. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24072. * @param noMipmap Forces the texture to not create mip map information if true
  24073. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24074. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24075. * @param onLoad define a callback triggered when the texture has been loaded
  24076. * @param onError define a callback triggered when an error occurred during the loading session
  24077. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24078. * @returns the created texture
  24079. */
  24080. 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;
  24081. }
  24082. }
  24083. declare module "babylonjs/PostProcesses/postProcessManager" {
  24084. import { Nullable } from "babylonjs/types";
  24085. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24086. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24087. import { Scene } from "babylonjs/scene";
  24088. /**
  24089. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24090. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24091. */
  24092. export class PostProcessManager {
  24093. private _scene;
  24094. private _indexBuffer;
  24095. private _vertexBuffers;
  24096. /**
  24097. * Creates a new instance PostProcess
  24098. * @param scene The scene that the post process is associated with.
  24099. */
  24100. constructor(scene: Scene);
  24101. private _prepareBuffers;
  24102. private _buildIndexBuffer;
  24103. /**
  24104. * Rebuilds the vertex buffers of the manager.
  24105. * @hidden
  24106. */
  24107. _rebuild(): void;
  24108. /**
  24109. * Prepares a frame to be run through a post process.
  24110. * @param sourceTexture The input texture to the post procesess. (default: null)
  24111. * @param postProcesses An array of post processes to be run. (default: null)
  24112. * @returns True if the post processes were able to be run.
  24113. * @hidden
  24114. */
  24115. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24116. /**
  24117. * Manually render a set of post processes to a texture.
  24118. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24119. * @param postProcesses An array of post processes to be run.
  24120. * @param targetTexture The target texture to render to.
  24121. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24122. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24123. * @param lodLevel defines which lod of the texture to render to
  24124. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24125. */
  24126. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24127. /**
  24128. * Finalize the result of the output of the postprocesses.
  24129. * @param doNotPresent If true the result will not be displayed to the screen.
  24130. * @param targetTexture The target texture to render to.
  24131. * @param faceIndex The index of the face to bind the target texture to.
  24132. * @param postProcesses The array of post processes to render.
  24133. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24134. * @hidden
  24135. */
  24136. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24137. /**
  24138. * Disposes of the post process manager.
  24139. */
  24140. dispose(): void;
  24141. }
  24142. }
  24143. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24144. import { Observable } from "babylonjs/Misc/observable";
  24145. import { SmartArray } from "babylonjs/Misc/smartArray";
  24146. import { Nullable, Immutable } from "babylonjs/types";
  24147. import { Camera } from "babylonjs/Cameras/camera";
  24148. import { Scene } from "babylonjs/scene";
  24149. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24150. import { Color4 } from "babylonjs/Maths/math.color";
  24151. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24153. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24154. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24155. import { Texture } from "babylonjs/Materials/Textures/texture";
  24156. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24157. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24158. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24159. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24160. import { Engine } from "babylonjs/Engines/engine";
  24161. /**
  24162. * This Helps creating a texture that will be created from a camera in your scene.
  24163. * It is basically a dynamic texture that could be used to create special effects for instance.
  24164. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24165. */
  24166. export class RenderTargetTexture extends Texture {
  24167. isCube: boolean;
  24168. /**
  24169. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24170. */
  24171. static readonly REFRESHRATE_RENDER_ONCE: number;
  24172. /**
  24173. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24174. */
  24175. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24176. /**
  24177. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24178. * the central point of your effect and can save a lot of performances.
  24179. */
  24180. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24181. /**
  24182. * Use this predicate to dynamically define the list of mesh you want to render.
  24183. * If set, the renderList property will be overwritten.
  24184. */
  24185. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24186. private _renderList;
  24187. /**
  24188. * Use this list to define the list of mesh you want to render.
  24189. */
  24190. get renderList(): Nullable<Array<AbstractMesh>>;
  24191. set renderList(value: Nullable<Array<AbstractMesh>>);
  24192. /**
  24193. * Use this function to overload the renderList array at rendering time.
  24194. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24195. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24196. * the cube (if the RTT is a cube, else layerOrFace=0).
  24197. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24198. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24199. * hold dummy elements!
  24200. */
  24201. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24202. private _hookArray;
  24203. /**
  24204. * Define if particles should be rendered in your texture.
  24205. */
  24206. renderParticles: boolean;
  24207. /**
  24208. * Define if sprites should be rendered in your texture.
  24209. */
  24210. renderSprites: boolean;
  24211. /**
  24212. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24213. */
  24214. coordinatesMode: number;
  24215. /**
  24216. * Define the camera used to render the texture.
  24217. */
  24218. activeCamera: Nullable<Camera>;
  24219. /**
  24220. * Override the mesh isReady function with your own one.
  24221. */
  24222. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24223. /**
  24224. * Override the render function of the texture with your own one.
  24225. */
  24226. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24227. /**
  24228. * Define if camera post processes should be use while rendering the texture.
  24229. */
  24230. useCameraPostProcesses: boolean;
  24231. /**
  24232. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24233. */
  24234. ignoreCameraViewport: boolean;
  24235. private _postProcessManager;
  24236. private _postProcesses;
  24237. private _resizeObserver;
  24238. /**
  24239. * An event triggered when the texture is unbind.
  24240. */
  24241. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24242. /**
  24243. * An event triggered when the texture is unbind.
  24244. */
  24245. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24246. private _onAfterUnbindObserver;
  24247. /**
  24248. * Set a after unbind callback in the texture.
  24249. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24250. */
  24251. set onAfterUnbind(callback: () => void);
  24252. /**
  24253. * An event triggered before rendering the texture
  24254. */
  24255. onBeforeRenderObservable: Observable<number>;
  24256. private _onBeforeRenderObserver;
  24257. /**
  24258. * Set a before render callback in the texture.
  24259. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24260. */
  24261. set onBeforeRender(callback: (faceIndex: number) => void);
  24262. /**
  24263. * An event triggered after rendering the texture
  24264. */
  24265. onAfterRenderObservable: Observable<number>;
  24266. private _onAfterRenderObserver;
  24267. /**
  24268. * Set a after render callback in the texture.
  24269. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24270. */
  24271. set onAfterRender(callback: (faceIndex: number) => void);
  24272. /**
  24273. * An event triggered after the texture clear
  24274. */
  24275. onClearObservable: Observable<Engine>;
  24276. private _onClearObserver;
  24277. /**
  24278. * Set a clear callback in the texture.
  24279. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24280. */
  24281. set onClear(callback: (Engine: Engine) => void);
  24282. /**
  24283. * An event triggered when the texture is resized.
  24284. */
  24285. onResizeObservable: Observable<RenderTargetTexture>;
  24286. /**
  24287. * Define the clear color of the Render Target if it should be different from the scene.
  24288. */
  24289. clearColor: Color4;
  24290. protected _size: number | {
  24291. width: number;
  24292. height: number;
  24293. layers?: number;
  24294. };
  24295. protected _initialSizeParameter: number | {
  24296. width: number;
  24297. height: number;
  24298. } | {
  24299. ratio: number;
  24300. };
  24301. protected _sizeRatio: Nullable<number>;
  24302. /** @hidden */
  24303. _generateMipMaps: boolean;
  24304. protected _renderingManager: RenderingManager;
  24305. /** @hidden */
  24306. _waitingRenderList: string[];
  24307. protected _doNotChangeAspectRatio: boolean;
  24308. protected _currentRefreshId: number;
  24309. protected _refreshRate: number;
  24310. protected _textureMatrix: Matrix;
  24311. protected _samples: number;
  24312. protected _renderTargetOptions: RenderTargetCreationOptions;
  24313. /**
  24314. * Gets render target creation options that were used.
  24315. */
  24316. get renderTargetOptions(): RenderTargetCreationOptions;
  24317. protected _onRatioRescale(): void;
  24318. /**
  24319. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24320. * It must define where the camera used to render the texture is set
  24321. */
  24322. boundingBoxPosition: Vector3;
  24323. private _boundingBoxSize;
  24324. /**
  24325. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24326. * When defined, the cubemap will switch to local mode
  24327. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24328. * @example https://www.babylonjs-playground.com/#RNASML
  24329. */
  24330. set boundingBoxSize(value: Vector3);
  24331. get boundingBoxSize(): Vector3;
  24332. /**
  24333. * In case the RTT has been created with a depth texture, get the associated
  24334. * depth texture.
  24335. * Otherwise, return null.
  24336. */
  24337. get depthStencilTexture(): Nullable<InternalTexture>;
  24338. /**
  24339. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24340. * or used a shadow, depth texture...
  24341. * @param name The friendly name of the texture
  24342. * @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)
  24343. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24344. * @param generateMipMaps True if mip maps need to be generated after render.
  24345. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24346. * @param type The type of the buffer in the RTT (int, half float, float...)
  24347. * @param isCube True if a cube texture needs to be created
  24348. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24349. * @param generateDepthBuffer True to generate a depth buffer
  24350. * @param generateStencilBuffer True to generate a stencil buffer
  24351. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24352. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24353. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24354. */
  24355. constructor(name: string, size: number | {
  24356. width: number;
  24357. height: number;
  24358. layers?: number;
  24359. } | {
  24360. ratio: number;
  24361. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24362. /**
  24363. * Creates a depth stencil texture.
  24364. * This is only available in WebGL 2 or with the depth texture extension available.
  24365. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24366. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24367. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24368. */
  24369. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24370. private _processSizeParameter;
  24371. /**
  24372. * Define the number of samples to use in case of MSAA.
  24373. * It defaults to one meaning no MSAA has been enabled.
  24374. */
  24375. get samples(): number;
  24376. set samples(value: number);
  24377. /**
  24378. * Resets the refresh counter of the texture and start bak from scratch.
  24379. * Could be useful to regenerate the texture if it is setup to render only once.
  24380. */
  24381. resetRefreshCounter(): void;
  24382. /**
  24383. * Define the refresh rate of the texture or the rendering frequency.
  24384. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24385. */
  24386. get refreshRate(): number;
  24387. set refreshRate(value: number);
  24388. /**
  24389. * Adds a post process to the render target rendering passes.
  24390. * @param postProcess define the post process to add
  24391. */
  24392. addPostProcess(postProcess: PostProcess): void;
  24393. /**
  24394. * Clear all the post processes attached to the render target
  24395. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24396. */
  24397. clearPostProcesses(dispose?: boolean): void;
  24398. /**
  24399. * Remove one of the post process from the list of attached post processes to the texture
  24400. * @param postProcess define the post process to remove from the list
  24401. */
  24402. removePostProcess(postProcess: PostProcess): void;
  24403. /** @hidden */
  24404. _shouldRender(): boolean;
  24405. /**
  24406. * Gets the actual render size of the texture.
  24407. * @returns the width of the render size
  24408. */
  24409. getRenderSize(): number;
  24410. /**
  24411. * Gets the actual render width of the texture.
  24412. * @returns the width of the render size
  24413. */
  24414. getRenderWidth(): number;
  24415. /**
  24416. * Gets the actual render height of the texture.
  24417. * @returns the height of the render size
  24418. */
  24419. getRenderHeight(): number;
  24420. /**
  24421. * Gets the actual number of layers of the texture.
  24422. * @returns the number of layers
  24423. */
  24424. getRenderLayers(): number;
  24425. /**
  24426. * Get if the texture can be rescaled or not.
  24427. */
  24428. get canRescale(): boolean;
  24429. /**
  24430. * Resize the texture using a ratio.
  24431. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24432. */
  24433. scale(ratio: number): void;
  24434. /**
  24435. * Get the texture reflection matrix used to rotate/transform the reflection.
  24436. * @returns the reflection matrix
  24437. */
  24438. getReflectionTextureMatrix(): Matrix;
  24439. /**
  24440. * Resize the texture to a new desired size.
  24441. * Be carrefull as it will recreate all the data in the new texture.
  24442. * @param size Define the new size. It can be:
  24443. * - a number for squared texture,
  24444. * - an object containing { width: number, height: number }
  24445. * - or an object containing a ratio { ratio: number }
  24446. */
  24447. resize(size: number | {
  24448. width: number;
  24449. height: number;
  24450. } | {
  24451. ratio: number;
  24452. }): void;
  24453. private _defaultRenderListPrepared;
  24454. /**
  24455. * Renders all the objects from the render list into the texture.
  24456. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24457. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24458. */
  24459. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24460. private _bestReflectionRenderTargetDimension;
  24461. private _prepareRenderingManager;
  24462. /**
  24463. * @hidden
  24464. * @param faceIndex face index to bind to if this is a cubetexture
  24465. * @param layer defines the index of the texture to bind in the array
  24466. */
  24467. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24468. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24469. private renderToTarget;
  24470. /**
  24471. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24472. * This allowed control for front to back rendering or reversly depending of the special needs.
  24473. *
  24474. * @param renderingGroupId The rendering group id corresponding to its index
  24475. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24476. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24477. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24478. */
  24479. 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;
  24480. /**
  24481. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24482. *
  24483. * @param renderingGroupId The rendering group id corresponding to its index
  24484. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24485. */
  24486. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24487. /**
  24488. * Clones the texture.
  24489. * @returns the cloned texture
  24490. */
  24491. clone(): RenderTargetTexture;
  24492. /**
  24493. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24494. * @returns The JSON representation of the texture
  24495. */
  24496. serialize(): any;
  24497. /**
  24498. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24499. */
  24500. disposeFramebufferObjects(): void;
  24501. /**
  24502. * Dispose the texture and release its associated resources.
  24503. */
  24504. dispose(): void;
  24505. /** @hidden */
  24506. _rebuild(): void;
  24507. /**
  24508. * Clear the info related to rendering groups preventing retention point in material dispose.
  24509. */
  24510. freeRenderingGroups(): void;
  24511. /**
  24512. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24513. * @returns the view count
  24514. */
  24515. getViewCount(): number;
  24516. }
  24517. }
  24518. declare module "babylonjs/Misc/guid" {
  24519. /**
  24520. * Class used to manipulate GUIDs
  24521. */
  24522. export class GUID {
  24523. /**
  24524. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24525. * Be aware Math.random() could cause collisions, but:
  24526. * "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"
  24527. * @returns a pseudo random id
  24528. */
  24529. static RandomId(): string;
  24530. }
  24531. }
  24532. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24533. import { Nullable } from "babylonjs/types";
  24534. import { Scene } from "babylonjs/scene";
  24535. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24536. import { Material } from "babylonjs/Materials/material";
  24537. import { Effect } from "babylonjs/Materials/effect";
  24538. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24539. /**
  24540. * Options to be used when creating a shadow depth material
  24541. */
  24542. export interface IIOptionShadowDepthMaterial {
  24543. /** Variables in the vertex shader code that need to have their names remapped.
  24544. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24545. * "var_name" should be either: worldPos or vNormalW
  24546. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24547. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24548. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24549. */
  24550. remappedVariables?: string[];
  24551. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24552. standalone?: boolean;
  24553. }
  24554. /**
  24555. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24556. */
  24557. export class ShadowDepthWrapper {
  24558. private _scene;
  24559. private _options?;
  24560. private _baseMaterial;
  24561. private _onEffectCreatedObserver;
  24562. private _subMeshToEffect;
  24563. private _subMeshToDepthEffect;
  24564. private _meshes;
  24565. /** @hidden */
  24566. _matriceNames: any;
  24567. /** Gets the standalone status of the wrapper */
  24568. get standalone(): boolean;
  24569. /** Gets the base material the wrapper is built upon */
  24570. get baseMaterial(): Material;
  24571. /**
  24572. * Instantiate a new shadow depth wrapper.
  24573. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24574. * generate the shadow depth map. For more information, please refer to the documentation:
  24575. * https://doc.babylonjs.com/babylon101/shadows
  24576. * @param baseMaterial Material to wrap
  24577. * @param scene Define the scene the material belongs to
  24578. * @param options Options used to create the wrapper
  24579. */
  24580. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24581. /**
  24582. * Gets the effect to use to generate the depth map
  24583. * @param subMesh subMesh to get the effect for
  24584. * @param shadowGenerator shadow generator to get the effect for
  24585. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24586. */
  24587. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24588. /**
  24589. * Specifies that the submesh is ready to be used for depth rendering
  24590. * @param subMesh submesh to check
  24591. * @param defines the list of defines to take into account when checking the effect
  24592. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24593. * @param useInstances specifies that instances should be used
  24594. * @returns a boolean indicating that the submesh is ready or not
  24595. */
  24596. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24597. /**
  24598. * Disposes the resources
  24599. */
  24600. dispose(): void;
  24601. private _makeEffect;
  24602. }
  24603. }
  24604. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24606. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24607. import { Nullable } from "babylonjs/types";
  24608. module "babylonjs/Engines/thinEngine" {
  24609. interface ThinEngine {
  24610. /**
  24611. * Unbind a list of render target textures from the webGL context
  24612. * This is used only when drawBuffer extension or webGL2 are active
  24613. * @param textures defines the render target textures to unbind
  24614. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24615. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24616. */
  24617. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24618. /**
  24619. * Create a multi render target texture
  24620. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24621. * @param size defines the size of the texture
  24622. * @param options defines the creation options
  24623. * @returns the cube texture as an InternalTexture
  24624. */
  24625. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24626. /**
  24627. * Update the sample count for a given multiple render target texture
  24628. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24629. * @param textures defines the textures to update
  24630. * @param samples defines the sample count to set
  24631. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24632. */
  24633. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24634. /**
  24635. * Select a subsets of attachments to draw to.
  24636. * @param attachments gl attachments
  24637. */
  24638. bindAttachments(attachments: number[]): void;
  24639. }
  24640. }
  24641. }
  24642. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24643. import { Scene } from "babylonjs/scene";
  24644. import { Engine } from "babylonjs/Engines/engine";
  24645. import { Texture } from "babylonjs/Materials/Textures/texture";
  24646. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24647. import "babylonjs/Engines/Extensions/engine.multiRender";
  24648. /**
  24649. * Creation options of the multi render target texture.
  24650. */
  24651. export interface IMultiRenderTargetOptions {
  24652. /**
  24653. * Define if the texture needs to create mip maps after render.
  24654. */
  24655. generateMipMaps?: boolean;
  24656. /**
  24657. * Define the types of all the draw buffers we want to create
  24658. */
  24659. types?: number[];
  24660. /**
  24661. * Define the sampling modes of all the draw buffers we want to create
  24662. */
  24663. samplingModes?: number[];
  24664. /**
  24665. * Define if a depth buffer is required
  24666. */
  24667. generateDepthBuffer?: boolean;
  24668. /**
  24669. * Define if a stencil buffer is required
  24670. */
  24671. generateStencilBuffer?: boolean;
  24672. /**
  24673. * Define if a depth texture is required instead of a depth buffer
  24674. */
  24675. generateDepthTexture?: boolean;
  24676. /**
  24677. * Define the number of desired draw buffers
  24678. */
  24679. textureCount?: number;
  24680. /**
  24681. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24682. */
  24683. doNotChangeAspectRatio?: boolean;
  24684. /**
  24685. * Define the default type of the buffers we are creating
  24686. */
  24687. defaultType?: number;
  24688. }
  24689. /**
  24690. * A multi render target, like a render target provides the ability to render to a texture.
  24691. * Unlike the render target, it can render to several draw buffers in one draw.
  24692. * This is specially interesting in deferred rendering or for any effects requiring more than
  24693. * just one color from a single pass.
  24694. */
  24695. export class MultiRenderTarget extends RenderTargetTexture {
  24696. private _internalTextures;
  24697. private _textures;
  24698. private _multiRenderTargetOptions;
  24699. private _count;
  24700. /**
  24701. * Get if draw buffers are currently supported by the used hardware and browser.
  24702. */
  24703. get isSupported(): boolean;
  24704. /**
  24705. * Get the list of textures generated by the multi render target.
  24706. */
  24707. get textures(): Texture[];
  24708. /**
  24709. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24710. */
  24711. get count(): number;
  24712. /**
  24713. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24714. */
  24715. get depthTexture(): Texture;
  24716. /**
  24717. * Set the wrapping mode on U of all the textures we are rendering to.
  24718. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24719. */
  24720. set wrapU(wrap: number);
  24721. /**
  24722. * Set the wrapping mode on V of all the textures we are rendering to.
  24723. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24724. */
  24725. set wrapV(wrap: number);
  24726. /**
  24727. * Instantiate a new multi render target texture.
  24728. * A multi render target, like a render target provides the ability to render to a texture.
  24729. * Unlike the render target, it can render to several draw buffers in one draw.
  24730. * This is specially interesting in deferred rendering or for any effects requiring more than
  24731. * just one color from a single pass.
  24732. * @param name Define the name of the texture
  24733. * @param size Define the size of the buffers to render to
  24734. * @param count Define the number of target we are rendering into
  24735. * @param scene Define the scene the texture belongs to
  24736. * @param options Define the options used to create the multi render target
  24737. */
  24738. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24739. /** @hidden */
  24740. _rebuild(): void;
  24741. private _createInternalTextures;
  24742. private _createTextures;
  24743. /**
  24744. * Define the number of samples used if MSAA is enabled.
  24745. */
  24746. get samples(): number;
  24747. set samples(value: number);
  24748. /**
  24749. * Resize all the textures in the multi render target.
  24750. * Be carrefull as it will recreate all the data in the new texture.
  24751. * @param size Define the new size
  24752. */
  24753. resize(size: any): void;
  24754. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24755. /**
  24756. * Dispose the render targets and their associated resources
  24757. */
  24758. dispose(): void;
  24759. /**
  24760. * Release all the underlying texture used as draw buffers.
  24761. */
  24762. releaseInternalTextures(): void;
  24763. }
  24764. }
  24765. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24766. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24767. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24768. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24769. /** @hidden */
  24770. export var imageProcessingPixelShader: {
  24771. name: string;
  24772. shader: string;
  24773. };
  24774. }
  24775. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24776. import { Nullable } from "babylonjs/types";
  24777. import { Color4 } from "babylonjs/Maths/math.color";
  24778. import { Camera } from "babylonjs/Cameras/camera";
  24779. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24780. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24781. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24782. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24783. import { Engine } from "babylonjs/Engines/engine";
  24784. import "babylonjs/Shaders/imageProcessing.fragment";
  24785. import "babylonjs/Shaders/postprocess.vertex";
  24786. /**
  24787. * ImageProcessingPostProcess
  24788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24789. */
  24790. export class ImageProcessingPostProcess extends PostProcess {
  24791. /**
  24792. * Default configuration related to image processing available in the PBR Material.
  24793. */
  24794. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24795. /**
  24796. * Gets the image processing configuration used either in this material.
  24797. */
  24798. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24799. /**
  24800. * Sets the Default image processing configuration used either in the this material.
  24801. *
  24802. * If sets to null, the scene one is in use.
  24803. */
  24804. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24805. /**
  24806. * Keep track of the image processing observer to allow dispose and replace.
  24807. */
  24808. private _imageProcessingObserver;
  24809. /**
  24810. * Attaches a new image processing configuration to the PBR Material.
  24811. * @param configuration
  24812. */
  24813. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24814. /**
  24815. * If the post process is supported.
  24816. */
  24817. get isSupported(): boolean;
  24818. /**
  24819. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24820. */
  24821. get colorCurves(): Nullable<ColorCurves>;
  24822. /**
  24823. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24824. */
  24825. set colorCurves(value: Nullable<ColorCurves>);
  24826. /**
  24827. * Gets wether the color curves effect is enabled.
  24828. */
  24829. get colorCurvesEnabled(): boolean;
  24830. /**
  24831. * Sets wether the color curves effect is enabled.
  24832. */
  24833. set colorCurvesEnabled(value: boolean);
  24834. /**
  24835. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24836. */
  24837. get colorGradingTexture(): Nullable<BaseTexture>;
  24838. /**
  24839. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24840. */
  24841. set colorGradingTexture(value: Nullable<BaseTexture>);
  24842. /**
  24843. * Gets wether the color grading effect is enabled.
  24844. */
  24845. get colorGradingEnabled(): boolean;
  24846. /**
  24847. * Gets wether the color grading effect is enabled.
  24848. */
  24849. set colorGradingEnabled(value: boolean);
  24850. /**
  24851. * Gets exposure used in the effect.
  24852. */
  24853. get exposure(): number;
  24854. /**
  24855. * Sets exposure used in the effect.
  24856. */
  24857. set exposure(value: number);
  24858. /**
  24859. * Gets wether tonemapping is enabled or not.
  24860. */
  24861. get toneMappingEnabled(): boolean;
  24862. /**
  24863. * Sets wether tonemapping is enabled or not
  24864. */
  24865. set toneMappingEnabled(value: boolean);
  24866. /**
  24867. * Gets the type of tone mapping effect.
  24868. */
  24869. get toneMappingType(): number;
  24870. /**
  24871. * Sets the type of tone mapping effect.
  24872. */
  24873. set toneMappingType(value: number);
  24874. /**
  24875. * Gets contrast used in the effect.
  24876. */
  24877. get contrast(): number;
  24878. /**
  24879. * Sets contrast used in the effect.
  24880. */
  24881. set contrast(value: number);
  24882. /**
  24883. * Gets Vignette stretch size.
  24884. */
  24885. get vignetteStretch(): number;
  24886. /**
  24887. * Sets Vignette stretch size.
  24888. */
  24889. set vignetteStretch(value: number);
  24890. /**
  24891. * Gets Vignette centre X Offset.
  24892. */
  24893. get vignetteCentreX(): number;
  24894. /**
  24895. * Sets Vignette centre X Offset.
  24896. */
  24897. set vignetteCentreX(value: number);
  24898. /**
  24899. * Gets Vignette centre Y Offset.
  24900. */
  24901. get vignetteCentreY(): number;
  24902. /**
  24903. * Sets Vignette centre Y Offset.
  24904. */
  24905. set vignetteCentreY(value: number);
  24906. /**
  24907. * Gets Vignette weight or intensity of the vignette effect.
  24908. */
  24909. get vignetteWeight(): number;
  24910. /**
  24911. * Sets Vignette weight or intensity of the vignette effect.
  24912. */
  24913. set vignetteWeight(value: number);
  24914. /**
  24915. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24916. * if vignetteEnabled is set to true.
  24917. */
  24918. get vignetteColor(): Color4;
  24919. /**
  24920. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24921. * if vignetteEnabled is set to true.
  24922. */
  24923. set vignetteColor(value: Color4);
  24924. /**
  24925. * Gets Camera field of view used by the Vignette effect.
  24926. */
  24927. get vignetteCameraFov(): number;
  24928. /**
  24929. * Sets Camera field of view used by the Vignette effect.
  24930. */
  24931. set vignetteCameraFov(value: number);
  24932. /**
  24933. * Gets the vignette blend mode allowing different kind of effect.
  24934. */
  24935. get vignetteBlendMode(): number;
  24936. /**
  24937. * Sets the vignette blend mode allowing different kind of effect.
  24938. */
  24939. set vignetteBlendMode(value: number);
  24940. /**
  24941. * Gets wether the vignette effect is enabled.
  24942. */
  24943. get vignetteEnabled(): boolean;
  24944. /**
  24945. * Sets wether the vignette effect is enabled.
  24946. */
  24947. set vignetteEnabled(value: boolean);
  24948. private _fromLinearSpace;
  24949. /**
  24950. * Gets wether the input of the processing is in Gamma or Linear Space.
  24951. */
  24952. get fromLinearSpace(): boolean;
  24953. /**
  24954. * Sets wether the input of the processing is in Gamma or Linear Space.
  24955. */
  24956. set fromLinearSpace(value: boolean);
  24957. /**
  24958. * Defines cache preventing GC.
  24959. */
  24960. private _defines;
  24961. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24962. /**
  24963. * "ImageProcessingPostProcess"
  24964. * @returns "ImageProcessingPostProcess"
  24965. */
  24966. getClassName(): string;
  24967. /**
  24968. * @hidden
  24969. */
  24970. _updateParameters(): void;
  24971. dispose(camera?: Camera): void;
  24972. }
  24973. }
  24974. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  24975. /** @hidden */
  24976. export var fibonacci: {
  24977. name: string;
  24978. shader: string;
  24979. };
  24980. }
  24981. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  24982. /** @hidden */
  24983. export var subSurfaceScatteringFunctions: {
  24984. name: string;
  24985. shader: string;
  24986. };
  24987. }
  24988. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  24989. /** @hidden */
  24990. export var diffusionProfile: {
  24991. name: string;
  24992. shader: string;
  24993. };
  24994. }
  24995. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  24996. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  24997. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24998. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  24999. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25000. /** @hidden */
  25001. export var subSurfaceScatteringPixelShader: {
  25002. name: string;
  25003. shader: string;
  25004. };
  25005. }
  25006. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25007. import { Nullable } from "babylonjs/types";
  25008. import { Camera } from "babylonjs/Cameras/camera";
  25009. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25010. import { Engine } from "babylonjs/Engines/engine";
  25011. import { Scene } from "babylonjs/scene";
  25012. import "babylonjs/Shaders/imageProcessing.fragment";
  25013. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25014. import "babylonjs/Shaders/postprocess.vertex";
  25015. /**
  25016. * Sub surface scattering post process
  25017. */
  25018. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25019. /** @hidden */
  25020. texelWidth: number;
  25021. /** @hidden */
  25022. texelHeight: number;
  25023. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25024. }
  25025. }
  25026. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25027. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25028. /**
  25029. * Interface for defining prepass effects in the prepass post-process pipeline
  25030. */
  25031. export interface PrePassEffectConfiguration {
  25032. /**
  25033. * Post process to attach for this effect
  25034. */
  25035. postProcess: PostProcess;
  25036. /**
  25037. * Is the effect enabled
  25038. */
  25039. enabled: boolean;
  25040. /**
  25041. * Disposes the effect configuration
  25042. */
  25043. dispose(): void;
  25044. /**
  25045. * Disposes the effect configuration
  25046. */
  25047. createPostProcess: () => PostProcess;
  25048. }
  25049. }
  25050. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25051. import { Scene } from "babylonjs/scene";
  25052. import { Color3 } from "babylonjs/Maths/math.color";
  25053. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25054. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25055. /**
  25056. * Contains all parameters needed for the prepass to perform
  25057. * screen space subsurface scattering
  25058. */
  25059. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25060. private _ssDiffusionS;
  25061. private _ssFilterRadii;
  25062. private _ssDiffusionD;
  25063. /**
  25064. * Post process to attach for screen space subsurface scattering
  25065. */
  25066. postProcess: SubSurfaceScatteringPostProcess;
  25067. /**
  25068. * Diffusion profile color for subsurface scattering
  25069. */
  25070. get ssDiffusionS(): number[];
  25071. /**
  25072. * Diffusion profile max color channel value for subsurface scattering
  25073. */
  25074. get ssDiffusionD(): number[];
  25075. /**
  25076. * Diffusion profile filter radius for subsurface scattering
  25077. */
  25078. get ssFilterRadii(): number[];
  25079. /**
  25080. * Is subsurface enabled
  25081. */
  25082. enabled: boolean;
  25083. /**
  25084. * Diffusion profile colors for subsurface scattering
  25085. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25086. * See ...
  25087. * Note that you can only store up to 5 of them
  25088. */
  25089. ssDiffusionProfileColors: Color3[];
  25090. /**
  25091. * Defines the ratio real world => scene units.
  25092. * Used for subsurface scattering
  25093. */
  25094. metersPerUnit: number;
  25095. private _scene;
  25096. /**
  25097. * Builds a subsurface configuration object
  25098. * @param scene The scene
  25099. */
  25100. constructor(scene: Scene);
  25101. /**
  25102. * Adds a new diffusion profile.
  25103. * Useful for more realistic subsurface scattering on diverse materials.
  25104. * @param color The color of the diffusion profile. Should be the average color of the material.
  25105. * @return The index of the diffusion profile for the material subsurface configuration
  25106. */
  25107. addDiffusionProfile(color: Color3): number;
  25108. /**
  25109. * Creates the sss post process
  25110. * @return The created post process
  25111. */
  25112. createPostProcess(): SubSurfaceScatteringPostProcess;
  25113. /**
  25114. * Deletes all diffusion profiles.
  25115. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25116. */
  25117. clearAllDiffusionProfiles(): void;
  25118. /**
  25119. * Disposes this object
  25120. */
  25121. dispose(): void;
  25122. /**
  25123. * @hidden
  25124. * https://zero-radiance.github.io/post/sampling-diffusion/
  25125. *
  25126. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25127. * ------------------------------------------------------------------------------------
  25128. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25129. * PDF[r, phi, s] = r * R[r, phi, s]
  25130. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25131. * ------------------------------------------------------------------------------------
  25132. * We importance sample the color channel with the widest scattering distance.
  25133. */
  25134. getDiffusionProfileParameters(color: Color3): number;
  25135. /**
  25136. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25137. * 'u' is the random number (the value of the CDF): [0, 1).
  25138. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25139. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25140. */
  25141. private _sampleBurleyDiffusionProfile;
  25142. }
  25143. }
  25144. declare module "babylonjs/Rendering/prePassRenderer" {
  25145. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25146. import { Scene } from "babylonjs/scene";
  25147. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25148. import { Effect } from "babylonjs/Materials/effect";
  25149. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25150. /**
  25151. * Renders a pre pass of the scene
  25152. * This means every mesh in the scene will be rendered to a render target texture
  25153. * And then this texture will be composited to the rendering canvas with post processes
  25154. * It is necessary for effects like subsurface scattering or deferred shading
  25155. */
  25156. export class PrePassRenderer {
  25157. /** @hidden */
  25158. static _SceneComponentInitialization: (scene: Scene) => void;
  25159. private _scene;
  25160. private _engine;
  25161. private _isDirty;
  25162. /**
  25163. * Number of textures in the multi render target texture where the scene is directly rendered
  25164. */
  25165. readonly mrtCount: number;
  25166. /**
  25167. * The render target where the scene is directly rendered
  25168. */
  25169. prePassRT: MultiRenderTarget;
  25170. private _mrtTypes;
  25171. private _multiRenderAttachments;
  25172. private _defaultAttachments;
  25173. private _clearAttachments;
  25174. private _postProcesses;
  25175. private readonly _clearColor;
  25176. /**
  25177. * Image processing post process for composition
  25178. */
  25179. imageProcessingPostProcess: ImageProcessingPostProcess;
  25180. /**
  25181. * Configuration for sub surface scattering post process
  25182. */
  25183. subSurfaceConfiguration: SubSurfaceConfiguration;
  25184. /**
  25185. * Should materials render their geometry on the MRT
  25186. */
  25187. materialsShouldRenderGeometry: boolean;
  25188. /**
  25189. * Should materials render the irradiance information on the MRT
  25190. */
  25191. materialsShouldRenderIrradiance: boolean;
  25192. private _enabled;
  25193. /**
  25194. * Indicates if the prepass is enabled
  25195. */
  25196. get enabled(): boolean;
  25197. /**
  25198. * How many samples are used for MSAA of the scene render target
  25199. */
  25200. get samples(): number;
  25201. set samples(n: number);
  25202. /**
  25203. * Instanciates a prepass renderer
  25204. * @param scene The scene
  25205. */
  25206. constructor(scene: Scene);
  25207. private _initializeAttachments;
  25208. private _createCompositionEffect;
  25209. /**
  25210. * Indicates if rendering a prepass is supported
  25211. */
  25212. get isSupported(): boolean;
  25213. /**
  25214. * Sets the proper output textures to draw in the engine.
  25215. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25216. */
  25217. bindAttachmentsForEffect(effect: Effect): void;
  25218. /**
  25219. * @hidden
  25220. */
  25221. _beforeCameraDraw(): void;
  25222. /**
  25223. * @hidden
  25224. */
  25225. _afterCameraDraw(): void;
  25226. private _checkRTSize;
  25227. private _bindFrameBuffer;
  25228. /**
  25229. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25230. */
  25231. clear(): void;
  25232. private _setState;
  25233. private _enable;
  25234. private _disable;
  25235. private _resetPostProcessChain;
  25236. private _bindPostProcessChain;
  25237. /**
  25238. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25239. */
  25240. markAsDirty(): void;
  25241. private _update;
  25242. /**
  25243. * Disposes the prepass renderer.
  25244. */
  25245. dispose(): void;
  25246. }
  25247. }
  25248. declare module "babylonjs/Materials/material" {
  25249. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25250. import { SmartArray } from "babylonjs/Misc/smartArray";
  25251. import { Observable } from "babylonjs/Misc/observable";
  25252. import { Nullable } from "babylonjs/types";
  25253. import { Scene } from "babylonjs/scene";
  25254. import { Matrix } from "babylonjs/Maths/math.vector";
  25255. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25257. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25258. import { Effect } from "babylonjs/Materials/effect";
  25259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25260. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25261. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25262. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25263. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25264. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25265. import { Mesh } from "babylonjs/Meshes/mesh";
  25266. import { Animation } from "babylonjs/Animations/animation";
  25267. /**
  25268. * Options for compiling materials.
  25269. */
  25270. export interface IMaterialCompilationOptions {
  25271. /**
  25272. * Defines whether clip planes are enabled.
  25273. */
  25274. clipPlane: boolean;
  25275. /**
  25276. * Defines whether instances are enabled.
  25277. */
  25278. useInstances: boolean;
  25279. }
  25280. /**
  25281. * Options passed when calling customShaderNameResolve
  25282. */
  25283. export interface ICustomShaderNameResolveOptions {
  25284. /**
  25285. * 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
  25286. */
  25287. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25288. }
  25289. /**
  25290. * Base class for the main features of a material in Babylon.js
  25291. */
  25292. export class Material implements IAnimatable {
  25293. /**
  25294. * Returns the triangle fill mode
  25295. */
  25296. static readonly TriangleFillMode: number;
  25297. /**
  25298. * Returns the wireframe mode
  25299. */
  25300. static readonly WireFrameFillMode: number;
  25301. /**
  25302. * Returns the point fill mode
  25303. */
  25304. static readonly PointFillMode: number;
  25305. /**
  25306. * Returns the point list draw mode
  25307. */
  25308. static readonly PointListDrawMode: number;
  25309. /**
  25310. * Returns the line list draw mode
  25311. */
  25312. static readonly LineListDrawMode: number;
  25313. /**
  25314. * Returns the line loop draw mode
  25315. */
  25316. static readonly LineLoopDrawMode: number;
  25317. /**
  25318. * Returns the line strip draw mode
  25319. */
  25320. static readonly LineStripDrawMode: number;
  25321. /**
  25322. * Returns the triangle strip draw mode
  25323. */
  25324. static readonly TriangleStripDrawMode: number;
  25325. /**
  25326. * Returns the triangle fan draw mode
  25327. */
  25328. static readonly TriangleFanDrawMode: number;
  25329. /**
  25330. * Stores the clock-wise side orientation
  25331. */
  25332. static readonly ClockWiseSideOrientation: number;
  25333. /**
  25334. * Stores the counter clock-wise side orientation
  25335. */
  25336. static readonly CounterClockWiseSideOrientation: number;
  25337. /**
  25338. * The dirty texture flag value
  25339. */
  25340. static readonly TextureDirtyFlag: number;
  25341. /**
  25342. * The dirty light flag value
  25343. */
  25344. static readonly LightDirtyFlag: number;
  25345. /**
  25346. * The dirty fresnel flag value
  25347. */
  25348. static readonly FresnelDirtyFlag: number;
  25349. /**
  25350. * The dirty attribute flag value
  25351. */
  25352. static readonly AttributesDirtyFlag: number;
  25353. /**
  25354. * The dirty misc flag value
  25355. */
  25356. static readonly MiscDirtyFlag: number;
  25357. /**
  25358. * The all dirty flag value
  25359. */
  25360. static readonly AllDirtyFlag: number;
  25361. /**
  25362. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25363. */
  25364. static readonly MATERIAL_OPAQUE: number;
  25365. /**
  25366. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25367. */
  25368. static readonly MATERIAL_ALPHATEST: number;
  25369. /**
  25370. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25371. */
  25372. static readonly MATERIAL_ALPHABLEND: number;
  25373. /**
  25374. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25375. * They are also discarded below the alpha cutoff threshold to improve performances.
  25376. */
  25377. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25378. /**
  25379. * The Whiteout method is used to blend normals.
  25380. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25381. */
  25382. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25383. /**
  25384. * The Reoriented Normal Mapping method is used to blend normals.
  25385. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25386. */
  25387. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25388. /**
  25389. * Custom callback helping to override the default shader used in the material.
  25390. */
  25391. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25392. /**
  25393. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25394. */
  25395. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25396. /**
  25397. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25398. * This means that the material can keep using a previous shader while a new one is being compiled.
  25399. * This is mostly used when shader parallel compilation is supported (true by default)
  25400. */
  25401. allowShaderHotSwapping: boolean;
  25402. /**
  25403. * The ID of the material
  25404. */
  25405. id: string;
  25406. /**
  25407. * Gets or sets the unique id of the material
  25408. */
  25409. uniqueId: number;
  25410. /**
  25411. * The name of the material
  25412. */
  25413. name: string;
  25414. /**
  25415. * Gets or sets user defined metadata
  25416. */
  25417. metadata: any;
  25418. /**
  25419. * For internal use only. Please do not use.
  25420. */
  25421. reservedDataStore: any;
  25422. /**
  25423. * Specifies if the ready state should be checked on each call
  25424. */
  25425. checkReadyOnEveryCall: boolean;
  25426. /**
  25427. * Specifies if the ready state should be checked once
  25428. */
  25429. checkReadyOnlyOnce: boolean;
  25430. /**
  25431. * The state of the material
  25432. */
  25433. state: string;
  25434. /**
  25435. * If the material can be rendered to several textures with MRT extension
  25436. */
  25437. get canRenderToMRT(): boolean;
  25438. /**
  25439. * The alpha value of the material
  25440. */
  25441. protected _alpha: number;
  25442. /**
  25443. * List of inspectable custom properties (used by the Inspector)
  25444. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25445. */
  25446. inspectableCustomProperties: IInspectable[];
  25447. /**
  25448. * Sets the alpha value of the material
  25449. */
  25450. set alpha(value: number);
  25451. /**
  25452. * Gets the alpha value of the material
  25453. */
  25454. get alpha(): number;
  25455. /**
  25456. * Specifies if back face culling is enabled
  25457. */
  25458. protected _backFaceCulling: boolean;
  25459. /**
  25460. * Sets the back-face culling state
  25461. */
  25462. set backFaceCulling(value: boolean);
  25463. /**
  25464. * Gets the back-face culling state
  25465. */
  25466. get backFaceCulling(): boolean;
  25467. /**
  25468. * Stores the value for side orientation
  25469. */
  25470. sideOrientation: number;
  25471. /**
  25472. * Callback triggered when the material is compiled
  25473. */
  25474. onCompiled: Nullable<(effect: Effect) => void>;
  25475. /**
  25476. * Callback triggered when an error occurs
  25477. */
  25478. onError: Nullable<(effect: Effect, errors: string) => void>;
  25479. /**
  25480. * Callback triggered to get the render target textures
  25481. */
  25482. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25483. /**
  25484. * Gets a boolean indicating that current material needs to register RTT
  25485. */
  25486. get hasRenderTargetTextures(): boolean;
  25487. /**
  25488. * Specifies if the material should be serialized
  25489. */
  25490. doNotSerialize: boolean;
  25491. /**
  25492. * @hidden
  25493. */
  25494. _storeEffectOnSubMeshes: boolean;
  25495. /**
  25496. * Stores the animations for the material
  25497. */
  25498. animations: Nullable<Array<Animation>>;
  25499. /**
  25500. * An event triggered when the material is disposed
  25501. */
  25502. onDisposeObservable: Observable<Material>;
  25503. /**
  25504. * An observer which watches for dispose events
  25505. */
  25506. private _onDisposeObserver;
  25507. private _onUnBindObservable;
  25508. /**
  25509. * Called during a dispose event
  25510. */
  25511. set onDispose(callback: () => void);
  25512. private _onBindObservable;
  25513. /**
  25514. * An event triggered when the material is bound
  25515. */
  25516. get onBindObservable(): Observable<AbstractMesh>;
  25517. /**
  25518. * An observer which watches for bind events
  25519. */
  25520. private _onBindObserver;
  25521. /**
  25522. * Called during a bind event
  25523. */
  25524. set onBind(callback: (Mesh: AbstractMesh) => void);
  25525. /**
  25526. * An event triggered when the material is unbound
  25527. */
  25528. get onUnBindObservable(): Observable<Material>;
  25529. protected _onEffectCreatedObservable: Nullable<Observable<{
  25530. effect: Effect;
  25531. subMesh: Nullable<SubMesh>;
  25532. }>>;
  25533. /**
  25534. * An event triggered when the effect is (re)created
  25535. */
  25536. get onEffectCreatedObservable(): Observable<{
  25537. effect: Effect;
  25538. subMesh: Nullable<SubMesh>;
  25539. }>;
  25540. /**
  25541. * Stores the value of the alpha mode
  25542. */
  25543. private _alphaMode;
  25544. /**
  25545. * Sets the value of the alpha mode.
  25546. *
  25547. * | Value | Type | Description |
  25548. * | --- | --- | --- |
  25549. * | 0 | ALPHA_DISABLE | |
  25550. * | 1 | ALPHA_ADD | |
  25551. * | 2 | ALPHA_COMBINE | |
  25552. * | 3 | ALPHA_SUBTRACT | |
  25553. * | 4 | ALPHA_MULTIPLY | |
  25554. * | 5 | ALPHA_MAXIMIZED | |
  25555. * | 6 | ALPHA_ONEONE | |
  25556. * | 7 | ALPHA_PREMULTIPLIED | |
  25557. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25558. * | 9 | ALPHA_INTERPOLATE | |
  25559. * | 10 | ALPHA_SCREENMODE | |
  25560. *
  25561. */
  25562. set alphaMode(value: number);
  25563. /**
  25564. * Gets the value of the alpha mode
  25565. */
  25566. get alphaMode(): number;
  25567. /**
  25568. * Stores the state of the need depth pre-pass value
  25569. */
  25570. private _needDepthPrePass;
  25571. /**
  25572. * Sets the need depth pre-pass value
  25573. */
  25574. set needDepthPrePass(value: boolean);
  25575. /**
  25576. * Gets the depth pre-pass value
  25577. */
  25578. get needDepthPrePass(): boolean;
  25579. /**
  25580. * Specifies if depth writing should be disabled
  25581. */
  25582. disableDepthWrite: boolean;
  25583. /**
  25584. * Specifies if color writing should be disabled
  25585. */
  25586. disableColorWrite: boolean;
  25587. /**
  25588. * Specifies if depth writing should be forced
  25589. */
  25590. forceDepthWrite: boolean;
  25591. /**
  25592. * Specifies the depth function that should be used. 0 means the default engine function
  25593. */
  25594. depthFunction: number;
  25595. /**
  25596. * Specifies if there should be a separate pass for culling
  25597. */
  25598. separateCullingPass: boolean;
  25599. /**
  25600. * Stores the state specifing if fog should be enabled
  25601. */
  25602. private _fogEnabled;
  25603. /**
  25604. * Sets the state for enabling fog
  25605. */
  25606. set fogEnabled(value: boolean);
  25607. /**
  25608. * Gets the value of the fog enabled state
  25609. */
  25610. get fogEnabled(): boolean;
  25611. /**
  25612. * Stores the size of points
  25613. */
  25614. pointSize: number;
  25615. /**
  25616. * Stores the z offset value
  25617. */
  25618. zOffset: number;
  25619. get wireframe(): boolean;
  25620. /**
  25621. * Sets the state of wireframe mode
  25622. */
  25623. set wireframe(value: boolean);
  25624. /**
  25625. * Gets the value specifying if point clouds are enabled
  25626. */
  25627. get pointsCloud(): boolean;
  25628. /**
  25629. * Sets the state of point cloud mode
  25630. */
  25631. set pointsCloud(value: boolean);
  25632. /**
  25633. * Gets the material fill mode
  25634. */
  25635. get fillMode(): number;
  25636. /**
  25637. * Sets the material fill mode
  25638. */
  25639. set fillMode(value: number);
  25640. /**
  25641. * @hidden
  25642. * Stores the effects for the material
  25643. */
  25644. _effect: Nullable<Effect>;
  25645. /**
  25646. * Specifies if uniform buffers should be used
  25647. */
  25648. private _useUBO;
  25649. /**
  25650. * Stores a reference to the scene
  25651. */
  25652. private _scene;
  25653. /**
  25654. * Stores the fill mode state
  25655. */
  25656. private _fillMode;
  25657. /**
  25658. * Specifies if the depth write state should be cached
  25659. */
  25660. private _cachedDepthWriteState;
  25661. /**
  25662. * Specifies if the color write state should be cached
  25663. */
  25664. private _cachedColorWriteState;
  25665. /**
  25666. * Specifies if the depth function state should be cached
  25667. */
  25668. private _cachedDepthFunctionState;
  25669. /**
  25670. * Stores the uniform buffer
  25671. */
  25672. protected _uniformBuffer: UniformBuffer;
  25673. /** @hidden */
  25674. _indexInSceneMaterialArray: number;
  25675. /** @hidden */
  25676. meshMap: Nullable<{
  25677. [id: string]: AbstractMesh | undefined;
  25678. }>;
  25679. /**
  25680. * Creates a material instance
  25681. * @param name defines the name of the material
  25682. * @param scene defines the scene to reference
  25683. * @param doNotAdd specifies if the material should be added to the scene
  25684. */
  25685. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25686. /**
  25687. * Returns a string representation of the current material
  25688. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25689. * @returns a string with material information
  25690. */
  25691. toString(fullDetails?: boolean): string;
  25692. /**
  25693. * Gets the class name of the material
  25694. * @returns a string with the class name of the material
  25695. */
  25696. getClassName(): string;
  25697. /**
  25698. * Specifies if updates for the material been locked
  25699. */
  25700. get isFrozen(): boolean;
  25701. /**
  25702. * Locks updates for the material
  25703. */
  25704. freeze(): void;
  25705. /**
  25706. * Unlocks updates for the material
  25707. */
  25708. unfreeze(): void;
  25709. /**
  25710. * Specifies if the material is ready to be used
  25711. * @param mesh defines the mesh to check
  25712. * @param useInstances specifies if instances should be used
  25713. * @returns a boolean indicating if the material is ready to be used
  25714. */
  25715. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25716. /**
  25717. * Specifies that the submesh is ready to be used
  25718. * @param mesh defines the mesh to check
  25719. * @param subMesh defines which submesh to check
  25720. * @param useInstances specifies that instances should be used
  25721. * @returns a boolean indicating that the submesh is ready or not
  25722. */
  25723. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25724. /**
  25725. * Returns the material effect
  25726. * @returns the effect associated with the material
  25727. */
  25728. getEffect(): Nullable<Effect>;
  25729. /**
  25730. * Returns the current scene
  25731. * @returns a Scene
  25732. */
  25733. getScene(): Scene;
  25734. /**
  25735. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25736. */
  25737. protected _forceAlphaTest: boolean;
  25738. /**
  25739. * The transparency mode of the material.
  25740. */
  25741. protected _transparencyMode: Nullable<number>;
  25742. /**
  25743. * Gets the current transparency mode.
  25744. */
  25745. get transparencyMode(): Nullable<number>;
  25746. /**
  25747. * Sets the transparency mode of the material.
  25748. *
  25749. * | Value | Type | Description |
  25750. * | ----- | ----------------------------------- | ----------- |
  25751. * | 0 | OPAQUE | |
  25752. * | 1 | ALPHATEST | |
  25753. * | 2 | ALPHABLEND | |
  25754. * | 3 | ALPHATESTANDBLEND | |
  25755. *
  25756. */
  25757. set transparencyMode(value: Nullable<number>);
  25758. /**
  25759. * Returns true if alpha blending should be disabled.
  25760. */
  25761. protected get _disableAlphaBlending(): boolean;
  25762. /**
  25763. * Specifies whether or not this material should be rendered in alpha blend mode.
  25764. * @returns a boolean specifying if alpha blending is needed
  25765. */
  25766. needAlphaBlending(): boolean;
  25767. /**
  25768. * Specifies if the mesh will require alpha blending
  25769. * @param mesh defines the mesh to check
  25770. * @returns a boolean specifying if alpha blending is needed for the mesh
  25771. */
  25772. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25773. /**
  25774. * Specifies whether or not this material should be rendered in alpha test mode.
  25775. * @returns a boolean specifying if an alpha test is needed.
  25776. */
  25777. needAlphaTesting(): boolean;
  25778. /**
  25779. * Specifies if material alpha testing should be turned on for the mesh
  25780. * @param mesh defines the mesh to check
  25781. */
  25782. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25783. /**
  25784. * Gets the texture used for the alpha test
  25785. * @returns the texture to use for alpha testing
  25786. */
  25787. getAlphaTestTexture(): Nullable<BaseTexture>;
  25788. /**
  25789. * Marks the material to indicate that it needs to be re-calculated
  25790. */
  25791. markDirty(): void;
  25792. /** @hidden */
  25793. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25794. /**
  25795. * Binds the material to the mesh
  25796. * @param world defines the world transformation matrix
  25797. * @param mesh defines the mesh to bind the material to
  25798. */
  25799. bind(world: Matrix, mesh?: Mesh): void;
  25800. /**
  25801. * Binds the submesh to the material
  25802. * @param world defines the world transformation matrix
  25803. * @param mesh defines the mesh containing the submesh
  25804. * @param subMesh defines the submesh to bind the material to
  25805. */
  25806. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25807. /**
  25808. * Binds the world matrix to the material
  25809. * @param world defines the world transformation matrix
  25810. */
  25811. bindOnlyWorldMatrix(world: Matrix): void;
  25812. /**
  25813. * Binds the scene's uniform buffer to the effect.
  25814. * @param effect defines the effect to bind to the scene uniform buffer
  25815. * @param sceneUbo defines the uniform buffer storing scene data
  25816. */
  25817. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25818. /**
  25819. * Binds the view matrix to the effect
  25820. * @param effect defines the effect to bind the view matrix to
  25821. */
  25822. bindView(effect: Effect): void;
  25823. /**
  25824. * Binds the view projection matrix to the effect
  25825. * @param effect defines the effect to bind the view projection matrix to
  25826. */
  25827. bindViewProjection(effect: Effect): void;
  25828. /**
  25829. * Processes to execute after binding the material to a mesh
  25830. * @param mesh defines the rendered mesh
  25831. */
  25832. protected _afterBind(mesh?: Mesh): void;
  25833. /**
  25834. * Unbinds the material from the mesh
  25835. */
  25836. unbind(): void;
  25837. /**
  25838. * Gets the active textures from the material
  25839. * @returns an array of textures
  25840. */
  25841. getActiveTextures(): BaseTexture[];
  25842. /**
  25843. * Specifies if the material uses a texture
  25844. * @param texture defines the texture to check against the material
  25845. * @returns a boolean specifying if the material uses the texture
  25846. */
  25847. hasTexture(texture: BaseTexture): boolean;
  25848. /**
  25849. * Makes a duplicate of the material, and gives it a new name
  25850. * @param name defines the new name for the duplicated material
  25851. * @returns the cloned material
  25852. */
  25853. clone(name: string): Nullable<Material>;
  25854. /**
  25855. * Gets the meshes bound to the material
  25856. * @returns an array of meshes bound to the material
  25857. */
  25858. getBindedMeshes(): AbstractMesh[];
  25859. /**
  25860. * Force shader compilation
  25861. * @param mesh defines the mesh associated with this material
  25862. * @param onCompiled defines a function to execute once the material is compiled
  25863. * @param options defines the options to configure the compilation
  25864. * @param onError defines a function to execute if the material fails compiling
  25865. */
  25866. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25867. /**
  25868. * Force shader compilation
  25869. * @param mesh defines the mesh that will use this material
  25870. * @param options defines additional options for compiling the shaders
  25871. * @returns a promise that resolves when the compilation completes
  25872. */
  25873. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25874. private static readonly _AllDirtyCallBack;
  25875. private static readonly _ImageProcessingDirtyCallBack;
  25876. private static readonly _TextureDirtyCallBack;
  25877. private static readonly _FresnelDirtyCallBack;
  25878. private static readonly _MiscDirtyCallBack;
  25879. private static readonly _LightsDirtyCallBack;
  25880. private static readonly _AttributeDirtyCallBack;
  25881. private static _FresnelAndMiscDirtyCallBack;
  25882. private static _TextureAndMiscDirtyCallBack;
  25883. private static readonly _DirtyCallbackArray;
  25884. private static readonly _RunDirtyCallBacks;
  25885. /**
  25886. * Marks a define in the material to indicate that it needs to be re-computed
  25887. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25888. */
  25889. markAsDirty(flag: number): void;
  25890. /**
  25891. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25892. * @param func defines a function which checks material defines against the submeshes
  25893. */
  25894. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25895. /**
  25896. * Indicates that the scene should check if the rendering now needs a prepass
  25897. */
  25898. protected _markScenePrePassDirty(): void;
  25899. /**
  25900. * Indicates that we need to re-calculated for all submeshes
  25901. */
  25902. protected _markAllSubMeshesAsAllDirty(): void;
  25903. /**
  25904. * Indicates that image processing needs to be re-calculated for all submeshes
  25905. */
  25906. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25907. /**
  25908. * Indicates that textures need to be re-calculated for all submeshes
  25909. */
  25910. protected _markAllSubMeshesAsTexturesDirty(): void;
  25911. /**
  25912. * Indicates that fresnel needs to be re-calculated for all submeshes
  25913. */
  25914. protected _markAllSubMeshesAsFresnelDirty(): void;
  25915. /**
  25916. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25917. */
  25918. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25919. /**
  25920. * Indicates that lights need to be re-calculated for all submeshes
  25921. */
  25922. protected _markAllSubMeshesAsLightsDirty(): void;
  25923. /**
  25924. * Indicates that attributes need to be re-calculated for all submeshes
  25925. */
  25926. protected _markAllSubMeshesAsAttributesDirty(): void;
  25927. /**
  25928. * Indicates that misc needs to be re-calculated for all submeshes
  25929. */
  25930. protected _markAllSubMeshesAsMiscDirty(): void;
  25931. /**
  25932. * Indicates that textures and misc need to be re-calculated for all submeshes
  25933. */
  25934. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25935. /**
  25936. * Sets the required values to the prepass renderer.
  25937. * @param prePassRenderer defines the prepass renderer to setup.
  25938. * @returns true if the pre pass is needed.
  25939. */
  25940. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25941. /**
  25942. * Disposes the material
  25943. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25944. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25945. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25946. */
  25947. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25948. /** @hidden */
  25949. private releaseVertexArrayObject;
  25950. /**
  25951. * Serializes this material
  25952. * @returns the serialized material object
  25953. */
  25954. serialize(): any;
  25955. /**
  25956. * Creates a material from parsed material data
  25957. * @param parsedMaterial defines parsed material data
  25958. * @param scene defines the hosting scene
  25959. * @param rootUrl defines the root URL to use to load textures
  25960. * @returns a new material
  25961. */
  25962. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25963. }
  25964. }
  25965. declare module "babylonjs/Materials/multiMaterial" {
  25966. import { Nullable } from "babylonjs/types";
  25967. import { Scene } from "babylonjs/scene";
  25968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25969. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25970. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25971. import { Material } from "babylonjs/Materials/material";
  25972. /**
  25973. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25974. * separate meshes. This can be use to improve performances.
  25975. * @see https://doc.babylonjs.com/how_to/multi_materials
  25976. */
  25977. export class MultiMaterial extends Material {
  25978. private _subMaterials;
  25979. /**
  25980. * Gets or Sets the list of Materials used within the multi material.
  25981. * They need to be ordered according to the submeshes order in the associated mesh
  25982. */
  25983. get subMaterials(): Nullable<Material>[];
  25984. set subMaterials(value: Nullable<Material>[]);
  25985. /**
  25986. * Function used to align with Node.getChildren()
  25987. * @returns the list of Materials used within the multi material
  25988. */
  25989. getChildren(): Nullable<Material>[];
  25990. /**
  25991. * Instantiates a new Multi Material
  25992. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25993. * separate meshes. This can be use to improve performances.
  25994. * @see https://doc.babylonjs.com/how_to/multi_materials
  25995. * @param name Define the name in the scene
  25996. * @param scene Define the scene the material belongs to
  25997. */
  25998. constructor(name: string, scene: Scene);
  25999. private _hookArray;
  26000. /**
  26001. * Get one of the submaterial by its index in the submaterials array
  26002. * @param index The index to look the sub material at
  26003. * @returns The Material if the index has been defined
  26004. */
  26005. getSubMaterial(index: number): Nullable<Material>;
  26006. /**
  26007. * Get the list of active textures for the whole sub materials list.
  26008. * @returns All the textures that will be used during the rendering
  26009. */
  26010. getActiveTextures(): BaseTexture[];
  26011. /**
  26012. * Gets the current class name of the material e.g. "MultiMaterial"
  26013. * Mainly use in serialization.
  26014. * @returns the class name
  26015. */
  26016. getClassName(): string;
  26017. /**
  26018. * Checks if the material is ready to render the requested sub mesh
  26019. * @param mesh Define the mesh the submesh belongs to
  26020. * @param subMesh Define the sub mesh to look readyness for
  26021. * @param useInstances Define whether or not the material is used with instances
  26022. * @returns true if ready, otherwise false
  26023. */
  26024. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26025. /**
  26026. * Clones the current material and its related sub materials
  26027. * @param name Define the name of the newly cloned material
  26028. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26029. * @returns the cloned material
  26030. */
  26031. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26032. /**
  26033. * Serializes the materials into a JSON representation.
  26034. * @returns the JSON representation
  26035. */
  26036. serialize(): any;
  26037. /**
  26038. * Dispose the material and release its associated resources
  26039. * @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)
  26040. * @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)
  26041. * @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)
  26042. */
  26043. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26044. /**
  26045. * Creates a MultiMaterial from parsed MultiMaterial data.
  26046. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26047. * @param scene defines the hosting scene
  26048. * @returns a new MultiMaterial
  26049. */
  26050. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26051. }
  26052. }
  26053. declare module "babylonjs/Meshes/subMesh" {
  26054. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26055. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26056. import { Engine } from "babylonjs/Engines/engine";
  26057. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26058. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26059. import { Effect } from "babylonjs/Materials/effect";
  26060. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26061. import { Plane } from "babylonjs/Maths/math.plane";
  26062. import { Collider } from "babylonjs/Collisions/collider";
  26063. import { Material } from "babylonjs/Materials/material";
  26064. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26066. import { Mesh } from "babylonjs/Meshes/mesh";
  26067. import { Ray } from "babylonjs/Culling/ray";
  26068. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26069. /**
  26070. * Defines a subdivision inside a mesh
  26071. */
  26072. export class SubMesh implements ICullable {
  26073. /** the material index to use */
  26074. materialIndex: number;
  26075. /** vertex index start */
  26076. verticesStart: number;
  26077. /** vertices count */
  26078. verticesCount: number;
  26079. /** index start */
  26080. indexStart: number;
  26081. /** indices count */
  26082. indexCount: number;
  26083. /** @hidden */
  26084. _materialDefines: Nullable<MaterialDefines>;
  26085. /** @hidden */
  26086. _materialEffect: Nullable<Effect>;
  26087. /** @hidden */
  26088. _effectOverride: Nullable<Effect>;
  26089. /**
  26090. * Gets material defines used by the effect associated to the sub mesh
  26091. */
  26092. get materialDefines(): Nullable<MaterialDefines>;
  26093. /**
  26094. * Sets material defines used by the effect associated to the sub mesh
  26095. */
  26096. set materialDefines(defines: Nullable<MaterialDefines>);
  26097. /**
  26098. * Gets associated effect
  26099. */
  26100. get effect(): Nullable<Effect>;
  26101. /**
  26102. * Sets associated effect (effect used to render this submesh)
  26103. * @param effect defines the effect to associate with
  26104. * @param defines defines the set of defines used to compile this effect
  26105. */
  26106. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26107. /** @hidden */
  26108. _linesIndexCount: number;
  26109. private _mesh;
  26110. private _renderingMesh;
  26111. private _boundingInfo;
  26112. private _linesIndexBuffer;
  26113. /** @hidden */
  26114. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26115. /** @hidden */
  26116. _trianglePlanes: Plane[];
  26117. /** @hidden */
  26118. _lastColliderTransformMatrix: Nullable<Matrix>;
  26119. /** @hidden */
  26120. _renderId: number;
  26121. /** @hidden */
  26122. _alphaIndex: number;
  26123. /** @hidden */
  26124. _distanceToCamera: number;
  26125. /** @hidden */
  26126. _id: number;
  26127. private _currentMaterial;
  26128. /**
  26129. * Add a new submesh to a mesh
  26130. * @param materialIndex defines the material index to use
  26131. * @param verticesStart defines vertex index start
  26132. * @param verticesCount defines vertices count
  26133. * @param indexStart defines index start
  26134. * @param indexCount defines indices count
  26135. * @param mesh defines the parent mesh
  26136. * @param renderingMesh defines an optional rendering mesh
  26137. * @param createBoundingBox defines if bounding box should be created for this submesh
  26138. * @returns the new submesh
  26139. */
  26140. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26141. /**
  26142. * Creates a new submesh
  26143. * @param materialIndex defines the material index to use
  26144. * @param verticesStart defines vertex index start
  26145. * @param verticesCount defines vertices count
  26146. * @param indexStart defines index start
  26147. * @param indexCount defines indices count
  26148. * @param mesh defines the parent mesh
  26149. * @param renderingMesh defines an optional rendering mesh
  26150. * @param createBoundingBox defines if bounding box should be created for this submesh
  26151. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26152. */
  26153. constructor(
  26154. /** the material index to use */
  26155. materialIndex: number,
  26156. /** vertex index start */
  26157. verticesStart: number,
  26158. /** vertices count */
  26159. verticesCount: number,
  26160. /** index start */
  26161. indexStart: number,
  26162. /** indices count */
  26163. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26164. /**
  26165. * Returns true if this submesh covers the entire parent mesh
  26166. * @ignorenaming
  26167. */
  26168. get IsGlobal(): boolean;
  26169. /**
  26170. * Returns the submesh BoudingInfo object
  26171. * @returns current bounding info (or mesh's one if the submesh is global)
  26172. */
  26173. getBoundingInfo(): BoundingInfo;
  26174. /**
  26175. * Sets the submesh BoundingInfo
  26176. * @param boundingInfo defines the new bounding info to use
  26177. * @returns the SubMesh
  26178. */
  26179. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26180. /**
  26181. * Returns the mesh of the current submesh
  26182. * @return the parent mesh
  26183. */
  26184. getMesh(): AbstractMesh;
  26185. /**
  26186. * Returns the rendering mesh of the submesh
  26187. * @returns the rendering mesh (could be different from parent mesh)
  26188. */
  26189. getRenderingMesh(): Mesh;
  26190. /**
  26191. * Returns the replacement mesh of the submesh
  26192. * @returns the replacement mesh (could be different from parent mesh)
  26193. */
  26194. getReplacementMesh(): Nullable<AbstractMesh>;
  26195. /**
  26196. * Returns the effective mesh of the submesh
  26197. * @returns the effective mesh (could be different from parent mesh)
  26198. */
  26199. getEffectiveMesh(): AbstractMesh;
  26200. /**
  26201. * Returns the submesh material
  26202. * @returns null or the current material
  26203. */
  26204. getMaterial(): Nullable<Material>;
  26205. private _IsMultiMaterial;
  26206. /**
  26207. * Sets a new updated BoundingInfo object to the submesh
  26208. * @param data defines an optional position array to use to determine the bounding info
  26209. * @returns the SubMesh
  26210. */
  26211. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26212. /** @hidden */
  26213. _checkCollision(collider: Collider): boolean;
  26214. /**
  26215. * Updates the submesh BoundingInfo
  26216. * @param world defines the world matrix to use to update the bounding info
  26217. * @returns the submesh
  26218. */
  26219. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26220. /**
  26221. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26222. * @param frustumPlanes defines the frustum planes
  26223. * @returns true if the submesh is intersecting with the frustum
  26224. */
  26225. isInFrustum(frustumPlanes: Plane[]): boolean;
  26226. /**
  26227. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26228. * @param frustumPlanes defines the frustum planes
  26229. * @returns true if the submesh is inside the frustum
  26230. */
  26231. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26232. /**
  26233. * Renders the submesh
  26234. * @param enableAlphaMode defines if alpha needs to be used
  26235. * @returns the submesh
  26236. */
  26237. render(enableAlphaMode: boolean): SubMesh;
  26238. /**
  26239. * @hidden
  26240. */
  26241. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26242. /**
  26243. * Checks if the submesh intersects with a ray
  26244. * @param ray defines the ray to test
  26245. * @returns true is the passed ray intersects the submesh bounding box
  26246. */
  26247. canIntersects(ray: Ray): boolean;
  26248. /**
  26249. * Intersects current submesh with a ray
  26250. * @param ray defines the ray to test
  26251. * @param positions defines mesh's positions array
  26252. * @param indices defines mesh's indices array
  26253. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26254. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26255. * @returns intersection info or null if no intersection
  26256. */
  26257. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26258. /** @hidden */
  26259. private _intersectLines;
  26260. /** @hidden */
  26261. private _intersectUnIndexedLines;
  26262. /** @hidden */
  26263. private _intersectTriangles;
  26264. /** @hidden */
  26265. private _intersectUnIndexedTriangles;
  26266. /** @hidden */
  26267. _rebuild(): void;
  26268. /**
  26269. * Creates a new submesh from the passed mesh
  26270. * @param newMesh defines the new hosting mesh
  26271. * @param newRenderingMesh defines an optional rendering mesh
  26272. * @returns the new submesh
  26273. */
  26274. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26275. /**
  26276. * Release associated resources
  26277. */
  26278. dispose(): void;
  26279. /**
  26280. * Gets the class name
  26281. * @returns the string "SubMesh".
  26282. */
  26283. getClassName(): string;
  26284. /**
  26285. * Creates a new submesh from indices data
  26286. * @param materialIndex the index of the main mesh material
  26287. * @param startIndex the index where to start the copy in the mesh indices array
  26288. * @param indexCount the number of indices to copy then from the startIndex
  26289. * @param mesh the main mesh to create the submesh from
  26290. * @param renderingMesh the optional rendering mesh
  26291. * @returns a new submesh
  26292. */
  26293. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26294. }
  26295. }
  26296. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26297. /**
  26298. * Class used to represent data loading progression
  26299. */
  26300. export class SceneLoaderFlags {
  26301. private static _ForceFullSceneLoadingForIncremental;
  26302. private static _ShowLoadingScreen;
  26303. private static _CleanBoneMatrixWeights;
  26304. private static _loggingLevel;
  26305. /**
  26306. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26307. */
  26308. static get ForceFullSceneLoadingForIncremental(): boolean;
  26309. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26310. /**
  26311. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26312. */
  26313. static get ShowLoadingScreen(): boolean;
  26314. static set ShowLoadingScreen(value: boolean);
  26315. /**
  26316. * Defines the current logging level (while loading the scene)
  26317. * @ignorenaming
  26318. */
  26319. static get loggingLevel(): number;
  26320. static set loggingLevel(value: number);
  26321. /**
  26322. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26323. */
  26324. static get CleanBoneMatrixWeights(): boolean;
  26325. static set CleanBoneMatrixWeights(value: boolean);
  26326. }
  26327. }
  26328. declare module "babylonjs/Meshes/geometry" {
  26329. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26330. import { Scene } from "babylonjs/scene";
  26331. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26332. import { Engine } from "babylonjs/Engines/engine";
  26333. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26334. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26335. import { Effect } from "babylonjs/Materials/effect";
  26336. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26337. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26338. import { Mesh } from "babylonjs/Meshes/mesh";
  26339. /**
  26340. * Class used to store geometry data (vertex buffers + index buffer)
  26341. */
  26342. export class Geometry implements IGetSetVerticesData {
  26343. /**
  26344. * Gets or sets the ID of the geometry
  26345. */
  26346. id: string;
  26347. /**
  26348. * Gets or sets the unique ID of the geometry
  26349. */
  26350. uniqueId: number;
  26351. /**
  26352. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26353. */
  26354. delayLoadState: number;
  26355. /**
  26356. * Gets the file containing the data to load when running in delay load state
  26357. */
  26358. delayLoadingFile: Nullable<string>;
  26359. /**
  26360. * Callback called when the geometry is updated
  26361. */
  26362. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26363. private _scene;
  26364. private _engine;
  26365. private _meshes;
  26366. private _totalVertices;
  26367. /** @hidden */
  26368. _indices: IndicesArray;
  26369. /** @hidden */
  26370. _vertexBuffers: {
  26371. [key: string]: VertexBuffer;
  26372. };
  26373. private _isDisposed;
  26374. private _extend;
  26375. private _boundingBias;
  26376. /** @hidden */
  26377. _delayInfo: Array<string>;
  26378. private _indexBuffer;
  26379. private _indexBufferIsUpdatable;
  26380. /** @hidden */
  26381. _boundingInfo: Nullable<BoundingInfo>;
  26382. /** @hidden */
  26383. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26384. /** @hidden */
  26385. _softwareSkinningFrameId: number;
  26386. private _vertexArrayObjects;
  26387. private _updatable;
  26388. /** @hidden */
  26389. _positions: Nullable<Vector3[]>;
  26390. /**
  26391. * 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
  26392. */
  26393. get boundingBias(): Vector2;
  26394. /**
  26395. * 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
  26396. */
  26397. set boundingBias(value: Vector2);
  26398. /**
  26399. * Static function used to attach a new empty geometry to a mesh
  26400. * @param mesh defines the mesh to attach the geometry to
  26401. * @returns the new Geometry
  26402. */
  26403. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26404. /** Get the list of meshes using this geometry */
  26405. get meshes(): Mesh[];
  26406. /**
  26407. * 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
  26408. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26409. */
  26410. useBoundingInfoFromGeometry: boolean;
  26411. /**
  26412. * Creates a new geometry
  26413. * @param id defines the unique ID
  26414. * @param scene defines the hosting scene
  26415. * @param vertexData defines the VertexData used to get geometry data
  26416. * @param updatable defines if geometry must be updatable (false by default)
  26417. * @param mesh defines the mesh that will be associated with the geometry
  26418. */
  26419. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26420. /**
  26421. * Gets the current extend of the geometry
  26422. */
  26423. get extend(): {
  26424. minimum: Vector3;
  26425. maximum: Vector3;
  26426. };
  26427. /**
  26428. * Gets the hosting scene
  26429. * @returns the hosting Scene
  26430. */
  26431. getScene(): Scene;
  26432. /**
  26433. * Gets the hosting engine
  26434. * @returns the hosting Engine
  26435. */
  26436. getEngine(): Engine;
  26437. /**
  26438. * Defines if the geometry is ready to use
  26439. * @returns true if the geometry is ready to be used
  26440. */
  26441. isReady(): boolean;
  26442. /**
  26443. * Gets a value indicating that the geometry should not be serialized
  26444. */
  26445. get doNotSerialize(): boolean;
  26446. /** @hidden */
  26447. _rebuild(): void;
  26448. /**
  26449. * Affects all geometry data in one call
  26450. * @param vertexData defines the geometry data
  26451. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26452. */
  26453. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26454. /**
  26455. * Set specific vertex data
  26456. * @param kind defines the data kind (Position, normal, etc...)
  26457. * @param data defines the vertex data to use
  26458. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26459. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26460. */
  26461. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26462. /**
  26463. * Removes a specific vertex data
  26464. * @param kind defines the data kind (Position, normal, etc...)
  26465. */
  26466. removeVerticesData(kind: string): void;
  26467. /**
  26468. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26469. * @param buffer defines the vertex buffer to use
  26470. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26471. */
  26472. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26473. /**
  26474. * Update a specific vertex buffer
  26475. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26476. * It will do nothing if the buffer is not updatable
  26477. * @param kind defines the data kind (Position, normal, etc...)
  26478. * @param data defines the data to use
  26479. * @param offset defines the offset in the target buffer where to store the data
  26480. * @param useBytes set to true if the offset is in bytes
  26481. */
  26482. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26483. /**
  26484. * Update a specific vertex buffer
  26485. * This function will create a new buffer if the current one is not updatable
  26486. * @param kind defines the data kind (Position, normal, etc...)
  26487. * @param data defines the data to use
  26488. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26489. */
  26490. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26491. private _updateBoundingInfo;
  26492. /** @hidden */
  26493. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26494. /**
  26495. * Gets total number of vertices
  26496. * @returns the total number of vertices
  26497. */
  26498. getTotalVertices(): number;
  26499. /**
  26500. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26501. * @param kind defines the data kind (Position, normal, etc...)
  26502. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26503. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26504. * @returns a float array containing vertex data
  26505. */
  26506. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26507. /**
  26508. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26509. * @param kind defines the data kind (Position, normal, etc...)
  26510. * @returns true if the vertex buffer with the specified kind is updatable
  26511. */
  26512. isVertexBufferUpdatable(kind: string): boolean;
  26513. /**
  26514. * Gets a specific vertex buffer
  26515. * @param kind defines the data kind (Position, normal, etc...)
  26516. * @returns a VertexBuffer
  26517. */
  26518. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26519. /**
  26520. * Returns all vertex buffers
  26521. * @return an object holding all vertex buffers indexed by kind
  26522. */
  26523. getVertexBuffers(): Nullable<{
  26524. [key: string]: VertexBuffer;
  26525. }>;
  26526. /**
  26527. * Gets a boolean indicating if specific vertex buffer is present
  26528. * @param kind defines the data kind (Position, normal, etc...)
  26529. * @returns true if data is present
  26530. */
  26531. isVerticesDataPresent(kind: string): boolean;
  26532. /**
  26533. * Gets a list of all attached data kinds (Position, normal, etc...)
  26534. * @returns a list of string containing all kinds
  26535. */
  26536. getVerticesDataKinds(): string[];
  26537. /**
  26538. * Update index buffer
  26539. * @param indices defines the indices to store in the index buffer
  26540. * @param offset defines the offset in the target buffer where to store the data
  26541. * @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)
  26542. */
  26543. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26544. /**
  26545. * Creates a new index buffer
  26546. * @param indices defines the indices to store in the index buffer
  26547. * @param totalVertices defines the total number of vertices (could be null)
  26548. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26549. */
  26550. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26551. /**
  26552. * Return the total number of indices
  26553. * @returns the total number of indices
  26554. */
  26555. getTotalIndices(): number;
  26556. /**
  26557. * Gets the index buffer array
  26558. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26559. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26560. * @returns the index buffer array
  26561. */
  26562. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26563. /**
  26564. * Gets the index buffer
  26565. * @return the index buffer
  26566. */
  26567. getIndexBuffer(): Nullable<DataBuffer>;
  26568. /** @hidden */
  26569. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26570. /**
  26571. * Release the associated resources for a specific mesh
  26572. * @param mesh defines the source mesh
  26573. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26574. */
  26575. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26576. /**
  26577. * Apply current geometry to a given mesh
  26578. * @param mesh defines the mesh to apply geometry to
  26579. */
  26580. applyToMesh(mesh: Mesh): void;
  26581. private _updateExtend;
  26582. private _applyToMesh;
  26583. private notifyUpdate;
  26584. /**
  26585. * Load the geometry if it was flagged as delay loaded
  26586. * @param scene defines the hosting scene
  26587. * @param onLoaded defines a callback called when the geometry is loaded
  26588. */
  26589. load(scene: Scene, onLoaded?: () => void): void;
  26590. private _queueLoad;
  26591. /**
  26592. * Invert the geometry to move from a right handed system to a left handed one.
  26593. */
  26594. toLeftHanded(): void;
  26595. /** @hidden */
  26596. _resetPointsArrayCache(): void;
  26597. /** @hidden */
  26598. _generatePointsArray(): boolean;
  26599. /**
  26600. * Gets a value indicating if the geometry is disposed
  26601. * @returns true if the geometry was disposed
  26602. */
  26603. isDisposed(): boolean;
  26604. private _disposeVertexArrayObjects;
  26605. /**
  26606. * Free all associated resources
  26607. */
  26608. dispose(): void;
  26609. /**
  26610. * Clone the current geometry into a new geometry
  26611. * @param id defines the unique ID of the new geometry
  26612. * @returns a new geometry object
  26613. */
  26614. copy(id: string): Geometry;
  26615. /**
  26616. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26617. * @return a JSON representation of the current geometry data (without the vertices data)
  26618. */
  26619. serialize(): any;
  26620. private toNumberArray;
  26621. /**
  26622. * Serialize all vertices data into a JSON oject
  26623. * @returns a JSON representation of the current geometry data
  26624. */
  26625. serializeVerticeData(): any;
  26626. /**
  26627. * Extracts a clone of a mesh geometry
  26628. * @param mesh defines the source mesh
  26629. * @param id defines the unique ID of the new geometry object
  26630. * @returns the new geometry object
  26631. */
  26632. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26633. /**
  26634. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26635. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26636. * Be aware Math.random() could cause collisions, but:
  26637. * "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"
  26638. * @returns a string containing a new GUID
  26639. */
  26640. static RandomId(): string;
  26641. /** @hidden */
  26642. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26643. private static _CleanMatricesWeights;
  26644. /**
  26645. * Create a new geometry from persisted data (Using .babylon file format)
  26646. * @param parsedVertexData defines the persisted data
  26647. * @param scene defines the hosting scene
  26648. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26649. * @returns the new geometry object
  26650. */
  26651. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26652. }
  26653. }
  26654. declare module "babylonjs/Meshes/mesh.vertexData" {
  26655. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26656. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26657. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26658. import { Geometry } from "babylonjs/Meshes/geometry";
  26659. import { Mesh } from "babylonjs/Meshes/mesh";
  26660. /**
  26661. * Define an interface for all classes that will get and set the data on vertices
  26662. */
  26663. export interface IGetSetVerticesData {
  26664. /**
  26665. * Gets a boolean indicating if specific vertex data is present
  26666. * @param kind defines the vertex data kind to use
  26667. * @returns true is data kind is present
  26668. */
  26669. isVerticesDataPresent(kind: string): boolean;
  26670. /**
  26671. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26672. * @param kind defines the data kind (Position, normal, etc...)
  26673. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26674. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26675. * @returns a float array containing vertex data
  26676. */
  26677. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26678. /**
  26679. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26680. * @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.
  26681. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26682. * @returns the indices array or an empty array if the mesh has no geometry
  26683. */
  26684. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26685. /**
  26686. * Set specific vertex data
  26687. * @param kind defines the data kind (Position, normal, etc...)
  26688. * @param data defines the vertex data to use
  26689. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26690. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26691. */
  26692. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26693. /**
  26694. * Update a specific associated vertex buffer
  26695. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26696. * - VertexBuffer.PositionKind
  26697. * - VertexBuffer.UVKind
  26698. * - VertexBuffer.UV2Kind
  26699. * - VertexBuffer.UV3Kind
  26700. * - VertexBuffer.UV4Kind
  26701. * - VertexBuffer.UV5Kind
  26702. * - VertexBuffer.UV6Kind
  26703. * - VertexBuffer.ColorKind
  26704. * - VertexBuffer.MatricesIndicesKind
  26705. * - VertexBuffer.MatricesIndicesExtraKind
  26706. * - VertexBuffer.MatricesWeightsKind
  26707. * - VertexBuffer.MatricesWeightsExtraKind
  26708. * @param data defines the data source
  26709. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26710. * @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)
  26711. */
  26712. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26713. /**
  26714. * Creates a new index buffer
  26715. * @param indices defines the indices to store in the index buffer
  26716. * @param totalVertices defines the total number of vertices (could be null)
  26717. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26718. */
  26719. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26720. }
  26721. /**
  26722. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26723. */
  26724. export class VertexData {
  26725. /**
  26726. * Mesh side orientation : usually the external or front surface
  26727. */
  26728. static readonly FRONTSIDE: number;
  26729. /**
  26730. * Mesh side orientation : usually the internal or back surface
  26731. */
  26732. static readonly BACKSIDE: number;
  26733. /**
  26734. * Mesh side orientation : both internal and external or front and back surfaces
  26735. */
  26736. static readonly DOUBLESIDE: number;
  26737. /**
  26738. * Mesh side orientation : by default, `FRONTSIDE`
  26739. */
  26740. static readonly DEFAULTSIDE: number;
  26741. /**
  26742. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26743. */
  26744. positions: Nullable<FloatArray>;
  26745. /**
  26746. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26747. */
  26748. normals: Nullable<FloatArray>;
  26749. /**
  26750. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26751. */
  26752. tangents: Nullable<FloatArray>;
  26753. /**
  26754. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26755. */
  26756. uvs: Nullable<FloatArray>;
  26757. /**
  26758. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26759. */
  26760. uvs2: Nullable<FloatArray>;
  26761. /**
  26762. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26763. */
  26764. uvs3: Nullable<FloatArray>;
  26765. /**
  26766. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26767. */
  26768. uvs4: Nullable<FloatArray>;
  26769. /**
  26770. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26771. */
  26772. uvs5: Nullable<FloatArray>;
  26773. /**
  26774. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26775. */
  26776. uvs6: Nullable<FloatArray>;
  26777. /**
  26778. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26779. */
  26780. colors: Nullable<FloatArray>;
  26781. /**
  26782. * 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).
  26783. */
  26784. matricesIndices: Nullable<FloatArray>;
  26785. /**
  26786. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26787. */
  26788. matricesWeights: Nullable<FloatArray>;
  26789. /**
  26790. * An array extending the number of possible indices
  26791. */
  26792. matricesIndicesExtra: Nullable<FloatArray>;
  26793. /**
  26794. * An array extending the number of possible weights when the number of indices is extended
  26795. */
  26796. matricesWeightsExtra: Nullable<FloatArray>;
  26797. /**
  26798. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26799. */
  26800. indices: Nullable<IndicesArray>;
  26801. /**
  26802. * Uses the passed data array to set the set the values for the specified kind of data
  26803. * @param data a linear array of floating numbers
  26804. * @param kind the type of data that is being set, eg positions, colors etc
  26805. */
  26806. set(data: FloatArray, kind: string): void;
  26807. /**
  26808. * Associates the vertexData to the passed Mesh.
  26809. * Sets it as updatable or not (default `false`)
  26810. * @param mesh the mesh the vertexData is applied to
  26811. * @param updatable when used and having the value true allows new data to update the vertexData
  26812. * @returns the VertexData
  26813. */
  26814. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26815. /**
  26816. * Associates the vertexData to the passed Geometry.
  26817. * Sets it as updatable or not (default `false`)
  26818. * @param geometry the geometry the vertexData is applied to
  26819. * @param updatable when used and having the value true allows new data to update the vertexData
  26820. * @returns VertexData
  26821. */
  26822. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26823. /**
  26824. * Updates the associated mesh
  26825. * @param mesh the mesh to be updated
  26826. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26827. * @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
  26828. * @returns VertexData
  26829. */
  26830. updateMesh(mesh: Mesh): VertexData;
  26831. /**
  26832. * Updates the associated geometry
  26833. * @param geometry the geometry to be updated
  26834. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26835. * @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
  26836. * @returns VertexData.
  26837. */
  26838. updateGeometry(geometry: Geometry): VertexData;
  26839. private _applyTo;
  26840. private _update;
  26841. /**
  26842. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26843. * @param matrix the transforming matrix
  26844. * @returns the VertexData
  26845. */
  26846. transform(matrix: Matrix): VertexData;
  26847. /**
  26848. * Merges the passed VertexData into the current one
  26849. * @param other the VertexData to be merged into the current one
  26850. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26851. * @returns the modified VertexData
  26852. */
  26853. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26854. private _mergeElement;
  26855. private _validate;
  26856. /**
  26857. * Serializes the VertexData
  26858. * @returns a serialized object
  26859. */
  26860. serialize(): any;
  26861. /**
  26862. * Extracts the vertexData from a mesh
  26863. * @param mesh the mesh from which to extract the VertexData
  26864. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26865. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26866. * @returns the object VertexData associated to the passed mesh
  26867. */
  26868. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26869. /**
  26870. * Extracts the vertexData from the geometry
  26871. * @param geometry the geometry from which to extract the VertexData
  26872. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26873. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26874. * @returns the object VertexData associated to the passed mesh
  26875. */
  26876. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26877. private static _ExtractFrom;
  26878. /**
  26879. * Creates the VertexData for a Ribbon
  26880. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26881. * * pathArray array of paths, each of which an array of successive Vector3
  26882. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26883. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26884. * * 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
  26885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26886. * * 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)
  26887. * * 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)
  26888. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26889. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26890. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26891. * @returns the VertexData of the ribbon
  26892. */
  26893. static CreateRibbon(options: {
  26894. pathArray: Vector3[][];
  26895. closeArray?: boolean;
  26896. closePath?: boolean;
  26897. offset?: number;
  26898. sideOrientation?: number;
  26899. frontUVs?: Vector4;
  26900. backUVs?: Vector4;
  26901. invertUV?: boolean;
  26902. uvs?: Vector2[];
  26903. colors?: Color4[];
  26904. }): VertexData;
  26905. /**
  26906. * Creates the VertexData for a box
  26907. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26908. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26909. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26910. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26911. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26912. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26913. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26915. * * 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)
  26916. * * 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)
  26917. * @returns the VertexData of the box
  26918. */
  26919. static CreateBox(options: {
  26920. size?: number;
  26921. width?: number;
  26922. height?: number;
  26923. depth?: number;
  26924. faceUV?: Vector4[];
  26925. faceColors?: Color4[];
  26926. sideOrientation?: number;
  26927. frontUVs?: Vector4;
  26928. backUVs?: Vector4;
  26929. }): VertexData;
  26930. /**
  26931. * Creates the VertexData for a tiled box
  26932. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26933. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26934. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26935. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26936. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26937. * @returns the VertexData of the box
  26938. */
  26939. static CreateTiledBox(options: {
  26940. pattern?: number;
  26941. width?: number;
  26942. height?: number;
  26943. depth?: number;
  26944. tileSize?: number;
  26945. tileWidth?: number;
  26946. tileHeight?: number;
  26947. alignHorizontal?: number;
  26948. alignVertical?: number;
  26949. faceUV?: Vector4[];
  26950. faceColors?: Color4[];
  26951. sideOrientation?: number;
  26952. }): VertexData;
  26953. /**
  26954. * Creates the VertexData for a tiled plane
  26955. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26956. * * pattern a limited pattern arrangement depending on the number
  26957. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26958. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26959. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26960. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26961. * * 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)
  26962. * * 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)
  26963. * @returns the VertexData of the tiled plane
  26964. */
  26965. static CreateTiledPlane(options: {
  26966. pattern?: number;
  26967. tileSize?: number;
  26968. tileWidth?: number;
  26969. tileHeight?: number;
  26970. size?: number;
  26971. width?: number;
  26972. height?: number;
  26973. alignHorizontal?: number;
  26974. alignVertical?: number;
  26975. sideOrientation?: number;
  26976. frontUVs?: Vector4;
  26977. backUVs?: Vector4;
  26978. }): VertexData;
  26979. /**
  26980. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26981. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26982. * * segments sets the number of horizontal strips optional, default 32
  26983. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26984. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26985. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26986. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26987. * * 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
  26988. * * 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
  26989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26990. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26991. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26992. * @returns the VertexData of the ellipsoid
  26993. */
  26994. static CreateSphere(options: {
  26995. segments?: number;
  26996. diameter?: number;
  26997. diameterX?: number;
  26998. diameterY?: number;
  26999. diameterZ?: number;
  27000. arc?: number;
  27001. slice?: number;
  27002. sideOrientation?: number;
  27003. frontUVs?: Vector4;
  27004. backUVs?: Vector4;
  27005. }): VertexData;
  27006. /**
  27007. * Creates the VertexData for a cylinder, cone or prism
  27008. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27009. * * height sets the height (y direction) of the cylinder, optional, default 2
  27010. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27011. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27012. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27013. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27014. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27015. * * 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
  27016. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27017. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27018. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27019. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27020. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27021. * * 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)
  27022. * * 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)
  27023. * @returns the VertexData of the cylinder, cone or prism
  27024. */
  27025. static CreateCylinder(options: {
  27026. height?: number;
  27027. diameterTop?: number;
  27028. diameterBottom?: number;
  27029. diameter?: number;
  27030. tessellation?: number;
  27031. subdivisions?: number;
  27032. arc?: number;
  27033. faceColors?: Color4[];
  27034. faceUV?: Vector4[];
  27035. hasRings?: boolean;
  27036. enclose?: boolean;
  27037. sideOrientation?: number;
  27038. frontUVs?: Vector4;
  27039. backUVs?: Vector4;
  27040. }): VertexData;
  27041. /**
  27042. * Creates the VertexData for a torus
  27043. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27044. * * diameter the diameter of the torus, optional default 1
  27045. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27046. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27047. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27048. * * 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)
  27049. * * 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)
  27050. * @returns the VertexData of the torus
  27051. */
  27052. static CreateTorus(options: {
  27053. diameter?: number;
  27054. thickness?: number;
  27055. tessellation?: number;
  27056. sideOrientation?: number;
  27057. frontUVs?: Vector4;
  27058. backUVs?: Vector4;
  27059. }): VertexData;
  27060. /**
  27061. * Creates the VertexData of the LineSystem
  27062. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27063. * - lines an array of lines, each line being an array of successive Vector3
  27064. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27065. * @returns the VertexData of the LineSystem
  27066. */
  27067. static CreateLineSystem(options: {
  27068. lines: Vector3[][];
  27069. colors?: Nullable<Color4[][]>;
  27070. }): VertexData;
  27071. /**
  27072. * Create the VertexData for a DashedLines
  27073. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27074. * - points an array successive Vector3
  27075. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27076. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27077. * - dashNb the intended total number of dashes, optional, default 200
  27078. * @returns the VertexData for the DashedLines
  27079. */
  27080. static CreateDashedLines(options: {
  27081. points: Vector3[];
  27082. dashSize?: number;
  27083. gapSize?: number;
  27084. dashNb?: number;
  27085. }): VertexData;
  27086. /**
  27087. * Creates the VertexData for a Ground
  27088. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27089. * - width the width (x direction) of the ground, optional, default 1
  27090. * - height the height (z direction) of the ground, optional, default 1
  27091. * - subdivisions the number of subdivisions per side, optional, default 1
  27092. * @returns the VertexData of the Ground
  27093. */
  27094. static CreateGround(options: {
  27095. width?: number;
  27096. height?: number;
  27097. subdivisions?: number;
  27098. subdivisionsX?: number;
  27099. subdivisionsY?: number;
  27100. }): VertexData;
  27101. /**
  27102. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27103. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27104. * * xmin the ground minimum X coordinate, optional, default -1
  27105. * * zmin the ground minimum Z coordinate, optional, default -1
  27106. * * xmax the ground maximum X coordinate, optional, default 1
  27107. * * zmax the ground maximum Z coordinate, optional, default 1
  27108. * * 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}
  27109. * * 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}
  27110. * @returns the VertexData of the TiledGround
  27111. */
  27112. static CreateTiledGround(options: {
  27113. xmin: number;
  27114. zmin: number;
  27115. xmax: number;
  27116. zmax: number;
  27117. subdivisions?: {
  27118. w: number;
  27119. h: number;
  27120. };
  27121. precision?: {
  27122. w: number;
  27123. h: number;
  27124. };
  27125. }): VertexData;
  27126. /**
  27127. * Creates the VertexData of the Ground designed from a heightmap
  27128. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27129. * * width the width (x direction) of the ground
  27130. * * height the height (z direction) of the ground
  27131. * * subdivisions the number of subdivisions per side
  27132. * * minHeight the minimum altitude on the ground, optional, default 0
  27133. * * maxHeight the maximum altitude on the ground, optional default 1
  27134. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27135. * * buffer the array holding the image color data
  27136. * * bufferWidth the width of image
  27137. * * bufferHeight the height of image
  27138. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27139. * @returns the VertexData of the Ground designed from a heightmap
  27140. */
  27141. static CreateGroundFromHeightMap(options: {
  27142. width: number;
  27143. height: number;
  27144. subdivisions: number;
  27145. minHeight: number;
  27146. maxHeight: number;
  27147. colorFilter: Color3;
  27148. buffer: Uint8Array;
  27149. bufferWidth: number;
  27150. bufferHeight: number;
  27151. alphaFilter: number;
  27152. }): VertexData;
  27153. /**
  27154. * Creates the VertexData for a Plane
  27155. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27156. * * size sets the width and height of the plane to the value of size, optional default 1
  27157. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27158. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27160. * * 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)
  27161. * * 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)
  27162. * @returns the VertexData of the box
  27163. */
  27164. static CreatePlane(options: {
  27165. size?: number;
  27166. width?: number;
  27167. height?: number;
  27168. sideOrientation?: number;
  27169. frontUVs?: Vector4;
  27170. backUVs?: Vector4;
  27171. }): VertexData;
  27172. /**
  27173. * Creates the VertexData of the Disc or regular Polygon
  27174. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27175. * * radius the radius of the disc, optional default 0.5
  27176. * * tessellation the number of polygon sides, optional, default 64
  27177. * * 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
  27178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27179. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27180. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27181. * @returns the VertexData of the box
  27182. */
  27183. static CreateDisc(options: {
  27184. radius?: number;
  27185. tessellation?: number;
  27186. arc?: number;
  27187. sideOrientation?: number;
  27188. frontUVs?: Vector4;
  27189. backUVs?: Vector4;
  27190. }): VertexData;
  27191. /**
  27192. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27193. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27194. * @param polygon a mesh built from polygonTriangulation.build()
  27195. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27196. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27197. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27198. * @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)
  27199. * @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)
  27200. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27201. * @returns the VertexData of the Polygon
  27202. */
  27203. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27204. /**
  27205. * Creates the VertexData of the IcoSphere
  27206. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27207. * * radius the radius of the IcoSphere, optional default 1
  27208. * * radiusX allows stretching in the x direction, optional, default radius
  27209. * * radiusY allows stretching in the y direction, optional, default radius
  27210. * * radiusZ allows stretching in the z direction, optional, default radius
  27211. * * flat when true creates a flat shaded mesh, optional, default true
  27212. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27213. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27214. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27215. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27216. * @returns the VertexData of the IcoSphere
  27217. */
  27218. static CreateIcoSphere(options: {
  27219. radius?: number;
  27220. radiusX?: number;
  27221. radiusY?: number;
  27222. radiusZ?: number;
  27223. flat?: boolean;
  27224. subdivisions?: number;
  27225. sideOrientation?: number;
  27226. frontUVs?: Vector4;
  27227. backUVs?: Vector4;
  27228. }): VertexData;
  27229. /**
  27230. * Creates the VertexData for a Polyhedron
  27231. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27232. * * type provided types are:
  27233. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27234. * * 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)
  27235. * * size the size of the IcoSphere, optional default 1
  27236. * * sizeX allows stretching in the x direction, optional, default size
  27237. * * sizeY allows stretching in the y direction, optional, default size
  27238. * * sizeZ allows stretching in the z direction, optional, default size
  27239. * * 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
  27240. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27241. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27242. * * flat when true creates a flat shaded mesh, optional, default true
  27243. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27245. * * 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)
  27246. * * 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)
  27247. * @returns the VertexData of the Polyhedron
  27248. */
  27249. static CreatePolyhedron(options: {
  27250. type?: number;
  27251. size?: number;
  27252. sizeX?: number;
  27253. sizeY?: number;
  27254. sizeZ?: number;
  27255. custom?: any;
  27256. faceUV?: Vector4[];
  27257. faceColors?: Color4[];
  27258. flat?: boolean;
  27259. sideOrientation?: number;
  27260. frontUVs?: Vector4;
  27261. backUVs?: Vector4;
  27262. }): VertexData;
  27263. /**
  27264. * Creates the VertexData for a TorusKnot
  27265. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27266. * * radius the radius of the torus knot, optional, default 2
  27267. * * tube the thickness of the tube, optional, default 0.5
  27268. * * radialSegments the number of sides on each tube segments, optional, default 32
  27269. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27270. * * p the number of windings around the z axis, optional, default 2
  27271. * * q the number of windings around the x axis, optional, default 3
  27272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27273. * * 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)
  27274. * * 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)
  27275. * @returns the VertexData of the Torus Knot
  27276. */
  27277. static CreateTorusKnot(options: {
  27278. radius?: number;
  27279. tube?: number;
  27280. radialSegments?: number;
  27281. tubularSegments?: number;
  27282. p?: number;
  27283. q?: number;
  27284. sideOrientation?: number;
  27285. frontUVs?: Vector4;
  27286. backUVs?: Vector4;
  27287. }): VertexData;
  27288. /**
  27289. * Compute normals for given positions and indices
  27290. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27291. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27292. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27293. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27294. * * facetNormals : optional array of facet normals (vector3)
  27295. * * facetPositions : optional array of facet positions (vector3)
  27296. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27297. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27298. * * bInfo : optional bounding info, required for facetPartitioning computation
  27299. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27300. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27301. * * useRightHandedSystem: optional boolean to for right handed system computation
  27302. * * depthSort : optional boolean to enable the facet depth sort computation
  27303. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27304. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27305. */
  27306. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27307. facetNormals?: any;
  27308. facetPositions?: any;
  27309. facetPartitioning?: any;
  27310. ratio?: number;
  27311. bInfo?: any;
  27312. bbSize?: Vector3;
  27313. subDiv?: any;
  27314. useRightHandedSystem?: boolean;
  27315. depthSort?: boolean;
  27316. distanceTo?: Vector3;
  27317. depthSortedFacets?: any;
  27318. }): void;
  27319. /** @hidden */
  27320. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27321. /**
  27322. * Applies VertexData created from the imported parameters to the geometry
  27323. * @param parsedVertexData the parsed data from an imported file
  27324. * @param geometry the geometry to apply the VertexData to
  27325. */
  27326. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27327. }
  27328. }
  27329. declare module "babylonjs/Morph/morphTarget" {
  27330. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27331. import { Observable } from "babylonjs/Misc/observable";
  27332. import { Nullable, FloatArray } from "babylonjs/types";
  27333. import { Scene } from "babylonjs/scene";
  27334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27335. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27336. /**
  27337. * Defines a target to use with MorphTargetManager
  27338. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27339. */
  27340. export class MorphTarget implements IAnimatable {
  27341. /** defines the name of the target */
  27342. name: string;
  27343. /**
  27344. * Gets or sets the list of animations
  27345. */
  27346. animations: import("babylonjs/Animations/animation").Animation[];
  27347. private _scene;
  27348. private _positions;
  27349. private _normals;
  27350. private _tangents;
  27351. private _uvs;
  27352. private _influence;
  27353. private _uniqueId;
  27354. /**
  27355. * Observable raised when the influence changes
  27356. */
  27357. onInfluenceChanged: Observable<boolean>;
  27358. /** @hidden */
  27359. _onDataLayoutChanged: Observable<void>;
  27360. /**
  27361. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27362. */
  27363. get influence(): number;
  27364. set influence(influence: number);
  27365. /**
  27366. * Gets or sets the id of the morph Target
  27367. */
  27368. id: string;
  27369. private _animationPropertiesOverride;
  27370. /**
  27371. * Gets or sets the animation properties override
  27372. */
  27373. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27374. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27375. /**
  27376. * Creates a new MorphTarget
  27377. * @param name defines the name of the target
  27378. * @param influence defines the influence to use
  27379. * @param scene defines the scene the morphtarget belongs to
  27380. */
  27381. constructor(
  27382. /** defines the name of the target */
  27383. name: string, influence?: number, scene?: Nullable<Scene>);
  27384. /**
  27385. * Gets the unique ID of this manager
  27386. */
  27387. get uniqueId(): number;
  27388. /**
  27389. * Gets a boolean defining if the target contains position data
  27390. */
  27391. get hasPositions(): boolean;
  27392. /**
  27393. * Gets a boolean defining if the target contains normal data
  27394. */
  27395. get hasNormals(): boolean;
  27396. /**
  27397. * Gets a boolean defining if the target contains tangent data
  27398. */
  27399. get hasTangents(): boolean;
  27400. /**
  27401. * Gets a boolean defining if the target contains texture coordinates data
  27402. */
  27403. get hasUVs(): boolean;
  27404. /**
  27405. * Affects position data to this target
  27406. * @param data defines the position data to use
  27407. */
  27408. setPositions(data: Nullable<FloatArray>): void;
  27409. /**
  27410. * Gets the position data stored in this target
  27411. * @returns a FloatArray containing the position data (or null if not present)
  27412. */
  27413. getPositions(): Nullable<FloatArray>;
  27414. /**
  27415. * Affects normal data to this target
  27416. * @param data defines the normal data to use
  27417. */
  27418. setNormals(data: Nullable<FloatArray>): void;
  27419. /**
  27420. * Gets the normal data stored in this target
  27421. * @returns a FloatArray containing the normal data (or null if not present)
  27422. */
  27423. getNormals(): Nullable<FloatArray>;
  27424. /**
  27425. * Affects tangent data to this target
  27426. * @param data defines the tangent data to use
  27427. */
  27428. setTangents(data: Nullable<FloatArray>): void;
  27429. /**
  27430. * Gets the tangent data stored in this target
  27431. * @returns a FloatArray containing the tangent data (or null if not present)
  27432. */
  27433. getTangents(): Nullable<FloatArray>;
  27434. /**
  27435. * Affects texture coordinates data to this target
  27436. * @param data defines the texture coordinates data to use
  27437. */
  27438. setUVs(data: Nullable<FloatArray>): void;
  27439. /**
  27440. * Gets the texture coordinates data stored in this target
  27441. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27442. */
  27443. getUVs(): Nullable<FloatArray>;
  27444. /**
  27445. * Clone the current target
  27446. * @returns a new MorphTarget
  27447. */
  27448. clone(): MorphTarget;
  27449. /**
  27450. * Serializes the current target into a Serialization object
  27451. * @returns the serialized object
  27452. */
  27453. serialize(): any;
  27454. /**
  27455. * Returns the string "MorphTarget"
  27456. * @returns "MorphTarget"
  27457. */
  27458. getClassName(): string;
  27459. /**
  27460. * Creates a new target from serialized data
  27461. * @param serializationObject defines the serialized data to use
  27462. * @returns a new MorphTarget
  27463. */
  27464. static Parse(serializationObject: any): MorphTarget;
  27465. /**
  27466. * Creates a MorphTarget from mesh data
  27467. * @param mesh defines the source mesh
  27468. * @param name defines the name to use for the new target
  27469. * @param influence defines the influence to attach to the target
  27470. * @returns a new MorphTarget
  27471. */
  27472. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27473. }
  27474. }
  27475. declare module "babylonjs/Morph/morphTargetManager" {
  27476. import { Nullable } from "babylonjs/types";
  27477. import { Scene } from "babylonjs/scene";
  27478. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27479. /**
  27480. * This class is used to deform meshes using morphing between different targets
  27481. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27482. */
  27483. export class MorphTargetManager {
  27484. private _targets;
  27485. private _targetInfluenceChangedObservers;
  27486. private _targetDataLayoutChangedObservers;
  27487. private _activeTargets;
  27488. private _scene;
  27489. private _influences;
  27490. private _supportsNormals;
  27491. private _supportsTangents;
  27492. private _supportsUVs;
  27493. private _vertexCount;
  27494. private _uniqueId;
  27495. private _tempInfluences;
  27496. /**
  27497. * Gets or sets a boolean indicating if normals must be morphed
  27498. */
  27499. enableNormalMorphing: boolean;
  27500. /**
  27501. * Gets or sets a boolean indicating if tangents must be morphed
  27502. */
  27503. enableTangentMorphing: boolean;
  27504. /**
  27505. * Gets or sets a boolean indicating if UV must be morphed
  27506. */
  27507. enableUVMorphing: boolean;
  27508. /**
  27509. * Creates a new MorphTargetManager
  27510. * @param scene defines the current scene
  27511. */
  27512. constructor(scene?: Nullable<Scene>);
  27513. /**
  27514. * Gets the unique ID of this manager
  27515. */
  27516. get uniqueId(): number;
  27517. /**
  27518. * Gets the number of vertices handled by this manager
  27519. */
  27520. get vertexCount(): number;
  27521. /**
  27522. * Gets a boolean indicating if this manager supports morphing of normals
  27523. */
  27524. get supportsNormals(): boolean;
  27525. /**
  27526. * Gets a boolean indicating if this manager supports morphing of tangents
  27527. */
  27528. get supportsTangents(): boolean;
  27529. /**
  27530. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27531. */
  27532. get supportsUVs(): boolean;
  27533. /**
  27534. * Gets the number of targets stored in this manager
  27535. */
  27536. get numTargets(): number;
  27537. /**
  27538. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27539. */
  27540. get numInfluencers(): number;
  27541. /**
  27542. * Gets the list of influences (one per target)
  27543. */
  27544. get influences(): Float32Array;
  27545. /**
  27546. * Gets the active target at specified index. An active target is a target with an influence > 0
  27547. * @param index defines the index to check
  27548. * @returns the requested target
  27549. */
  27550. getActiveTarget(index: number): MorphTarget;
  27551. /**
  27552. * Gets the target at specified index
  27553. * @param index defines the index to check
  27554. * @returns the requested target
  27555. */
  27556. getTarget(index: number): MorphTarget;
  27557. /**
  27558. * Add a new target to this manager
  27559. * @param target defines the target to add
  27560. */
  27561. addTarget(target: MorphTarget): void;
  27562. /**
  27563. * Removes a target from the manager
  27564. * @param target defines the target to remove
  27565. */
  27566. removeTarget(target: MorphTarget): void;
  27567. /**
  27568. * Clone the current manager
  27569. * @returns a new MorphTargetManager
  27570. */
  27571. clone(): MorphTargetManager;
  27572. /**
  27573. * Serializes the current manager into a Serialization object
  27574. * @returns the serialized object
  27575. */
  27576. serialize(): any;
  27577. private _syncActiveTargets;
  27578. /**
  27579. * Syncrhonize the targets with all the meshes using this morph target manager
  27580. */
  27581. synchronize(): void;
  27582. /**
  27583. * Creates a new MorphTargetManager from serialized data
  27584. * @param serializationObject defines the serialized data
  27585. * @param scene defines the hosting scene
  27586. * @returns the new MorphTargetManager
  27587. */
  27588. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27589. }
  27590. }
  27591. declare module "babylonjs/Meshes/meshLODLevel" {
  27592. import { Mesh } from "babylonjs/Meshes/mesh";
  27593. import { Nullable } from "babylonjs/types";
  27594. /**
  27595. * Class used to represent a specific level of detail of a mesh
  27596. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27597. */
  27598. export class MeshLODLevel {
  27599. /** Defines the distance where this level should start being displayed */
  27600. distance: number;
  27601. /** Defines the mesh to use to render this level */
  27602. mesh: Nullable<Mesh>;
  27603. /**
  27604. * Creates a new LOD level
  27605. * @param distance defines the distance where this level should star being displayed
  27606. * @param mesh defines the mesh to use to render this level
  27607. */
  27608. constructor(
  27609. /** Defines the distance where this level should start being displayed */
  27610. distance: number,
  27611. /** Defines the mesh to use to render this level */
  27612. mesh: Nullable<Mesh>);
  27613. }
  27614. }
  27615. declare module "babylonjs/Misc/canvasGenerator" {
  27616. /**
  27617. * Helper class used to generate a canvas to manipulate images
  27618. */
  27619. export class CanvasGenerator {
  27620. /**
  27621. * Create a new canvas (or offscreen canvas depending on the context)
  27622. * @param width defines the expected width
  27623. * @param height defines the expected height
  27624. * @return a new canvas or offscreen canvas
  27625. */
  27626. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27627. }
  27628. }
  27629. declare module "babylonjs/Meshes/groundMesh" {
  27630. import { Scene } from "babylonjs/scene";
  27631. import { Vector3 } from "babylonjs/Maths/math.vector";
  27632. import { Mesh } from "babylonjs/Meshes/mesh";
  27633. /**
  27634. * Mesh representing the gorund
  27635. */
  27636. export class GroundMesh extends Mesh {
  27637. /** If octree should be generated */
  27638. generateOctree: boolean;
  27639. private _heightQuads;
  27640. /** @hidden */
  27641. _subdivisionsX: number;
  27642. /** @hidden */
  27643. _subdivisionsY: number;
  27644. /** @hidden */
  27645. _width: number;
  27646. /** @hidden */
  27647. _height: number;
  27648. /** @hidden */
  27649. _minX: number;
  27650. /** @hidden */
  27651. _maxX: number;
  27652. /** @hidden */
  27653. _minZ: number;
  27654. /** @hidden */
  27655. _maxZ: number;
  27656. constructor(name: string, scene: Scene);
  27657. /**
  27658. * "GroundMesh"
  27659. * @returns "GroundMesh"
  27660. */
  27661. getClassName(): string;
  27662. /**
  27663. * The minimum of x and y subdivisions
  27664. */
  27665. get subdivisions(): number;
  27666. /**
  27667. * X subdivisions
  27668. */
  27669. get subdivisionsX(): number;
  27670. /**
  27671. * Y subdivisions
  27672. */
  27673. get subdivisionsY(): number;
  27674. /**
  27675. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27676. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27677. * @param chunksCount the number of subdivisions for x and y
  27678. * @param octreeBlocksSize (Default: 32)
  27679. */
  27680. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27681. /**
  27682. * Returns a height (y) value in the Worl system :
  27683. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27684. * @param x x coordinate
  27685. * @param z z coordinate
  27686. * @returns the ground y position if (x, z) are outside the ground surface.
  27687. */
  27688. getHeightAtCoordinates(x: number, z: number): number;
  27689. /**
  27690. * Returns a normalized vector (Vector3) orthogonal to the ground
  27691. * at the ground coordinates (x, z) expressed in the World system.
  27692. * @param x x coordinate
  27693. * @param z z coordinate
  27694. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27695. */
  27696. getNormalAtCoordinates(x: number, z: number): Vector3;
  27697. /**
  27698. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27699. * at the ground coordinates (x, z) expressed in the World system.
  27700. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27701. * @param x x coordinate
  27702. * @param z z coordinate
  27703. * @param ref vector to store the result
  27704. * @returns the GroundMesh.
  27705. */
  27706. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27707. /**
  27708. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27709. * if the ground has been updated.
  27710. * This can be used in the render loop.
  27711. * @returns the GroundMesh.
  27712. */
  27713. updateCoordinateHeights(): GroundMesh;
  27714. private _getFacetAt;
  27715. private _initHeightQuads;
  27716. private _computeHeightQuads;
  27717. /**
  27718. * Serializes this ground mesh
  27719. * @param serializationObject object to write serialization to
  27720. */
  27721. serialize(serializationObject: any): void;
  27722. /**
  27723. * Parses a serialized ground mesh
  27724. * @param parsedMesh the serialized mesh
  27725. * @param scene the scene to create the ground mesh in
  27726. * @returns the created ground mesh
  27727. */
  27728. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27729. }
  27730. }
  27731. declare module "babylonjs/Physics/physicsJoint" {
  27732. import { Vector3 } from "babylonjs/Maths/math.vector";
  27733. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27734. /**
  27735. * Interface for Physics-Joint data
  27736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27737. */
  27738. export interface PhysicsJointData {
  27739. /**
  27740. * The main pivot of the joint
  27741. */
  27742. mainPivot?: Vector3;
  27743. /**
  27744. * The connected pivot of the joint
  27745. */
  27746. connectedPivot?: Vector3;
  27747. /**
  27748. * The main axis of the joint
  27749. */
  27750. mainAxis?: Vector3;
  27751. /**
  27752. * The connected axis of the joint
  27753. */
  27754. connectedAxis?: Vector3;
  27755. /**
  27756. * The collision of the joint
  27757. */
  27758. collision?: boolean;
  27759. /**
  27760. * Native Oimo/Cannon/Energy data
  27761. */
  27762. nativeParams?: any;
  27763. }
  27764. /**
  27765. * This is a holder class for the physics joint created by the physics plugin
  27766. * It holds a set of functions to control the underlying joint
  27767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27768. */
  27769. export class PhysicsJoint {
  27770. /**
  27771. * The type of the physics joint
  27772. */
  27773. type: number;
  27774. /**
  27775. * The data for the physics joint
  27776. */
  27777. jointData: PhysicsJointData;
  27778. private _physicsJoint;
  27779. protected _physicsPlugin: IPhysicsEnginePlugin;
  27780. /**
  27781. * Initializes the physics joint
  27782. * @param type The type of the physics joint
  27783. * @param jointData The data for the physics joint
  27784. */
  27785. constructor(
  27786. /**
  27787. * The type of the physics joint
  27788. */
  27789. type: number,
  27790. /**
  27791. * The data for the physics joint
  27792. */
  27793. jointData: PhysicsJointData);
  27794. /**
  27795. * Gets the physics joint
  27796. */
  27797. get physicsJoint(): any;
  27798. /**
  27799. * Sets the physics joint
  27800. */
  27801. set physicsJoint(newJoint: any);
  27802. /**
  27803. * Sets the physics plugin
  27804. */
  27805. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27806. /**
  27807. * Execute a function that is physics-plugin specific.
  27808. * @param {Function} func the function that will be executed.
  27809. * It accepts two parameters: the physics world and the physics joint
  27810. */
  27811. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27812. /**
  27813. * Distance-Joint type
  27814. */
  27815. static DistanceJoint: number;
  27816. /**
  27817. * Hinge-Joint type
  27818. */
  27819. static HingeJoint: number;
  27820. /**
  27821. * Ball-and-Socket joint type
  27822. */
  27823. static BallAndSocketJoint: number;
  27824. /**
  27825. * Wheel-Joint type
  27826. */
  27827. static WheelJoint: number;
  27828. /**
  27829. * Slider-Joint type
  27830. */
  27831. static SliderJoint: number;
  27832. /**
  27833. * Prismatic-Joint type
  27834. */
  27835. static PrismaticJoint: number;
  27836. /**
  27837. * Universal-Joint type
  27838. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27839. */
  27840. static UniversalJoint: number;
  27841. /**
  27842. * Hinge-Joint 2 type
  27843. */
  27844. static Hinge2Joint: number;
  27845. /**
  27846. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27847. */
  27848. static PointToPointJoint: number;
  27849. /**
  27850. * Spring-Joint type
  27851. */
  27852. static SpringJoint: number;
  27853. /**
  27854. * Lock-Joint type
  27855. */
  27856. static LockJoint: number;
  27857. }
  27858. /**
  27859. * A class representing a physics distance joint
  27860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27861. */
  27862. export class DistanceJoint extends PhysicsJoint {
  27863. /**
  27864. *
  27865. * @param jointData The data for the Distance-Joint
  27866. */
  27867. constructor(jointData: DistanceJointData);
  27868. /**
  27869. * Update the predefined distance.
  27870. * @param maxDistance The maximum preferred distance
  27871. * @param minDistance The minimum preferred distance
  27872. */
  27873. updateDistance(maxDistance: number, minDistance?: number): void;
  27874. }
  27875. /**
  27876. * Represents a Motor-Enabled Joint
  27877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27878. */
  27879. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27880. /**
  27881. * Initializes the Motor-Enabled Joint
  27882. * @param type The type of the joint
  27883. * @param jointData The physica joint data for the joint
  27884. */
  27885. constructor(type: number, jointData: PhysicsJointData);
  27886. /**
  27887. * Set the motor values.
  27888. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27889. * @param force the force to apply
  27890. * @param maxForce max force for this motor.
  27891. */
  27892. setMotor(force?: number, maxForce?: number): void;
  27893. /**
  27894. * Set the motor's limits.
  27895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27896. * @param upperLimit The upper limit of the motor
  27897. * @param lowerLimit The lower limit of the motor
  27898. */
  27899. setLimit(upperLimit: number, lowerLimit?: number): void;
  27900. }
  27901. /**
  27902. * This class represents a single physics Hinge-Joint
  27903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27904. */
  27905. export class HingeJoint extends MotorEnabledJoint {
  27906. /**
  27907. * Initializes the Hinge-Joint
  27908. * @param jointData The joint data for the Hinge-Joint
  27909. */
  27910. constructor(jointData: PhysicsJointData);
  27911. /**
  27912. * Set the motor values.
  27913. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27914. * @param {number} force the force to apply
  27915. * @param {number} maxForce max force for this motor.
  27916. */
  27917. setMotor(force?: number, maxForce?: number): void;
  27918. /**
  27919. * Set the motor's limits.
  27920. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27921. * @param upperLimit The upper limit of the motor
  27922. * @param lowerLimit The lower limit of the motor
  27923. */
  27924. setLimit(upperLimit: number, lowerLimit?: number): void;
  27925. }
  27926. /**
  27927. * This class represents a dual hinge physics joint (same as wheel joint)
  27928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27929. */
  27930. export class Hinge2Joint extends MotorEnabledJoint {
  27931. /**
  27932. * Initializes the Hinge2-Joint
  27933. * @param jointData The joint data for the Hinge2-Joint
  27934. */
  27935. constructor(jointData: PhysicsJointData);
  27936. /**
  27937. * Set the motor values.
  27938. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27939. * @param {number} targetSpeed the speed the motor is to reach
  27940. * @param {number} maxForce max force for this motor.
  27941. * @param {motorIndex} the motor's index, 0 or 1.
  27942. */
  27943. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27944. /**
  27945. * Set the motor limits.
  27946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27947. * @param {number} upperLimit the upper limit
  27948. * @param {number} lowerLimit lower limit
  27949. * @param {motorIndex} the motor's index, 0 or 1.
  27950. */
  27951. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27952. }
  27953. /**
  27954. * Interface for a motor enabled joint
  27955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27956. */
  27957. export interface IMotorEnabledJoint {
  27958. /**
  27959. * Physics joint
  27960. */
  27961. physicsJoint: any;
  27962. /**
  27963. * Sets the motor of the motor-enabled joint
  27964. * @param force The force of the motor
  27965. * @param maxForce The maximum force of the motor
  27966. * @param motorIndex The index of the motor
  27967. */
  27968. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27969. /**
  27970. * Sets the limit of the motor
  27971. * @param upperLimit The upper limit of the motor
  27972. * @param lowerLimit The lower limit of the motor
  27973. * @param motorIndex The index of the motor
  27974. */
  27975. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27976. }
  27977. /**
  27978. * Joint data for a Distance-Joint
  27979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27980. */
  27981. export interface DistanceJointData extends PhysicsJointData {
  27982. /**
  27983. * Max distance the 2 joint objects can be apart
  27984. */
  27985. maxDistance: number;
  27986. }
  27987. /**
  27988. * Joint data from a spring joint
  27989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27990. */
  27991. export interface SpringJointData extends PhysicsJointData {
  27992. /**
  27993. * Length of the spring
  27994. */
  27995. length: number;
  27996. /**
  27997. * Stiffness of the spring
  27998. */
  27999. stiffness: number;
  28000. /**
  28001. * Damping of the spring
  28002. */
  28003. damping: number;
  28004. /** this callback will be called when applying the force to the impostors. */
  28005. forceApplicationCallback: () => void;
  28006. }
  28007. }
  28008. declare module "babylonjs/Physics/physicsRaycastResult" {
  28009. import { Vector3 } from "babylonjs/Maths/math.vector";
  28010. /**
  28011. * Holds the data for the raycast result
  28012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28013. */
  28014. export class PhysicsRaycastResult {
  28015. private _hasHit;
  28016. private _hitDistance;
  28017. private _hitNormalWorld;
  28018. private _hitPointWorld;
  28019. private _rayFromWorld;
  28020. private _rayToWorld;
  28021. /**
  28022. * Gets if there was a hit
  28023. */
  28024. get hasHit(): boolean;
  28025. /**
  28026. * Gets the distance from the hit
  28027. */
  28028. get hitDistance(): number;
  28029. /**
  28030. * Gets the hit normal/direction in the world
  28031. */
  28032. get hitNormalWorld(): Vector3;
  28033. /**
  28034. * Gets the hit point in the world
  28035. */
  28036. get hitPointWorld(): Vector3;
  28037. /**
  28038. * Gets the ray "start point" of the ray in the world
  28039. */
  28040. get rayFromWorld(): Vector3;
  28041. /**
  28042. * Gets the ray "end point" of the ray in the world
  28043. */
  28044. get rayToWorld(): Vector3;
  28045. /**
  28046. * Sets the hit data (normal & point in world space)
  28047. * @param hitNormalWorld defines the normal in world space
  28048. * @param hitPointWorld defines the point in world space
  28049. */
  28050. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28051. /**
  28052. * Sets the distance from the start point to the hit point
  28053. * @param distance
  28054. */
  28055. setHitDistance(distance: number): void;
  28056. /**
  28057. * Calculates the distance manually
  28058. */
  28059. calculateHitDistance(): void;
  28060. /**
  28061. * Resets all the values to default
  28062. * @param from The from point on world space
  28063. * @param to The to point on world space
  28064. */
  28065. reset(from?: Vector3, to?: Vector3): void;
  28066. }
  28067. /**
  28068. * Interface for the size containing width and height
  28069. */
  28070. interface IXYZ {
  28071. /**
  28072. * X
  28073. */
  28074. x: number;
  28075. /**
  28076. * Y
  28077. */
  28078. y: number;
  28079. /**
  28080. * Z
  28081. */
  28082. z: number;
  28083. }
  28084. }
  28085. declare module "babylonjs/Physics/IPhysicsEngine" {
  28086. import { Nullable } from "babylonjs/types";
  28087. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28089. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28090. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28091. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28092. /**
  28093. * Interface used to describe a physics joint
  28094. */
  28095. export interface PhysicsImpostorJoint {
  28096. /** Defines the main impostor to which the joint is linked */
  28097. mainImpostor: PhysicsImpostor;
  28098. /** Defines the impostor that is connected to the main impostor using this joint */
  28099. connectedImpostor: PhysicsImpostor;
  28100. /** Defines the joint itself */
  28101. joint: PhysicsJoint;
  28102. }
  28103. /** @hidden */
  28104. export interface IPhysicsEnginePlugin {
  28105. world: any;
  28106. name: string;
  28107. setGravity(gravity: Vector3): void;
  28108. setTimeStep(timeStep: number): void;
  28109. getTimeStep(): number;
  28110. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28111. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28112. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28113. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28114. removePhysicsBody(impostor: PhysicsImpostor): void;
  28115. generateJoint(joint: PhysicsImpostorJoint): void;
  28116. removeJoint(joint: PhysicsImpostorJoint): void;
  28117. isSupported(): boolean;
  28118. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28119. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28120. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28121. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28122. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28123. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28124. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28125. getBodyMass(impostor: PhysicsImpostor): number;
  28126. getBodyFriction(impostor: PhysicsImpostor): number;
  28127. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28128. getBodyRestitution(impostor: PhysicsImpostor): number;
  28129. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28130. getBodyPressure?(impostor: PhysicsImpostor): number;
  28131. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28132. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28133. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28134. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28135. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28136. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28137. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28138. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28139. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28140. sleepBody(impostor: PhysicsImpostor): void;
  28141. wakeUpBody(impostor: PhysicsImpostor): void;
  28142. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28143. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28144. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28145. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28146. getRadius(impostor: PhysicsImpostor): number;
  28147. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28148. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28149. dispose(): void;
  28150. }
  28151. /**
  28152. * Interface used to define a physics engine
  28153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28154. */
  28155. export interface IPhysicsEngine {
  28156. /**
  28157. * Gets the gravity vector used by the simulation
  28158. */
  28159. gravity: Vector3;
  28160. /**
  28161. * Sets the gravity vector used by the simulation
  28162. * @param gravity defines the gravity vector to use
  28163. */
  28164. setGravity(gravity: Vector3): void;
  28165. /**
  28166. * Set the time step of the physics engine.
  28167. * Default is 1/60.
  28168. * To slow it down, enter 1/600 for example.
  28169. * To speed it up, 1/30
  28170. * @param newTimeStep the new timestep to apply to this world.
  28171. */
  28172. setTimeStep(newTimeStep: number): void;
  28173. /**
  28174. * Get the time step of the physics engine.
  28175. * @returns the current time step
  28176. */
  28177. getTimeStep(): number;
  28178. /**
  28179. * Set the sub time step of the physics engine.
  28180. * Default is 0 meaning there is no sub steps
  28181. * To increase physics resolution precision, set a small value (like 1 ms)
  28182. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28183. */
  28184. setSubTimeStep(subTimeStep: number): void;
  28185. /**
  28186. * Get the sub time step of the physics engine.
  28187. * @returns the current sub time step
  28188. */
  28189. getSubTimeStep(): number;
  28190. /**
  28191. * Release all resources
  28192. */
  28193. dispose(): void;
  28194. /**
  28195. * Gets the name of the current physics plugin
  28196. * @returns the name of the plugin
  28197. */
  28198. getPhysicsPluginName(): string;
  28199. /**
  28200. * Adding a new impostor for the impostor tracking.
  28201. * This will be done by the impostor itself.
  28202. * @param impostor the impostor to add
  28203. */
  28204. addImpostor(impostor: PhysicsImpostor): void;
  28205. /**
  28206. * Remove an impostor from the engine.
  28207. * This impostor and its mesh will not longer be updated by the physics engine.
  28208. * @param impostor the impostor to remove
  28209. */
  28210. removeImpostor(impostor: PhysicsImpostor): void;
  28211. /**
  28212. * Add a joint to the physics engine
  28213. * @param mainImpostor defines the main impostor to which the joint is added.
  28214. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28215. * @param joint defines the joint that will connect both impostors.
  28216. */
  28217. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28218. /**
  28219. * Removes a joint from the simulation
  28220. * @param mainImpostor defines the impostor used with the joint
  28221. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28222. * @param joint defines the joint to remove
  28223. */
  28224. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28225. /**
  28226. * Gets the current plugin used to run the simulation
  28227. * @returns current plugin
  28228. */
  28229. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28230. /**
  28231. * Gets the list of physic impostors
  28232. * @returns an array of PhysicsImpostor
  28233. */
  28234. getImpostors(): Array<PhysicsImpostor>;
  28235. /**
  28236. * Gets the impostor for a physics enabled object
  28237. * @param object defines the object impersonated by the impostor
  28238. * @returns the PhysicsImpostor or null if not found
  28239. */
  28240. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28241. /**
  28242. * Gets the impostor for a physics body object
  28243. * @param body defines physics body used by the impostor
  28244. * @returns the PhysicsImpostor or null if not found
  28245. */
  28246. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28247. /**
  28248. * Does a raycast in the physics world
  28249. * @param from when should the ray start?
  28250. * @param to when should the ray end?
  28251. * @returns PhysicsRaycastResult
  28252. */
  28253. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28254. /**
  28255. * Called by the scene. No need to call it.
  28256. * @param delta defines the timespam between frames
  28257. */
  28258. _step(delta: number): void;
  28259. }
  28260. }
  28261. declare module "babylonjs/Physics/physicsImpostor" {
  28262. import { Nullable, IndicesArray } from "babylonjs/types";
  28263. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28264. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28266. import { Scene } from "babylonjs/scene";
  28267. import { Bone } from "babylonjs/Bones/bone";
  28268. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28269. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28270. import { Space } from "babylonjs/Maths/math.axis";
  28271. /**
  28272. * The interface for the physics imposter parameters
  28273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28274. */
  28275. export interface PhysicsImpostorParameters {
  28276. /**
  28277. * The mass of the physics imposter
  28278. */
  28279. mass: number;
  28280. /**
  28281. * The friction of the physics imposter
  28282. */
  28283. friction?: number;
  28284. /**
  28285. * The coefficient of restitution of the physics imposter
  28286. */
  28287. restitution?: number;
  28288. /**
  28289. * The native options of the physics imposter
  28290. */
  28291. nativeOptions?: any;
  28292. /**
  28293. * Specifies if the parent should be ignored
  28294. */
  28295. ignoreParent?: boolean;
  28296. /**
  28297. * Specifies if bi-directional transformations should be disabled
  28298. */
  28299. disableBidirectionalTransformation?: boolean;
  28300. /**
  28301. * The pressure inside the physics imposter, soft object only
  28302. */
  28303. pressure?: number;
  28304. /**
  28305. * The stiffness the physics imposter, soft object only
  28306. */
  28307. stiffness?: number;
  28308. /**
  28309. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28310. */
  28311. velocityIterations?: number;
  28312. /**
  28313. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28314. */
  28315. positionIterations?: number;
  28316. /**
  28317. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28318. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28319. * Add to fix multiple points
  28320. */
  28321. fixedPoints?: number;
  28322. /**
  28323. * The collision margin around a soft object
  28324. */
  28325. margin?: number;
  28326. /**
  28327. * The collision margin around a soft object
  28328. */
  28329. damping?: number;
  28330. /**
  28331. * The path for a rope based on an extrusion
  28332. */
  28333. path?: any;
  28334. /**
  28335. * The shape of an extrusion used for a rope based on an extrusion
  28336. */
  28337. shape?: any;
  28338. }
  28339. /**
  28340. * Interface for a physics-enabled object
  28341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28342. */
  28343. export interface IPhysicsEnabledObject {
  28344. /**
  28345. * The position of the physics-enabled object
  28346. */
  28347. position: Vector3;
  28348. /**
  28349. * The rotation of the physics-enabled object
  28350. */
  28351. rotationQuaternion: Nullable<Quaternion>;
  28352. /**
  28353. * The scale of the physics-enabled object
  28354. */
  28355. scaling: Vector3;
  28356. /**
  28357. * The rotation of the physics-enabled object
  28358. */
  28359. rotation?: Vector3;
  28360. /**
  28361. * The parent of the physics-enabled object
  28362. */
  28363. parent?: any;
  28364. /**
  28365. * The bounding info of the physics-enabled object
  28366. * @returns The bounding info of the physics-enabled object
  28367. */
  28368. getBoundingInfo(): BoundingInfo;
  28369. /**
  28370. * Computes the world matrix
  28371. * @param force Specifies if the world matrix should be computed by force
  28372. * @returns A world matrix
  28373. */
  28374. computeWorldMatrix(force: boolean): Matrix;
  28375. /**
  28376. * Gets the world matrix
  28377. * @returns A world matrix
  28378. */
  28379. getWorldMatrix?(): Matrix;
  28380. /**
  28381. * Gets the child meshes
  28382. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28383. * @returns An array of abstract meshes
  28384. */
  28385. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28386. /**
  28387. * Gets the vertex data
  28388. * @param kind The type of vertex data
  28389. * @returns A nullable array of numbers, or a float32 array
  28390. */
  28391. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28392. /**
  28393. * Gets the indices from the mesh
  28394. * @returns A nullable array of index arrays
  28395. */
  28396. getIndices?(): Nullable<IndicesArray>;
  28397. /**
  28398. * Gets the scene from the mesh
  28399. * @returns the indices array or null
  28400. */
  28401. getScene?(): Scene;
  28402. /**
  28403. * Gets the absolute position from the mesh
  28404. * @returns the absolute position
  28405. */
  28406. getAbsolutePosition(): Vector3;
  28407. /**
  28408. * Gets the absolute pivot point from the mesh
  28409. * @returns the absolute pivot point
  28410. */
  28411. getAbsolutePivotPoint(): Vector3;
  28412. /**
  28413. * Rotates the mesh
  28414. * @param axis The axis of rotation
  28415. * @param amount The amount of rotation
  28416. * @param space The space of the rotation
  28417. * @returns The rotation transform node
  28418. */
  28419. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28420. /**
  28421. * Translates the mesh
  28422. * @param axis The axis of translation
  28423. * @param distance The distance of translation
  28424. * @param space The space of the translation
  28425. * @returns The transform node
  28426. */
  28427. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28428. /**
  28429. * Sets the absolute position of the mesh
  28430. * @param absolutePosition The absolute position of the mesh
  28431. * @returns The transform node
  28432. */
  28433. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28434. /**
  28435. * Gets the class name of the mesh
  28436. * @returns The class name
  28437. */
  28438. getClassName(): string;
  28439. }
  28440. /**
  28441. * Represents a physics imposter
  28442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28443. */
  28444. export class PhysicsImpostor {
  28445. /**
  28446. * The physics-enabled object used as the physics imposter
  28447. */
  28448. object: IPhysicsEnabledObject;
  28449. /**
  28450. * The type of the physics imposter
  28451. */
  28452. type: number;
  28453. private _options;
  28454. private _scene?;
  28455. /**
  28456. * The default object size of the imposter
  28457. */
  28458. static DEFAULT_OBJECT_SIZE: Vector3;
  28459. /**
  28460. * The identity quaternion of the imposter
  28461. */
  28462. static IDENTITY_QUATERNION: Quaternion;
  28463. /** @hidden */
  28464. _pluginData: any;
  28465. private _physicsEngine;
  28466. private _physicsBody;
  28467. private _bodyUpdateRequired;
  28468. private _onBeforePhysicsStepCallbacks;
  28469. private _onAfterPhysicsStepCallbacks;
  28470. /** @hidden */
  28471. _onPhysicsCollideCallbacks: Array<{
  28472. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28473. otherImpostors: Array<PhysicsImpostor>;
  28474. }>;
  28475. private _deltaPosition;
  28476. private _deltaRotation;
  28477. private _deltaRotationConjugated;
  28478. /** @hidden */
  28479. _isFromLine: boolean;
  28480. private _parent;
  28481. private _isDisposed;
  28482. private static _tmpVecs;
  28483. private static _tmpQuat;
  28484. /**
  28485. * Specifies if the physics imposter is disposed
  28486. */
  28487. get isDisposed(): boolean;
  28488. /**
  28489. * Gets the mass of the physics imposter
  28490. */
  28491. get mass(): number;
  28492. set mass(value: number);
  28493. /**
  28494. * Gets the coefficient of friction
  28495. */
  28496. get friction(): number;
  28497. /**
  28498. * Sets the coefficient of friction
  28499. */
  28500. set friction(value: number);
  28501. /**
  28502. * Gets the coefficient of restitution
  28503. */
  28504. get restitution(): number;
  28505. /**
  28506. * Sets the coefficient of restitution
  28507. */
  28508. set restitution(value: number);
  28509. /**
  28510. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28511. */
  28512. get pressure(): number;
  28513. /**
  28514. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28515. */
  28516. set pressure(value: number);
  28517. /**
  28518. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28519. */
  28520. get stiffness(): number;
  28521. /**
  28522. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28523. */
  28524. set stiffness(value: number);
  28525. /**
  28526. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28527. */
  28528. get velocityIterations(): number;
  28529. /**
  28530. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28531. */
  28532. set velocityIterations(value: number);
  28533. /**
  28534. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28535. */
  28536. get positionIterations(): number;
  28537. /**
  28538. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28539. */
  28540. set positionIterations(value: number);
  28541. /**
  28542. * The unique id of the physics imposter
  28543. * set by the physics engine when adding this impostor to the array
  28544. */
  28545. uniqueId: number;
  28546. /**
  28547. * @hidden
  28548. */
  28549. soft: boolean;
  28550. /**
  28551. * @hidden
  28552. */
  28553. segments: number;
  28554. private _joints;
  28555. /**
  28556. * Initializes the physics imposter
  28557. * @param object The physics-enabled object used as the physics imposter
  28558. * @param type The type of the physics imposter
  28559. * @param _options The options for the physics imposter
  28560. * @param _scene The Babylon scene
  28561. */
  28562. constructor(
  28563. /**
  28564. * The physics-enabled object used as the physics imposter
  28565. */
  28566. object: IPhysicsEnabledObject,
  28567. /**
  28568. * The type of the physics imposter
  28569. */
  28570. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28571. /**
  28572. * This function will completly initialize this impostor.
  28573. * It will create a new body - but only if this mesh has no parent.
  28574. * If it has, this impostor will not be used other than to define the impostor
  28575. * of the child mesh.
  28576. * @hidden
  28577. */
  28578. _init(): void;
  28579. private _getPhysicsParent;
  28580. /**
  28581. * Should a new body be generated.
  28582. * @returns boolean specifying if body initialization is required
  28583. */
  28584. isBodyInitRequired(): boolean;
  28585. /**
  28586. * Sets the updated scaling
  28587. * @param updated Specifies if the scaling is updated
  28588. */
  28589. setScalingUpdated(): void;
  28590. /**
  28591. * Force a regeneration of this or the parent's impostor's body.
  28592. * Use under cautious - This will remove all joints already implemented.
  28593. */
  28594. forceUpdate(): void;
  28595. /**
  28596. * Gets the body that holds this impostor. Either its own, or its parent.
  28597. */
  28598. get physicsBody(): any;
  28599. /**
  28600. * Get the parent of the physics imposter
  28601. * @returns Physics imposter or null
  28602. */
  28603. get parent(): Nullable<PhysicsImpostor>;
  28604. /**
  28605. * Sets the parent of the physics imposter
  28606. */
  28607. set parent(value: Nullable<PhysicsImpostor>);
  28608. /**
  28609. * Set the physics body. Used mainly by the physics engine/plugin
  28610. */
  28611. set physicsBody(physicsBody: any);
  28612. /**
  28613. * Resets the update flags
  28614. */
  28615. resetUpdateFlags(): void;
  28616. /**
  28617. * Gets the object extend size
  28618. * @returns the object extend size
  28619. */
  28620. getObjectExtendSize(): Vector3;
  28621. /**
  28622. * Gets the object center
  28623. * @returns The object center
  28624. */
  28625. getObjectCenter(): Vector3;
  28626. /**
  28627. * Get a specific parameter from the options parameters
  28628. * @param paramName The object parameter name
  28629. * @returns The object parameter
  28630. */
  28631. getParam(paramName: string): any;
  28632. /**
  28633. * Sets a specific parameter in the options given to the physics plugin
  28634. * @param paramName The parameter name
  28635. * @param value The value of the parameter
  28636. */
  28637. setParam(paramName: string, value: number): void;
  28638. /**
  28639. * Specifically change the body's mass option. Won't recreate the physics body object
  28640. * @param mass The mass of the physics imposter
  28641. */
  28642. setMass(mass: number): void;
  28643. /**
  28644. * Gets the linear velocity
  28645. * @returns linear velocity or null
  28646. */
  28647. getLinearVelocity(): Nullable<Vector3>;
  28648. /**
  28649. * Sets the linear velocity
  28650. * @param velocity linear velocity or null
  28651. */
  28652. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28653. /**
  28654. * Gets the angular velocity
  28655. * @returns angular velocity or null
  28656. */
  28657. getAngularVelocity(): Nullable<Vector3>;
  28658. /**
  28659. * Sets the angular velocity
  28660. * @param velocity The velocity or null
  28661. */
  28662. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28663. /**
  28664. * Execute a function with the physics plugin native code
  28665. * Provide a function the will have two variables - the world object and the physics body object
  28666. * @param func The function to execute with the physics plugin native code
  28667. */
  28668. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28669. /**
  28670. * Register a function that will be executed before the physics world is stepping forward
  28671. * @param func The function to execute before the physics world is stepped forward
  28672. */
  28673. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28674. /**
  28675. * Unregister a function that will be executed before the physics world is stepping forward
  28676. * @param func The function to execute before the physics world is stepped forward
  28677. */
  28678. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28679. /**
  28680. * Register a function that will be executed after the physics step
  28681. * @param func The function to execute after physics step
  28682. */
  28683. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28684. /**
  28685. * Unregisters a function that will be executed after the physics step
  28686. * @param func The function to execute after physics step
  28687. */
  28688. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28689. /**
  28690. * register a function that will be executed when this impostor collides against a different body
  28691. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28692. * @param func Callback that is executed on collision
  28693. */
  28694. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28695. /**
  28696. * Unregisters the physics imposter on contact
  28697. * @param collideAgainst The physics object to collide against
  28698. * @param func Callback to execute on collision
  28699. */
  28700. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28701. private _tmpQuat;
  28702. private _tmpQuat2;
  28703. /**
  28704. * Get the parent rotation
  28705. * @returns The parent rotation
  28706. */
  28707. getParentsRotation(): Quaternion;
  28708. /**
  28709. * this function is executed by the physics engine.
  28710. */
  28711. beforeStep: () => void;
  28712. /**
  28713. * this function is executed by the physics engine
  28714. */
  28715. afterStep: () => void;
  28716. /**
  28717. * Legacy collision detection event support
  28718. */
  28719. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28720. /**
  28721. * event and body object due to cannon's event-based architecture.
  28722. */
  28723. onCollide: (e: {
  28724. body: any;
  28725. }) => void;
  28726. /**
  28727. * Apply a force
  28728. * @param force The force to apply
  28729. * @param contactPoint The contact point for the force
  28730. * @returns The physics imposter
  28731. */
  28732. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28733. /**
  28734. * Apply an impulse
  28735. * @param force The impulse force
  28736. * @param contactPoint The contact point for the impulse force
  28737. * @returns The physics imposter
  28738. */
  28739. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28740. /**
  28741. * A help function to create a joint
  28742. * @param otherImpostor A physics imposter used to create a joint
  28743. * @param jointType The type of joint
  28744. * @param jointData The data for the joint
  28745. * @returns The physics imposter
  28746. */
  28747. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28748. /**
  28749. * Add a joint to this impostor with a different impostor
  28750. * @param otherImpostor A physics imposter used to add a joint
  28751. * @param joint The joint to add
  28752. * @returns The physics imposter
  28753. */
  28754. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28755. /**
  28756. * Add an anchor to a cloth impostor
  28757. * @param otherImpostor rigid impostor to anchor to
  28758. * @param width ratio across width from 0 to 1
  28759. * @param height ratio up height from 0 to 1
  28760. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28761. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28762. * @returns impostor the soft imposter
  28763. */
  28764. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28765. /**
  28766. * Add a hook to a rope impostor
  28767. * @param otherImpostor rigid impostor to anchor to
  28768. * @param length ratio across rope from 0 to 1
  28769. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28770. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28771. * @returns impostor the rope imposter
  28772. */
  28773. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28774. /**
  28775. * Will keep this body still, in a sleep mode.
  28776. * @returns the physics imposter
  28777. */
  28778. sleep(): PhysicsImpostor;
  28779. /**
  28780. * Wake the body up.
  28781. * @returns The physics imposter
  28782. */
  28783. wakeUp(): PhysicsImpostor;
  28784. /**
  28785. * Clones the physics imposter
  28786. * @param newObject The physics imposter clones to this physics-enabled object
  28787. * @returns A nullable physics imposter
  28788. */
  28789. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28790. /**
  28791. * Disposes the physics imposter
  28792. */
  28793. dispose(): void;
  28794. /**
  28795. * Sets the delta position
  28796. * @param position The delta position amount
  28797. */
  28798. setDeltaPosition(position: Vector3): void;
  28799. /**
  28800. * Sets the delta rotation
  28801. * @param rotation The delta rotation amount
  28802. */
  28803. setDeltaRotation(rotation: Quaternion): void;
  28804. /**
  28805. * Gets the box size of the physics imposter and stores the result in the input parameter
  28806. * @param result Stores the box size
  28807. * @returns The physics imposter
  28808. */
  28809. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28810. /**
  28811. * Gets the radius of the physics imposter
  28812. * @returns Radius of the physics imposter
  28813. */
  28814. getRadius(): number;
  28815. /**
  28816. * Sync a bone with this impostor
  28817. * @param bone The bone to sync to the impostor.
  28818. * @param boneMesh The mesh that the bone is influencing.
  28819. * @param jointPivot The pivot of the joint / bone in local space.
  28820. * @param distToJoint Optional distance from the impostor to the joint.
  28821. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28822. */
  28823. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28824. /**
  28825. * Sync impostor to a bone
  28826. * @param bone The bone that the impostor will be synced to.
  28827. * @param boneMesh The mesh that the bone is influencing.
  28828. * @param jointPivot The pivot of the joint / bone in local space.
  28829. * @param distToJoint Optional distance from the impostor to the joint.
  28830. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28831. * @param boneAxis Optional vector3 axis the bone is aligned with
  28832. */
  28833. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28834. /**
  28835. * No-Imposter type
  28836. */
  28837. static NoImpostor: number;
  28838. /**
  28839. * Sphere-Imposter type
  28840. */
  28841. static SphereImpostor: number;
  28842. /**
  28843. * Box-Imposter type
  28844. */
  28845. static BoxImpostor: number;
  28846. /**
  28847. * Plane-Imposter type
  28848. */
  28849. static PlaneImpostor: number;
  28850. /**
  28851. * Mesh-imposter type
  28852. */
  28853. static MeshImpostor: number;
  28854. /**
  28855. * Capsule-Impostor type (Ammo.js plugin only)
  28856. */
  28857. static CapsuleImpostor: number;
  28858. /**
  28859. * Cylinder-Imposter type
  28860. */
  28861. static CylinderImpostor: number;
  28862. /**
  28863. * Particle-Imposter type
  28864. */
  28865. static ParticleImpostor: number;
  28866. /**
  28867. * Heightmap-Imposter type
  28868. */
  28869. static HeightmapImpostor: number;
  28870. /**
  28871. * ConvexHull-Impostor type (Ammo.js plugin only)
  28872. */
  28873. static ConvexHullImpostor: number;
  28874. /**
  28875. * Custom-Imposter type (Ammo.js plugin only)
  28876. */
  28877. static CustomImpostor: number;
  28878. /**
  28879. * Rope-Imposter type
  28880. */
  28881. static RopeImpostor: number;
  28882. /**
  28883. * Cloth-Imposter type
  28884. */
  28885. static ClothImpostor: number;
  28886. /**
  28887. * Softbody-Imposter type
  28888. */
  28889. static SoftbodyImpostor: number;
  28890. }
  28891. }
  28892. declare module "babylonjs/Meshes/mesh" {
  28893. import { Observable } from "babylonjs/Misc/observable";
  28894. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28895. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28896. import { Camera } from "babylonjs/Cameras/camera";
  28897. import { Scene } from "babylonjs/scene";
  28898. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28899. import { Color4 } from "babylonjs/Maths/math.color";
  28900. import { Engine } from "babylonjs/Engines/engine";
  28901. import { Node } from "babylonjs/node";
  28902. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28903. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28904. import { Buffer } from "babylonjs/Meshes/buffer";
  28905. import { Geometry } from "babylonjs/Meshes/geometry";
  28906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28908. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28909. import { Effect } from "babylonjs/Materials/effect";
  28910. import { Material } from "babylonjs/Materials/material";
  28911. import { Skeleton } from "babylonjs/Bones/skeleton";
  28912. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28913. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28914. import { Path3D } from "babylonjs/Maths/math.path";
  28915. import { Plane } from "babylonjs/Maths/math.plane";
  28916. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28917. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28918. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28919. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28920. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28921. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28922. /**
  28923. * @hidden
  28924. **/
  28925. export class _CreationDataStorage {
  28926. closePath?: boolean;
  28927. closeArray?: boolean;
  28928. idx: number[];
  28929. dashSize: number;
  28930. gapSize: number;
  28931. path3D: Path3D;
  28932. pathArray: Vector3[][];
  28933. arc: number;
  28934. radius: number;
  28935. cap: number;
  28936. tessellation: number;
  28937. }
  28938. /**
  28939. * @hidden
  28940. **/
  28941. class _InstanceDataStorage {
  28942. visibleInstances: any;
  28943. batchCache: _InstancesBatch;
  28944. instancesBufferSize: number;
  28945. instancesBuffer: Nullable<Buffer>;
  28946. instancesData: Float32Array;
  28947. overridenInstanceCount: number;
  28948. isFrozen: boolean;
  28949. previousBatch: Nullable<_InstancesBatch>;
  28950. hardwareInstancedRendering: boolean;
  28951. sideOrientation: number;
  28952. manualUpdate: boolean;
  28953. }
  28954. /**
  28955. * @hidden
  28956. **/
  28957. export class _InstancesBatch {
  28958. mustReturn: boolean;
  28959. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28960. renderSelf: boolean[];
  28961. hardwareInstancedRendering: boolean[];
  28962. }
  28963. /**
  28964. * @hidden
  28965. **/
  28966. class _ThinInstanceDataStorage {
  28967. instancesCount: number;
  28968. matrixBuffer: Nullable<Buffer>;
  28969. matrixBufferSize: number;
  28970. matrixData: Nullable<Float32Array>;
  28971. boundingVectors: Array<Vector3>;
  28972. worldMatrices: Nullable<Matrix[]>;
  28973. }
  28974. /**
  28975. * Class used to represent renderable models
  28976. */
  28977. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28978. /**
  28979. * Mesh side orientation : usually the external or front surface
  28980. */
  28981. static readonly FRONTSIDE: number;
  28982. /**
  28983. * Mesh side orientation : usually the internal or back surface
  28984. */
  28985. static readonly BACKSIDE: number;
  28986. /**
  28987. * Mesh side orientation : both internal and external or front and back surfaces
  28988. */
  28989. static readonly DOUBLESIDE: number;
  28990. /**
  28991. * Mesh side orientation : by default, `FRONTSIDE`
  28992. */
  28993. static readonly DEFAULTSIDE: number;
  28994. /**
  28995. * Mesh cap setting : no cap
  28996. */
  28997. static readonly NO_CAP: number;
  28998. /**
  28999. * Mesh cap setting : one cap at the beginning of the mesh
  29000. */
  29001. static readonly CAP_START: number;
  29002. /**
  29003. * Mesh cap setting : one cap at the end of the mesh
  29004. */
  29005. static readonly CAP_END: number;
  29006. /**
  29007. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29008. */
  29009. static readonly CAP_ALL: number;
  29010. /**
  29011. * Mesh pattern setting : no flip or rotate
  29012. */
  29013. static readonly NO_FLIP: number;
  29014. /**
  29015. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29016. */
  29017. static readonly FLIP_TILE: number;
  29018. /**
  29019. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29020. */
  29021. static readonly ROTATE_TILE: number;
  29022. /**
  29023. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29024. */
  29025. static readonly FLIP_ROW: number;
  29026. /**
  29027. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29028. */
  29029. static readonly ROTATE_ROW: number;
  29030. /**
  29031. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29032. */
  29033. static readonly FLIP_N_ROTATE_TILE: number;
  29034. /**
  29035. * Mesh pattern setting : rotate pattern and rotate
  29036. */
  29037. static readonly FLIP_N_ROTATE_ROW: number;
  29038. /**
  29039. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29040. */
  29041. static readonly CENTER: number;
  29042. /**
  29043. * Mesh tile positioning : part tiles on left
  29044. */
  29045. static readonly LEFT: number;
  29046. /**
  29047. * Mesh tile positioning : part tiles on right
  29048. */
  29049. static readonly RIGHT: number;
  29050. /**
  29051. * Mesh tile positioning : part tiles on top
  29052. */
  29053. static readonly TOP: number;
  29054. /**
  29055. * Mesh tile positioning : part tiles on bottom
  29056. */
  29057. static readonly BOTTOM: number;
  29058. /**
  29059. * Gets the default side orientation.
  29060. * @param orientation the orientation to value to attempt to get
  29061. * @returns the default orientation
  29062. * @hidden
  29063. */
  29064. static _GetDefaultSideOrientation(orientation?: number): number;
  29065. private _internalMeshDataInfo;
  29066. get computeBonesUsingShaders(): boolean;
  29067. set computeBonesUsingShaders(value: boolean);
  29068. /**
  29069. * An event triggered before rendering the mesh
  29070. */
  29071. get onBeforeRenderObservable(): Observable<Mesh>;
  29072. /**
  29073. * An event triggered before binding the mesh
  29074. */
  29075. get onBeforeBindObservable(): Observable<Mesh>;
  29076. /**
  29077. * An event triggered after rendering the mesh
  29078. */
  29079. get onAfterRenderObservable(): Observable<Mesh>;
  29080. /**
  29081. * An event triggered before drawing the mesh
  29082. */
  29083. get onBeforeDrawObservable(): Observable<Mesh>;
  29084. private _onBeforeDrawObserver;
  29085. /**
  29086. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29087. */
  29088. set onBeforeDraw(callback: () => void);
  29089. get hasInstances(): boolean;
  29090. get hasThinInstances(): boolean;
  29091. /**
  29092. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29093. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29094. */
  29095. delayLoadState: number;
  29096. /**
  29097. * Gets the list of instances created from this mesh
  29098. * it is not supposed to be modified manually.
  29099. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29100. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29101. */
  29102. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29103. /**
  29104. * Gets the file containing delay loading data for this mesh
  29105. */
  29106. delayLoadingFile: string;
  29107. /** @hidden */
  29108. _binaryInfo: any;
  29109. /**
  29110. * User defined function used to change how LOD level selection is done
  29111. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29112. */
  29113. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29114. /**
  29115. * Gets or sets the morph target manager
  29116. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29117. */
  29118. get morphTargetManager(): Nullable<MorphTargetManager>;
  29119. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29120. /** @hidden */
  29121. _creationDataStorage: Nullable<_CreationDataStorage>;
  29122. /** @hidden */
  29123. _geometry: Nullable<Geometry>;
  29124. /** @hidden */
  29125. _delayInfo: Array<string>;
  29126. /** @hidden */
  29127. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29128. /** @hidden */
  29129. _instanceDataStorage: _InstanceDataStorage;
  29130. /** @hidden */
  29131. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29132. private _effectiveMaterial;
  29133. /** @hidden */
  29134. _shouldGenerateFlatShading: boolean;
  29135. /** @hidden */
  29136. _originalBuilderSideOrientation: number;
  29137. /**
  29138. * Use this property to change the original side orientation defined at construction time
  29139. */
  29140. overrideMaterialSideOrientation: Nullable<number>;
  29141. /**
  29142. * Gets the source mesh (the one used to clone this one from)
  29143. */
  29144. get source(): Nullable<Mesh>;
  29145. /**
  29146. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29147. */
  29148. get isUnIndexed(): boolean;
  29149. set isUnIndexed(value: boolean);
  29150. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29151. get worldMatrixInstancedBuffer(): Float32Array;
  29152. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29153. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29154. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29155. /**
  29156. * @constructor
  29157. * @param name The value used by scene.getMeshByName() to do a lookup.
  29158. * @param scene The scene to add this mesh to.
  29159. * @param parent The parent of this mesh, if it has one
  29160. * @param source An optional Mesh from which geometry is shared, cloned.
  29161. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29162. * When false, achieved by calling a clone(), also passing False.
  29163. * This will make creation of children, recursive.
  29164. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29165. */
  29166. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29167. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29168. doNotInstantiate: boolean;
  29169. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29170. /**
  29171. * Gets the class name
  29172. * @returns the string "Mesh".
  29173. */
  29174. getClassName(): string;
  29175. /** @hidden */
  29176. get _isMesh(): boolean;
  29177. /**
  29178. * Returns a description of this mesh
  29179. * @param fullDetails define if full details about this mesh must be used
  29180. * @returns a descriptive string representing this mesh
  29181. */
  29182. toString(fullDetails?: boolean): string;
  29183. /** @hidden */
  29184. _unBindEffect(): void;
  29185. /**
  29186. * Gets a boolean indicating if this mesh has LOD
  29187. */
  29188. get hasLODLevels(): boolean;
  29189. /**
  29190. * Gets the list of MeshLODLevel associated with the current mesh
  29191. * @returns an array of MeshLODLevel
  29192. */
  29193. getLODLevels(): MeshLODLevel[];
  29194. private _sortLODLevels;
  29195. /**
  29196. * Add a mesh as LOD level triggered at the given distance.
  29197. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29198. * @param distance The distance from the center of the object to show this level
  29199. * @param mesh The mesh to be added as LOD level (can be null)
  29200. * @return This mesh (for chaining)
  29201. */
  29202. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29203. /**
  29204. * Returns the LOD level mesh at the passed distance or null if not found.
  29205. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29206. * @param distance The distance from the center of the object to show this level
  29207. * @returns a Mesh or `null`
  29208. */
  29209. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29210. /**
  29211. * Remove a mesh from the LOD array
  29212. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29213. * @param mesh defines the mesh to be removed
  29214. * @return This mesh (for chaining)
  29215. */
  29216. removeLODLevel(mesh: Mesh): Mesh;
  29217. /**
  29218. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29219. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29220. * @param camera defines the camera to use to compute distance
  29221. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29222. * @return This mesh (for chaining)
  29223. */
  29224. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29225. /**
  29226. * Gets the mesh internal Geometry object
  29227. */
  29228. get geometry(): Nullable<Geometry>;
  29229. /**
  29230. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29231. * @returns the total number of vertices
  29232. */
  29233. getTotalVertices(): number;
  29234. /**
  29235. * Returns the content of an associated vertex buffer
  29236. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29237. * - VertexBuffer.PositionKind
  29238. * - VertexBuffer.UVKind
  29239. * - VertexBuffer.UV2Kind
  29240. * - VertexBuffer.UV3Kind
  29241. * - VertexBuffer.UV4Kind
  29242. * - VertexBuffer.UV5Kind
  29243. * - VertexBuffer.UV6Kind
  29244. * - VertexBuffer.ColorKind
  29245. * - VertexBuffer.MatricesIndicesKind
  29246. * - VertexBuffer.MatricesIndicesExtraKind
  29247. * - VertexBuffer.MatricesWeightsKind
  29248. * - VertexBuffer.MatricesWeightsExtraKind
  29249. * @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
  29250. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29251. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29252. */
  29253. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29254. /**
  29255. * Returns the mesh VertexBuffer object from the requested `kind`
  29256. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29257. * - VertexBuffer.PositionKind
  29258. * - VertexBuffer.NormalKind
  29259. * - VertexBuffer.UVKind
  29260. * - VertexBuffer.UV2Kind
  29261. * - VertexBuffer.UV3Kind
  29262. * - VertexBuffer.UV4Kind
  29263. * - VertexBuffer.UV5Kind
  29264. * - VertexBuffer.UV6Kind
  29265. * - VertexBuffer.ColorKind
  29266. * - VertexBuffer.MatricesIndicesKind
  29267. * - VertexBuffer.MatricesIndicesExtraKind
  29268. * - VertexBuffer.MatricesWeightsKind
  29269. * - VertexBuffer.MatricesWeightsExtraKind
  29270. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29271. */
  29272. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29273. /**
  29274. * Tests if a specific vertex buffer is associated with this mesh
  29275. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29276. * - VertexBuffer.PositionKind
  29277. * - VertexBuffer.NormalKind
  29278. * - VertexBuffer.UVKind
  29279. * - VertexBuffer.UV2Kind
  29280. * - VertexBuffer.UV3Kind
  29281. * - VertexBuffer.UV4Kind
  29282. * - VertexBuffer.UV5Kind
  29283. * - VertexBuffer.UV6Kind
  29284. * - VertexBuffer.ColorKind
  29285. * - VertexBuffer.MatricesIndicesKind
  29286. * - VertexBuffer.MatricesIndicesExtraKind
  29287. * - VertexBuffer.MatricesWeightsKind
  29288. * - VertexBuffer.MatricesWeightsExtraKind
  29289. * @returns a boolean
  29290. */
  29291. isVerticesDataPresent(kind: string): boolean;
  29292. /**
  29293. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29294. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29295. * - VertexBuffer.PositionKind
  29296. * - VertexBuffer.UVKind
  29297. * - VertexBuffer.UV2Kind
  29298. * - VertexBuffer.UV3Kind
  29299. * - VertexBuffer.UV4Kind
  29300. * - VertexBuffer.UV5Kind
  29301. * - VertexBuffer.UV6Kind
  29302. * - VertexBuffer.ColorKind
  29303. * - VertexBuffer.MatricesIndicesKind
  29304. * - VertexBuffer.MatricesIndicesExtraKind
  29305. * - VertexBuffer.MatricesWeightsKind
  29306. * - VertexBuffer.MatricesWeightsExtraKind
  29307. * @returns a boolean
  29308. */
  29309. isVertexBufferUpdatable(kind: string): boolean;
  29310. /**
  29311. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29312. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29313. * - VertexBuffer.PositionKind
  29314. * - VertexBuffer.NormalKind
  29315. * - VertexBuffer.UVKind
  29316. * - VertexBuffer.UV2Kind
  29317. * - VertexBuffer.UV3Kind
  29318. * - VertexBuffer.UV4Kind
  29319. * - VertexBuffer.UV5Kind
  29320. * - VertexBuffer.UV6Kind
  29321. * - VertexBuffer.ColorKind
  29322. * - VertexBuffer.MatricesIndicesKind
  29323. * - VertexBuffer.MatricesIndicesExtraKind
  29324. * - VertexBuffer.MatricesWeightsKind
  29325. * - VertexBuffer.MatricesWeightsExtraKind
  29326. * @returns an array of strings
  29327. */
  29328. getVerticesDataKinds(): string[];
  29329. /**
  29330. * Returns a positive integer : the total number of indices in this mesh geometry.
  29331. * @returns the numner of indices or zero if the mesh has no geometry.
  29332. */
  29333. getTotalIndices(): number;
  29334. /**
  29335. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29336. * @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.
  29337. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29338. * @returns the indices array or an empty array if the mesh has no geometry
  29339. */
  29340. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29341. get isBlocked(): boolean;
  29342. /**
  29343. * Determine if the current mesh is ready to be rendered
  29344. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29345. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29346. * @returns true if all associated assets are ready (material, textures, shaders)
  29347. */
  29348. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29349. /**
  29350. * 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.
  29351. */
  29352. get areNormalsFrozen(): boolean;
  29353. /**
  29354. * 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.
  29355. * @returns the current mesh
  29356. */
  29357. freezeNormals(): Mesh;
  29358. /**
  29359. * 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
  29360. * @returns the current mesh
  29361. */
  29362. unfreezeNormals(): Mesh;
  29363. /**
  29364. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29365. */
  29366. set overridenInstanceCount(count: number);
  29367. /** @hidden */
  29368. _preActivate(): Mesh;
  29369. /** @hidden */
  29370. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29371. /** @hidden */
  29372. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29373. protected _afterComputeWorldMatrix(): void;
  29374. /** @hidden */
  29375. _postActivate(): void;
  29376. /**
  29377. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29378. * This means the mesh underlying bounding box and sphere are recomputed.
  29379. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29380. * @returns the current mesh
  29381. */
  29382. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29383. /** @hidden */
  29384. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29385. /**
  29386. * This function will subdivide the mesh into multiple submeshes
  29387. * @param count defines the expected number of submeshes
  29388. */
  29389. subdivide(count: number): void;
  29390. /**
  29391. * Copy a FloatArray into a specific associated vertex buffer
  29392. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29393. * - VertexBuffer.PositionKind
  29394. * - VertexBuffer.UVKind
  29395. * - VertexBuffer.UV2Kind
  29396. * - VertexBuffer.UV3Kind
  29397. * - VertexBuffer.UV4Kind
  29398. * - VertexBuffer.UV5Kind
  29399. * - VertexBuffer.UV6Kind
  29400. * - VertexBuffer.ColorKind
  29401. * - VertexBuffer.MatricesIndicesKind
  29402. * - VertexBuffer.MatricesIndicesExtraKind
  29403. * - VertexBuffer.MatricesWeightsKind
  29404. * - VertexBuffer.MatricesWeightsExtraKind
  29405. * @param data defines the data source
  29406. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29407. * @param stride defines the data stride size (can be null)
  29408. * @returns the current mesh
  29409. */
  29410. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29411. /**
  29412. * Delete a vertex buffer associated with this mesh
  29413. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29414. * - VertexBuffer.PositionKind
  29415. * - VertexBuffer.UVKind
  29416. * - VertexBuffer.UV2Kind
  29417. * - VertexBuffer.UV3Kind
  29418. * - VertexBuffer.UV4Kind
  29419. * - VertexBuffer.UV5Kind
  29420. * - VertexBuffer.UV6Kind
  29421. * - VertexBuffer.ColorKind
  29422. * - VertexBuffer.MatricesIndicesKind
  29423. * - VertexBuffer.MatricesIndicesExtraKind
  29424. * - VertexBuffer.MatricesWeightsKind
  29425. * - VertexBuffer.MatricesWeightsExtraKind
  29426. */
  29427. removeVerticesData(kind: string): void;
  29428. /**
  29429. * Flags an associated vertex buffer as updatable
  29430. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29431. * - VertexBuffer.PositionKind
  29432. * - VertexBuffer.UVKind
  29433. * - VertexBuffer.UV2Kind
  29434. * - VertexBuffer.UV3Kind
  29435. * - VertexBuffer.UV4Kind
  29436. * - VertexBuffer.UV5Kind
  29437. * - VertexBuffer.UV6Kind
  29438. * - VertexBuffer.ColorKind
  29439. * - VertexBuffer.MatricesIndicesKind
  29440. * - VertexBuffer.MatricesIndicesExtraKind
  29441. * - VertexBuffer.MatricesWeightsKind
  29442. * - VertexBuffer.MatricesWeightsExtraKind
  29443. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29444. */
  29445. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29446. /**
  29447. * Sets the mesh global Vertex Buffer
  29448. * @param buffer defines the buffer to use
  29449. * @returns the current mesh
  29450. */
  29451. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29452. /**
  29453. * Update a specific associated vertex buffer
  29454. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29455. * - VertexBuffer.PositionKind
  29456. * - VertexBuffer.UVKind
  29457. * - VertexBuffer.UV2Kind
  29458. * - VertexBuffer.UV3Kind
  29459. * - VertexBuffer.UV4Kind
  29460. * - VertexBuffer.UV5Kind
  29461. * - VertexBuffer.UV6Kind
  29462. * - VertexBuffer.ColorKind
  29463. * - VertexBuffer.MatricesIndicesKind
  29464. * - VertexBuffer.MatricesIndicesExtraKind
  29465. * - VertexBuffer.MatricesWeightsKind
  29466. * - VertexBuffer.MatricesWeightsExtraKind
  29467. * @param data defines the data source
  29468. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29469. * @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)
  29470. * @returns the current mesh
  29471. */
  29472. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29473. /**
  29474. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29475. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29476. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29477. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29478. * @returns the current mesh
  29479. */
  29480. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29481. /**
  29482. * Creates a un-shared specific occurence of the geometry for the mesh.
  29483. * @returns the current mesh
  29484. */
  29485. makeGeometryUnique(): Mesh;
  29486. /**
  29487. * Set the index buffer of this mesh
  29488. * @param indices defines the source data
  29489. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29490. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29491. * @returns the current mesh
  29492. */
  29493. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29494. /**
  29495. * Update the current index buffer
  29496. * @param indices defines the source data
  29497. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29498. * @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)
  29499. * @returns the current mesh
  29500. */
  29501. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29502. /**
  29503. * Invert the geometry to move from a right handed system to a left handed one.
  29504. * @returns the current mesh
  29505. */
  29506. toLeftHanded(): Mesh;
  29507. /** @hidden */
  29508. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29509. /** @hidden */
  29510. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29511. /**
  29512. * Registers for this mesh a javascript function called just before the rendering process
  29513. * @param func defines the function to call before rendering this mesh
  29514. * @returns the current mesh
  29515. */
  29516. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29517. /**
  29518. * Disposes a previously registered javascript function called before the rendering
  29519. * @param func defines the function to remove
  29520. * @returns the current mesh
  29521. */
  29522. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29523. /**
  29524. * Registers for this mesh a javascript function called just after the rendering is complete
  29525. * @param func defines the function to call after rendering this mesh
  29526. * @returns the current mesh
  29527. */
  29528. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29529. /**
  29530. * Disposes a previously registered javascript function called after the rendering.
  29531. * @param func defines the function to remove
  29532. * @returns the current mesh
  29533. */
  29534. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29535. /** @hidden */
  29536. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29537. /** @hidden */
  29538. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29539. /** @hidden */
  29540. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29541. /** @hidden */
  29542. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29543. /** @hidden */
  29544. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29545. /** @hidden */
  29546. _rebuild(): void;
  29547. /** @hidden */
  29548. _freeze(): void;
  29549. /** @hidden */
  29550. _unFreeze(): void;
  29551. /**
  29552. * 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
  29553. * @param subMesh defines the subMesh to render
  29554. * @param enableAlphaMode defines if alpha mode can be changed
  29555. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29556. * @returns the current mesh
  29557. */
  29558. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29559. private _onBeforeDraw;
  29560. /**
  29561. * Renormalize the mesh and patch it up if there are no weights
  29562. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29563. * However in the case of zero weights then we set just a single influence to 1.
  29564. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29565. */
  29566. cleanMatrixWeights(): void;
  29567. private normalizeSkinFourWeights;
  29568. private normalizeSkinWeightsAndExtra;
  29569. /**
  29570. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29571. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29572. * the user know there was an issue with importing the mesh
  29573. * @returns a validation object with skinned, valid and report string
  29574. */
  29575. validateSkinning(): {
  29576. skinned: boolean;
  29577. valid: boolean;
  29578. report: string;
  29579. };
  29580. /** @hidden */
  29581. _checkDelayState(): Mesh;
  29582. private _queueLoad;
  29583. /**
  29584. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29585. * A mesh is in the frustum if its bounding box intersects the frustum
  29586. * @param frustumPlanes defines the frustum to test
  29587. * @returns true if the mesh is in the frustum planes
  29588. */
  29589. isInFrustum(frustumPlanes: Plane[]): boolean;
  29590. /**
  29591. * Sets the mesh material by the material or multiMaterial `id` property
  29592. * @param id is a string identifying the material or the multiMaterial
  29593. * @returns the current mesh
  29594. */
  29595. setMaterialByID(id: string): Mesh;
  29596. /**
  29597. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29598. * @returns an array of IAnimatable
  29599. */
  29600. getAnimatables(): IAnimatable[];
  29601. /**
  29602. * Modifies the mesh geometry according to the passed transformation matrix.
  29603. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29604. * The mesh normals are modified using the same transformation.
  29605. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29606. * @param transform defines the transform matrix to use
  29607. * @see https://doc.babylonjs.com/resources/baking_transformations
  29608. * @returns the current mesh
  29609. */
  29610. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29611. /**
  29612. * Modifies the mesh geometry according to its own current World Matrix.
  29613. * The mesh World Matrix is then reset.
  29614. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29615. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29616. * @see https://doc.babylonjs.com/resources/baking_transformations
  29617. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29618. * @returns the current mesh
  29619. */
  29620. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29621. /** @hidden */
  29622. get _positions(): Nullable<Vector3[]>;
  29623. /** @hidden */
  29624. _resetPointsArrayCache(): Mesh;
  29625. /** @hidden */
  29626. _generatePointsArray(): boolean;
  29627. /**
  29628. * Returns a new Mesh object generated from the current mesh properties.
  29629. * This method must not get confused with createInstance()
  29630. * @param name is a string, the name given to the new mesh
  29631. * @param newParent can be any Node object (default `null`)
  29632. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29633. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29634. * @returns a new mesh
  29635. */
  29636. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29637. /**
  29638. * Releases resources associated with this mesh.
  29639. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29640. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29641. */
  29642. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29643. /** @hidden */
  29644. _disposeInstanceSpecificData(): void;
  29645. /** @hidden */
  29646. _disposeThinInstanceSpecificData(): void;
  29647. /**
  29648. * Modifies the mesh geometry according to a displacement map.
  29649. * 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.
  29650. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29651. * @param url is a string, the URL from the image file is to be downloaded.
  29652. * @param minHeight is the lower limit of the displacement.
  29653. * @param maxHeight is the upper limit of the displacement.
  29654. * @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.
  29655. * @param uvOffset is an optional vector2 used to offset UV.
  29656. * @param uvScale is an optional vector2 used to scale UV.
  29657. * @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.
  29658. * @returns the Mesh.
  29659. */
  29660. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29661. /**
  29662. * Modifies the mesh geometry according to a displacementMap buffer.
  29663. * 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.
  29664. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29665. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29666. * @param heightMapWidth is the width of the buffer image.
  29667. * @param heightMapHeight is the height of the buffer image.
  29668. * @param minHeight is the lower limit of the displacement.
  29669. * @param maxHeight is the upper limit of the displacement.
  29670. * @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.
  29671. * @param uvOffset is an optional vector2 used to offset UV.
  29672. * @param uvScale is an optional vector2 used to scale UV.
  29673. * @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.
  29674. * @returns the Mesh.
  29675. */
  29676. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29677. /**
  29678. * Modify the mesh to get a flat shading rendering.
  29679. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29680. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29681. * @returns current mesh
  29682. */
  29683. convertToFlatShadedMesh(): Mesh;
  29684. /**
  29685. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29686. * In other words, more vertices, no more indices and a single bigger VBO.
  29687. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29688. * @returns current mesh
  29689. */
  29690. convertToUnIndexedMesh(): Mesh;
  29691. /**
  29692. * Inverses facet orientations.
  29693. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29694. * @param flipNormals will also inverts the normals
  29695. * @returns current mesh
  29696. */
  29697. flipFaces(flipNormals?: boolean): Mesh;
  29698. /**
  29699. * Increase the number of facets and hence vertices in a mesh
  29700. * Vertex normals are interpolated from existing vertex normals
  29701. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29702. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29703. */
  29704. increaseVertices(numberPerEdge: number): void;
  29705. /**
  29706. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29707. * This will undo any application of covertToFlatShadedMesh
  29708. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29709. */
  29710. forceSharedVertices(): void;
  29711. /** @hidden */
  29712. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29713. /** @hidden */
  29714. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29715. /**
  29716. * Creates a new InstancedMesh object from the mesh model.
  29717. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29718. * @param name defines the name of the new instance
  29719. * @returns a new InstancedMesh
  29720. */
  29721. createInstance(name: string): InstancedMesh;
  29722. /**
  29723. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29724. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29725. * @returns the current mesh
  29726. */
  29727. synchronizeInstances(): Mesh;
  29728. /**
  29729. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29730. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29731. * This should be used together with the simplification to avoid disappearing triangles.
  29732. * @param successCallback an optional success callback to be called after the optimization finished.
  29733. * @returns the current mesh
  29734. */
  29735. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29736. /**
  29737. * Serialize current mesh
  29738. * @param serializationObject defines the object which will receive the serialization data
  29739. */
  29740. serialize(serializationObject: any): void;
  29741. /** @hidden */
  29742. _syncGeometryWithMorphTargetManager(): void;
  29743. /** @hidden */
  29744. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29745. /**
  29746. * Returns a new Mesh object parsed from the source provided.
  29747. * @param parsedMesh is the source
  29748. * @param scene defines the hosting scene
  29749. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29750. * @returns a new Mesh
  29751. */
  29752. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29753. /**
  29754. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29755. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29756. * @param name defines the name of the mesh to create
  29757. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29758. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29759. * @param closePath creates a seam between the first and the last points of each path of the path array
  29760. * @param offset is taken in account only if the `pathArray` is containing a single path
  29761. * @param scene defines the hosting scene
  29762. * @param updatable defines if the mesh must be flagged as updatable
  29763. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29764. * @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)
  29765. * @returns a new Mesh
  29766. */
  29767. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29768. /**
  29769. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29770. * @param name defines the name of the mesh to create
  29771. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29772. * @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
  29773. * @param scene defines the hosting scene
  29774. * @param updatable defines if the mesh must be flagged as updatable
  29775. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29776. * @returns a new Mesh
  29777. */
  29778. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29779. /**
  29780. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29781. * @param name defines the name of the mesh to create
  29782. * @param size sets the size (float) of each box side (default 1)
  29783. * @param scene defines the hosting scene
  29784. * @param updatable defines if the mesh must be flagged as updatable
  29785. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29786. * @returns a new Mesh
  29787. */
  29788. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29789. /**
  29790. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29791. * @param name defines the name of the mesh to create
  29792. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29793. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29794. * @param scene defines the hosting scene
  29795. * @param updatable defines if the mesh must be flagged as updatable
  29796. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29797. * @returns a new Mesh
  29798. */
  29799. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29800. /**
  29801. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29802. * @param name defines the name of the mesh to create
  29803. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29804. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29805. * @param scene defines the hosting scene
  29806. * @returns a new Mesh
  29807. */
  29808. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29809. /**
  29810. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29811. * @param name defines the name of the mesh to create
  29812. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29813. * @param diameterTop set the top cap diameter (floats, default 1)
  29814. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29815. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29816. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29817. * @param scene defines the hosting scene
  29818. * @param updatable defines if the mesh must be flagged as updatable
  29819. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29820. * @returns a new Mesh
  29821. */
  29822. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29823. /**
  29824. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29825. * @param name defines the name of the mesh to create
  29826. * @param diameter sets the diameter size (float) of the torus (default 1)
  29827. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29828. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29829. * @param scene defines the hosting scene
  29830. * @param updatable defines if the mesh must be flagged as updatable
  29831. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29832. * @returns a new Mesh
  29833. */
  29834. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29835. /**
  29836. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29837. * @param name defines the name of the mesh to create
  29838. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29839. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29840. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29841. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29842. * @param p the number of windings on X axis (positive integers, default 2)
  29843. * @param q the number of windings on Y axis (positive integers, default 3)
  29844. * @param scene defines the hosting scene
  29845. * @param updatable defines if the mesh must be flagged as updatable
  29846. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29847. * @returns a new Mesh
  29848. */
  29849. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29850. /**
  29851. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29852. * @param name defines the name of the mesh to create
  29853. * @param points is an array successive Vector3
  29854. * @param scene defines the hosting scene
  29855. * @param updatable defines if the mesh must be flagged as updatable
  29856. * @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).
  29857. * @returns a new Mesh
  29858. */
  29859. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29860. /**
  29861. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29862. * @param name defines the name of the mesh to create
  29863. * @param points is an array successive Vector3
  29864. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29865. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29866. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29867. * @param scene defines the hosting scene
  29868. * @param updatable defines if the mesh must be flagged as updatable
  29869. * @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)
  29870. * @returns a new Mesh
  29871. */
  29872. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29873. /**
  29874. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29875. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29876. * 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.
  29877. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29878. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29879. * Remember you can only change the shape positions, not their number when updating a polygon.
  29880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29881. * @param name defines the name of the mesh to create
  29882. * @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
  29883. * @param scene defines the hosting scene
  29884. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29885. * @param updatable defines if the mesh must be flagged as updatable
  29886. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29887. * @param earcutInjection can be used to inject your own earcut reference
  29888. * @returns a new Mesh
  29889. */
  29890. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29891. /**
  29892. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29894. * @param name defines the name of the mesh to create
  29895. * @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
  29896. * @param depth defines the height of extrusion
  29897. * @param scene defines the hosting scene
  29898. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29899. * @param updatable defines if the mesh must be flagged as updatable
  29900. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29901. * @param earcutInjection can be used to inject your own earcut reference
  29902. * @returns a new Mesh
  29903. */
  29904. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29905. /**
  29906. * Creates an extruded shape mesh.
  29907. * 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
  29908. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29910. * @param name defines the name of the mesh to create
  29911. * @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
  29912. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29913. * @param scale is the value to scale the shape
  29914. * @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
  29915. * @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
  29916. * @param scene defines the hosting scene
  29917. * @param updatable defines if the mesh must be flagged as updatable
  29918. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29919. * @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)
  29920. * @returns a new Mesh
  29921. */
  29922. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29923. /**
  29924. * Creates an custom extruded shape mesh.
  29925. * The custom extrusion is a parametric shape.
  29926. * It has no predefined shape. Its final shape will depend on the input parameters.
  29927. * Please consider using the same method from the MeshBuilder class instead
  29928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29929. * @param name defines the name of the mesh to create
  29930. * @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
  29931. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29932. * @param scaleFunction is a custom Javascript function called on each path point
  29933. * @param rotationFunction is a custom Javascript function called on each path point
  29934. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29935. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29936. * @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
  29937. * @param scene defines the hosting scene
  29938. * @param updatable defines if the mesh must be flagged as updatable
  29939. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29940. * @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)
  29941. * @returns a new Mesh
  29942. */
  29943. 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;
  29944. /**
  29945. * Creates lathe mesh.
  29946. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29947. * Please consider using the same method from the MeshBuilder class instead
  29948. * @param name defines the name of the mesh to create
  29949. * @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
  29950. * @param radius is the radius value of the lathe
  29951. * @param tessellation is the side number of the lathe.
  29952. * @param scene defines the hosting scene
  29953. * @param updatable defines if the mesh must be flagged as updatable
  29954. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29955. * @returns a new Mesh
  29956. */
  29957. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29958. /**
  29959. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29960. * @param name defines the name of the mesh to create
  29961. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29962. * @param scene defines the hosting scene
  29963. * @param updatable defines if the mesh must be flagged as updatable
  29964. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29965. * @returns a new Mesh
  29966. */
  29967. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29968. /**
  29969. * Creates a ground mesh.
  29970. * Please consider using the same method from the MeshBuilder class instead
  29971. * @param name defines the name of the mesh to create
  29972. * @param width set the width of the ground
  29973. * @param height set the height of the ground
  29974. * @param subdivisions sets the number of subdivisions per side
  29975. * @param scene defines the hosting scene
  29976. * @param updatable defines if the mesh must be flagged as updatable
  29977. * @returns a new Mesh
  29978. */
  29979. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29980. /**
  29981. * Creates a tiled ground mesh.
  29982. * Please consider using the same method from the MeshBuilder class instead
  29983. * @param name defines the name of the mesh to create
  29984. * @param xmin set the ground minimum X coordinate
  29985. * @param zmin set the ground minimum Y coordinate
  29986. * @param xmax set the ground maximum X coordinate
  29987. * @param zmax set the ground maximum Z coordinate
  29988. * @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
  29989. * @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
  29990. * @param scene defines the hosting scene
  29991. * @param updatable defines if the mesh must be flagged as updatable
  29992. * @returns a new Mesh
  29993. */
  29994. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29995. w: number;
  29996. h: number;
  29997. }, precision: {
  29998. w: number;
  29999. h: number;
  30000. }, scene: Scene, updatable?: boolean): Mesh;
  30001. /**
  30002. * Creates a ground mesh from a height map.
  30003. * Please consider using the same method from the MeshBuilder class instead
  30004. * @see https://doc.babylonjs.com/babylon101/height_map
  30005. * @param name defines the name of the mesh to create
  30006. * @param url sets the URL of the height map image resource
  30007. * @param width set the ground width size
  30008. * @param height set the ground height size
  30009. * @param subdivisions sets the number of subdivision per side
  30010. * @param minHeight is the minimum altitude on the ground
  30011. * @param maxHeight is the maximum altitude on the ground
  30012. * @param scene defines the hosting scene
  30013. * @param updatable defines if the mesh must be flagged as updatable
  30014. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30015. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30016. * @returns a new Mesh
  30017. */
  30018. 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;
  30019. /**
  30020. * Creates a tube mesh.
  30021. * The tube is a parametric shape.
  30022. * It has no predefined shape. Its final shape will depend on the input parameters.
  30023. * Please consider using the same method from the MeshBuilder class instead
  30024. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30025. * @param name defines the name of the mesh to create
  30026. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30027. * @param radius sets the tube radius size
  30028. * @param tessellation is the number of sides on the tubular surface
  30029. * @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
  30030. * @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
  30031. * @param scene defines the hosting scene
  30032. * @param updatable defines if the mesh must be flagged as updatable
  30033. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30034. * @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)
  30035. * @returns a new Mesh
  30036. */
  30037. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30038. (i: number, distance: number): number;
  30039. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30040. /**
  30041. * Creates a polyhedron mesh.
  30042. * Please consider using the same method from the MeshBuilder class instead.
  30043. * * 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
  30044. * * The parameter `size` (positive float, default 1) sets the polygon size
  30045. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30046. * * 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`
  30047. * * 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
  30048. * * 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)`)
  30049. * * 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
  30050. * * 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
  30051. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30054. * @param name defines the name of the mesh to create
  30055. * @param options defines the options used to create the mesh
  30056. * @param scene defines the hosting scene
  30057. * @returns a new Mesh
  30058. */
  30059. static CreatePolyhedron(name: string, options: {
  30060. type?: number;
  30061. size?: number;
  30062. sizeX?: number;
  30063. sizeY?: number;
  30064. sizeZ?: number;
  30065. custom?: any;
  30066. faceUV?: Vector4[];
  30067. faceColors?: Color4[];
  30068. updatable?: boolean;
  30069. sideOrientation?: number;
  30070. }, scene: Scene): Mesh;
  30071. /**
  30072. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30073. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30074. * * 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`)
  30075. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30076. * * 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
  30077. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30080. * @param name defines the name of the mesh
  30081. * @param options defines the options used to create the mesh
  30082. * @param scene defines the hosting scene
  30083. * @returns a new Mesh
  30084. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30085. */
  30086. static CreateIcoSphere(name: string, options: {
  30087. radius?: number;
  30088. flat?: boolean;
  30089. subdivisions?: number;
  30090. sideOrientation?: number;
  30091. updatable?: boolean;
  30092. }, scene: Scene): Mesh;
  30093. /**
  30094. * Creates a decal mesh.
  30095. * Please consider using the same method from the MeshBuilder class instead.
  30096. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30097. * @param name defines the name of the mesh
  30098. * @param sourceMesh defines the mesh receiving the decal
  30099. * @param position sets the position of the decal in world coordinates
  30100. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30101. * @param size sets the decal scaling
  30102. * @param angle sets the angle to rotate the decal
  30103. * @returns a new Mesh
  30104. */
  30105. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30106. /**
  30107. * Prepare internal position array for software CPU skinning
  30108. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30109. */
  30110. setPositionsForCPUSkinning(): Float32Array;
  30111. /**
  30112. * Prepare internal normal array for software CPU skinning
  30113. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30114. */
  30115. setNormalsForCPUSkinning(): Float32Array;
  30116. /**
  30117. * Updates the vertex buffer by applying transformation from the bones
  30118. * @param skeleton defines the skeleton to apply to current mesh
  30119. * @returns the current mesh
  30120. */
  30121. applySkeleton(skeleton: Skeleton): Mesh;
  30122. /**
  30123. * 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
  30124. * @param meshes defines the list of meshes to scan
  30125. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30126. */
  30127. static MinMax(meshes: AbstractMesh[]): {
  30128. min: Vector3;
  30129. max: Vector3;
  30130. };
  30131. /**
  30132. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30133. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30134. * @returns a vector3
  30135. */
  30136. static Center(meshesOrMinMaxVector: {
  30137. min: Vector3;
  30138. max: Vector3;
  30139. } | AbstractMesh[]): Vector3;
  30140. /**
  30141. * Merge the array of meshes into a single mesh for performance reasons.
  30142. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30143. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30144. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30145. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30146. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30147. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30148. * @returns a new mesh
  30149. */
  30150. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30151. /** @hidden */
  30152. addInstance(instance: InstancedMesh): void;
  30153. /** @hidden */
  30154. removeInstance(instance: InstancedMesh): void;
  30155. }
  30156. }
  30157. declare module "babylonjs/Cameras/camera" {
  30158. import { SmartArray } from "babylonjs/Misc/smartArray";
  30159. import { Observable } from "babylonjs/Misc/observable";
  30160. import { Nullable } from "babylonjs/types";
  30161. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30162. import { Scene } from "babylonjs/scene";
  30163. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30164. import { Node } from "babylonjs/node";
  30165. import { Mesh } from "babylonjs/Meshes/mesh";
  30166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30167. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30168. import { Viewport } from "babylonjs/Maths/math.viewport";
  30169. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30170. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30171. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30172. import { Ray } from "babylonjs/Culling/ray";
  30173. /**
  30174. * This is the base class of all the camera used in the application.
  30175. * @see https://doc.babylonjs.com/features/cameras
  30176. */
  30177. export class Camera extends Node {
  30178. /** @hidden */
  30179. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30180. /**
  30181. * This is the default projection mode used by the cameras.
  30182. * It helps recreating a feeling of perspective and better appreciate depth.
  30183. * This is the best way to simulate real life cameras.
  30184. */
  30185. static readonly PERSPECTIVE_CAMERA: number;
  30186. /**
  30187. * This helps creating camera with an orthographic mode.
  30188. * 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.
  30189. */
  30190. static readonly ORTHOGRAPHIC_CAMERA: number;
  30191. /**
  30192. * This is the default FOV mode for perspective cameras.
  30193. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30194. */
  30195. static readonly FOVMODE_VERTICAL_FIXED: number;
  30196. /**
  30197. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30198. */
  30199. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30200. /**
  30201. * This specifies ther is no need for a camera rig.
  30202. * Basically only one eye is rendered corresponding to the camera.
  30203. */
  30204. static readonly RIG_MODE_NONE: number;
  30205. /**
  30206. * Simulates a camera Rig with one blue eye and one red eye.
  30207. * This can be use with 3d blue and red glasses.
  30208. */
  30209. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30210. /**
  30211. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30212. */
  30213. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30214. /**
  30215. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30216. */
  30217. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30218. /**
  30219. * Defines that both eyes of the camera will be rendered over under each other.
  30220. */
  30221. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30222. /**
  30223. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30224. */
  30225. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30226. /**
  30227. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30228. */
  30229. static readonly RIG_MODE_VR: number;
  30230. /**
  30231. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30232. */
  30233. static readonly RIG_MODE_WEBVR: number;
  30234. /**
  30235. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30236. */
  30237. static readonly RIG_MODE_CUSTOM: number;
  30238. /**
  30239. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30240. */
  30241. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30242. /**
  30243. * Define the input manager associated with the camera.
  30244. */
  30245. inputs: CameraInputsManager<Camera>;
  30246. /** @hidden */
  30247. _position: Vector3;
  30248. /**
  30249. * Define the current local position of the camera in the scene
  30250. */
  30251. get position(): Vector3;
  30252. set position(newPosition: Vector3);
  30253. /**
  30254. * The vector the camera should consider as up.
  30255. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30256. */
  30257. upVector: Vector3;
  30258. /**
  30259. * Define the current limit on the left side for an orthographic camera
  30260. * In scene unit
  30261. */
  30262. orthoLeft: Nullable<number>;
  30263. /**
  30264. * Define the current limit on the right side for an orthographic camera
  30265. * In scene unit
  30266. */
  30267. orthoRight: Nullable<number>;
  30268. /**
  30269. * Define the current limit on the bottom side for an orthographic camera
  30270. * In scene unit
  30271. */
  30272. orthoBottom: Nullable<number>;
  30273. /**
  30274. * Define the current limit on the top side for an orthographic camera
  30275. * In scene unit
  30276. */
  30277. orthoTop: Nullable<number>;
  30278. /**
  30279. * Field Of View is set in Radians. (default is 0.8)
  30280. */
  30281. fov: number;
  30282. /**
  30283. * Define the minimum distance the camera can see from.
  30284. * This is important to note that the depth buffer are not infinite and the closer it starts
  30285. * the more your scene might encounter depth fighting issue.
  30286. */
  30287. minZ: number;
  30288. /**
  30289. * Define the maximum distance the camera can see to.
  30290. * This is important to note that the depth buffer are not infinite and the further it end
  30291. * the more your scene might encounter depth fighting issue.
  30292. */
  30293. maxZ: number;
  30294. /**
  30295. * Define the default inertia of the camera.
  30296. * This helps giving a smooth feeling to the camera movement.
  30297. */
  30298. inertia: number;
  30299. /**
  30300. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30301. */
  30302. mode: number;
  30303. /**
  30304. * Define whether the camera is intermediate.
  30305. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30306. */
  30307. isIntermediate: boolean;
  30308. /**
  30309. * Define the viewport of the camera.
  30310. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30311. */
  30312. viewport: Viewport;
  30313. /**
  30314. * Restricts the camera to viewing objects with the same layerMask.
  30315. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30316. */
  30317. layerMask: number;
  30318. /**
  30319. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30320. */
  30321. fovMode: number;
  30322. /**
  30323. * Rig mode of the camera.
  30324. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30325. * This is normally controlled byt the camera themselves as internal use.
  30326. */
  30327. cameraRigMode: number;
  30328. /**
  30329. * Defines the distance between both "eyes" in case of a RIG
  30330. */
  30331. interaxialDistance: number;
  30332. /**
  30333. * Defines if stereoscopic rendering is done side by side or over under.
  30334. */
  30335. isStereoscopicSideBySide: boolean;
  30336. /**
  30337. * 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
  30338. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30339. * else in the scene. (Eg. security camera)
  30340. *
  30341. * 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)
  30342. */
  30343. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30344. /**
  30345. * When set, the camera will render to this render target instead of the default canvas
  30346. *
  30347. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30348. */
  30349. outputRenderTarget: Nullable<RenderTargetTexture>;
  30350. /**
  30351. * Observable triggered when the camera view matrix has changed.
  30352. */
  30353. onViewMatrixChangedObservable: Observable<Camera>;
  30354. /**
  30355. * Observable triggered when the camera Projection matrix has changed.
  30356. */
  30357. onProjectionMatrixChangedObservable: Observable<Camera>;
  30358. /**
  30359. * Observable triggered when the inputs have been processed.
  30360. */
  30361. onAfterCheckInputsObservable: Observable<Camera>;
  30362. /**
  30363. * Observable triggered when reset has been called and applied to the camera.
  30364. */
  30365. onRestoreStateObservable: Observable<Camera>;
  30366. /**
  30367. * Is this camera a part of a rig system?
  30368. */
  30369. isRigCamera: boolean;
  30370. /**
  30371. * If isRigCamera set to true this will be set with the parent camera.
  30372. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30373. */
  30374. rigParent?: Camera;
  30375. /** @hidden */
  30376. _cameraRigParams: any;
  30377. /** @hidden */
  30378. _rigCameras: Camera[];
  30379. /** @hidden */
  30380. _rigPostProcess: Nullable<PostProcess>;
  30381. protected _webvrViewMatrix: Matrix;
  30382. /** @hidden */
  30383. _skipRendering: boolean;
  30384. /** @hidden */
  30385. _projectionMatrix: Matrix;
  30386. /** @hidden */
  30387. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30388. /** @hidden */
  30389. _activeMeshes: SmartArray<AbstractMesh>;
  30390. protected _globalPosition: Vector3;
  30391. /** @hidden */
  30392. _computedViewMatrix: Matrix;
  30393. private _doNotComputeProjectionMatrix;
  30394. private _transformMatrix;
  30395. private _frustumPlanes;
  30396. private _refreshFrustumPlanes;
  30397. private _storedFov;
  30398. private _stateStored;
  30399. /**
  30400. * Instantiates a new camera object.
  30401. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30402. * @see https://doc.babylonjs.com/features/cameras
  30403. * @param name Defines the name of the camera in the scene
  30404. * @param position Defines the position of the camera
  30405. * @param scene Defines the scene the camera belongs too
  30406. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30407. */
  30408. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30409. /**
  30410. * Store current camera state (fov, position, etc..)
  30411. * @returns the camera
  30412. */
  30413. storeState(): Camera;
  30414. /**
  30415. * Restores the camera state values if it has been stored. You must call storeState() first
  30416. */
  30417. protected _restoreStateValues(): boolean;
  30418. /**
  30419. * Restored camera state. You must call storeState() first.
  30420. * @returns true if restored and false otherwise
  30421. */
  30422. restoreState(): boolean;
  30423. /**
  30424. * Gets the class name of the camera.
  30425. * @returns the class name
  30426. */
  30427. getClassName(): string;
  30428. /** @hidden */
  30429. readonly _isCamera: boolean;
  30430. /**
  30431. * Gets a string representation of the camera useful for debug purpose.
  30432. * @param fullDetails Defines that a more verboe level of logging is required
  30433. * @returns the string representation
  30434. */
  30435. toString(fullDetails?: boolean): string;
  30436. /**
  30437. * Gets the current world space position of the camera.
  30438. */
  30439. get globalPosition(): Vector3;
  30440. /**
  30441. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30442. * @returns the active meshe list
  30443. */
  30444. getActiveMeshes(): SmartArray<AbstractMesh>;
  30445. /**
  30446. * Check whether a mesh is part of the current active mesh list of the camera
  30447. * @param mesh Defines the mesh to check
  30448. * @returns true if active, false otherwise
  30449. */
  30450. isActiveMesh(mesh: Mesh): boolean;
  30451. /**
  30452. * Is this camera ready to be used/rendered
  30453. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30454. * @return true if the camera is ready
  30455. */
  30456. isReady(completeCheck?: boolean): boolean;
  30457. /** @hidden */
  30458. _initCache(): void;
  30459. /** @hidden */
  30460. _updateCache(ignoreParentClass?: boolean): void;
  30461. /** @hidden */
  30462. _isSynchronized(): boolean;
  30463. /** @hidden */
  30464. _isSynchronizedViewMatrix(): boolean;
  30465. /** @hidden */
  30466. _isSynchronizedProjectionMatrix(): boolean;
  30467. /**
  30468. * Attach the input controls to a specific dom element to get the input from.
  30469. * @param element Defines the element the controls should be listened from
  30470. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30471. */
  30472. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30473. /**
  30474. * Detach the current controls from the specified dom element.
  30475. * @param element Defines the element to stop listening the inputs from
  30476. */
  30477. detachControl(element: HTMLElement): void;
  30478. /**
  30479. * Update the camera state according to the different inputs gathered during the frame.
  30480. */
  30481. update(): void;
  30482. /** @hidden */
  30483. _checkInputs(): void;
  30484. /** @hidden */
  30485. get rigCameras(): Camera[];
  30486. /**
  30487. * Gets the post process used by the rig cameras
  30488. */
  30489. get rigPostProcess(): Nullable<PostProcess>;
  30490. /**
  30491. * Internal, gets the first post proces.
  30492. * @returns the first post process to be run on this camera.
  30493. */
  30494. _getFirstPostProcess(): Nullable<PostProcess>;
  30495. private _cascadePostProcessesToRigCams;
  30496. /**
  30497. * Attach a post process to the camera.
  30498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30499. * @param postProcess The post process to attach to the camera
  30500. * @param insertAt The position of the post process in case several of them are in use in the scene
  30501. * @returns the position the post process has been inserted at
  30502. */
  30503. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30504. /**
  30505. * Detach a post process to the camera.
  30506. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30507. * @param postProcess The post process to detach from the camera
  30508. */
  30509. detachPostProcess(postProcess: PostProcess): void;
  30510. /**
  30511. * Gets the current world matrix of the camera
  30512. */
  30513. getWorldMatrix(): Matrix;
  30514. /** @hidden */
  30515. _getViewMatrix(): Matrix;
  30516. /**
  30517. * Gets the current view matrix of the camera.
  30518. * @param force forces the camera to recompute the matrix without looking at the cached state
  30519. * @returns the view matrix
  30520. */
  30521. getViewMatrix(force?: boolean): Matrix;
  30522. /**
  30523. * Freeze the projection matrix.
  30524. * It will prevent the cache check of the camera projection compute and can speed up perf
  30525. * if no parameter of the camera are meant to change
  30526. * @param projection Defines manually a projection if necessary
  30527. */
  30528. freezeProjectionMatrix(projection?: Matrix): void;
  30529. /**
  30530. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30531. */
  30532. unfreezeProjectionMatrix(): void;
  30533. /**
  30534. * Gets the current projection matrix of the camera.
  30535. * @param force forces the camera to recompute the matrix without looking at the cached state
  30536. * @returns the projection matrix
  30537. */
  30538. getProjectionMatrix(force?: boolean): Matrix;
  30539. /**
  30540. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30541. * @returns a Matrix
  30542. */
  30543. getTransformationMatrix(): Matrix;
  30544. private _updateFrustumPlanes;
  30545. /**
  30546. * Checks if a cullable object (mesh...) is in the camera frustum
  30547. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30548. * @param target The object to check
  30549. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30550. * @returns true if the object is in frustum otherwise false
  30551. */
  30552. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30553. /**
  30554. * Checks if a cullable object (mesh...) is in the camera frustum
  30555. * Unlike isInFrustum this cheks the full bounding box
  30556. * @param target The object to check
  30557. * @returns true if the object is in frustum otherwise false
  30558. */
  30559. isCompletelyInFrustum(target: ICullable): boolean;
  30560. /**
  30561. * Gets a ray in the forward direction from the camera.
  30562. * @param length Defines the length of the ray to create
  30563. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30564. * @param origin Defines the start point of the ray which defaults to the camera position
  30565. * @returns the forward ray
  30566. */
  30567. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30568. /**
  30569. * Gets a ray in the forward direction from the camera.
  30570. * @param refRay the ray to (re)use when setting the values
  30571. * @param length Defines the length of the ray to create
  30572. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30573. * @param origin Defines the start point of the ray which defaults to the camera position
  30574. * @returns the forward ray
  30575. */
  30576. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30577. /**
  30578. * Releases resources associated with this node.
  30579. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30580. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30581. */
  30582. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30583. /** @hidden */
  30584. _isLeftCamera: boolean;
  30585. /**
  30586. * Gets the left camera of a rig setup in case of Rigged Camera
  30587. */
  30588. get isLeftCamera(): boolean;
  30589. /** @hidden */
  30590. _isRightCamera: boolean;
  30591. /**
  30592. * Gets the right camera of a rig setup in case of Rigged Camera
  30593. */
  30594. get isRightCamera(): boolean;
  30595. /**
  30596. * Gets the left camera of a rig setup in case of Rigged Camera
  30597. */
  30598. get leftCamera(): Nullable<FreeCamera>;
  30599. /**
  30600. * Gets the right camera of a rig setup in case of Rigged Camera
  30601. */
  30602. get rightCamera(): Nullable<FreeCamera>;
  30603. /**
  30604. * Gets the left camera target of a rig setup in case of Rigged Camera
  30605. * @returns the target position
  30606. */
  30607. getLeftTarget(): Nullable<Vector3>;
  30608. /**
  30609. * Gets the right camera target of a rig setup in case of Rigged Camera
  30610. * @returns the target position
  30611. */
  30612. getRightTarget(): Nullable<Vector3>;
  30613. /**
  30614. * @hidden
  30615. */
  30616. setCameraRigMode(mode: number, rigParams: any): void;
  30617. /** @hidden */
  30618. static _setStereoscopicRigMode(camera: Camera): void;
  30619. /** @hidden */
  30620. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30621. /** @hidden */
  30622. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30623. /** @hidden */
  30624. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30625. /** @hidden */
  30626. _getVRProjectionMatrix(): Matrix;
  30627. protected _updateCameraRotationMatrix(): void;
  30628. protected _updateWebVRCameraRotationMatrix(): void;
  30629. /**
  30630. * This function MUST be overwritten by the different WebVR cameras available.
  30631. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30632. * @hidden
  30633. */
  30634. _getWebVRProjectionMatrix(): Matrix;
  30635. /**
  30636. * This function MUST be overwritten by the different WebVR cameras available.
  30637. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30638. * @hidden
  30639. */
  30640. _getWebVRViewMatrix(): Matrix;
  30641. /** @hidden */
  30642. setCameraRigParameter(name: string, value: any): void;
  30643. /**
  30644. * needs to be overridden by children so sub has required properties to be copied
  30645. * @hidden
  30646. */
  30647. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30648. /**
  30649. * May need to be overridden by children
  30650. * @hidden
  30651. */
  30652. _updateRigCameras(): void;
  30653. /** @hidden */
  30654. _setupInputs(): void;
  30655. /**
  30656. * Serialiaze the camera setup to a json represention
  30657. * @returns the JSON representation
  30658. */
  30659. serialize(): any;
  30660. /**
  30661. * Clones the current camera.
  30662. * @param name The cloned camera name
  30663. * @returns the cloned camera
  30664. */
  30665. clone(name: string): Camera;
  30666. /**
  30667. * Gets the direction of the camera relative to a given local axis.
  30668. * @param localAxis Defines the reference axis to provide a relative direction.
  30669. * @return the direction
  30670. */
  30671. getDirection(localAxis: Vector3): Vector3;
  30672. /**
  30673. * Returns the current camera absolute rotation
  30674. */
  30675. get absoluteRotation(): Quaternion;
  30676. /**
  30677. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30678. * @param localAxis Defines the reference axis to provide a relative direction.
  30679. * @param result Defines the vector to store the result in
  30680. */
  30681. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30682. /**
  30683. * Gets a camera constructor for a given camera type
  30684. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30685. * @param name The name of the camera the result will be able to instantiate
  30686. * @param scene The scene the result will construct the camera in
  30687. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30688. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30689. * @returns a factory method to construc the camera
  30690. */
  30691. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30692. /**
  30693. * Compute the world matrix of the camera.
  30694. * @returns the camera world matrix
  30695. */
  30696. computeWorldMatrix(): Matrix;
  30697. /**
  30698. * Parse a JSON and creates the camera from the parsed information
  30699. * @param parsedCamera The JSON to parse
  30700. * @param scene The scene to instantiate the camera in
  30701. * @returns the newly constructed camera
  30702. */
  30703. static Parse(parsedCamera: any, scene: Scene): Camera;
  30704. }
  30705. }
  30706. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30707. import { Nullable } from "babylonjs/types";
  30708. import { Scene } from "babylonjs/scene";
  30709. import { Vector4 } from "babylonjs/Maths/math.vector";
  30710. import { Mesh } from "babylonjs/Meshes/mesh";
  30711. /**
  30712. * Class containing static functions to help procedurally build meshes
  30713. */
  30714. export class DiscBuilder {
  30715. /**
  30716. * Creates a plane polygonal mesh. By default, this is a disc
  30717. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30718. * * 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
  30719. * * 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
  30720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30723. * @param name defines the name of the mesh
  30724. * @param options defines the options used to create the mesh
  30725. * @param scene defines the hosting scene
  30726. * @returns the plane polygonal mesh
  30727. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30728. */
  30729. static CreateDisc(name: string, options: {
  30730. radius?: number;
  30731. tessellation?: number;
  30732. arc?: number;
  30733. updatable?: boolean;
  30734. sideOrientation?: number;
  30735. frontUVs?: Vector4;
  30736. backUVs?: Vector4;
  30737. }, scene?: Nullable<Scene>): Mesh;
  30738. }
  30739. }
  30740. declare module "babylonjs/Materials/fresnelParameters" {
  30741. import { DeepImmutable } from "babylonjs/types";
  30742. import { Color3 } from "babylonjs/Maths/math.color";
  30743. /**
  30744. * Options to be used when creating a FresnelParameters.
  30745. */
  30746. export type IFresnelParametersCreationOptions = {
  30747. /**
  30748. * Define the color used on edges (grazing angle)
  30749. */
  30750. leftColor?: Color3;
  30751. /**
  30752. * Define the color used on center
  30753. */
  30754. rightColor?: Color3;
  30755. /**
  30756. * Define bias applied to computed fresnel term
  30757. */
  30758. bias?: number;
  30759. /**
  30760. * Defined the power exponent applied to fresnel term
  30761. */
  30762. power?: number;
  30763. /**
  30764. * Define if the fresnel effect is enable or not.
  30765. */
  30766. isEnabled?: boolean;
  30767. };
  30768. /**
  30769. * Serialized format for FresnelParameters.
  30770. */
  30771. export type IFresnelParametersSerialized = {
  30772. /**
  30773. * Define the color used on edges (grazing angle) [as an array]
  30774. */
  30775. leftColor: number[];
  30776. /**
  30777. * Define the color used on center [as an array]
  30778. */
  30779. rightColor: number[];
  30780. /**
  30781. * Define bias applied to computed fresnel term
  30782. */
  30783. bias: number;
  30784. /**
  30785. * Defined the power exponent applied to fresnel term
  30786. */
  30787. power?: number;
  30788. /**
  30789. * Define if the fresnel effect is enable or not.
  30790. */
  30791. isEnabled: boolean;
  30792. };
  30793. /**
  30794. * This represents all the required information to add a fresnel effect on a material:
  30795. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30796. */
  30797. export class FresnelParameters {
  30798. private _isEnabled;
  30799. /**
  30800. * Define if the fresnel effect is enable or not.
  30801. */
  30802. get isEnabled(): boolean;
  30803. set isEnabled(value: boolean);
  30804. /**
  30805. * Define the color used on edges (grazing angle)
  30806. */
  30807. leftColor: Color3;
  30808. /**
  30809. * Define the color used on center
  30810. */
  30811. rightColor: Color3;
  30812. /**
  30813. * Define bias applied to computed fresnel term
  30814. */
  30815. bias: number;
  30816. /**
  30817. * Defined the power exponent applied to fresnel term
  30818. */
  30819. power: number;
  30820. /**
  30821. * Creates a new FresnelParameters object.
  30822. *
  30823. * @param options provide your own settings to optionally to override defaults
  30824. */
  30825. constructor(options?: IFresnelParametersCreationOptions);
  30826. /**
  30827. * Clones the current fresnel and its valuues
  30828. * @returns a clone fresnel configuration
  30829. */
  30830. clone(): FresnelParameters;
  30831. /**
  30832. * Determines equality between FresnelParameters objects
  30833. * @param otherFresnelParameters defines the second operand
  30834. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30835. */
  30836. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30837. /**
  30838. * Serializes the current fresnel parameters to a JSON representation.
  30839. * @return the JSON serialization
  30840. */
  30841. serialize(): IFresnelParametersSerialized;
  30842. /**
  30843. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30844. * @param parsedFresnelParameters Define the JSON representation
  30845. * @returns the parsed parameters
  30846. */
  30847. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30848. }
  30849. }
  30850. declare module "babylonjs/Materials/materialFlags" {
  30851. /**
  30852. * This groups all the flags used to control the materials channel.
  30853. */
  30854. export class MaterialFlags {
  30855. private static _DiffuseTextureEnabled;
  30856. /**
  30857. * Are diffuse textures enabled in the application.
  30858. */
  30859. static get DiffuseTextureEnabled(): boolean;
  30860. static set DiffuseTextureEnabled(value: boolean);
  30861. private static _DetailTextureEnabled;
  30862. /**
  30863. * Are detail textures enabled in the application.
  30864. */
  30865. static get DetailTextureEnabled(): boolean;
  30866. static set DetailTextureEnabled(value: boolean);
  30867. private static _AmbientTextureEnabled;
  30868. /**
  30869. * Are ambient textures enabled in the application.
  30870. */
  30871. static get AmbientTextureEnabled(): boolean;
  30872. static set AmbientTextureEnabled(value: boolean);
  30873. private static _OpacityTextureEnabled;
  30874. /**
  30875. * Are opacity textures enabled in the application.
  30876. */
  30877. static get OpacityTextureEnabled(): boolean;
  30878. static set OpacityTextureEnabled(value: boolean);
  30879. private static _ReflectionTextureEnabled;
  30880. /**
  30881. * Are reflection textures enabled in the application.
  30882. */
  30883. static get ReflectionTextureEnabled(): boolean;
  30884. static set ReflectionTextureEnabled(value: boolean);
  30885. private static _EmissiveTextureEnabled;
  30886. /**
  30887. * Are emissive textures enabled in the application.
  30888. */
  30889. static get EmissiveTextureEnabled(): boolean;
  30890. static set EmissiveTextureEnabled(value: boolean);
  30891. private static _SpecularTextureEnabled;
  30892. /**
  30893. * Are specular textures enabled in the application.
  30894. */
  30895. static get SpecularTextureEnabled(): boolean;
  30896. static set SpecularTextureEnabled(value: boolean);
  30897. private static _BumpTextureEnabled;
  30898. /**
  30899. * Are bump textures enabled in the application.
  30900. */
  30901. static get BumpTextureEnabled(): boolean;
  30902. static set BumpTextureEnabled(value: boolean);
  30903. private static _LightmapTextureEnabled;
  30904. /**
  30905. * Are lightmap textures enabled in the application.
  30906. */
  30907. static get LightmapTextureEnabled(): boolean;
  30908. static set LightmapTextureEnabled(value: boolean);
  30909. private static _RefractionTextureEnabled;
  30910. /**
  30911. * Are refraction textures enabled in the application.
  30912. */
  30913. static get RefractionTextureEnabled(): boolean;
  30914. static set RefractionTextureEnabled(value: boolean);
  30915. private static _ColorGradingTextureEnabled;
  30916. /**
  30917. * Are color grading textures enabled in the application.
  30918. */
  30919. static get ColorGradingTextureEnabled(): boolean;
  30920. static set ColorGradingTextureEnabled(value: boolean);
  30921. private static _FresnelEnabled;
  30922. /**
  30923. * Are fresnels enabled in the application.
  30924. */
  30925. static get FresnelEnabled(): boolean;
  30926. static set FresnelEnabled(value: boolean);
  30927. private static _ClearCoatTextureEnabled;
  30928. /**
  30929. * Are clear coat textures enabled in the application.
  30930. */
  30931. static get ClearCoatTextureEnabled(): boolean;
  30932. static set ClearCoatTextureEnabled(value: boolean);
  30933. private static _ClearCoatBumpTextureEnabled;
  30934. /**
  30935. * Are clear coat bump textures enabled in the application.
  30936. */
  30937. static get ClearCoatBumpTextureEnabled(): boolean;
  30938. static set ClearCoatBumpTextureEnabled(value: boolean);
  30939. private static _ClearCoatTintTextureEnabled;
  30940. /**
  30941. * Are clear coat tint textures enabled in the application.
  30942. */
  30943. static get ClearCoatTintTextureEnabled(): boolean;
  30944. static set ClearCoatTintTextureEnabled(value: boolean);
  30945. private static _SheenTextureEnabled;
  30946. /**
  30947. * Are sheen textures enabled in the application.
  30948. */
  30949. static get SheenTextureEnabled(): boolean;
  30950. static set SheenTextureEnabled(value: boolean);
  30951. private static _AnisotropicTextureEnabled;
  30952. /**
  30953. * Are anisotropic textures enabled in the application.
  30954. */
  30955. static get AnisotropicTextureEnabled(): boolean;
  30956. static set AnisotropicTextureEnabled(value: boolean);
  30957. private static _ThicknessTextureEnabled;
  30958. /**
  30959. * Are thickness textures enabled in the application.
  30960. */
  30961. static get ThicknessTextureEnabled(): boolean;
  30962. static set ThicknessTextureEnabled(value: boolean);
  30963. }
  30964. }
  30965. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30966. /** @hidden */
  30967. export var defaultFragmentDeclaration: {
  30968. name: string;
  30969. shader: string;
  30970. };
  30971. }
  30972. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30973. /** @hidden */
  30974. export var defaultUboDeclaration: {
  30975. name: string;
  30976. shader: string;
  30977. };
  30978. }
  30979. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  30980. /** @hidden */
  30981. export var prePassDeclaration: {
  30982. name: string;
  30983. shader: string;
  30984. };
  30985. }
  30986. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30987. /** @hidden */
  30988. export var lightFragmentDeclaration: {
  30989. name: string;
  30990. shader: string;
  30991. };
  30992. }
  30993. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30994. /** @hidden */
  30995. export var lightUboDeclaration: {
  30996. name: string;
  30997. shader: string;
  30998. };
  30999. }
  31000. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31001. /** @hidden */
  31002. export var lightsFragmentFunctions: {
  31003. name: string;
  31004. shader: string;
  31005. };
  31006. }
  31007. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31008. /** @hidden */
  31009. export var shadowsFragmentFunctions: {
  31010. name: string;
  31011. shader: string;
  31012. };
  31013. }
  31014. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31015. /** @hidden */
  31016. export var fresnelFunction: {
  31017. name: string;
  31018. shader: string;
  31019. };
  31020. }
  31021. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31022. /** @hidden */
  31023. export var bumpFragmentMainFunctions: {
  31024. name: string;
  31025. shader: string;
  31026. };
  31027. }
  31028. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31029. /** @hidden */
  31030. export var bumpFragmentFunctions: {
  31031. name: string;
  31032. shader: string;
  31033. };
  31034. }
  31035. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31036. /** @hidden */
  31037. export var logDepthDeclaration: {
  31038. name: string;
  31039. shader: string;
  31040. };
  31041. }
  31042. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31043. /** @hidden */
  31044. export var bumpFragment: {
  31045. name: string;
  31046. shader: string;
  31047. };
  31048. }
  31049. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31050. /** @hidden */
  31051. export var depthPrePass: {
  31052. name: string;
  31053. shader: string;
  31054. };
  31055. }
  31056. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31057. /** @hidden */
  31058. export var lightFragment: {
  31059. name: string;
  31060. shader: string;
  31061. };
  31062. }
  31063. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31064. /** @hidden */
  31065. export var logDepthFragment: {
  31066. name: string;
  31067. shader: string;
  31068. };
  31069. }
  31070. declare module "babylonjs/Shaders/default.fragment" {
  31071. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31072. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31073. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31074. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31075. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31076. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31077. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31078. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31079. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31080. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31081. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31082. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31083. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31084. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31085. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31086. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31087. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31088. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31089. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31090. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31091. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31092. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31093. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31094. /** @hidden */
  31095. export var defaultPixelShader: {
  31096. name: string;
  31097. shader: string;
  31098. };
  31099. }
  31100. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31101. /** @hidden */
  31102. export var defaultVertexDeclaration: {
  31103. name: string;
  31104. shader: string;
  31105. };
  31106. }
  31107. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31108. /** @hidden */
  31109. export var bumpVertexDeclaration: {
  31110. name: string;
  31111. shader: string;
  31112. };
  31113. }
  31114. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31115. /** @hidden */
  31116. export var bumpVertex: {
  31117. name: string;
  31118. shader: string;
  31119. };
  31120. }
  31121. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31122. /** @hidden */
  31123. export var fogVertex: {
  31124. name: string;
  31125. shader: string;
  31126. };
  31127. }
  31128. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31129. /** @hidden */
  31130. export var shadowsVertex: {
  31131. name: string;
  31132. shader: string;
  31133. };
  31134. }
  31135. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31136. /** @hidden */
  31137. export var pointCloudVertex: {
  31138. name: string;
  31139. shader: string;
  31140. };
  31141. }
  31142. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31143. /** @hidden */
  31144. export var logDepthVertex: {
  31145. name: string;
  31146. shader: string;
  31147. };
  31148. }
  31149. declare module "babylonjs/Shaders/default.vertex" {
  31150. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31151. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31152. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31153. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31154. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31155. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31156. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31157. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31158. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31159. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31160. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31161. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31162. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31163. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31164. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31165. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31166. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31167. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31168. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31169. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31170. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31171. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31172. /** @hidden */
  31173. export var defaultVertexShader: {
  31174. name: string;
  31175. shader: string;
  31176. };
  31177. }
  31178. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31179. import { Nullable } from "babylonjs/types";
  31180. import { Scene } from "babylonjs/scene";
  31181. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31182. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31183. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31184. /**
  31185. * @hidden
  31186. */
  31187. export interface IMaterialDetailMapDefines {
  31188. DETAIL: boolean;
  31189. DETAILDIRECTUV: number;
  31190. DETAIL_NORMALBLENDMETHOD: number;
  31191. /** @hidden */
  31192. _areTexturesDirty: boolean;
  31193. }
  31194. /**
  31195. * Define the code related to the detail map parameters of a material
  31196. *
  31197. * Inspired from:
  31198. * 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
  31199. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31200. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31201. */
  31202. export class DetailMapConfiguration {
  31203. private _texture;
  31204. /**
  31205. * The detail texture of the material.
  31206. */
  31207. texture: Nullable<BaseTexture>;
  31208. /**
  31209. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31210. * Bigger values mean stronger blending
  31211. */
  31212. diffuseBlendLevel: number;
  31213. /**
  31214. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31215. * Bigger values mean stronger blending. Only used with PBR materials
  31216. */
  31217. roughnessBlendLevel: number;
  31218. /**
  31219. * Defines how strong the bump effect from the detail map is
  31220. * Bigger values mean stronger effect
  31221. */
  31222. bumpLevel: number;
  31223. private _normalBlendMethod;
  31224. /**
  31225. * The method used to blend the bump and detail normals together
  31226. */
  31227. normalBlendMethod: number;
  31228. private _isEnabled;
  31229. /**
  31230. * Enable or disable the detail map on this material
  31231. */
  31232. isEnabled: boolean;
  31233. /** @hidden */
  31234. private _internalMarkAllSubMeshesAsTexturesDirty;
  31235. /** @hidden */
  31236. _markAllSubMeshesAsTexturesDirty(): void;
  31237. /**
  31238. * Instantiate a new detail map
  31239. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31240. */
  31241. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31242. /**
  31243. * Gets whether the submesh is ready to be used or not.
  31244. * @param defines the list of "defines" to update.
  31245. * @param scene defines the scene the material belongs to.
  31246. * @returns - boolean indicating that the submesh is ready or not.
  31247. */
  31248. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31249. /**
  31250. * Update the defines for detail map usage
  31251. * @param defines the list of "defines" to update.
  31252. * @param scene defines the scene the material belongs to.
  31253. */
  31254. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31255. /**
  31256. * Binds the material data.
  31257. * @param uniformBuffer defines the Uniform buffer to fill in.
  31258. * @param scene defines the scene the material belongs to.
  31259. * @param isFrozen defines whether the material is frozen or not.
  31260. */
  31261. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31262. /**
  31263. * Checks to see if a texture is used in the material.
  31264. * @param texture - Base texture to use.
  31265. * @returns - Boolean specifying if a texture is used in the material.
  31266. */
  31267. hasTexture(texture: BaseTexture): boolean;
  31268. /**
  31269. * Returns an array of the actively used textures.
  31270. * @param activeTextures Array of BaseTextures
  31271. */
  31272. getActiveTextures(activeTextures: BaseTexture[]): void;
  31273. /**
  31274. * Returns the animatable textures.
  31275. * @param animatables Array of animatable textures.
  31276. */
  31277. getAnimatables(animatables: IAnimatable[]): void;
  31278. /**
  31279. * Disposes the resources of the material.
  31280. * @param forceDisposeTextures - Forces the disposal of all textures.
  31281. */
  31282. dispose(forceDisposeTextures?: boolean): void;
  31283. /**
  31284. * Get the current class name useful for serialization or dynamic coding.
  31285. * @returns "DetailMap"
  31286. */
  31287. getClassName(): string;
  31288. /**
  31289. * Add the required uniforms to the current list.
  31290. * @param uniforms defines the current uniform list.
  31291. */
  31292. static AddUniforms(uniforms: string[]): void;
  31293. /**
  31294. * Add the required samplers to the current list.
  31295. * @param samplers defines the current sampler list.
  31296. */
  31297. static AddSamplers(samplers: string[]): void;
  31298. /**
  31299. * Add the required uniforms to the current buffer.
  31300. * @param uniformBuffer defines the current uniform buffer.
  31301. */
  31302. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31303. /**
  31304. * Makes a duplicate of the current instance into another one.
  31305. * @param detailMap define the instance where to copy the info
  31306. */
  31307. copyTo(detailMap: DetailMapConfiguration): void;
  31308. /**
  31309. * Serializes this detail map instance
  31310. * @returns - An object with the serialized instance.
  31311. */
  31312. serialize(): any;
  31313. /**
  31314. * Parses a detail map setting from a serialized object.
  31315. * @param source - Serialized object.
  31316. * @param scene Defines the scene we are parsing for
  31317. * @param rootUrl Defines the rootUrl to load from
  31318. */
  31319. parse(source: any, scene: Scene, rootUrl: string): void;
  31320. }
  31321. }
  31322. declare module "babylonjs/Materials/standardMaterial" {
  31323. import { SmartArray } from "babylonjs/Misc/smartArray";
  31324. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31325. import { Nullable } from "babylonjs/types";
  31326. import { Scene } from "babylonjs/scene";
  31327. import { Matrix } from "babylonjs/Maths/math.vector";
  31328. import { Color3 } from "babylonjs/Maths/math.color";
  31329. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31331. import { Mesh } from "babylonjs/Meshes/mesh";
  31332. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31333. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31334. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31335. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31336. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31337. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31338. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31339. import "babylonjs/Shaders/default.fragment";
  31340. import "babylonjs/Shaders/default.vertex";
  31341. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31342. /** @hidden */
  31343. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31344. MAINUV1: boolean;
  31345. MAINUV2: boolean;
  31346. DIFFUSE: boolean;
  31347. DIFFUSEDIRECTUV: number;
  31348. DETAIL: boolean;
  31349. DETAILDIRECTUV: number;
  31350. DETAIL_NORMALBLENDMETHOD: number;
  31351. AMBIENT: boolean;
  31352. AMBIENTDIRECTUV: number;
  31353. OPACITY: boolean;
  31354. OPACITYDIRECTUV: number;
  31355. OPACITYRGB: boolean;
  31356. REFLECTION: boolean;
  31357. EMISSIVE: boolean;
  31358. EMISSIVEDIRECTUV: number;
  31359. SPECULAR: boolean;
  31360. SPECULARDIRECTUV: number;
  31361. BUMP: boolean;
  31362. BUMPDIRECTUV: number;
  31363. PARALLAX: boolean;
  31364. PARALLAXOCCLUSION: boolean;
  31365. SPECULAROVERALPHA: boolean;
  31366. CLIPPLANE: boolean;
  31367. CLIPPLANE2: boolean;
  31368. CLIPPLANE3: boolean;
  31369. CLIPPLANE4: boolean;
  31370. CLIPPLANE5: boolean;
  31371. CLIPPLANE6: boolean;
  31372. ALPHATEST: boolean;
  31373. DEPTHPREPASS: boolean;
  31374. ALPHAFROMDIFFUSE: boolean;
  31375. POINTSIZE: boolean;
  31376. FOG: boolean;
  31377. SPECULARTERM: boolean;
  31378. DIFFUSEFRESNEL: boolean;
  31379. OPACITYFRESNEL: boolean;
  31380. REFLECTIONFRESNEL: boolean;
  31381. REFRACTIONFRESNEL: boolean;
  31382. EMISSIVEFRESNEL: boolean;
  31383. FRESNEL: boolean;
  31384. NORMAL: boolean;
  31385. UV1: boolean;
  31386. UV2: boolean;
  31387. VERTEXCOLOR: boolean;
  31388. VERTEXALPHA: boolean;
  31389. NUM_BONE_INFLUENCERS: number;
  31390. BonesPerMesh: number;
  31391. BONETEXTURE: boolean;
  31392. INSTANCES: boolean;
  31393. THIN_INSTANCES: boolean;
  31394. GLOSSINESS: boolean;
  31395. ROUGHNESS: boolean;
  31396. EMISSIVEASILLUMINATION: boolean;
  31397. LINKEMISSIVEWITHDIFFUSE: boolean;
  31398. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31399. LIGHTMAP: boolean;
  31400. LIGHTMAPDIRECTUV: number;
  31401. OBJECTSPACE_NORMALMAP: boolean;
  31402. USELIGHTMAPASSHADOWMAP: boolean;
  31403. REFLECTIONMAP_3D: boolean;
  31404. REFLECTIONMAP_SPHERICAL: boolean;
  31405. REFLECTIONMAP_PLANAR: boolean;
  31406. REFLECTIONMAP_CUBIC: boolean;
  31407. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31408. REFLECTIONMAP_PROJECTION: boolean;
  31409. REFLECTIONMAP_SKYBOX: boolean;
  31410. REFLECTIONMAP_EXPLICIT: boolean;
  31411. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31412. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31413. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31414. INVERTCUBICMAP: boolean;
  31415. LOGARITHMICDEPTH: boolean;
  31416. REFRACTION: boolean;
  31417. REFRACTIONMAP_3D: boolean;
  31418. REFLECTIONOVERALPHA: boolean;
  31419. TWOSIDEDLIGHTING: boolean;
  31420. SHADOWFLOAT: boolean;
  31421. MORPHTARGETS: boolean;
  31422. MORPHTARGETS_NORMAL: boolean;
  31423. MORPHTARGETS_TANGENT: boolean;
  31424. MORPHTARGETS_UV: boolean;
  31425. NUM_MORPH_INFLUENCERS: number;
  31426. NONUNIFORMSCALING: boolean;
  31427. PREMULTIPLYALPHA: boolean;
  31428. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31429. ALPHABLEND: boolean;
  31430. PREPASS: boolean;
  31431. SCENE_MRT_COUNT: number;
  31432. RGBDLIGHTMAP: boolean;
  31433. RGBDREFLECTION: boolean;
  31434. RGBDREFRACTION: boolean;
  31435. IMAGEPROCESSING: boolean;
  31436. VIGNETTE: boolean;
  31437. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31438. VIGNETTEBLENDMODEOPAQUE: boolean;
  31439. TONEMAPPING: boolean;
  31440. TONEMAPPING_ACES: boolean;
  31441. CONTRAST: boolean;
  31442. COLORCURVES: boolean;
  31443. COLORGRADING: boolean;
  31444. COLORGRADING3D: boolean;
  31445. SAMPLER3DGREENDEPTH: boolean;
  31446. SAMPLER3DBGRMAP: boolean;
  31447. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31448. MULTIVIEW: boolean;
  31449. /**
  31450. * If the reflection texture on this material is in linear color space
  31451. * @hidden
  31452. */
  31453. IS_REFLECTION_LINEAR: boolean;
  31454. /**
  31455. * If the refraction texture on this material is in linear color space
  31456. * @hidden
  31457. */
  31458. IS_REFRACTION_LINEAR: boolean;
  31459. EXPOSURE: boolean;
  31460. constructor();
  31461. setReflectionMode(modeToEnable: string): void;
  31462. }
  31463. /**
  31464. * This is the default material used in Babylon. It is the best trade off between quality
  31465. * and performances.
  31466. * @see https://doc.babylonjs.com/babylon101/materials
  31467. */
  31468. export class StandardMaterial extends PushMaterial {
  31469. private _diffuseTexture;
  31470. /**
  31471. * The basic texture of the material as viewed under a light.
  31472. */
  31473. diffuseTexture: Nullable<BaseTexture>;
  31474. private _ambientTexture;
  31475. /**
  31476. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31477. */
  31478. ambientTexture: Nullable<BaseTexture>;
  31479. private _opacityTexture;
  31480. /**
  31481. * Define the transparency of the material from a texture.
  31482. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31483. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31484. */
  31485. opacityTexture: Nullable<BaseTexture>;
  31486. private _reflectionTexture;
  31487. /**
  31488. * Define the texture used to display the reflection.
  31489. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31490. */
  31491. reflectionTexture: Nullable<BaseTexture>;
  31492. private _emissiveTexture;
  31493. /**
  31494. * Define texture of the material as if self lit.
  31495. * This will be mixed in the final result even in the absence of light.
  31496. */
  31497. emissiveTexture: Nullable<BaseTexture>;
  31498. private _specularTexture;
  31499. /**
  31500. * Define how the color and intensity of the highlight given by the light in the material.
  31501. */
  31502. specularTexture: Nullable<BaseTexture>;
  31503. private _bumpTexture;
  31504. /**
  31505. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31506. * 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.
  31507. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31508. */
  31509. bumpTexture: Nullable<BaseTexture>;
  31510. private _lightmapTexture;
  31511. /**
  31512. * Complex lighting can be computationally expensive to compute at runtime.
  31513. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31514. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31515. */
  31516. lightmapTexture: Nullable<BaseTexture>;
  31517. private _refractionTexture;
  31518. /**
  31519. * Define the texture used to display the refraction.
  31520. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31521. */
  31522. refractionTexture: Nullable<BaseTexture>;
  31523. /**
  31524. * The color of the material lit by the environmental background lighting.
  31525. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31526. */
  31527. ambientColor: Color3;
  31528. /**
  31529. * The basic color of the material as viewed under a light.
  31530. */
  31531. diffuseColor: Color3;
  31532. /**
  31533. * Define how the color and intensity of the highlight given by the light in the material.
  31534. */
  31535. specularColor: Color3;
  31536. /**
  31537. * Define the color of the material as if self lit.
  31538. * This will be mixed in the final result even in the absence of light.
  31539. */
  31540. emissiveColor: Color3;
  31541. /**
  31542. * Defines how sharp are the highlights in the material.
  31543. * The bigger the value the sharper giving a more glossy feeling to the result.
  31544. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31545. */
  31546. specularPower: number;
  31547. private _useAlphaFromDiffuseTexture;
  31548. /**
  31549. * Does the transparency come from the diffuse texture alpha channel.
  31550. */
  31551. useAlphaFromDiffuseTexture: boolean;
  31552. private _useEmissiveAsIllumination;
  31553. /**
  31554. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31555. */
  31556. useEmissiveAsIllumination: boolean;
  31557. private _linkEmissiveWithDiffuse;
  31558. /**
  31559. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31560. * the emissive level when the final color is close to one.
  31561. */
  31562. linkEmissiveWithDiffuse: boolean;
  31563. private _useSpecularOverAlpha;
  31564. /**
  31565. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31566. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31567. */
  31568. useSpecularOverAlpha: boolean;
  31569. private _useReflectionOverAlpha;
  31570. /**
  31571. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31572. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31573. */
  31574. useReflectionOverAlpha: boolean;
  31575. private _disableLighting;
  31576. /**
  31577. * Does lights from the scene impacts this material.
  31578. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31579. */
  31580. disableLighting: boolean;
  31581. private _useObjectSpaceNormalMap;
  31582. /**
  31583. * Allows using an object space normal map (instead of tangent space).
  31584. */
  31585. useObjectSpaceNormalMap: boolean;
  31586. private _useParallax;
  31587. /**
  31588. * Is parallax enabled or not.
  31589. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31590. */
  31591. useParallax: boolean;
  31592. private _useParallaxOcclusion;
  31593. /**
  31594. * Is parallax occlusion enabled or not.
  31595. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31596. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31597. */
  31598. useParallaxOcclusion: boolean;
  31599. /**
  31600. * 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.
  31601. */
  31602. parallaxScaleBias: number;
  31603. private _roughness;
  31604. /**
  31605. * Helps to define how blurry the reflections should appears in the material.
  31606. */
  31607. roughness: number;
  31608. /**
  31609. * In case of refraction, define the value of the index of refraction.
  31610. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31611. */
  31612. indexOfRefraction: number;
  31613. /**
  31614. * Invert the refraction texture alongside the y axis.
  31615. * It can be useful with procedural textures or probe for instance.
  31616. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31617. */
  31618. invertRefractionY: boolean;
  31619. /**
  31620. * Defines the alpha limits in alpha test mode.
  31621. */
  31622. alphaCutOff: number;
  31623. private _useLightmapAsShadowmap;
  31624. /**
  31625. * In case of light mapping, define whether the map contains light or shadow informations.
  31626. */
  31627. useLightmapAsShadowmap: boolean;
  31628. private _diffuseFresnelParameters;
  31629. /**
  31630. * Define the diffuse fresnel parameters of the material.
  31631. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31632. */
  31633. diffuseFresnelParameters: FresnelParameters;
  31634. private _opacityFresnelParameters;
  31635. /**
  31636. * Define the opacity fresnel parameters of the material.
  31637. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31638. */
  31639. opacityFresnelParameters: FresnelParameters;
  31640. private _reflectionFresnelParameters;
  31641. /**
  31642. * Define the reflection fresnel parameters of the material.
  31643. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31644. */
  31645. reflectionFresnelParameters: FresnelParameters;
  31646. private _refractionFresnelParameters;
  31647. /**
  31648. * Define the refraction fresnel parameters of the material.
  31649. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31650. */
  31651. refractionFresnelParameters: FresnelParameters;
  31652. private _emissiveFresnelParameters;
  31653. /**
  31654. * Define the emissive fresnel parameters of the material.
  31655. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31656. */
  31657. emissiveFresnelParameters: FresnelParameters;
  31658. private _useReflectionFresnelFromSpecular;
  31659. /**
  31660. * If true automatically deducts the fresnels values from the material specularity.
  31661. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31662. */
  31663. useReflectionFresnelFromSpecular: boolean;
  31664. private _useGlossinessFromSpecularMapAlpha;
  31665. /**
  31666. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31667. */
  31668. useGlossinessFromSpecularMapAlpha: boolean;
  31669. private _maxSimultaneousLights;
  31670. /**
  31671. * Defines the maximum number of lights that can be used in the material
  31672. */
  31673. maxSimultaneousLights: number;
  31674. private _invertNormalMapX;
  31675. /**
  31676. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31677. */
  31678. invertNormalMapX: boolean;
  31679. private _invertNormalMapY;
  31680. /**
  31681. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31682. */
  31683. invertNormalMapY: boolean;
  31684. private _twoSidedLighting;
  31685. /**
  31686. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31687. */
  31688. twoSidedLighting: boolean;
  31689. /**
  31690. * Default configuration related to image processing available in the standard Material.
  31691. */
  31692. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31693. /**
  31694. * Gets the image processing configuration used either in this material.
  31695. */
  31696. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31697. /**
  31698. * Sets the Default image processing configuration used either in the this material.
  31699. *
  31700. * If sets to null, the scene one is in use.
  31701. */
  31702. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31703. /**
  31704. * Keep track of the image processing observer to allow dispose and replace.
  31705. */
  31706. private _imageProcessingObserver;
  31707. /**
  31708. * Attaches a new image processing configuration to the Standard Material.
  31709. * @param configuration
  31710. */
  31711. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31712. /**
  31713. * Gets wether the color curves effect is enabled.
  31714. */
  31715. get cameraColorCurvesEnabled(): boolean;
  31716. /**
  31717. * Sets wether the color curves effect is enabled.
  31718. */
  31719. set cameraColorCurvesEnabled(value: boolean);
  31720. /**
  31721. * Gets wether the color grading effect is enabled.
  31722. */
  31723. get cameraColorGradingEnabled(): boolean;
  31724. /**
  31725. * Gets wether the color grading effect is enabled.
  31726. */
  31727. set cameraColorGradingEnabled(value: boolean);
  31728. /**
  31729. * Gets wether tonemapping is enabled or not.
  31730. */
  31731. get cameraToneMappingEnabled(): boolean;
  31732. /**
  31733. * Sets wether tonemapping is enabled or not
  31734. */
  31735. set cameraToneMappingEnabled(value: boolean);
  31736. /**
  31737. * The camera exposure used on this material.
  31738. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31739. * This corresponds to a photographic exposure.
  31740. */
  31741. get cameraExposure(): number;
  31742. /**
  31743. * The camera exposure used on this material.
  31744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31745. * This corresponds to a photographic exposure.
  31746. */
  31747. set cameraExposure(value: number);
  31748. /**
  31749. * Gets The camera contrast used on this material.
  31750. */
  31751. get cameraContrast(): number;
  31752. /**
  31753. * Sets The camera contrast used on this material.
  31754. */
  31755. set cameraContrast(value: number);
  31756. /**
  31757. * Gets the Color Grading 2D Lookup Texture.
  31758. */
  31759. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31760. /**
  31761. * Sets the Color Grading 2D Lookup Texture.
  31762. */
  31763. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31764. /**
  31765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31767. * 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;
  31768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31769. */
  31770. get cameraColorCurves(): Nullable<ColorCurves>;
  31771. /**
  31772. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31773. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31774. * 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;
  31775. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31776. */
  31777. set cameraColorCurves(value: Nullable<ColorCurves>);
  31778. /**
  31779. * Can this material render to several textures at once
  31780. */
  31781. get canRenderToMRT(): boolean;
  31782. /**
  31783. * Defines the detail map parameters for the material.
  31784. */
  31785. readonly detailMap: DetailMapConfiguration;
  31786. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31787. protected _worldViewProjectionMatrix: Matrix;
  31788. protected _globalAmbientColor: Color3;
  31789. protected _useLogarithmicDepth: boolean;
  31790. protected _rebuildInParallel: boolean;
  31791. /**
  31792. * Instantiates a new standard material.
  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. * @param name Define the name of the material in the scene
  31797. * @param scene Define the scene the material belong to
  31798. */
  31799. constructor(name: string, scene: Scene);
  31800. /**
  31801. * Gets a boolean indicating that current material needs to register RTT
  31802. */
  31803. get hasRenderTargetTextures(): boolean;
  31804. /**
  31805. * Gets the current class name of the material e.g. "StandardMaterial"
  31806. * Mainly use in serialization.
  31807. * @returns the class name
  31808. */
  31809. getClassName(): string;
  31810. /**
  31811. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31812. * You can try switching to logarithmic depth.
  31813. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31814. */
  31815. get useLogarithmicDepth(): boolean;
  31816. set useLogarithmicDepth(value: boolean);
  31817. /**
  31818. * Specifies if the material will require alpha blending
  31819. * @returns a boolean specifying if alpha blending is needed
  31820. */
  31821. needAlphaBlending(): boolean;
  31822. /**
  31823. * Specifies if this material should be rendered in alpha test mode
  31824. * @returns a boolean specifying if an alpha test is needed.
  31825. */
  31826. needAlphaTesting(): boolean;
  31827. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31828. /**
  31829. * Get the texture used for alpha test purpose.
  31830. * @returns the diffuse texture in case of the standard material.
  31831. */
  31832. getAlphaTestTexture(): Nullable<BaseTexture>;
  31833. /**
  31834. * Get if the submesh is ready to be used and all its information available.
  31835. * Child classes can use it to update shaders
  31836. * @param mesh defines the mesh to check
  31837. * @param subMesh defines which submesh to check
  31838. * @param useInstances specifies that instances should be used
  31839. * @returns a boolean indicating that the submesh is ready or not
  31840. */
  31841. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31842. /**
  31843. * Builds the material UBO layouts.
  31844. * Used internally during the effect preparation.
  31845. */
  31846. buildUniformLayout(): void;
  31847. /**
  31848. * Unbinds the material from the mesh
  31849. */
  31850. unbind(): void;
  31851. /**
  31852. * Binds the submesh to this material by preparing the effect and shader to draw
  31853. * @param world defines the world transformation matrix
  31854. * @param mesh defines the mesh containing the submesh
  31855. * @param subMesh defines the submesh to bind the material to
  31856. */
  31857. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31858. /**
  31859. * Get the list of animatables in the material.
  31860. * @returns the list of animatables object used in the material
  31861. */
  31862. getAnimatables(): IAnimatable[];
  31863. /**
  31864. * Gets the active textures from the material
  31865. * @returns an array of textures
  31866. */
  31867. getActiveTextures(): BaseTexture[];
  31868. /**
  31869. * Specifies if the material uses a texture
  31870. * @param texture defines the texture to check against the material
  31871. * @returns a boolean specifying if the material uses the texture
  31872. */
  31873. hasTexture(texture: BaseTexture): boolean;
  31874. /**
  31875. * Disposes the material
  31876. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31877. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31878. */
  31879. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31880. /**
  31881. * Makes a duplicate of the material, and gives it a new name
  31882. * @param name defines the new name for the duplicated material
  31883. * @returns the cloned material
  31884. */
  31885. clone(name: string): StandardMaterial;
  31886. /**
  31887. * Serializes this material in a JSON representation
  31888. * @returns the serialized material object
  31889. */
  31890. serialize(): any;
  31891. /**
  31892. * Creates a standard material from parsed material data
  31893. * @param source defines the JSON representation of the material
  31894. * @param scene defines the hosting scene
  31895. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31896. * @returns a new standard material
  31897. */
  31898. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31899. /**
  31900. * Are diffuse textures enabled in the application.
  31901. */
  31902. static get DiffuseTextureEnabled(): boolean;
  31903. static set DiffuseTextureEnabled(value: boolean);
  31904. /**
  31905. * Are detail textures enabled in the application.
  31906. */
  31907. static get DetailTextureEnabled(): boolean;
  31908. static set DetailTextureEnabled(value: boolean);
  31909. /**
  31910. * Are ambient textures enabled in the application.
  31911. */
  31912. static get AmbientTextureEnabled(): boolean;
  31913. static set AmbientTextureEnabled(value: boolean);
  31914. /**
  31915. * Are opacity textures enabled in the application.
  31916. */
  31917. static get OpacityTextureEnabled(): boolean;
  31918. static set OpacityTextureEnabled(value: boolean);
  31919. /**
  31920. * Are reflection textures enabled in the application.
  31921. */
  31922. static get ReflectionTextureEnabled(): boolean;
  31923. static set ReflectionTextureEnabled(value: boolean);
  31924. /**
  31925. * Are emissive textures enabled in the application.
  31926. */
  31927. static get EmissiveTextureEnabled(): boolean;
  31928. static set EmissiveTextureEnabled(value: boolean);
  31929. /**
  31930. * Are specular textures enabled in the application.
  31931. */
  31932. static get SpecularTextureEnabled(): boolean;
  31933. static set SpecularTextureEnabled(value: boolean);
  31934. /**
  31935. * Are bump textures enabled in the application.
  31936. */
  31937. static get BumpTextureEnabled(): boolean;
  31938. static set BumpTextureEnabled(value: boolean);
  31939. /**
  31940. * Are lightmap textures enabled in the application.
  31941. */
  31942. static get LightmapTextureEnabled(): boolean;
  31943. static set LightmapTextureEnabled(value: boolean);
  31944. /**
  31945. * Are refraction textures enabled in the application.
  31946. */
  31947. static get RefractionTextureEnabled(): boolean;
  31948. static set RefractionTextureEnabled(value: boolean);
  31949. /**
  31950. * Are color grading textures enabled in the application.
  31951. */
  31952. static get ColorGradingTextureEnabled(): boolean;
  31953. static set ColorGradingTextureEnabled(value: boolean);
  31954. /**
  31955. * Are fresnels enabled in the application.
  31956. */
  31957. static get FresnelEnabled(): boolean;
  31958. static set FresnelEnabled(value: boolean);
  31959. }
  31960. }
  31961. declare module "babylonjs/Particles/solidParticleSystem" {
  31962. import { Nullable } from "babylonjs/types";
  31963. import { Mesh } from "babylonjs/Meshes/mesh";
  31964. import { Scene, IDisposable } from "babylonjs/scene";
  31965. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31966. import { Material } from "babylonjs/Materials/material";
  31967. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31968. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31969. /**
  31970. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31971. *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.
  31972. * The SPS is also a particle system. It provides some methods to manage the particles.
  31973. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31974. *
  31975. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31976. */
  31977. export class SolidParticleSystem implements IDisposable {
  31978. /**
  31979. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31980. * Example : var p = SPS.particles[i];
  31981. */
  31982. particles: SolidParticle[];
  31983. /**
  31984. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31985. */
  31986. nbParticles: number;
  31987. /**
  31988. * If the particles must ever face the camera (default false). Useful for planar particles.
  31989. */
  31990. billboard: boolean;
  31991. /**
  31992. * Recompute normals when adding a shape
  31993. */
  31994. recomputeNormals: boolean;
  31995. /**
  31996. * This a counter ofr your own usage. It's not set by any SPS functions.
  31997. */
  31998. counter: number;
  31999. /**
  32000. * The SPS name. This name is also given to the underlying mesh.
  32001. */
  32002. name: string;
  32003. /**
  32004. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32005. */
  32006. mesh: Mesh;
  32007. /**
  32008. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32009. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32010. */
  32011. vars: any;
  32012. /**
  32013. * This array is populated when the SPS is set as 'pickable'.
  32014. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32015. * Each element of this array is an object `{idx: int, faceId: int}`.
  32016. * `idx` is the picked particle index in the `SPS.particles` array
  32017. * `faceId` is the picked face index counted within this particle.
  32018. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32019. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32020. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32021. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32022. */
  32023. pickedParticles: {
  32024. idx: number;
  32025. faceId: number;
  32026. }[];
  32027. /**
  32028. * This array is populated when the SPS is set as 'pickable'
  32029. * Each key of this array is a submesh index.
  32030. * Each element of this array is a second array defined like this :
  32031. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32032. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32033. * `idx` is the picked particle index in the `SPS.particles` array
  32034. * `faceId` is the picked face index counted within this particle.
  32035. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32036. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32037. */
  32038. pickedBySubMesh: {
  32039. idx: number;
  32040. faceId: number;
  32041. }[][];
  32042. /**
  32043. * This array is populated when `enableDepthSort` is set to true.
  32044. * Each element of this array is an instance of the class DepthSortedParticle.
  32045. */
  32046. depthSortedParticles: DepthSortedParticle[];
  32047. /**
  32048. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32049. * @hidden
  32050. */
  32051. _bSphereOnly: boolean;
  32052. /**
  32053. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32054. * @hidden
  32055. */
  32056. _bSphereRadiusFactor: number;
  32057. private _scene;
  32058. private _positions;
  32059. private _indices;
  32060. private _normals;
  32061. private _colors;
  32062. private _uvs;
  32063. private _indices32;
  32064. private _positions32;
  32065. private _normals32;
  32066. private _fixedNormal32;
  32067. private _colors32;
  32068. private _uvs32;
  32069. private _index;
  32070. private _updatable;
  32071. private _pickable;
  32072. private _isVisibilityBoxLocked;
  32073. private _alwaysVisible;
  32074. private _depthSort;
  32075. private _expandable;
  32076. private _shapeCounter;
  32077. private _copy;
  32078. private _color;
  32079. private _computeParticleColor;
  32080. private _computeParticleTexture;
  32081. private _computeParticleRotation;
  32082. private _computeParticleVertex;
  32083. private _computeBoundingBox;
  32084. private _depthSortParticles;
  32085. private _camera;
  32086. private _mustUnrotateFixedNormals;
  32087. private _particlesIntersect;
  32088. private _needs32Bits;
  32089. private _isNotBuilt;
  32090. private _lastParticleId;
  32091. private _idxOfId;
  32092. private _multimaterialEnabled;
  32093. private _useModelMaterial;
  32094. private _indicesByMaterial;
  32095. private _materialIndexes;
  32096. private _depthSortFunction;
  32097. private _materialSortFunction;
  32098. private _materials;
  32099. private _multimaterial;
  32100. private _materialIndexesById;
  32101. private _defaultMaterial;
  32102. private _autoUpdateSubMeshes;
  32103. private _tmpVertex;
  32104. /**
  32105. * Creates a SPS (Solid Particle System) object.
  32106. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32107. * @param scene (Scene) is the scene in which the SPS is added.
  32108. * @param options defines the options of the sps e.g.
  32109. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32110. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32111. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32112. * * 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.
  32113. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32114. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32115. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32116. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32117. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32118. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32119. */
  32120. constructor(name: string, scene: Scene, options?: {
  32121. updatable?: boolean;
  32122. isPickable?: boolean;
  32123. enableDepthSort?: boolean;
  32124. particleIntersection?: boolean;
  32125. boundingSphereOnly?: boolean;
  32126. bSphereRadiusFactor?: number;
  32127. expandable?: boolean;
  32128. useModelMaterial?: boolean;
  32129. enableMultiMaterial?: boolean;
  32130. });
  32131. /**
  32132. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32133. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32134. * @returns the created mesh
  32135. */
  32136. buildMesh(): Mesh;
  32137. /**
  32138. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32139. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32140. * Thus the particles generated from `digest()` have their property `position` set yet.
  32141. * @param mesh ( Mesh ) is the mesh to be digested
  32142. * @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
  32143. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32144. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32145. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32146. * @returns the current SPS
  32147. */
  32148. digest(mesh: Mesh, options?: {
  32149. facetNb?: number;
  32150. number?: number;
  32151. delta?: number;
  32152. storage?: [];
  32153. }): SolidParticleSystem;
  32154. /**
  32155. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32156. * @hidden
  32157. */
  32158. private _unrotateFixedNormals;
  32159. /**
  32160. * Resets the temporary working copy particle
  32161. * @hidden
  32162. */
  32163. private _resetCopy;
  32164. /**
  32165. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32166. * @param p the current index in the positions array to be updated
  32167. * @param ind the current index in the indices array
  32168. * @param shape a Vector3 array, the shape geometry
  32169. * @param positions the positions array to be updated
  32170. * @param meshInd the shape indices array
  32171. * @param indices the indices array to be updated
  32172. * @param meshUV the shape uv array
  32173. * @param uvs the uv array to be updated
  32174. * @param meshCol the shape color array
  32175. * @param colors the color array to be updated
  32176. * @param meshNor the shape normals array
  32177. * @param normals the normals array to be updated
  32178. * @param idx the particle index
  32179. * @param idxInShape the particle index in its shape
  32180. * @param options the addShape() method passed options
  32181. * @model the particle model
  32182. * @hidden
  32183. */
  32184. private _meshBuilder;
  32185. /**
  32186. * Returns a shape Vector3 array from positions float array
  32187. * @param positions float array
  32188. * @returns a vector3 array
  32189. * @hidden
  32190. */
  32191. private _posToShape;
  32192. /**
  32193. * Returns a shapeUV array from a float uvs (array deep copy)
  32194. * @param uvs as a float array
  32195. * @returns a shapeUV array
  32196. * @hidden
  32197. */
  32198. private _uvsToShapeUV;
  32199. /**
  32200. * Adds a new particle object in the particles array
  32201. * @param idx particle index in particles array
  32202. * @param id particle id
  32203. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32204. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32205. * @param model particle ModelShape object
  32206. * @param shapeId model shape identifier
  32207. * @param idxInShape index of the particle in the current model
  32208. * @param bInfo model bounding info object
  32209. * @param storage target storage array, if any
  32210. * @hidden
  32211. */
  32212. private _addParticle;
  32213. /**
  32214. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32215. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32216. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32217. * @param nb (positive integer) the number of particles to be created from this model
  32218. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32219. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32220. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32221. * @returns the number of shapes in the system
  32222. */
  32223. addShape(mesh: Mesh, nb: number, options?: {
  32224. positionFunction?: any;
  32225. vertexFunction?: any;
  32226. storage?: [];
  32227. }): number;
  32228. /**
  32229. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32230. * @hidden
  32231. */
  32232. private _rebuildParticle;
  32233. /**
  32234. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32235. * @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.
  32236. * @returns the SPS.
  32237. */
  32238. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32239. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32240. * Returns an array with the removed particles.
  32241. * 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.
  32242. * The SPS can't be empty so at least one particle needs to remain in place.
  32243. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32244. * @param start index of the first particle to remove
  32245. * @param end index of the last particle to remove (included)
  32246. * @returns an array populated with the removed particles
  32247. */
  32248. removeParticles(start: number, end: number): SolidParticle[];
  32249. /**
  32250. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32251. * @param solidParticleArray an array populated with Solid Particles objects
  32252. * @returns the SPS
  32253. */
  32254. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32255. /**
  32256. * Creates a new particle and modifies the SPS mesh geometry :
  32257. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32258. * - calls _addParticle() to populate the particle array
  32259. * factorized code from addShape() and insertParticlesFromArray()
  32260. * @param idx particle index in the particles array
  32261. * @param i particle index in its shape
  32262. * @param modelShape particle ModelShape object
  32263. * @param shape shape vertex array
  32264. * @param meshInd shape indices array
  32265. * @param meshUV shape uv array
  32266. * @param meshCol shape color array
  32267. * @param meshNor shape normals array
  32268. * @param bbInfo shape bounding info
  32269. * @param storage target particle storage
  32270. * @options addShape() passed options
  32271. * @hidden
  32272. */
  32273. private _insertNewParticle;
  32274. /**
  32275. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32276. * This method calls `updateParticle()` for each particle of the SPS.
  32277. * For an animated SPS, it is usually called within the render loop.
  32278. * 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.
  32279. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32280. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32281. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32282. * @returns the SPS.
  32283. */
  32284. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32285. /**
  32286. * Disposes the SPS.
  32287. */
  32288. dispose(): void;
  32289. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32290. * idx is the particle index in the SPS
  32291. * faceId is the picked face index counted within this particle.
  32292. * Returns null if the pickInfo can't identify a picked particle.
  32293. * @param pickingInfo (PickingInfo object)
  32294. * @returns {idx: number, faceId: number} or null
  32295. */
  32296. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32297. idx: number;
  32298. faceId: number;
  32299. }>;
  32300. /**
  32301. * Returns a SolidParticle object from its identifier : particle.id
  32302. * @param id (integer) the particle Id
  32303. * @returns the searched particle or null if not found in the SPS.
  32304. */
  32305. getParticleById(id: number): Nullable<SolidParticle>;
  32306. /**
  32307. * Returns a new array populated with the particles having the passed shapeId.
  32308. * @param shapeId (integer) the shape identifier
  32309. * @returns a new solid particle array
  32310. */
  32311. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32312. /**
  32313. * Populates the passed array "ref" with the particles having the passed shapeId.
  32314. * @param shapeId the shape identifier
  32315. * @returns the SPS
  32316. * @param ref
  32317. */
  32318. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32319. /**
  32320. * Computes the required SubMeshes according the materials assigned to the particles.
  32321. * @returns the solid particle system.
  32322. * Does nothing if called before the SPS mesh is built.
  32323. */
  32324. computeSubMeshes(): SolidParticleSystem;
  32325. /**
  32326. * Sorts the solid particles by material when MultiMaterial is enabled.
  32327. * Updates the indices32 array.
  32328. * Updates the indicesByMaterial array.
  32329. * Updates the mesh indices array.
  32330. * @returns the SPS
  32331. * @hidden
  32332. */
  32333. private _sortParticlesByMaterial;
  32334. /**
  32335. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32336. * @hidden
  32337. */
  32338. private _setMaterialIndexesById;
  32339. /**
  32340. * Returns an array with unique values of Materials from the passed array
  32341. * @param array the material array to be checked and filtered
  32342. * @hidden
  32343. */
  32344. private _filterUniqueMaterialId;
  32345. /**
  32346. * Sets a new Standard Material as _defaultMaterial if not already set.
  32347. * @hidden
  32348. */
  32349. private _setDefaultMaterial;
  32350. /**
  32351. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32352. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32353. * @returns the SPS.
  32354. */
  32355. refreshVisibleSize(): SolidParticleSystem;
  32356. /**
  32357. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32358. * @param size the size (float) of the visibility box
  32359. * note : this doesn't lock the SPS mesh bounding box.
  32360. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32361. */
  32362. setVisibilityBox(size: number): void;
  32363. /**
  32364. * Gets whether the SPS as always visible or not
  32365. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32366. */
  32367. get isAlwaysVisible(): boolean;
  32368. /**
  32369. * Sets the SPS as always visible or not
  32370. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32371. */
  32372. set isAlwaysVisible(val: boolean);
  32373. /**
  32374. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32375. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32376. */
  32377. set isVisibilityBoxLocked(val: boolean);
  32378. /**
  32379. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32380. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32381. */
  32382. get isVisibilityBoxLocked(): boolean;
  32383. /**
  32384. * Tells to `setParticles()` to compute the particle rotations or not.
  32385. * Default value : true. The SPS is faster when it's set to false.
  32386. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32387. */
  32388. set computeParticleRotation(val: boolean);
  32389. /**
  32390. * Tells to `setParticles()` to compute the particle colors or not.
  32391. * Default value : true. The SPS is faster when it's set to false.
  32392. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32393. */
  32394. set computeParticleColor(val: boolean);
  32395. set computeParticleTexture(val: boolean);
  32396. /**
  32397. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32398. * Default value : false. The SPS is faster when it's set to false.
  32399. * Note : the particle custom vertex positions aren't stored values.
  32400. */
  32401. set computeParticleVertex(val: boolean);
  32402. /**
  32403. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32404. */
  32405. set computeBoundingBox(val: boolean);
  32406. /**
  32407. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32408. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32409. * Default : `true`
  32410. */
  32411. set depthSortParticles(val: boolean);
  32412. /**
  32413. * Gets if `setParticles()` computes the particle rotations or not.
  32414. * Default value : true. The SPS is faster when it's set to false.
  32415. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32416. */
  32417. get computeParticleRotation(): boolean;
  32418. /**
  32419. * Gets if `setParticles()` computes the particle colors or not.
  32420. * Default value : true. The SPS is faster when it's set to false.
  32421. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32422. */
  32423. get computeParticleColor(): boolean;
  32424. /**
  32425. * Gets if `setParticles()` computes the particle textures or not.
  32426. * Default value : true. The SPS is faster when it's set to false.
  32427. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32428. */
  32429. get computeParticleTexture(): boolean;
  32430. /**
  32431. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32432. * Default value : false. The SPS is faster when it's set to false.
  32433. * Note : the particle custom vertex positions aren't stored values.
  32434. */
  32435. get computeParticleVertex(): boolean;
  32436. /**
  32437. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32438. */
  32439. get computeBoundingBox(): boolean;
  32440. /**
  32441. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32442. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32443. * Default : `true`
  32444. */
  32445. get depthSortParticles(): boolean;
  32446. /**
  32447. * Gets if the SPS is created as expandable at construction time.
  32448. * Default : `false`
  32449. */
  32450. get expandable(): boolean;
  32451. /**
  32452. * Gets if the SPS supports the Multi Materials
  32453. */
  32454. get multimaterialEnabled(): boolean;
  32455. /**
  32456. * Gets if the SPS uses the model materials for its own multimaterial.
  32457. */
  32458. get useModelMaterial(): boolean;
  32459. /**
  32460. * The SPS used material array.
  32461. */
  32462. get materials(): Material[];
  32463. /**
  32464. * Sets the SPS MultiMaterial from the passed materials.
  32465. * Note : the passed array is internally copied and not used then by reference.
  32466. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32467. */
  32468. setMultiMaterial(materials: Material[]): void;
  32469. /**
  32470. * The SPS computed multimaterial object
  32471. */
  32472. get multimaterial(): MultiMaterial;
  32473. set multimaterial(mm: MultiMaterial);
  32474. /**
  32475. * If the subMeshes must be updated on the next call to setParticles()
  32476. */
  32477. get autoUpdateSubMeshes(): boolean;
  32478. set autoUpdateSubMeshes(val: boolean);
  32479. /**
  32480. * This function does nothing. It may be overwritten to set all the particle first values.
  32481. * The SPS doesn't call this function, you may have to call it by your own.
  32482. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32483. */
  32484. initParticles(): void;
  32485. /**
  32486. * This function does nothing. It may be overwritten to recycle a particle.
  32487. * The SPS doesn't call this function, you may have to call it by your own.
  32488. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32489. * @param particle The particle to recycle
  32490. * @returns the recycled particle
  32491. */
  32492. recycleParticle(particle: SolidParticle): SolidParticle;
  32493. /**
  32494. * Updates a particle : this function should be overwritten by the user.
  32495. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32496. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32497. * @example : just set a particle position or velocity and recycle conditions
  32498. * @param particle The particle to update
  32499. * @returns the updated particle
  32500. */
  32501. updateParticle(particle: SolidParticle): SolidParticle;
  32502. /**
  32503. * Updates a vertex of a particle : it can be overwritten by the user.
  32504. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32505. * @param particle the current particle
  32506. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32507. * @param pt the index of the current vertex in the particle shape
  32508. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32509. * @example : just set a vertex particle position or color
  32510. * @returns the sps
  32511. */
  32512. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32513. /**
  32514. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32515. * This does nothing and may be overwritten by the user.
  32516. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32517. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32518. * @param update the boolean update value actually passed to setParticles()
  32519. */
  32520. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32521. /**
  32522. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32523. * This will be passed three parameters.
  32524. * This does nothing and may be overwritten by the user.
  32525. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32526. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32527. * @param update the boolean update value actually passed to setParticles()
  32528. */
  32529. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32530. }
  32531. }
  32532. declare module "babylonjs/Particles/solidParticle" {
  32533. import { Nullable } from "babylonjs/types";
  32534. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32535. import { Color4 } from "babylonjs/Maths/math.color";
  32536. import { Mesh } from "babylonjs/Meshes/mesh";
  32537. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32538. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32539. import { Plane } from "babylonjs/Maths/math.plane";
  32540. import { Material } from "babylonjs/Materials/material";
  32541. /**
  32542. * Represents one particle of a solid particle system.
  32543. */
  32544. export class SolidParticle {
  32545. /**
  32546. * particle global index
  32547. */
  32548. idx: number;
  32549. /**
  32550. * particle identifier
  32551. */
  32552. id: number;
  32553. /**
  32554. * The color of the particle
  32555. */
  32556. color: Nullable<Color4>;
  32557. /**
  32558. * The world space position of the particle.
  32559. */
  32560. position: Vector3;
  32561. /**
  32562. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32563. */
  32564. rotation: Vector3;
  32565. /**
  32566. * The world space rotation quaternion of the particle.
  32567. */
  32568. rotationQuaternion: Nullable<Quaternion>;
  32569. /**
  32570. * The scaling of the particle.
  32571. */
  32572. scaling: Vector3;
  32573. /**
  32574. * The uvs of the particle.
  32575. */
  32576. uvs: Vector4;
  32577. /**
  32578. * The current speed of the particle.
  32579. */
  32580. velocity: Vector3;
  32581. /**
  32582. * The pivot point in the particle local space.
  32583. */
  32584. pivot: Vector3;
  32585. /**
  32586. * Must the particle be translated from its pivot point in its local space ?
  32587. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32588. * Default : false
  32589. */
  32590. translateFromPivot: boolean;
  32591. /**
  32592. * Is the particle active or not ?
  32593. */
  32594. alive: boolean;
  32595. /**
  32596. * Is the particle visible or not ?
  32597. */
  32598. isVisible: boolean;
  32599. /**
  32600. * Index of this particle in the global "positions" array (Internal use)
  32601. * @hidden
  32602. */
  32603. _pos: number;
  32604. /**
  32605. * @hidden Index of this particle in the global "indices" array (Internal use)
  32606. */
  32607. _ind: number;
  32608. /**
  32609. * @hidden ModelShape of this particle (Internal use)
  32610. */
  32611. _model: ModelShape;
  32612. /**
  32613. * ModelShape id of this particle
  32614. */
  32615. shapeId: number;
  32616. /**
  32617. * Index of the particle in its shape id
  32618. */
  32619. idxInShape: number;
  32620. /**
  32621. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32622. */
  32623. _modelBoundingInfo: BoundingInfo;
  32624. /**
  32625. * @hidden Particle BoundingInfo object (Internal use)
  32626. */
  32627. _boundingInfo: BoundingInfo;
  32628. /**
  32629. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32630. */
  32631. _sps: SolidParticleSystem;
  32632. /**
  32633. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32634. */
  32635. _stillInvisible: boolean;
  32636. /**
  32637. * @hidden Last computed particle rotation matrix
  32638. */
  32639. _rotationMatrix: number[];
  32640. /**
  32641. * Parent particle Id, if any.
  32642. * Default null.
  32643. */
  32644. parentId: Nullable<number>;
  32645. /**
  32646. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32647. */
  32648. materialIndex: Nullable<number>;
  32649. /**
  32650. * Custom object or properties.
  32651. */
  32652. props: Nullable<any>;
  32653. /**
  32654. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32655. * The possible values are :
  32656. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32657. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32658. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32659. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32660. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32661. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32662. * */
  32663. cullingStrategy: number;
  32664. /**
  32665. * @hidden Internal global position in the SPS.
  32666. */
  32667. _globalPosition: Vector3;
  32668. /**
  32669. * Creates a Solid Particle object.
  32670. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32671. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32672. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32673. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32674. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32675. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32676. * @param shapeId (integer) is the model shape identifier in the SPS.
  32677. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32678. * @param sps defines the sps it is associated to
  32679. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32680. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32681. */
  32682. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32683. /**
  32684. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32685. * @param target the particle target
  32686. * @returns the current particle
  32687. */
  32688. copyToRef(target: SolidParticle): SolidParticle;
  32689. /**
  32690. * Legacy support, changed scale to scaling
  32691. */
  32692. get scale(): Vector3;
  32693. /**
  32694. * Legacy support, changed scale to scaling
  32695. */
  32696. set scale(scale: Vector3);
  32697. /**
  32698. * Legacy support, changed quaternion to rotationQuaternion
  32699. */
  32700. get quaternion(): Nullable<Quaternion>;
  32701. /**
  32702. * Legacy support, changed quaternion to rotationQuaternion
  32703. */
  32704. set quaternion(q: Nullable<Quaternion>);
  32705. /**
  32706. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32707. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32708. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32709. * @returns true if it intersects
  32710. */
  32711. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32712. /**
  32713. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32714. * A particle is in the frustum if its bounding box intersects the frustum
  32715. * @param frustumPlanes defines the frustum to test
  32716. * @returns true if the particle is in the frustum planes
  32717. */
  32718. isInFrustum(frustumPlanes: Plane[]): boolean;
  32719. /**
  32720. * get the rotation matrix of the particle
  32721. * @hidden
  32722. */
  32723. getRotationMatrix(m: Matrix): void;
  32724. }
  32725. /**
  32726. * Represents the shape of the model used by one particle of a solid particle system.
  32727. * SPS internal tool, don't use it manually.
  32728. */
  32729. export class ModelShape {
  32730. /**
  32731. * The shape id
  32732. * @hidden
  32733. */
  32734. shapeID: number;
  32735. /**
  32736. * flat array of model positions (internal use)
  32737. * @hidden
  32738. */
  32739. _shape: Vector3[];
  32740. /**
  32741. * flat array of model UVs (internal use)
  32742. * @hidden
  32743. */
  32744. _shapeUV: number[];
  32745. /**
  32746. * color array of the model
  32747. * @hidden
  32748. */
  32749. _shapeColors: number[];
  32750. /**
  32751. * indices array of the model
  32752. * @hidden
  32753. */
  32754. _indices: number[];
  32755. /**
  32756. * normals array of the model
  32757. * @hidden
  32758. */
  32759. _normals: number[];
  32760. /**
  32761. * length of the shape in the model indices array (internal use)
  32762. * @hidden
  32763. */
  32764. _indicesLength: number;
  32765. /**
  32766. * Custom position function (internal use)
  32767. * @hidden
  32768. */
  32769. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32770. /**
  32771. * Custom vertex function (internal use)
  32772. * @hidden
  32773. */
  32774. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32775. /**
  32776. * Model material (internal use)
  32777. * @hidden
  32778. */
  32779. _material: Nullable<Material>;
  32780. /**
  32781. * 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.
  32782. * SPS internal tool, don't use it manually.
  32783. * @hidden
  32784. */
  32785. 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>);
  32786. }
  32787. /**
  32788. * Represents a Depth Sorted Particle in the solid particle system.
  32789. * @hidden
  32790. */
  32791. export class DepthSortedParticle {
  32792. /**
  32793. * Particle index
  32794. */
  32795. idx: number;
  32796. /**
  32797. * Index of the particle in the "indices" array
  32798. */
  32799. ind: number;
  32800. /**
  32801. * Length of the particle shape in the "indices" array
  32802. */
  32803. indicesLength: number;
  32804. /**
  32805. * Squared distance from the particle to the camera
  32806. */
  32807. sqDistance: number;
  32808. /**
  32809. * Material index when used with MultiMaterials
  32810. */
  32811. materialIndex: number;
  32812. /**
  32813. * Creates a new sorted particle
  32814. * @param materialIndex
  32815. */
  32816. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32817. }
  32818. /**
  32819. * Represents a solid particle vertex
  32820. */
  32821. export class SolidParticleVertex {
  32822. /**
  32823. * Vertex position
  32824. */
  32825. position: Vector3;
  32826. /**
  32827. * Vertex color
  32828. */
  32829. color: Color4;
  32830. /**
  32831. * Vertex UV
  32832. */
  32833. uv: Vector2;
  32834. /**
  32835. * Creates a new solid particle vertex
  32836. */
  32837. constructor();
  32838. /** Vertex x coordinate */
  32839. get x(): number;
  32840. set x(val: number);
  32841. /** Vertex y coordinate */
  32842. get y(): number;
  32843. set y(val: number);
  32844. /** Vertex z coordinate */
  32845. get z(): number;
  32846. set z(val: number);
  32847. }
  32848. }
  32849. declare module "babylonjs/Collisions/meshCollisionData" {
  32850. import { Collider } from "babylonjs/Collisions/collider";
  32851. import { Vector3 } from "babylonjs/Maths/math.vector";
  32852. import { Nullable } from "babylonjs/types";
  32853. import { Observer } from "babylonjs/Misc/observable";
  32854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32855. /**
  32856. * @hidden
  32857. */
  32858. export class _MeshCollisionData {
  32859. _checkCollisions: boolean;
  32860. _collisionMask: number;
  32861. _collisionGroup: number;
  32862. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32863. _collider: Nullable<Collider>;
  32864. _oldPositionForCollisions: Vector3;
  32865. _diffPositionForCollisions: Vector3;
  32866. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32867. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32868. }
  32869. }
  32870. declare module "babylonjs/Meshes/abstractMesh" {
  32871. import { Observable } from "babylonjs/Misc/observable";
  32872. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32873. import { Camera } from "babylonjs/Cameras/camera";
  32874. import { Scene, IDisposable } from "babylonjs/scene";
  32875. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32876. import { Node } from "babylonjs/node";
  32877. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32879. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32880. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32881. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32882. import { Material } from "babylonjs/Materials/material";
  32883. import { Light } from "babylonjs/Lights/light";
  32884. import { Skeleton } from "babylonjs/Bones/skeleton";
  32885. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32886. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32887. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32888. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32889. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32890. import { Plane } from "babylonjs/Maths/math.plane";
  32891. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32892. import { Ray } from "babylonjs/Culling/ray";
  32893. import { Collider } from "babylonjs/Collisions/collider";
  32894. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32895. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32896. /** @hidden */
  32897. class _FacetDataStorage {
  32898. facetPositions: Vector3[];
  32899. facetNormals: Vector3[];
  32900. facetPartitioning: number[][];
  32901. facetNb: number;
  32902. partitioningSubdivisions: number;
  32903. partitioningBBoxRatio: number;
  32904. facetDataEnabled: boolean;
  32905. facetParameters: any;
  32906. bbSize: Vector3;
  32907. subDiv: {
  32908. max: number;
  32909. X: number;
  32910. Y: number;
  32911. Z: number;
  32912. };
  32913. facetDepthSort: boolean;
  32914. facetDepthSortEnabled: boolean;
  32915. depthSortedIndices: IndicesArray;
  32916. depthSortedFacets: {
  32917. ind: number;
  32918. sqDistance: number;
  32919. }[];
  32920. facetDepthSortFunction: (f1: {
  32921. ind: number;
  32922. sqDistance: number;
  32923. }, f2: {
  32924. ind: number;
  32925. sqDistance: number;
  32926. }) => number;
  32927. facetDepthSortFrom: Vector3;
  32928. facetDepthSortOrigin: Vector3;
  32929. invertedMatrix: Matrix;
  32930. }
  32931. /**
  32932. * @hidden
  32933. **/
  32934. class _InternalAbstractMeshDataInfo {
  32935. _hasVertexAlpha: boolean;
  32936. _useVertexColors: boolean;
  32937. _numBoneInfluencers: number;
  32938. _applyFog: boolean;
  32939. _receiveShadows: boolean;
  32940. _facetData: _FacetDataStorage;
  32941. _visibility: number;
  32942. _skeleton: Nullable<Skeleton>;
  32943. _layerMask: number;
  32944. _computeBonesUsingShaders: boolean;
  32945. _isActive: boolean;
  32946. _onlyForInstances: boolean;
  32947. _isActiveIntermediate: boolean;
  32948. _onlyForInstancesIntermediate: boolean;
  32949. _actAsRegularMesh: boolean;
  32950. }
  32951. /**
  32952. * Class used to store all common mesh properties
  32953. */
  32954. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32955. /** No occlusion */
  32956. static OCCLUSION_TYPE_NONE: number;
  32957. /** Occlusion set to optimisitic */
  32958. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32959. /** Occlusion set to strict */
  32960. static OCCLUSION_TYPE_STRICT: number;
  32961. /** Use an accurante occlusion algorithm */
  32962. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32963. /** Use a conservative occlusion algorithm */
  32964. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32965. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32966. * Test order :
  32967. * Is the bounding sphere outside the frustum ?
  32968. * If not, are the bounding box vertices outside the frustum ?
  32969. * It not, then the cullable object is in the frustum.
  32970. */
  32971. static readonly CULLINGSTRATEGY_STANDARD: number;
  32972. /** Culling strategy : Bounding Sphere Only.
  32973. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32974. * It's also less accurate than the standard because some not visible objects can still be selected.
  32975. * Test : is the bounding sphere outside the frustum ?
  32976. * If not, then the cullable object is in the frustum.
  32977. */
  32978. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32979. /** Culling strategy : Optimistic Inclusion.
  32980. * This in an inclusion test first, then the standard exclusion test.
  32981. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32982. * 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.
  32983. * Anyway, it's as accurate as the standard strategy.
  32984. * Test :
  32985. * Is the cullable object bounding sphere center in the frustum ?
  32986. * If not, apply the default culling strategy.
  32987. */
  32988. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32989. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32990. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32991. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32992. * 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.
  32993. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32994. * Test :
  32995. * Is the cullable object bounding sphere center in the frustum ?
  32996. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32997. */
  32998. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32999. /**
  33000. * No billboard
  33001. */
  33002. static get BILLBOARDMODE_NONE(): number;
  33003. /** Billboard on X axis */
  33004. static get BILLBOARDMODE_X(): number;
  33005. /** Billboard on Y axis */
  33006. static get BILLBOARDMODE_Y(): number;
  33007. /** Billboard on Z axis */
  33008. static get BILLBOARDMODE_Z(): number;
  33009. /** Billboard on all axes */
  33010. static get BILLBOARDMODE_ALL(): number;
  33011. /** Billboard on using position instead of orientation */
  33012. static get BILLBOARDMODE_USE_POSITION(): number;
  33013. /** @hidden */
  33014. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33015. /**
  33016. * The culling strategy to use to check whether the mesh must be rendered or not.
  33017. * This value can be changed at any time and will be used on the next render mesh selection.
  33018. * The possible values are :
  33019. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33020. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33021. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33022. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33023. * Please read each static variable documentation to get details about the culling process.
  33024. * */
  33025. cullingStrategy: number;
  33026. /**
  33027. * Gets the number of facets in the mesh
  33028. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33029. */
  33030. get facetNb(): number;
  33031. /**
  33032. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33033. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33034. */
  33035. get partitioningSubdivisions(): number;
  33036. set partitioningSubdivisions(nb: number);
  33037. /**
  33038. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33039. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33040. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33041. */
  33042. get partitioningBBoxRatio(): number;
  33043. set partitioningBBoxRatio(ratio: number);
  33044. /**
  33045. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33046. * Works only for updatable meshes.
  33047. * Doesn't work with multi-materials
  33048. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33049. */
  33050. get mustDepthSortFacets(): boolean;
  33051. set mustDepthSortFacets(sort: boolean);
  33052. /**
  33053. * The location (Vector3) where the facet depth sort must be computed from.
  33054. * By default, the active camera position.
  33055. * Used only when facet depth sort is enabled
  33056. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33057. */
  33058. get facetDepthSortFrom(): Vector3;
  33059. set facetDepthSortFrom(location: Vector3);
  33060. /**
  33061. * gets a boolean indicating if facetData is enabled
  33062. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33063. */
  33064. get isFacetDataEnabled(): boolean;
  33065. /** @hidden */
  33066. _updateNonUniformScalingState(value: boolean): boolean;
  33067. /**
  33068. * An event triggered when this mesh collides with another one
  33069. */
  33070. onCollideObservable: Observable<AbstractMesh>;
  33071. /** Set a function to call when this mesh collides with another one */
  33072. set onCollide(callback: () => void);
  33073. /**
  33074. * An event triggered when the collision's position changes
  33075. */
  33076. onCollisionPositionChangeObservable: Observable<Vector3>;
  33077. /** Set a function to call when the collision's position changes */
  33078. set onCollisionPositionChange(callback: () => void);
  33079. /**
  33080. * An event triggered when material is changed
  33081. */
  33082. onMaterialChangedObservable: Observable<AbstractMesh>;
  33083. /**
  33084. * Gets or sets the orientation for POV movement & rotation
  33085. */
  33086. definedFacingForward: boolean;
  33087. /** @hidden */
  33088. _occlusionQuery: Nullable<WebGLQuery>;
  33089. /** @hidden */
  33090. _renderingGroup: Nullable<RenderingGroup>;
  33091. /**
  33092. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33093. */
  33094. get visibility(): number;
  33095. /**
  33096. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33097. */
  33098. set visibility(value: number);
  33099. /** Gets or sets the alpha index used to sort transparent meshes
  33100. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33101. */
  33102. alphaIndex: number;
  33103. /**
  33104. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33105. */
  33106. isVisible: boolean;
  33107. /**
  33108. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33109. */
  33110. isPickable: boolean;
  33111. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33112. showSubMeshesBoundingBox: boolean;
  33113. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33114. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33115. */
  33116. isBlocker: boolean;
  33117. /**
  33118. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33119. */
  33120. enablePointerMoveEvents: boolean;
  33121. /**
  33122. * Specifies the rendering group id for this mesh (0 by default)
  33123. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33124. */
  33125. renderingGroupId: number;
  33126. private _material;
  33127. /** Gets or sets current material */
  33128. get material(): Nullable<Material>;
  33129. set material(value: Nullable<Material>);
  33130. /**
  33131. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33132. * @see https://doc.babylonjs.com/babylon101/shadows
  33133. */
  33134. get receiveShadows(): boolean;
  33135. set receiveShadows(value: boolean);
  33136. /** Defines color to use when rendering outline */
  33137. outlineColor: Color3;
  33138. /** Define width to use when rendering outline */
  33139. outlineWidth: number;
  33140. /** Defines color to use when rendering overlay */
  33141. overlayColor: Color3;
  33142. /** Defines alpha to use when rendering overlay */
  33143. overlayAlpha: number;
  33144. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33145. get hasVertexAlpha(): boolean;
  33146. set hasVertexAlpha(value: boolean);
  33147. /** 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) */
  33148. get useVertexColors(): boolean;
  33149. set useVertexColors(value: boolean);
  33150. /**
  33151. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33152. */
  33153. get computeBonesUsingShaders(): boolean;
  33154. set computeBonesUsingShaders(value: boolean);
  33155. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33156. get numBoneInfluencers(): number;
  33157. set numBoneInfluencers(value: number);
  33158. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33159. get applyFog(): boolean;
  33160. set applyFog(value: boolean);
  33161. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33162. useOctreeForRenderingSelection: boolean;
  33163. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33164. useOctreeForPicking: boolean;
  33165. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33166. useOctreeForCollisions: boolean;
  33167. /**
  33168. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33169. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33170. */
  33171. get layerMask(): number;
  33172. set layerMask(value: number);
  33173. /**
  33174. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33175. */
  33176. alwaysSelectAsActiveMesh: boolean;
  33177. /**
  33178. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33179. */
  33180. doNotSyncBoundingInfo: boolean;
  33181. /**
  33182. * Gets or sets the current action manager
  33183. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33184. */
  33185. actionManager: Nullable<AbstractActionManager>;
  33186. private _meshCollisionData;
  33187. /**
  33188. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33189. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33190. */
  33191. ellipsoid: Vector3;
  33192. /**
  33193. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33194. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33195. */
  33196. ellipsoidOffset: Vector3;
  33197. /**
  33198. * Gets or sets a collision mask used to mask collisions (default is -1).
  33199. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33200. */
  33201. get collisionMask(): number;
  33202. set collisionMask(mask: number);
  33203. /**
  33204. * Gets or sets the current collision group mask (-1 by default).
  33205. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33206. */
  33207. get collisionGroup(): number;
  33208. set collisionGroup(mask: number);
  33209. /**
  33210. * Gets or sets current surrounding meshes (null by default).
  33211. *
  33212. * By default collision detection is tested against every mesh in the scene.
  33213. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33214. * meshes will be tested for the collision.
  33215. *
  33216. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33217. */
  33218. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33219. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33220. /**
  33221. * Defines edge width used when edgesRenderer is enabled
  33222. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33223. */
  33224. edgesWidth: number;
  33225. /**
  33226. * Defines edge color used when edgesRenderer is enabled
  33227. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33228. */
  33229. edgesColor: Color4;
  33230. /** @hidden */
  33231. _edgesRenderer: Nullable<IEdgesRenderer>;
  33232. /** @hidden */
  33233. _masterMesh: Nullable<AbstractMesh>;
  33234. /** @hidden */
  33235. _boundingInfo: Nullable<BoundingInfo>;
  33236. /** @hidden */
  33237. _renderId: number;
  33238. /**
  33239. * Gets or sets the list of subMeshes
  33240. * @see https://doc.babylonjs.com/how_to/multi_materials
  33241. */
  33242. subMeshes: SubMesh[];
  33243. /** @hidden */
  33244. _intersectionsInProgress: AbstractMesh[];
  33245. /** @hidden */
  33246. _unIndexed: boolean;
  33247. /** @hidden */
  33248. _lightSources: Light[];
  33249. /** Gets the list of lights affecting that mesh */
  33250. get lightSources(): Light[];
  33251. /** @hidden */
  33252. get _positions(): Nullable<Vector3[]>;
  33253. /** @hidden */
  33254. _waitingData: {
  33255. lods: Nullable<any>;
  33256. actions: Nullable<any>;
  33257. freezeWorldMatrix: Nullable<boolean>;
  33258. };
  33259. /** @hidden */
  33260. _bonesTransformMatrices: Nullable<Float32Array>;
  33261. /** @hidden */
  33262. _transformMatrixTexture: Nullable<RawTexture>;
  33263. /**
  33264. * Gets or sets a skeleton to apply skining transformations
  33265. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33266. */
  33267. set skeleton(value: Nullable<Skeleton>);
  33268. get skeleton(): Nullable<Skeleton>;
  33269. /**
  33270. * An event triggered when the mesh is rebuilt.
  33271. */
  33272. onRebuildObservable: Observable<AbstractMesh>;
  33273. /**
  33274. * Creates a new AbstractMesh
  33275. * @param name defines the name of the mesh
  33276. * @param scene defines the hosting scene
  33277. */
  33278. constructor(name: string, scene?: Nullable<Scene>);
  33279. /**
  33280. * Returns the string "AbstractMesh"
  33281. * @returns "AbstractMesh"
  33282. */
  33283. getClassName(): string;
  33284. /**
  33285. * Gets a string representation of the current mesh
  33286. * @param fullDetails defines a boolean indicating if full details must be included
  33287. * @returns a string representation of the current mesh
  33288. */
  33289. toString(fullDetails?: boolean): string;
  33290. /**
  33291. * @hidden
  33292. */
  33293. protected _getEffectiveParent(): Nullable<Node>;
  33294. /** @hidden */
  33295. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33296. /** @hidden */
  33297. _rebuild(): void;
  33298. /** @hidden */
  33299. _resyncLightSources(): void;
  33300. /** @hidden */
  33301. _resyncLightSource(light: Light): void;
  33302. /** @hidden */
  33303. _unBindEffect(): void;
  33304. /** @hidden */
  33305. _removeLightSource(light: Light, dispose: boolean): void;
  33306. private _markSubMeshesAsDirty;
  33307. /** @hidden */
  33308. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33309. /** @hidden */
  33310. _markSubMeshesAsAttributesDirty(): void;
  33311. /** @hidden */
  33312. _markSubMeshesAsMiscDirty(): void;
  33313. /**
  33314. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33315. */
  33316. get scaling(): Vector3;
  33317. set scaling(newScaling: Vector3);
  33318. /**
  33319. * Returns true if the mesh is blocked. Implemented by child classes
  33320. */
  33321. get isBlocked(): boolean;
  33322. /**
  33323. * Returns the mesh itself by default. Implemented by child classes
  33324. * @param camera defines the camera to use to pick the right LOD level
  33325. * @returns the currentAbstractMesh
  33326. */
  33327. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33328. /**
  33329. * Returns 0 by default. Implemented by child classes
  33330. * @returns an integer
  33331. */
  33332. getTotalVertices(): number;
  33333. /**
  33334. * Returns a positive integer : the total number of indices in this mesh geometry.
  33335. * @returns the numner of indices or zero if the mesh has no geometry.
  33336. */
  33337. getTotalIndices(): number;
  33338. /**
  33339. * Returns null by default. Implemented by child classes
  33340. * @returns null
  33341. */
  33342. getIndices(): Nullable<IndicesArray>;
  33343. /**
  33344. * Returns the array of the requested vertex data kind. Implemented by child classes
  33345. * @param kind defines the vertex data kind to use
  33346. * @returns null
  33347. */
  33348. getVerticesData(kind: string): Nullable<FloatArray>;
  33349. /**
  33350. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33351. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33352. * Note that a new underlying VertexBuffer object is created each call.
  33353. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33354. * @param kind defines vertex data kind:
  33355. * * VertexBuffer.PositionKind
  33356. * * VertexBuffer.UVKind
  33357. * * VertexBuffer.UV2Kind
  33358. * * VertexBuffer.UV3Kind
  33359. * * VertexBuffer.UV4Kind
  33360. * * VertexBuffer.UV5Kind
  33361. * * VertexBuffer.UV6Kind
  33362. * * VertexBuffer.ColorKind
  33363. * * VertexBuffer.MatricesIndicesKind
  33364. * * VertexBuffer.MatricesIndicesExtraKind
  33365. * * VertexBuffer.MatricesWeightsKind
  33366. * * VertexBuffer.MatricesWeightsExtraKind
  33367. * @param data defines the data source
  33368. * @param updatable defines if the data must be flagged as updatable (or static)
  33369. * @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
  33370. * @returns the current mesh
  33371. */
  33372. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33373. /**
  33374. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33375. * If the mesh has no geometry, it is simply returned as it is.
  33376. * @param kind defines vertex data kind:
  33377. * * VertexBuffer.PositionKind
  33378. * * VertexBuffer.UVKind
  33379. * * VertexBuffer.UV2Kind
  33380. * * VertexBuffer.UV3Kind
  33381. * * VertexBuffer.UV4Kind
  33382. * * VertexBuffer.UV5Kind
  33383. * * VertexBuffer.UV6Kind
  33384. * * VertexBuffer.ColorKind
  33385. * * VertexBuffer.MatricesIndicesKind
  33386. * * VertexBuffer.MatricesIndicesExtraKind
  33387. * * VertexBuffer.MatricesWeightsKind
  33388. * * VertexBuffer.MatricesWeightsExtraKind
  33389. * @param data defines the data source
  33390. * @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
  33391. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33392. * @returns the current mesh
  33393. */
  33394. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33395. /**
  33396. * Sets the mesh indices,
  33397. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33398. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33399. * @param totalVertices Defines the total number of vertices
  33400. * @returns the current mesh
  33401. */
  33402. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33403. /**
  33404. * Gets a boolean indicating if specific vertex data is present
  33405. * @param kind defines the vertex data kind to use
  33406. * @returns true is data kind is present
  33407. */
  33408. isVerticesDataPresent(kind: string): boolean;
  33409. /**
  33410. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33411. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33412. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33413. * @returns a BoundingInfo
  33414. */
  33415. getBoundingInfo(): BoundingInfo;
  33416. /**
  33417. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33418. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33419. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33420. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33421. * @returns the current mesh
  33422. */
  33423. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33424. /**
  33425. * Overwrite the current bounding info
  33426. * @param boundingInfo defines the new bounding info
  33427. * @returns the current mesh
  33428. */
  33429. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33430. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33431. get useBones(): boolean;
  33432. /** @hidden */
  33433. _preActivate(): void;
  33434. /** @hidden */
  33435. _preActivateForIntermediateRendering(renderId: number): void;
  33436. /** @hidden */
  33437. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33438. /** @hidden */
  33439. _postActivate(): void;
  33440. /** @hidden */
  33441. _freeze(): void;
  33442. /** @hidden */
  33443. _unFreeze(): void;
  33444. /**
  33445. * Gets the current world matrix
  33446. * @returns a Matrix
  33447. */
  33448. getWorldMatrix(): Matrix;
  33449. /** @hidden */
  33450. _getWorldMatrixDeterminant(): number;
  33451. /**
  33452. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33453. */
  33454. get isAnInstance(): boolean;
  33455. /**
  33456. * Gets a boolean indicating if this mesh has instances
  33457. */
  33458. get hasInstances(): boolean;
  33459. /**
  33460. * Gets a boolean indicating if this mesh has thin instances
  33461. */
  33462. get hasThinInstances(): boolean;
  33463. /**
  33464. * Perform relative position change from the point of view of behind the front of the mesh.
  33465. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33466. * Supports definition of mesh facing forward or backward
  33467. * @param amountRight defines the distance on the right axis
  33468. * @param amountUp defines the distance on the up axis
  33469. * @param amountForward defines the distance on the forward axis
  33470. * @returns the current mesh
  33471. */
  33472. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33473. /**
  33474. * Calculate relative position change from the point of view of behind the front of the mesh.
  33475. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33476. * Supports definition of mesh facing forward or backward
  33477. * @param amountRight defines the distance on the right axis
  33478. * @param amountUp defines the distance on the up axis
  33479. * @param amountForward defines the distance on the forward axis
  33480. * @returns the new displacement vector
  33481. */
  33482. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33483. /**
  33484. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33485. * Supports definition of mesh facing forward or backward
  33486. * @param flipBack defines the flip
  33487. * @param twirlClockwise defines the twirl
  33488. * @param tiltRight defines the tilt
  33489. * @returns the current mesh
  33490. */
  33491. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33492. /**
  33493. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33494. * Supports definition of mesh facing forward or backward.
  33495. * @param flipBack defines the flip
  33496. * @param twirlClockwise defines the twirl
  33497. * @param tiltRight defines the tilt
  33498. * @returns the new rotation vector
  33499. */
  33500. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33501. /**
  33502. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33503. * This means the mesh underlying bounding box and sphere are recomputed.
  33504. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33505. * @returns the current mesh
  33506. */
  33507. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33508. /** @hidden */
  33509. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33510. /** @hidden */
  33511. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33512. /** @hidden */
  33513. _updateBoundingInfo(): AbstractMesh;
  33514. /** @hidden */
  33515. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33516. /** @hidden */
  33517. protected _afterComputeWorldMatrix(): void;
  33518. /** @hidden */
  33519. get _effectiveMesh(): AbstractMesh;
  33520. /**
  33521. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33522. * A mesh is in the frustum if its bounding box intersects the frustum
  33523. * @param frustumPlanes defines the frustum to test
  33524. * @returns true if the mesh is in the frustum planes
  33525. */
  33526. isInFrustum(frustumPlanes: Plane[]): boolean;
  33527. /**
  33528. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33529. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33530. * @param frustumPlanes defines the frustum to test
  33531. * @returns true if the mesh is completely in the frustum planes
  33532. */
  33533. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33534. /**
  33535. * True if the mesh intersects another mesh or a SolidParticle object
  33536. * @param mesh defines a target mesh or SolidParticle to test
  33537. * @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)
  33538. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33539. * @returns true if there is an intersection
  33540. */
  33541. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33542. /**
  33543. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33544. * @param point defines the point to test
  33545. * @returns true if there is an intersection
  33546. */
  33547. intersectsPoint(point: Vector3): boolean;
  33548. /**
  33549. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33550. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33551. */
  33552. get checkCollisions(): boolean;
  33553. set checkCollisions(collisionEnabled: boolean);
  33554. /**
  33555. * Gets Collider object used to compute collisions (not physics)
  33556. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33557. */
  33558. get collider(): Nullable<Collider>;
  33559. /**
  33560. * Move the mesh using collision engine
  33561. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33562. * @param displacement defines the requested displacement vector
  33563. * @returns the current mesh
  33564. */
  33565. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33566. private _onCollisionPositionChange;
  33567. /** @hidden */
  33568. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33569. /** @hidden */
  33570. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33571. /** @hidden */
  33572. _checkCollision(collider: Collider): AbstractMesh;
  33573. /** @hidden */
  33574. _generatePointsArray(): boolean;
  33575. /**
  33576. * Checks if the passed Ray intersects with the mesh
  33577. * @param ray defines the ray to use
  33578. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33579. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33580. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33581. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33582. * @returns the picking info
  33583. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33584. */
  33585. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33586. /**
  33587. * Clones the current mesh
  33588. * @param name defines the mesh name
  33589. * @param newParent defines the new mesh parent
  33590. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33591. * @returns the new mesh
  33592. */
  33593. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33594. /**
  33595. * Disposes all the submeshes of the current meshnp
  33596. * @returns the current mesh
  33597. */
  33598. releaseSubMeshes(): AbstractMesh;
  33599. /**
  33600. * Releases resources associated with this abstract mesh.
  33601. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33602. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33603. */
  33604. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33605. /**
  33606. * Adds the passed mesh as a child to the current mesh
  33607. * @param mesh defines the child mesh
  33608. * @returns the current mesh
  33609. */
  33610. addChild(mesh: AbstractMesh): AbstractMesh;
  33611. /**
  33612. * Removes the passed mesh from the current mesh children list
  33613. * @param mesh defines the child mesh
  33614. * @returns the current mesh
  33615. */
  33616. removeChild(mesh: AbstractMesh): AbstractMesh;
  33617. /** @hidden */
  33618. private _initFacetData;
  33619. /**
  33620. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33621. * This method can be called within the render loop.
  33622. * 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
  33623. * @returns the current mesh
  33624. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33625. */
  33626. updateFacetData(): AbstractMesh;
  33627. /**
  33628. * Returns the facetLocalNormals array.
  33629. * The normals are expressed in the mesh local spac
  33630. * @returns an array of Vector3
  33631. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33632. */
  33633. getFacetLocalNormals(): Vector3[];
  33634. /**
  33635. * Returns the facetLocalPositions array.
  33636. * The facet positions are expressed in the mesh local space
  33637. * @returns an array of Vector3
  33638. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33639. */
  33640. getFacetLocalPositions(): Vector3[];
  33641. /**
  33642. * Returns the facetLocalPartioning array
  33643. * @returns an array of array of numbers
  33644. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33645. */
  33646. getFacetLocalPartitioning(): number[][];
  33647. /**
  33648. * Returns the i-th facet position in the world system.
  33649. * This method allocates a new Vector3 per call
  33650. * @param i defines the facet index
  33651. * @returns a new Vector3
  33652. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33653. */
  33654. getFacetPosition(i: number): Vector3;
  33655. /**
  33656. * Sets the reference Vector3 with the i-th facet position in the world system
  33657. * @param i defines the facet index
  33658. * @param ref defines the target vector
  33659. * @returns the current mesh
  33660. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33661. */
  33662. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33663. /**
  33664. * Returns the i-th facet normal in the world system.
  33665. * This method allocates a new Vector3 per call
  33666. * @param i defines the facet index
  33667. * @returns a new Vector3
  33668. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33669. */
  33670. getFacetNormal(i: number): Vector3;
  33671. /**
  33672. * Sets the reference Vector3 with the i-th facet normal in the world system
  33673. * @param i defines the facet index
  33674. * @param ref defines the target vector
  33675. * @returns the current mesh
  33676. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33677. */
  33678. getFacetNormalToRef(i: number, ref: Vector3): this;
  33679. /**
  33680. * 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)
  33681. * @param x defines x coordinate
  33682. * @param y defines y coordinate
  33683. * @param z defines z coordinate
  33684. * @returns the array of facet indexes
  33685. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33686. */
  33687. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33688. /**
  33689. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33690. * @param projected sets as the (x,y,z) world projection on the facet
  33691. * @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
  33692. * @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
  33693. * @param x defines x coordinate
  33694. * @param y defines y coordinate
  33695. * @param z defines z coordinate
  33696. * @returns the face index if found (or null instead)
  33697. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33698. */
  33699. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33700. /**
  33701. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33702. * @param projected sets as the (x,y,z) local projection on the facet
  33703. * @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
  33704. * @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
  33705. * @param x defines x coordinate
  33706. * @param y defines y coordinate
  33707. * @param z defines z coordinate
  33708. * @returns the face index if found (or null instead)
  33709. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33710. */
  33711. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33712. /**
  33713. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33714. * @returns the parameters
  33715. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33716. */
  33717. getFacetDataParameters(): any;
  33718. /**
  33719. * Disables the feature FacetData and frees the related memory
  33720. * @returns the current mesh
  33721. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33722. */
  33723. disableFacetData(): AbstractMesh;
  33724. /**
  33725. * Updates the AbstractMesh indices array
  33726. * @param indices defines the data source
  33727. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33728. * @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)
  33729. * @returns the current mesh
  33730. */
  33731. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33732. /**
  33733. * Creates new normals data for the mesh
  33734. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33735. * @returns the current mesh
  33736. */
  33737. createNormals(updatable: boolean): AbstractMesh;
  33738. /**
  33739. * Align the mesh with a normal
  33740. * @param normal defines the normal to use
  33741. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33742. * @returns the current mesh
  33743. */
  33744. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33745. /** @hidden */
  33746. _checkOcclusionQuery(): boolean;
  33747. /**
  33748. * Disables the mesh edge rendering mode
  33749. * @returns the currentAbstractMesh
  33750. */
  33751. disableEdgesRendering(): AbstractMesh;
  33752. /**
  33753. * Enables the edge rendering mode on the mesh.
  33754. * This mode makes the mesh edges visible
  33755. * @param epsilon defines the maximal distance between two angles to detect a face
  33756. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33757. * @returns the currentAbstractMesh
  33758. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33759. */
  33760. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33761. /**
  33762. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33763. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33764. */
  33765. getConnectedParticleSystems(): IParticleSystem[];
  33766. }
  33767. }
  33768. declare module "babylonjs/Actions/actionEvent" {
  33769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33770. import { Nullable } from "babylonjs/types";
  33771. import { Sprite } from "babylonjs/Sprites/sprite";
  33772. import { Scene } from "babylonjs/scene";
  33773. import { Vector2 } from "babylonjs/Maths/math.vector";
  33774. /**
  33775. * Interface used to define ActionEvent
  33776. */
  33777. export interface IActionEvent {
  33778. /** The mesh or sprite that triggered the action */
  33779. source: any;
  33780. /** The X mouse cursor position at the time of the event */
  33781. pointerX: number;
  33782. /** The Y mouse cursor position at the time of the event */
  33783. pointerY: number;
  33784. /** The mesh that is currently pointed at (can be null) */
  33785. meshUnderPointer: Nullable<AbstractMesh>;
  33786. /** the original (browser) event that triggered the ActionEvent */
  33787. sourceEvent?: any;
  33788. /** additional data for the event */
  33789. additionalData?: any;
  33790. }
  33791. /**
  33792. * ActionEvent is the event being sent when an action is triggered.
  33793. */
  33794. export class ActionEvent implements IActionEvent {
  33795. /** The mesh or sprite that triggered the action */
  33796. source: any;
  33797. /** The X mouse cursor position at the time of the event */
  33798. pointerX: number;
  33799. /** The Y mouse cursor position at the time of the event */
  33800. pointerY: number;
  33801. /** The mesh that is currently pointed at (can be null) */
  33802. meshUnderPointer: Nullable<AbstractMesh>;
  33803. /** the original (browser) event that triggered the ActionEvent */
  33804. sourceEvent?: any;
  33805. /** additional data for the event */
  33806. additionalData?: any;
  33807. /**
  33808. * Creates a new ActionEvent
  33809. * @param source The mesh or sprite that triggered the action
  33810. * @param pointerX The X mouse cursor position at the time of the event
  33811. * @param pointerY The Y mouse cursor position at the time of the event
  33812. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33813. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33814. * @param additionalData additional data for the event
  33815. */
  33816. constructor(
  33817. /** The mesh or sprite that triggered the action */
  33818. source: any,
  33819. /** The X mouse cursor position at the time of the event */
  33820. pointerX: number,
  33821. /** The Y mouse cursor position at the time of the event */
  33822. pointerY: number,
  33823. /** The mesh that is currently pointed at (can be null) */
  33824. meshUnderPointer: Nullable<AbstractMesh>,
  33825. /** the original (browser) event that triggered the ActionEvent */
  33826. sourceEvent?: any,
  33827. /** additional data for the event */
  33828. additionalData?: any);
  33829. /**
  33830. * Helper function to auto-create an ActionEvent from a source mesh.
  33831. * @param source The source mesh that triggered the event
  33832. * @param evt The original (browser) event
  33833. * @param additionalData additional data for the event
  33834. * @returns the new ActionEvent
  33835. */
  33836. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33837. /**
  33838. * Helper function to auto-create an ActionEvent from a source sprite
  33839. * @param source The source sprite that triggered the event
  33840. * @param scene Scene associated with the sprite
  33841. * @param evt The original (browser) event
  33842. * @param additionalData additional data for the event
  33843. * @returns the new ActionEvent
  33844. */
  33845. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33846. /**
  33847. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33848. * @param scene the scene where the event occurred
  33849. * @param evt The original (browser) event
  33850. * @returns the new ActionEvent
  33851. */
  33852. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33853. /**
  33854. * Helper function to auto-create an ActionEvent from a primitive
  33855. * @param prim defines the target primitive
  33856. * @param pointerPos defines the pointer position
  33857. * @param evt The original (browser) event
  33858. * @param additionalData additional data for the event
  33859. * @returns the new ActionEvent
  33860. */
  33861. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33862. }
  33863. }
  33864. declare module "babylonjs/Actions/abstractActionManager" {
  33865. import { IDisposable } from "babylonjs/scene";
  33866. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33867. import { IAction } from "babylonjs/Actions/action";
  33868. import { Nullable } from "babylonjs/types";
  33869. /**
  33870. * Abstract class used to decouple action Manager from scene and meshes.
  33871. * Do not instantiate.
  33872. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33873. */
  33874. export abstract class AbstractActionManager implements IDisposable {
  33875. /** Gets the list of active triggers */
  33876. static Triggers: {
  33877. [key: string]: number;
  33878. };
  33879. /** Gets the cursor to use when hovering items */
  33880. hoverCursor: string;
  33881. /** Gets the list of actions */
  33882. actions: IAction[];
  33883. /**
  33884. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33885. */
  33886. isRecursive: boolean;
  33887. /**
  33888. * Releases all associated resources
  33889. */
  33890. abstract dispose(): void;
  33891. /**
  33892. * Does this action manager has pointer triggers
  33893. */
  33894. abstract get hasPointerTriggers(): boolean;
  33895. /**
  33896. * Does this action manager has pick triggers
  33897. */
  33898. abstract get hasPickTriggers(): boolean;
  33899. /**
  33900. * Process a specific trigger
  33901. * @param trigger defines the trigger to process
  33902. * @param evt defines the event details to be processed
  33903. */
  33904. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33905. /**
  33906. * Does this action manager handles actions of any of the given triggers
  33907. * @param triggers defines the triggers to be tested
  33908. * @return a boolean indicating whether one (or more) of the triggers is handled
  33909. */
  33910. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33911. /**
  33912. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33913. * speed.
  33914. * @param triggerA defines the trigger to be tested
  33915. * @param triggerB defines the trigger to be tested
  33916. * @return a boolean indicating whether one (or more) of the triggers is handled
  33917. */
  33918. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33919. /**
  33920. * Does this action manager handles actions of a given trigger
  33921. * @param trigger defines the trigger to be tested
  33922. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33923. * @return whether the trigger is handled
  33924. */
  33925. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33926. /**
  33927. * Serialize this manager to a JSON object
  33928. * @param name defines the property name to store this manager
  33929. * @returns a JSON representation of this manager
  33930. */
  33931. abstract serialize(name: string): any;
  33932. /**
  33933. * Registers an action to this action manager
  33934. * @param action defines the action to be registered
  33935. * @return the action amended (prepared) after registration
  33936. */
  33937. abstract registerAction(action: IAction): Nullable<IAction>;
  33938. /**
  33939. * Unregisters an action to this action manager
  33940. * @param action defines the action to be unregistered
  33941. * @return a boolean indicating whether the action has been unregistered
  33942. */
  33943. abstract unregisterAction(action: IAction): Boolean;
  33944. /**
  33945. * Does exist one action manager with at least one trigger
  33946. **/
  33947. static get HasTriggers(): boolean;
  33948. /**
  33949. * Does exist one action manager with at least one pick trigger
  33950. **/
  33951. static get HasPickTriggers(): boolean;
  33952. /**
  33953. * Does exist one action manager that handles actions of a given trigger
  33954. * @param trigger defines the trigger to be tested
  33955. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33956. **/
  33957. static HasSpecificTrigger(trigger: number): boolean;
  33958. }
  33959. }
  33960. declare module "babylonjs/node" {
  33961. import { Scene } from "babylonjs/scene";
  33962. import { Nullable } from "babylonjs/types";
  33963. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33964. import { Engine } from "babylonjs/Engines/engine";
  33965. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33966. import { Observable } from "babylonjs/Misc/observable";
  33967. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33968. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33969. import { Animatable } from "babylonjs/Animations/animatable";
  33970. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33971. import { Animation } from "babylonjs/Animations/animation";
  33972. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33974. /**
  33975. * Defines how a node can be built from a string name.
  33976. */
  33977. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33978. /**
  33979. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33980. */
  33981. export class Node implements IBehaviorAware<Node> {
  33982. /** @hidden */
  33983. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33984. private static _NodeConstructors;
  33985. /**
  33986. * Add a new node constructor
  33987. * @param type defines the type name of the node to construct
  33988. * @param constructorFunc defines the constructor function
  33989. */
  33990. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33991. /**
  33992. * Returns a node constructor based on type name
  33993. * @param type defines the type name
  33994. * @param name defines the new node name
  33995. * @param scene defines the hosting scene
  33996. * @param options defines optional options to transmit to constructors
  33997. * @returns the new constructor or null
  33998. */
  33999. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34000. /**
  34001. * Gets or sets the name of the node
  34002. */
  34003. name: string;
  34004. /**
  34005. * Gets or sets the id of the node
  34006. */
  34007. id: string;
  34008. /**
  34009. * Gets or sets the unique id of the node
  34010. */
  34011. uniqueId: number;
  34012. /**
  34013. * Gets or sets a string used to store user defined state for the node
  34014. */
  34015. state: string;
  34016. /**
  34017. * Gets or sets an object used to store user defined information for the node
  34018. */
  34019. metadata: any;
  34020. /**
  34021. * For internal use only. Please do not use.
  34022. */
  34023. reservedDataStore: any;
  34024. /**
  34025. * List of inspectable custom properties (used by the Inspector)
  34026. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34027. */
  34028. inspectableCustomProperties: IInspectable[];
  34029. private _doNotSerialize;
  34030. /**
  34031. * Gets or sets a boolean used to define if the node must be serialized
  34032. */
  34033. get doNotSerialize(): boolean;
  34034. set doNotSerialize(value: boolean);
  34035. /** @hidden */
  34036. _isDisposed: boolean;
  34037. /**
  34038. * Gets a list of Animations associated with the node
  34039. */
  34040. animations: import("babylonjs/Animations/animation").Animation[];
  34041. protected _ranges: {
  34042. [name: string]: Nullable<AnimationRange>;
  34043. };
  34044. /**
  34045. * Callback raised when the node is ready to be used
  34046. */
  34047. onReady: Nullable<(node: Node) => void>;
  34048. private _isEnabled;
  34049. private _isParentEnabled;
  34050. private _isReady;
  34051. /** @hidden */
  34052. _currentRenderId: number;
  34053. private _parentUpdateId;
  34054. /** @hidden */
  34055. _childUpdateId: number;
  34056. /** @hidden */
  34057. _waitingParentId: Nullable<string>;
  34058. /** @hidden */
  34059. _scene: Scene;
  34060. /** @hidden */
  34061. _cache: any;
  34062. private _parentNode;
  34063. private _children;
  34064. /** @hidden */
  34065. _worldMatrix: Matrix;
  34066. /** @hidden */
  34067. _worldMatrixDeterminant: number;
  34068. /** @hidden */
  34069. _worldMatrixDeterminantIsDirty: boolean;
  34070. /** @hidden */
  34071. private _sceneRootNodesIndex;
  34072. /**
  34073. * Gets a boolean indicating if the node has been disposed
  34074. * @returns true if the node was disposed
  34075. */
  34076. isDisposed(): boolean;
  34077. /**
  34078. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34079. * @see https://doc.babylonjs.com/how_to/parenting
  34080. */
  34081. set parent(parent: Nullable<Node>);
  34082. get parent(): Nullable<Node>;
  34083. /** @hidden */
  34084. _addToSceneRootNodes(): void;
  34085. /** @hidden */
  34086. _removeFromSceneRootNodes(): void;
  34087. private _animationPropertiesOverride;
  34088. /**
  34089. * Gets or sets the animation properties override
  34090. */
  34091. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34092. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34093. /**
  34094. * Gets a string idenfifying the name of the class
  34095. * @returns "Node" string
  34096. */
  34097. getClassName(): string;
  34098. /** @hidden */
  34099. readonly _isNode: boolean;
  34100. /**
  34101. * An event triggered when the mesh is disposed
  34102. */
  34103. onDisposeObservable: Observable<Node>;
  34104. private _onDisposeObserver;
  34105. /**
  34106. * Sets a callback that will be raised when the node will be disposed
  34107. */
  34108. set onDispose(callback: () => void);
  34109. /**
  34110. * Creates a new Node
  34111. * @param name the name and id to be given to this node
  34112. * @param scene the scene this node will be added to
  34113. */
  34114. constructor(name: string, scene?: Nullable<Scene>);
  34115. /**
  34116. * Gets the scene of the node
  34117. * @returns a scene
  34118. */
  34119. getScene(): Scene;
  34120. /**
  34121. * Gets the engine of the node
  34122. * @returns a Engine
  34123. */
  34124. getEngine(): Engine;
  34125. private _behaviors;
  34126. /**
  34127. * Attach a behavior to the node
  34128. * @see https://doc.babylonjs.com/features/behaviour
  34129. * @param behavior defines the behavior to attach
  34130. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34131. * @returns the current Node
  34132. */
  34133. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34134. /**
  34135. * Remove an attached behavior
  34136. * @see https://doc.babylonjs.com/features/behaviour
  34137. * @param behavior defines the behavior to attach
  34138. * @returns the current Node
  34139. */
  34140. removeBehavior(behavior: Behavior<Node>): Node;
  34141. /**
  34142. * Gets the list of attached behaviors
  34143. * @see https://doc.babylonjs.com/features/behaviour
  34144. */
  34145. get behaviors(): Behavior<Node>[];
  34146. /**
  34147. * Gets an attached behavior by name
  34148. * @param name defines the name of the behavior to look for
  34149. * @see https://doc.babylonjs.com/features/behaviour
  34150. * @returns null if behavior was not found else the requested behavior
  34151. */
  34152. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34153. /**
  34154. * Returns the latest update of the World matrix
  34155. * @returns a Matrix
  34156. */
  34157. getWorldMatrix(): Matrix;
  34158. /** @hidden */
  34159. _getWorldMatrixDeterminant(): number;
  34160. /**
  34161. * Returns directly the latest state of the mesh World matrix.
  34162. * A Matrix is returned.
  34163. */
  34164. get worldMatrixFromCache(): Matrix;
  34165. /** @hidden */
  34166. _initCache(): void;
  34167. /** @hidden */
  34168. updateCache(force?: boolean): void;
  34169. /** @hidden */
  34170. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34171. /** @hidden */
  34172. _updateCache(ignoreParentClass?: boolean): void;
  34173. /** @hidden */
  34174. _isSynchronized(): boolean;
  34175. /** @hidden */
  34176. _markSyncedWithParent(): void;
  34177. /** @hidden */
  34178. isSynchronizedWithParent(): boolean;
  34179. /** @hidden */
  34180. isSynchronized(): boolean;
  34181. /**
  34182. * Is this node ready to be used/rendered
  34183. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34184. * @return true if the node is ready
  34185. */
  34186. isReady(completeCheck?: boolean): boolean;
  34187. /**
  34188. * Is this node enabled?
  34189. * 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
  34190. * @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
  34191. * @return whether this node (and its parent) is enabled
  34192. */
  34193. isEnabled(checkAncestors?: boolean): boolean;
  34194. /** @hidden */
  34195. protected _syncParentEnabledState(): void;
  34196. /**
  34197. * Set the enabled state of this node
  34198. * @param value defines the new enabled state
  34199. */
  34200. setEnabled(value: boolean): void;
  34201. /**
  34202. * Is this node a descendant of the given node?
  34203. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34204. * @param ancestor defines the parent node to inspect
  34205. * @returns a boolean indicating if this node is a descendant of the given node
  34206. */
  34207. isDescendantOf(ancestor: Node): boolean;
  34208. /** @hidden */
  34209. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34210. /**
  34211. * Will return all nodes that have this node as ascendant
  34212. * @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
  34213. * @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
  34214. * @return all children nodes of all types
  34215. */
  34216. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34217. /**
  34218. * Get all child-meshes of this node
  34219. * @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)
  34220. * @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
  34221. * @returns an array of AbstractMesh
  34222. */
  34223. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34224. /**
  34225. * Get all direct children of this node
  34226. * @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
  34227. * @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)
  34228. * @returns an array of Node
  34229. */
  34230. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34231. /** @hidden */
  34232. _setReady(state: boolean): void;
  34233. /**
  34234. * Get an animation by name
  34235. * @param name defines the name of the animation to look for
  34236. * @returns null if not found else the requested animation
  34237. */
  34238. getAnimationByName(name: string): Nullable<Animation>;
  34239. /**
  34240. * Creates an animation range for this node
  34241. * @param name defines the name of the range
  34242. * @param from defines the starting key
  34243. * @param to defines the end key
  34244. */
  34245. createAnimationRange(name: string, from: number, to: number): void;
  34246. /**
  34247. * Delete a specific animation range
  34248. * @param name defines the name of the range to delete
  34249. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34250. */
  34251. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34252. /**
  34253. * Get an animation range by name
  34254. * @param name defines the name of the animation range to look for
  34255. * @returns null if not found else the requested animation range
  34256. */
  34257. getAnimationRange(name: string): Nullable<AnimationRange>;
  34258. /**
  34259. * Gets the list of all animation ranges defined on this node
  34260. * @returns an array
  34261. */
  34262. getAnimationRanges(): Nullable<AnimationRange>[];
  34263. /**
  34264. * Will start the animation sequence
  34265. * @param name defines the range frames for animation sequence
  34266. * @param loop defines if the animation should loop (false by default)
  34267. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34268. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34269. * @returns the object created for this animation. If range does not exist, it will return null
  34270. */
  34271. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34272. /**
  34273. * Serialize animation ranges into a JSON compatible object
  34274. * @returns serialization object
  34275. */
  34276. serializeAnimationRanges(): any;
  34277. /**
  34278. * Computes the world matrix of the node
  34279. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34280. * @returns the world matrix
  34281. */
  34282. computeWorldMatrix(force?: boolean): Matrix;
  34283. /**
  34284. * Releases resources associated with this node.
  34285. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34286. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34287. */
  34288. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34289. /**
  34290. * Parse animation range data from a serialization object and store them into a given node
  34291. * @param node defines where to store the animation ranges
  34292. * @param parsedNode defines the serialization object to read data from
  34293. * @param scene defines the hosting scene
  34294. */
  34295. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34296. /**
  34297. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34298. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34299. * @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
  34300. * @returns the new bounding vectors
  34301. */
  34302. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34303. min: Vector3;
  34304. max: Vector3;
  34305. };
  34306. }
  34307. }
  34308. declare module "babylonjs/Animations/animation" {
  34309. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34310. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34311. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34312. import { Nullable } from "babylonjs/types";
  34313. import { Scene } from "babylonjs/scene";
  34314. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34315. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34316. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34317. import { Node } from "babylonjs/node";
  34318. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34319. import { Size } from "babylonjs/Maths/math.size";
  34320. import { Animatable } from "babylonjs/Animations/animatable";
  34321. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34322. /**
  34323. * @hidden
  34324. */
  34325. export class _IAnimationState {
  34326. key: number;
  34327. repeatCount: number;
  34328. workValue?: any;
  34329. loopMode?: number;
  34330. offsetValue?: any;
  34331. highLimitValue?: any;
  34332. }
  34333. /**
  34334. * Class used to store any kind of animation
  34335. */
  34336. export class Animation {
  34337. /**Name of the animation */
  34338. name: string;
  34339. /**Property to animate */
  34340. targetProperty: string;
  34341. /**The frames per second of the animation */
  34342. framePerSecond: number;
  34343. /**The data type of the animation */
  34344. dataType: number;
  34345. /**The loop mode of the animation */
  34346. loopMode?: number | undefined;
  34347. /**Specifies if blending should be enabled */
  34348. enableBlending?: boolean | undefined;
  34349. /**
  34350. * Use matrix interpolation instead of using direct key value when animating matrices
  34351. */
  34352. static AllowMatricesInterpolation: boolean;
  34353. /**
  34354. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34355. */
  34356. static AllowMatrixDecomposeForInterpolation: boolean;
  34357. /** Define the Url to load snippets */
  34358. static SnippetUrl: string;
  34359. /** Snippet ID if the animation was created from the snippet server */
  34360. snippetId: string;
  34361. /**
  34362. * Stores the key frames of the animation
  34363. */
  34364. private _keys;
  34365. /**
  34366. * Stores the easing function of the animation
  34367. */
  34368. private _easingFunction;
  34369. /**
  34370. * @hidden Internal use only
  34371. */
  34372. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34373. /**
  34374. * The set of event that will be linked to this animation
  34375. */
  34376. private _events;
  34377. /**
  34378. * Stores an array of target property paths
  34379. */
  34380. targetPropertyPath: string[];
  34381. /**
  34382. * Stores the blending speed of the animation
  34383. */
  34384. blendingSpeed: number;
  34385. /**
  34386. * Stores the animation ranges for the animation
  34387. */
  34388. private _ranges;
  34389. /**
  34390. * @hidden Internal use
  34391. */
  34392. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34393. /**
  34394. * Sets up an animation
  34395. * @param property The property to animate
  34396. * @param animationType The animation type to apply
  34397. * @param framePerSecond The frames per second of the animation
  34398. * @param easingFunction The easing function used in the animation
  34399. * @returns The created animation
  34400. */
  34401. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34402. /**
  34403. * Create and start an animation on a node
  34404. * @param name defines the name of the global animation that will be run on all nodes
  34405. * @param node defines the root node where the animation will take place
  34406. * @param targetProperty defines property to animate
  34407. * @param framePerSecond defines the number of frame per second yo use
  34408. * @param totalFrame defines the number of frames in total
  34409. * @param from defines the initial value
  34410. * @param to defines the final value
  34411. * @param loopMode defines which loop mode you want to use (off by default)
  34412. * @param easingFunction defines the easing function to use (linear by default)
  34413. * @param onAnimationEnd defines the callback to call when animation end
  34414. * @returns the animatable created for this animation
  34415. */
  34416. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34417. /**
  34418. * Create and start an animation on a node and its descendants
  34419. * @param name defines the name of the global animation that will be run on all nodes
  34420. * @param node defines the root node where the animation will take place
  34421. * @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
  34422. * @param targetProperty defines property to animate
  34423. * @param framePerSecond defines the number of frame per second to use
  34424. * @param totalFrame defines the number of frames in total
  34425. * @param from defines the initial value
  34426. * @param to defines the final value
  34427. * @param loopMode defines which loop mode you want to use (off by default)
  34428. * @param easingFunction defines the easing function to use (linear by default)
  34429. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34430. * @returns the list of animatables created for all nodes
  34431. * @example https://www.babylonjs-playground.com/#MH0VLI
  34432. */
  34433. 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[]>;
  34434. /**
  34435. * Creates a new animation, merges it with the existing animations and starts it
  34436. * @param name Name of the animation
  34437. * @param node Node which contains the scene that begins the animations
  34438. * @param targetProperty Specifies which property to animate
  34439. * @param framePerSecond The frames per second of the animation
  34440. * @param totalFrame The total number of frames
  34441. * @param from The frame at the beginning of the animation
  34442. * @param to The frame at the end of the animation
  34443. * @param loopMode Specifies the loop mode of the animation
  34444. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34445. * @param onAnimationEnd Callback to run once the animation is complete
  34446. * @returns Nullable animation
  34447. */
  34448. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34449. /**
  34450. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34451. * @param sourceAnimation defines the Animation containing keyframes to convert
  34452. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34453. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34454. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34455. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34456. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34457. */
  34458. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34459. /**
  34460. * Transition property of an host to the target Value
  34461. * @param property The property to transition
  34462. * @param targetValue The target Value of the property
  34463. * @param host The object where the property to animate belongs
  34464. * @param scene Scene used to run the animation
  34465. * @param frameRate Framerate (in frame/s) to use
  34466. * @param transition The transition type we want to use
  34467. * @param duration The duration of the animation, in milliseconds
  34468. * @param onAnimationEnd Callback trigger at the end of the animation
  34469. * @returns Nullable animation
  34470. */
  34471. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34472. /**
  34473. * Return the array of runtime animations currently using this animation
  34474. */
  34475. get runtimeAnimations(): RuntimeAnimation[];
  34476. /**
  34477. * Specifies if any of the runtime animations are currently running
  34478. */
  34479. get hasRunningRuntimeAnimations(): boolean;
  34480. /**
  34481. * Initializes the animation
  34482. * @param name Name of the animation
  34483. * @param targetProperty Property to animate
  34484. * @param framePerSecond The frames per second of the animation
  34485. * @param dataType The data type of the animation
  34486. * @param loopMode The loop mode of the animation
  34487. * @param enableBlending Specifies if blending should be enabled
  34488. */
  34489. constructor(
  34490. /**Name of the animation */
  34491. name: string,
  34492. /**Property to animate */
  34493. targetProperty: string,
  34494. /**The frames per second of the animation */
  34495. framePerSecond: number,
  34496. /**The data type of the animation */
  34497. dataType: number,
  34498. /**The loop mode of the animation */
  34499. loopMode?: number | undefined,
  34500. /**Specifies if blending should be enabled */
  34501. enableBlending?: boolean | undefined);
  34502. /**
  34503. * Converts the animation to a string
  34504. * @param fullDetails support for multiple levels of logging within scene loading
  34505. * @returns String form of the animation
  34506. */
  34507. toString(fullDetails?: boolean): string;
  34508. /**
  34509. * Add an event to this animation
  34510. * @param event Event to add
  34511. */
  34512. addEvent(event: AnimationEvent): void;
  34513. /**
  34514. * Remove all events found at the given frame
  34515. * @param frame The frame to remove events from
  34516. */
  34517. removeEvents(frame: number): void;
  34518. /**
  34519. * Retrieves all the events from the animation
  34520. * @returns Events from the animation
  34521. */
  34522. getEvents(): AnimationEvent[];
  34523. /**
  34524. * Creates an animation range
  34525. * @param name Name of the animation range
  34526. * @param from Starting frame of the animation range
  34527. * @param to Ending frame of the animation
  34528. */
  34529. createRange(name: string, from: number, to: number): void;
  34530. /**
  34531. * Deletes an animation range by name
  34532. * @param name Name of the animation range to delete
  34533. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34534. */
  34535. deleteRange(name: string, deleteFrames?: boolean): void;
  34536. /**
  34537. * Gets the animation range by name, or null if not defined
  34538. * @param name Name of the animation range
  34539. * @returns Nullable animation range
  34540. */
  34541. getRange(name: string): Nullable<AnimationRange>;
  34542. /**
  34543. * Gets the key frames from the animation
  34544. * @returns The key frames of the animation
  34545. */
  34546. getKeys(): Array<IAnimationKey>;
  34547. /**
  34548. * Gets the highest frame rate of the animation
  34549. * @returns Highest frame rate of the animation
  34550. */
  34551. getHighestFrame(): number;
  34552. /**
  34553. * Gets the easing function of the animation
  34554. * @returns Easing function of the animation
  34555. */
  34556. getEasingFunction(): IEasingFunction;
  34557. /**
  34558. * Sets the easing function of the animation
  34559. * @param easingFunction A custom mathematical formula for animation
  34560. */
  34561. setEasingFunction(easingFunction: EasingFunction): void;
  34562. /**
  34563. * Interpolates a scalar linearly
  34564. * @param startValue Start value of the animation curve
  34565. * @param endValue End value of the animation curve
  34566. * @param gradient Scalar amount to interpolate
  34567. * @returns Interpolated scalar value
  34568. */
  34569. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34570. /**
  34571. * Interpolates a scalar cubically
  34572. * @param startValue Start value of the animation curve
  34573. * @param outTangent End tangent of the animation
  34574. * @param endValue End value of the animation curve
  34575. * @param inTangent Start tangent of the animation curve
  34576. * @param gradient Scalar amount to interpolate
  34577. * @returns Interpolated scalar value
  34578. */
  34579. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34580. /**
  34581. * Interpolates a quaternion using a spherical linear interpolation
  34582. * @param startValue Start value of the animation curve
  34583. * @param endValue End value of the animation curve
  34584. * @param gradient Scalar amount to interpolate
  34585. * @returns Interpolated quaternion value
  34586. */
  34587. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34588. /**
  34589. * Interpolates a quaternion cubically
  34590. * @param startValue Start value of the animation curve
  34591. * @param outTangent End tangent of the animation curve
  34592. * @param endValue End value of the animation curve
  34593. * @param inTangent Start tangent of the animation curve
  34594. * @param gradient Scalar amount to interpolate
  34595. * @returns Interpolated quaternion value
  34596. */
  34597. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34598. /**
  34599. * Interpolates a Vector3 linearl
  34600. * @param startValue Start value of the animation curve
  34601. * @param endValue End value of the animation curve
  34602. * @param gradient Scalar amount to interpolate
  34603. * @returns Interpolated scalar value
  34604. */
  34605. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34606. /**
  34607. * Interpolates a Vector3 cubically
  34608. * @param startValue Start value of the animation curve
  34609. * @param outTangent End tangent of the animation
  34610. * @param endValue End value of the animation curve
  34611. * @param inTangent Start tangent of the animation curve
  34612. * @param gradient Scalar amount to interpolate
  34613. * @returns InterpolatedVector3 value
  34614. */
  34615. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34616. /**
  34617. * Interpolates a Vector2 linearly
  34618. * @param startValue Start value of the animation curve
  34619. * @param endValue End value of the animation curve
  34620. * @param gradient Scalar amount to interpolate
  34621. * @returns Interpolated Vector2 value
  34622. */
  34623. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34624. /**
  34625. * Interpolates a Vector2 cubically
  34626. * @param startValue Start value of the animation curve
  34627. * @param outTangent End tangent of the animation
  34628. * @param endValue End value of the animation curve
  34629. * @param inTangent Start tangent of the animation curve
  34630. * @param gradient Scalar amount to interpolate
  34631. * @returns Interpolated Vector2 value
  34632. */
  34633. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34634. /**
  34635. * Interpolates a size linearly
  34636. * @param startValue Start value of the animation curve
  34637. * @param endValue End value of the animation curve
  34638. * @param gradient Scalar amount to interpolate
  34639. * @returns Interpolated Size value
  34640. */
  34641. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34642. /**
  34643. * Interpolates a Color3 linearly
  34644. * @param startValue Start value of the animation curve
  34645. * @param endValue End value of the animation curve
  34646. * @param gradient Scalar amount to interpolate
  34647. * @returns Interpolated Color3 value
  34648. */
  34649. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34650. /**
  34651. * Interpolates a Color4 linearly
  34652. * @param startValue Start value of the animation curve
  34653. * @param endValue End value of the animation curve
  34654. * @param gradient Scalar amount to interpolate
  34655. * @returns Interpolated Color3 value
  34656. */
  34657. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34658. /**
  34659. * @hidden Internal use only
  34660. */
  34661. _getKeyValue(value: any): any;
  34662. /**
  34663. * @hidden Internal use only
  34664. */
  34665. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34666. /**
  34667. * Defines the function to use to interpolate matrices
  34668. * @param startValue defines the start matrix
  34669. * @param endValue defines the end matrix
  34670. * @param gradient defines the gradient between both matrices
  34671. * @param result defines an optional target matrix where to store the interpolation
  34672. * @returns the interpolated matrix
  34673. */
  34674. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34675. /**
  34676. * Makes a copy of the animation
  34677. * @returns Cloned animation
  34678. */
  34679. clone(): Animation;
  34680. /**
  34681. * Sets the key frames of the animation
  34682. * @param values The animation key frames to set
  34683. */
  34684. setKeys(values: Array<IAnimationKey>): void;
  34685. /**
  34686. * Serializes the animation to an object
  34687. * @returns Serialized object
  34688. */
  34689. serialize(): any;
  34690. /**
  34691. * Float animation type
  34692. */
  34693. static readonly ANIMATIONTYPE_FLOAT: number;
  34694. /**
  34695. * Vector3 animation type
  34696. */
  34697. static readonly ANIMATIONTYPE_VECTOR3: number;
  34698. /**
  34699. * Quaternion animation type
  34700. */
  34701. static readonly ANIMATIONTYPE_QUATERNION: number;
  34702. /**
  34703. * Matrix animation type
  34704. */
  34705. static readonly ANIMATIONTYPE_MATRIX: number;
  34706. /**
  34707. * Color3 animation type
  34708. */
  34709. static readonly ANIMATIONTYPE_COLOR3: number;
  34710. /**
  34711. * Color3 animation type
  34712. */
  34713. static readonly ANIMATIONTYPE_COLOR4: number;
  34714. /**
  34715. * Vector2 animation type
  34716. */
  34717. static readonly ANIMATIONTYPE_VECTOR2: number;
  34718. /**
  34719. * Size animation type
  34720. */
  34721. static readonly ANIMATIONTYPE_SIZE: number;
  34722. /**
  34723. * Relative Loop Mode
  34724. */
  34725. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34726. /**
  34727. * Cycle Loop Mode
  34728. */
  34729. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34730. /**
  34731. * Constant Loop Mode
  34732. */
  34733. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34734. /** @hidden */
  34735. static _UniversalLerp(left: any, right: any, amount: number): any;
  34736. /**
  34737. * Parses an animation object and creates an animation
  34738. * @param parsedAnimation Parsed animation object
  34739. * @returns Animation object
  34740. */
  34741. static Parse(parsedAnimation: any): Animation;
  34742. /**
  34743. * Appends the serialized animations from the source animations
  34744. * @param source Source containing the animations
  34745. * @param destination Target to store the animations
  34746. */
  34747. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34748. /**
  34749. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34750. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34751. * @param url defines the url to load from
  34752. * @returns a promise that will resolve to the new animation or an array of animations
  34753. */
  34754. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34755. /**
  34756. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34757. * @param snippetId defines the snippet to load
  34758. * @returns a promise that will resolve to the new animation or a new array of animations
  34759. */
  34760. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34761. }
  34762. }
  34763. declare module "babylonjs/Animations/animatable.interface" {
  34764. import { Nullable } from "babylonjs/types";
  34765. import { Animation } from "babylonjs/Animations/animation";
  34766. /**
  34767. * Interface containing an array of animations
  34768. */
  34769. export interface IAnimatable {
  34770. /**
  34771. * Array of animations
  34772. */
  34773. animations: Nullable<Array<Animation>>;
  34774. }
  34775. }
  34776. declare module "babylonjs/Misc/decorators" {
  34777. import { Nullable } from "babylonjs/types";
  34778. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34779. import { Scene } from "babylonjs/scene";
  34780. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34781. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34782. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34784. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34785. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34786. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34787. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34788. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34789. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34790. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34791. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34792. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34793. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34794. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34795. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34796. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34797. /**
  34798. * Decorator used to define property that can be serialized as reference to a camera
  34799. * @param sourceName defines the name of the property to decorate
  34800. */
  34801. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34802. /**
  34803. * Class used to help serialization objects
  34804. */
  34805. export class SerializationHelper {
  34806. /** @hidden */
  34807. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34808. /** @hidden */
  34809. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34810. /** @hidden */
  34811. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34812. /** @hidden */
  34813. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34814. /**
  34815. * Appends the serialized animations from the source animations
  34816. * @param source Source containing the animations
  34817. * @param destination Target to store the animations
  34818. */
  34819. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34820. /**
  34821. * Static function used to serialized a specific entity
  34822. * @param entity defines the entity to serialize
  34823. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34824. * @returns a JSON compatible object representing the serialization of the entity
  34825. */
  34826. static Serialize<T>(entity: T, serializationObject?: any): any;
  34827. /**
  34828. * Creates a new entity from a serialization data object
  34829. * @param creationFunction defines a function used to instanciated the new entity
  34830. * @param source defines the source serialization data
  34831. * @param scene defines the hosting scene
  34832. * @param rootUrl defines the root url for resources
  34833. * @returns a new entity
  34834. */
  34835. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34836. /**
  34837. * Clones an object
  34838. * @param creationFunction defines the function used to instanciate the new object
  34839. * @param source defines the source object
  34840. * @returns the cloned object
  34841. */
  34842. static Clone<T>(creationFunction: () => T, source: T): T;
  34843. /**
  34844. * Instanciates a new object based on a source one (some data will be shared between both object)
  34845. * @param creationFunction defines the function used to instanciate the new object
  34846. * @param source defines the source object
  34847. * @returns the new object
  34848. */
  34849. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34850. }
  34851. }
  34852. declare module "babylonjs/Materials/Textures/baseTexture" {
  34853. import { Observable } from "babylonjs/Misc/observable";
  34854. import { Nullable } from "babylonjs/types";
  34855. import { Scene } from "babylonjs/scene";
  34856. import { Matrix } from "babylonjs/Maths/math.vector";
  34857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34858. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34859. import { ISize } from "babylonjs/Maths/math.size";
  34860. import "babylonjs/Misc/fileTools";
  34861. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34862. /**
  34863. * Base class of all the textures in babylon.
  34864. * It groups all the common properties the materials, post process, lights... might need
  34865. * in order to make a correct use of the texture.
  34866. */
  34867. export class BaseTexture implements IAnimatable {
  34868. /**
  34869. * Default anisotropic filtering level for the application.
  34870. * It is set to 4 as a good tradeoff between perf and quality.
  34871. */
  34872. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34873. /**
  34874. * Gets or sets the unique id of the texture
  34875. */
  34876. uniqueId: number;
  34877. /**
  34878. * Define the name of the texture.
  34879. */
  34880. name: string;
  34881. /**
  34882. * Gets or sets an object used to store user defined information.
  34883. */
  34884. metadata: any;
  34885. /**
  34886. * For internal use only. Please do not use.
  34887. */
  34888. reservedDataStore: any;
  34889. private _hasAlpha;
  34890. /**
  34891. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34892. */
  34893. set hasAlpha(value: boolean);
  34894. get hasAlpha(): boolean;
  34895. /**
  34896. * Defines if the alpha value should be determined via the rgb values.
  34897. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34898. */
  34899. getAlphaFromRGB: boolean;
  34900. /**
  34901. * Intensity or strength of the texture.
  34902. * It is commonly used by materials to fine tune the intensity of the texture
  34903. */
  34904. level: number;
  34905. /**
  34906. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34907. * This is part of the texture as textures usually maps to one uv set.
  34908. */
  34909. coordinatesIndex: number;
  34910. private _coordinatesMode;
  34911. /**
  34912. * How a texture is mapped.
  34913. *
  34914. * | Value | Type | Description |
  34915. * | ----- | ----------------------------------- | ----------- |
  34916. * | 0 | EXPLICIT_MODE | |
  34917. * | 1 | SPHERICAL_MODE | |
  34918. * | 2 | PLANAR_MODE | |
  34919. * | 3 | CUBIC_MODE | |
  34920. * | 4 | PROJECTION_MODE | |
  34921. * | 5 | SKYBOX_MODE | |
  34922. * | 6 | INVCUBIC_MODE | |
  34923. * | 7 | EQUIRECTANGULAR_MODE | |
  34924. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34925. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34926. */
  34927. set coordinatesMode(value: number);
  34928. get coordinatesMode(): number;
  34929. /**
  34930. * | Value | Type | Description |
  34931. * | ----- | ------------------ | ----------- |
  34932. * | 0 | CLAMP_ADDRESSMODE | |
  34933. * | 1 | WRAP_ADDRESSMODE | |
  34934. * | 2 | MIRROR_ADDRESSMODE | |
  34935. */
  34936. wrapU: number;
  34937. /**
  34938. * | Value | Type | Description |
  34939. * | ----- | ------------------ | ----------- |
  34940. * | 0 | CLAMP_ADDRESSMODE | |
  34941. * | 1 | WRAP_ADDRESSMODE | |
  34942. * | 2 | MIRROR_ADDRESSMODE | |
  34943. */
  34944. wrapV: number;
  34945. /**
  34946. * | Value | Type | Description |
  34947. * | ----- | ------------------ | ----------- |
  34948. * | 0 | CLAMP_ADDRESSMODE | |
  34949. * | 1 | WRAP_ADDRESSMODE | |
  34950. * | 2 | MIRROR_ADDRESSMODE | |
  34951. */
  34952. wrapR: number;
  34953. /**
  34954. * With compliant hardware and browser (supporting anisotropic filtering)
  34955. * this defines the level of anisotropic filtering in the texture.
  34956. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34957. */
  34958. anisotropicFilteringLevel: number;
  34959. /**
  34960. * Define if the texture is a cube texture or if false a 2d texture.
  34961. */
  34962. get isCube(): boolean;
  34963. set isCube(value: boolean);
  34964. /**
  34965. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34966. */
  34967. get is3D(): boolean;
  34968. set is3D(value: boolean);
  34969. /**
  34970. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34971. */
  34972. get is2DArray(): boolean;
  34973. set is2DArray(value: boolean);
  34974. /**
  34975. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34976. * HDR texture are usually stored in linear space.
  34977. * This only impacts the PBR and Background materials
  34978. */
  34979. gammaSpace: boolean;
  34980. /**
  34981. * Gets or sets whether or not the texture contains RGBD data.
  34982. */
  34983. get isRGBD(): boolean;
  34984. set isRGBD(value: boolean);
  34985. /**
  34986. * Is Z inverted in the texture (useful in a cube texture).
  34987. */
  34988. invertZ: boolean;
  34989. /**
  34990. * Are mip maps generated for this texture or not.
  34991. */
  34992. get noMipmap(): boolean;
  34993. /**
  34994. * @hidden
  34995. */
  34996. lodLevelInAlpha: boolean;
  34997. /**
  34998. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34999. */
  35000. get lodGenerationOffset(): number;
  35001. set lodGenerationOffset(value: number);
  35002. /**
  35003. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35004. */
  35005. get lodGenerationScale(): number;
  35006. set lodGenerationScale(value: number);
  35007. /**
  35008. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35009. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35010. * average roughness values.
  35011. */
  35012. get linearSpecularLOD(): boolean;
  35013. set linearSpecularLOD(value: boolean);
  35014. /**
  35015. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35016. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35017. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35018. */
  35019. get irradianceTexture(): Nullable<BaseTexture>;
  35020. set irradianceTexture(value: Nullable<BaseTexture>);
  35021. /**
  35022. * Define if the texture is a render target.
  35023. */
  35024. isRenderTarget: boolean;
  35025. /**
  35026. * Define the unique id of the texture in the scene.
  35027. */
  35028. get uid(): string;
  35029. /** @hidden */
  35030. _prefiltered: boolean;
  35031. /**
  35032. * Return a string representation of the texture.
  35033. * @returns the texture as a string
  35034. */
  35035. toString(): string;
  35036. /**
  35037. * Get the class name of the texture.
  35038. * @returns "BaseTexture"
  35039. */
  35040. getClassName(): string;
  35041. /**
  35042. * Define the list of animation attached to the texture.
  35043. */
  35044. animations: import("babylonjs/Animations/animation").Animation[];
  35045. /**
  35046. * An event triggered when the texture is disposed.
  35047. */
  35048. onDisposeObservable: Observable<BaseTexture>;
  35049. private _onDisposeObserver;
  35050. /**
  35051. * Callback triggered when the texture has been disposed.
  35052. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35053. */
  35054. set onDispose(callback: () => void);
  35055. /**
  35056. * Define the current state of the loading sequence when in delayed load mode.
  35057. */
  35058. delayLoadState: number;
  35059. protected _scene: Nullable<Scene>;
  35060. protected _engine: Nullable<ThinEngine>;
  35061. /** @hidden */
  35062. _texture: Nullable<InternalTexture>;
  35063. private _uid;
  35064. /**
  35065. * Define if the texture is preventinga material to render or not.
  35066. * If not and the texture is not ready, the engine will use a default black texture instead.
  35067. */
  35068. get isBlocking(): boolean;
  35069. /**
  35070. * Instantiates a new BaseTexture.
  35071. * Base class of all the textures in babylon.
  35072. * It groups all the common properties the materials, post process, lights... might need
  35073. * in order to make a correct use of the texture.
  35074. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35075. */
  35076. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35077. /**
  35078. * Get the scene the texture belongs to.
  35079. * @returns the scene or null if undefined
  35080. */
  35081. getScene(): Nullable<Scene>;
  35082. /** @hidden */
  35083. protected _getEngine(): Nullable<ThinEngine>;
  35084. /**
  35085. * Get the texture transform matrix used to offset tile the texture for istance.
  35086. * @returns the transformation matrix
  35087. */
  35088. getTextureMatrix(): Matrix;
  35089. /**
  35090. * Get the texture reflection matrix used to rotate/transform the reflection.
  35091. * @returns the reflection matrix
  35092. */
  35093. getReflectionTextureMatrix(): Matrix;
  35094. /**
  35095. * Get the underlying lower level texture from Babylon.
  35096. * @returns the insternal texture
  35097. */
  35098. getInternalTexture(): Nullable<InternalTexture>;
  35099. /**
  35100. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35101. * @returns true if ready or not blocking
  35102. */
  35103. isReadyOrNotBlocking(): boolean;
  35104. /**
  35105. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35106. * @returns true if fully ready
  35107. */
  35108. isReady(): boolean;
  35109. private _cachedSize;
  35110. /**
  35111. * Get the size of the texture.
  35112. * @returns the texture size.
  35113. */
  35114. getSize(): ISize;
  35115. /**
  35116. * Get the base size of the texture.
  35117. * It can be different from the size if the texture has been resized for POT for instance
  35118. * @returns the base size
  35119. */
  35120. getBaseSize(): ISize;
  35121. /**
  35122. * Update the sampling mode of the texture.
  35123. * Default is Trilinear mode.
  35124. *
  35125. * | Value | Type | Description |
  35126. * | ----- | ------------------ | ----------- |
  35127. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35128. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35129. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35130. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35131. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35132. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35133. * | 7 | NEAREST_LINEAR | |
  35134. * | 8 | NEAREST_NEAREST | |
  35135. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35136. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35137. * | 11 | LINEAR_LINEAR | |
  35138. * | 12 | LINEAR_NEAREST | |
  35139. *
  35140. * > _mag_: magnification filter (close to the viewer)
  35141. * > _min_: minification filter (far from the viewer)
  35142. * > _mip_: filter used between mip map levels
  35143. *@param samplingMode Define the new sampling mode of the texture
  35144. */
  35145. updateSamplingMode(samplingMode: number): void;
  35146. /**
  35147. * Scales the texture if is `canRescale()`
  35148. * @param ratio the resize factor we want to use to rescale
  35149. */
  35150. scale(ratio: number): void;
  35151. /**
  35152. * Get if the texture can rescale.
  35153. */
  35154. get canRescale(): boolean;
  35155. /** @hidden */
  35156. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35157. /** @hidden */
  35158. _rebuild(): void;
  35159. /**
  35160. * Triggers the load sequence in delayed load mode.
  35161. */
  35162. delayLoad(): void;
  35163. /**
  35164. * Clones the texture.
  35165. * @returns the cloned texture
  35166. */
  35167. clone(): Nullable<BaseTexture>;
  35168. /**
  35169. * Get the texture underlying type (INT, FLOAT...)
  35170. */
  35171. get textureType(): number;
  35172. /**
  35173. * Get the texture underlying format (RGB, RGBA...)
  35174. */
  35175. get textureFormat(): number;
  35176. /**
  35177. * Indicates that textures need to be re-calculated for all materials
  35178. */
  35179. protected _markAllSubMeshesAsTexturesDirty(): void;
  35180. /**
  35181. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35182. * This will returns an RGBA array buffer containing either in values (0-255) or
  35183. * float values (0-1) depending of the underlying buffer type.
  35184. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35185. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35186. * @param buffer defines a user defined buffer to fill with data (can be null)
  35187. * @returns The Array buffer containing the pixels data.
  35188. */
  35189. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35190. /**
  35191. * Release and destroy the underlying lower level texture aka internalTexture.
  35192. */
  35193. releaseInternalTexture(): void;
  35194. /** @hidden */
  35195. get _lodTextureHigh(): Nullable<BaseTexture>;
  35196. /** @hidden */
  35197. get _lodTextureMid(): Nullable<BaseTexture>;
  35198. /** @hidden */
  35199. get _lodTextureLow(): Nullable<BaseTexture>;
  35200. /**
  35201. * Dispose the texture and release its associated resources.
  35202. */
  35203. dispose(): void;
  35204. /**
  35205. * Serialize the texture into a JSON representation that can be parsed later on.
  35206. * @returns the JSON representation of the texture
  35207. */
  35208. serialize(): any;
  35209. /**
  35210. * Helper function to be called back once a list of texture contains only ready textures.
  35211. * @param textures Define the list of textures to wait for
  35212. * @param callback Define the callback triggered once the entire list will be ready
  35213. */
  35214. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35215. private static _isScene;
  35216. }
  35217. }
  35218. declare module "babylonjs/Materials/effect" {
  35219. import { Observable } from "babylonjs/Misc/observable";
  35220. import { Nullable } from "babylonjs/types";
  35221. import { IDisposable } from "babylonjs/scene";
  35222. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35223. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35224. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35225. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35226. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35227. import { Engine } from "babylonjs/Engines/engine";
  35228. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35229. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35230. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35231. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35232. /**
  35233. * Options to be used when creating an effect.
  35234. */
  35235. export interface IEffectCreationOptions {
  35236. /**
  35237. * Atrributes that will be used in the shader.
  35238. */
  35239. attributes: string[];
  35240. /**
  35241. * Uniform varible names that will be set in the shader.
  35242. */
  35243. uniformsNames: string[];
  35244. /**
  35245. * Uniform buffer variable names that will be set in the shader.
  35246. */
  35247. uniformBuffersNames: string[];
  35248. /**
  35249. * Sampler texture variable names that will be set in the shader.
  35250. */
  35251. samplers: string[];
  35252. /**
  35253. * Define statements that will be set in the shader.
  35254. */
  35255. defines: any;
  35256. /**
  35257. * Possible fallbacks for this effect to improve performance when needed.
  35258. */
  35259. fallbacks: Nullable<IEffectFallbacks>;
  35260. /**
  35261. * Callback that will be called when the shader is compiled.
  35262. */
  35263. onCompiled: Nullable<(effect: Effect) => void>;
  35264. /**
  35265. * Callback that will be called if an error occurs during shader compilation.
  35266. */
  35267. onError: Nullable<(effect: Effect, errors: string) => void>;
  35268. /**
  35269. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35270. */
  35271. indexParameters?: any;
  35272. /**
  35273. * Max number of lights that can be used in the shader.
  35274. */
  35275. maxSimultaneousLights?: number;
  35276. /**
  35277. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35278. */
  35279. transformFeedbackVaryings?: Nullable<string[]>;
  35280. /**
  35281. * 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
  35282. */
  35283. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35284. /**
  35285. * Is this effect rendering to several color attachments ?
  35286. */
  35287. multiTarget?: boolean;
  35288. }
  35289. /**
  35290. * Effect containing vertex and fragment shader that can be executed on an object.
  35291. */
  35292. export class Effect implements IDisposable {
  35293. /**
  35294. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35295. */
  35296. static ShadersRepository: string;
  35297. /**
  35298. * Enable logging of the shader code when a compilation error occurs
  35299. */
  35300. static LogShaderCodeOnCompilationError: boolean;
  35301. /**
  35302. * Name of the effect.
  35303. */
  35304. name: any;
  35305. /**
  35306. * String container all the define statements that should be set on the shader.
  35307. */
  35308. defines: string;
  35309. /**
  35310. * Callback that will be called when the shader is compiled.
  35311. */
  35312. onCompiled: Nullable<(effect: Effect) => void>;
  35313. /**
  35314. * Callback that will be called if an error occurs during shader compilation.
  35315. */
  35316. onError: Nullable<(effect: Effect, errors: string) => void>;
  35317. /**
  35318. * Callback that will be called when effect is bound.
  35319. */
  35320. onBind: Nullable<(effect: Effect) => void>;
  35321. /**
  35322. * Unique ID of the effect.
  35323. */
  35324. uniqueId: number;
  35325. /**
  35326. * Observable that will be called when the shader is compiled.
  35327. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35328. */
  35329. onCompileObservable: Observable<Effect>;
  35330. /**
  35331. * Observable that will be called if an error occurs during shader compilation.
  35332. */
  35333. onErrorObservable: Observable<Effect>;
  35334. /** @hidden */
  35335. _onBindObservable: Nullable<Observable<Effect>>;
  35336. /**
  35337. * @hidden
  35338. * Specifies if the effect was previously ready
  35339. */
  35340. _wasPreviouslyReady: boolean;
  35341. /**
  35342. * Observable that will be called when effect is bound.
  35343. */
  35344. get onBindObservable(): Observable<Effect>;
  35345. /** @hidden */
  35346. _bonesComputationForcedToCPU: boolean;
  35347. /** @hidden */
  35348. _multiTarget: boolean;
  35349. private static _uniqueIdSeed;
  35350. private _engine;
  35351. private _uniformBuffersNames;
  35352. private _uniformBuffersNamesList;
  35353. private _uniformsNames;
  35354. private _samplerList;
  35355. private _samplers;
  35356. private _isReady;
  35357. private _compilationError;
  35358. private _allFallbacksProcessed;
  35359. private _attributesNames;
  35360. private _attributes;
  35361. private _attributeLocationByName;
  35362. private _uniforms;
  35363. /**
  35364. * Key for the effect.
  35365. * @hidden
  35366. */
  35367. _key: string;
  35368. private _indexParameters;
  35369. private _fallbacks;
  35370. private _vertexSourceCode;
  35371. private _fragmentSourceCode;
  35372. private _vertexSourceCodeOverride;
  35373. private _fragmentSourceCodeOverride;
  35374. private _transformFeedbackVaryings;
  35375. /**
  35376. * Compiled shader to webGL program.
  35377. * @hidden
  35378. */
  35379. _pipelineContext: Nullable<IPipelineContext>;
  35380. private _valueCache;
  35381. private static _baseCache;
  35382. /**
  35383. * Instantiates an effect.
  35384. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35385. * @param baseName Name of the effect.
  35386. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35387. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35388. * @param samplers List of sampler variables that will be passed to the shader.
  35389. * @param engine Engine to be used to render the effect
  35390. * @param defines Define statements to be added to the shader.
  35391. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35392. * @param onCompiled Callback that will be called when the shader is compiled.
  35393. * @param onError Callback that will be called if an error occurs during shader compilation.
  35394. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35395. */
  35396. 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);
  35397. private _useFinalCode;
  35398. /**
  35399. * Unique key for this effect
  35400. */
  35401. get key(): string;
  35402. /**
  35403. * If the effect has been compiled and prepared.
  35404. * @returns if the effect is compiled and prepared.
  35405. */
  35406. isReady(): boolean;
  35407. private _isReadyInternal;
  35408. /**
  35409. * The engine the effect was initialized with.
  35410. * @returns the engine.
  35411. */
  35412. getEngine(): Engine;
  35413. /**
  35414. * The pipeline context for this effect
  35415. * @returns the associated pipeline context
  35416. */
  35417. getPipelineContext(): Nullable<IPipelineContext>;
  35418. /**
  35419. * The set of names of attribute variables for the shader.
  35420. * @returns An array of attribute names.
  35421. */
  35422. getAttributesNames(): string[];
  35423. /**
  35424. * Returns the attribute at the given index.
  35425. * @param index The index of the attribute.
  35426. * @returns The location of the attribute.
  35427. */
  35428. getAttributeLocation(index: number): number;
  35429. /**
  35430. * Returns the attribute based on the name of the variable.
  35431. * @param name of the attribute to look up.
  35432. * @returns the attribute location.
  35433. */
  35434. getAttributeLocationByName(name: string): number;
  35435. /**
  35436. * The number of attributes.
  35437. * @returns the numnber of attributes.
  35438. */
  35439. getAttributesCount(): number;
  35440. /**
  35441. * Gets the index of a uniform variable.
  35442. * @param uniformName of the uniform to look up.
  35443. * @returns the index.
  35444. */
  35445. getUniformIndex(uniformName: string): number;
  35446. /**
  35447. * Returns the attribute based on the name of the variable.
  35448. * @param uniformName of the uniform to look up.
  35449. * @returns the location of the uniform.
  35450. */
  35451. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35452. /**
  35453. * Returns an array of sampler variable names
  35454. * @returns The array of sampler variable names.
  35455. */
  35456. getSamplers(): string[];
  35457. /**
  35458. * Returns an array of uniform variable names
  35459. * @returns The array of uniform variable names.
  35460. */
  35461. getUniformNames(): string[];
  35462. /**
  35463. * Returns an array of uniform buffer variable names
  35464. * @returns The array of uniform buffer variable names.
  35465. */
  35466. getUniformBuffersNames(): string[];
  35467. /**
  35468. * Returns the index parameters used to create the effect
  35469. * @returns The index parameters object
  35470. */
  35471. getIndexParameters(): any;
  35472. /**
  35473. * The error from the last compilation.
  35474. * @returns the error string.
  35475. */
  35476. getCompilationError(): string;
  35477. /**
  35478. * Gets a boolean indicating that all fallbacks were used during compilation
  35479. * @returns true if all fallbacks were used
  35480. */
  35481. allFallbacksProcessed(): boolean;
  35482. /**
  35483. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35484. * @param func The callback to be used.
  35485. */
  35486. executeWhenCompiled(func: (effect: Effect) => void): void;
  35487. private _checkIsReady;
  35488. private _loadShader;
  35489. /**
  35490. * Gets the vertex shader source code of this effect
  35491. */
  35492. get vertexSourceCode(): string;
  35493. /**
  35494. * Gets the fragment shader source code of this effect
  35495. */
  35496. get fragmentSourceCode(): string;
  35497. /**
  35498. * Recompiles the webGL program
  35499. * @param vertexSourceCode The source code for the vertex shader.
  35500. * @param fragmentSourceCode The source code for the fragment shader.
  35501. * @param onCompiled Callback called when completed.
  35502. * @param onError Callback called on error.
  35503. * @hidden
  35504. */
  35505. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35506. /**
  35507. * Prepares the effect
  35508. * @hidden
  35509. */
  35510. _prepareEffect(): void;
  35511. private _getShaderCodeAndErrorLine;
  35512. private _processCompilationErrors;
  35513. /**
  35514. * Checks if the effect is supported. (Must be called after compilation)
  35515. */
  35516. get isSupported(): boolean;
  35517. /**
  35518. * Binds a texture to the engine to be used as output of the shader.
  35519. * @param channel Name of the output variable.
  35520. * @param texture Texture to bind.
  35521. * @hidden
  35522. */
  35523. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35524. /**
  35525. * Sets a texture on the engine to be used in the shader.
  35526. * @param channel Name of the sampler variable.
  35527. * @param texture Texture to set.
  35528. */
  35529. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35530. /**
  35531. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35532. * @param channel Name of the sampler variable.
  35533. * @param texture Texture to set.
  35534. */
  35535. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35536. /**
  35537. * Sets an array of textures on the engine to be used in the shader.
  35538. * @param channel Name of the variable.
  35539. * @param textures Textures to set.
  35540. */
  35541. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35542. /**
  35543. * 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)
  35544. * @param channel Name of the sampler variable.
  35545. * @param postProcess Post process to get the input texture from.
  35546. */
  35547. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35548. /**
  35549. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35550. * 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)
  35551. * @param channel Name of the sampler variable.
  35552. * @param postProcess Post process to get the output texture from.
  35553. */
  35554. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35555. /** @hidden */
  35556. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35557. /** @hidden */
  35558. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35559. /** @hidden */
  35560. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35561. /** @hidden */
  35562. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35563. /**
  35564. * Binds a buffer to a uniform.
  35565. * @param buffer Buffer to bind.
  35566. * @param name Name of the uniform variable to bind to.
  35567. */
  35568. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35569. /**
  35570. * Binds block to a uniform.
  35571. * @param blockName Name of the block to bind.
  35572. * @param index Index to bind.
  35573. */
  35574. bindUniformBlock(blockName: string, index: number): void;
  35575. /**
  35576. * Sets an interger value on a uniform variable.
  35577. * @param uniformName Name of the variable.
  35578. * @param value Value to be set.
  35579. * @returns this effect.
  35580. */
  35581. setInt(uniformName: string, value: number): Effect;
  35582. /**
  35583. * Sets an int array on a uniform variable.
  35584. * @param uniformName Name of the variable.
  35585. * @param array array to be set.
  35586. * @returns this effect.
  35587. */
  35588. setIntArray(uniformName: string, array: Int32Array): Effect;
  35589. /**
  35590. * 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)
  35591. * @param uniformName Name of the variable.
  35592. * @param array array to be set.
  35593. * @returns this effect.
  35594. */
  35595. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35596. /**
  35597. * 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)
  35598. * @param uniformName Name of the variable.
  35599. * @param array array to be set.
  35600. * @returns this effect.
  35601. */
  35602. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35603. /**
  35604. * 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)
  35605. * @param uniformName Name of the variable.
  35606. * @param array array to be set.
  35607. * @returns this effect.
  35608. */
  35609. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35610. /**
  35611. * Sets an float array on a uniform variable.
  35612. * @param uniformName Name of the variable.
  35613. * @param array array to be set.
  35614. * @returns this effect.
  35615. */
  35616. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35617. /**
  35618. * 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)
  35619. * @param uniformName Name of the variable.
  35620. * @param array array to be set.
  35621. * @returns this effect.
  35622. */
  35623. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35624. /**
  35625. * 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)
  35626. * @param uniformName Name of the variable.
  35627. * @param array array to be set.
  35628. * @returns this effect.
  35629. */
  35630. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35631. /**
  35632. * 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)
  35633. * @param uniformName Name of the variable.
  35634. * @param array array to be set.
  35635. * @returns this effect.
  35636. */
  35637. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35638. /**
  35639. * Sets an array on a uniform variable.
  35640. * @param uniformName Name of the variable.
  35641. * @param array array to be set.
  35642. * @returns this effect.
  35643. */
  35644. setArray(uniformName: string, array: number[]): Effect;
  35645. /**
  35646. * 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)
  35647. * @param uniformName Name of the variable.
  35648. * @param array array to be set.
  35649. * @returns this effect.
  35650. */
  35651. setArray2(uniformName: string, array: number[]): Effect;
  35652. /**
  35653. * 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)
  35654. * @param uniformName Name of the variable.
  35655. * @param array array to be set.
  35656. * @returns this effect.
  35657. */
  35658. setArray3(uniformName: string, array: number[]): Effect;
  35659. /**
  35660. * 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)
  35661. * @param uniformName Name of the variable.
  35662. * @param array array to be set.
  35663. * @returns this effect.
  35664. */
  35665. setArray4(uniformName: string, array: number[]): Effect;
  35666. /**
  35667. * Sets matrices on a uniform variable.
  35668. * @param uniformName Name of the variable.
  35669. * @param matrices matrices to be set.
  35670. * @returns this effect.
  35671. */
  35672. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35673. /**
  35674. * Sets matrix on a uniform variable.
  35675. * @param uniformName Name of the variable.
  35676. * @param matrix matrix to be set.
  35677. * @returns this effect.
  35678. */
  35679. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35680. /**
  35681. * 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)
  35682. * @param uniformName Name of the variable.
  35683. * @param matrix matrix to be set.
  35684. * @returns this effect.
  35685. */
  35686. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35687. /**
  35688. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35689. * @param uniformName Name of the variable.
  35690. * @param matrix matrix to be set.
  35691. * @returns this effect.
  35692. */
  35693. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35694. /**
  35695. * Sets a float on a uniform variable.
  35696. * @param uniformName Name of the variable.
  35697. * @param value value to be set.
  35698. * @returns this effect.
  35699. */
  35700. setFloat(uniformName: string, value: number): Effect;
  35701. /**
  35702. * Sets a boolean on a uniform variable.
  35703. * @param uniformName Name of the variable.
  35704. * @param bool value to be set.
  35705. * @returns this effect.
  35706. */
  35707. setBool(uniformName: string, bool: boolean): Effect;
  35708. /**
  35709. * Sets a Vector2 on a uniform variable.
  35710. * @param uniformName Name of the variable.
  35711. * @param vector2 vector2 to be set.
  35712. * @returns this effect.
  35713. */
  35714. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35715. /**
  35716. * Sets a float2 on a uniform variable.
  35717. * @param uniformName Name of the variable.
  35718. * @param x First float in float2.
  35719. * @param y Second float in float2.
  35720. * @returns this effect.
  35721. */
  35722. setFloat2(uniformName: string, x: number, y: number): Effect;
  35723. /**
  35724. * Sets a Vector3 on a uniform variable.
  35725. * @param uniformName Name of the variable.
  35726. * @param vector3 Value to be set.
  35727. * @returns this effect.
  35728. */
  35729. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35730. /**
  35731. * Sets a float3 on a uniform variable.
  35732. * @param uniformName Name of the variable.
  35733. * @param x First float in float3.
  35734. * @param y Second float in float3.
  35735. * @param z Third float in float3.
  35736. * @returns this effect.
  35737. */
  35738. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35739. /**
  35740. * Sets a Vector4 on a uniform variable.
  35741. * @param uniformName Name of the variable.
  35742. * @param vector4 Value to be set.
  35743. * @returns this effect.
  35744. */
  35745. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35746. /**
  35747. * Sets a float4 on a uniform variable.
  35748. * @param uniformName Name of the variable.
  35749. * @param x First float in float4.
  35750. * @param y Second float in float4.
  35751. * @param z Third float in float4.
  35752. * @param w Fourth float in float4.
  35753. * @returns this effect.
  35754. */
  35755. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35756. /**
  35757. * Sets a Color3 on a uniform variable.
  35758. * @param uniformName Name of the variable.
  35759. * @param color3 Value to be set.
  35760. * @returns this effect.
  35761. */
  35762. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35763. /**
  35764. * Sets a Color4 on a uniform variable.
  35765. * @param uniformName Name of the variable.
  35766. * @param color3 Value to be set.
  35767. * @param alpha Alpha value to be set.
  35768. * @returns this effect.
  35769. */
  35770. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35771. /**
  35772. * Sets a Color4 on a uniform variable
  35773. * @param uniformName defines the name of the variable
  35774. * @param color4 defines the value to be set
  35775. * @returns this effect.
  35776. */
  35777. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35778. /** Release all associated resources */
  35779. dispose(): void;
  35780. /**
  35781. * This function will add a new shader to the shader store
  35782. * @param name the name of the shader
  35783. * @param pixelShader optional pixel shader content
  35784. * @param vertexShader optional vertex shader content
  35785. */
  35786. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35787. /**
  35788. * Store of each shader (The can be looked up using effect.key)
  35789. */
  35790. static ShadersStore: {
  35791. [key: string]: string;
  35792. };
  35793. /**
  35794. * Store of each included file for a shader (The can be looked up using effect.key)
  35795. */
  35796. static IncludesShadersStore: {
  35797. [key: string]: string;
  35798. };
  35799. /**
  35800. * Resets the cache of effects.
  35801. */
  35802. static ResetCache(): void;
  35803. }
  35804. }
  35805. declare module "babylonjs/Engines/engineCapabilities" {
  35806. /**
  35807. * Interface used to describe the capabilities of the engine relatively to the current browser
  35808. */
  35809. export interface EngineCapabilities {
  35810. /** Maximum textures units per fragment shader */
  35811. maxTexturesImageUnits: number;
  35812. /** Maximum texture units per vertex shader */
  35813. maxVertexTextureImageUnits: number;
  35814. /** Maximum textures units in the entire pipeline */
  35815. maxCombinedTexturesImageUnits: number;
  35816. /** Maximum texture size */
  35817. maxTextureSize: number;
  35818. /** Maximum texture samples */
  35819. maxSamples?: number;
  35820. /** Maximum cube texture size */
  35821. maxCubemapTextureSize: number;
  35822. /** Maximum render texture size */
  35823. maxRenderTextureSize: number;
  35824. /** Maximum number of vertex attributes */
  35825. maxVertexAttribs: number;
  35826. /** Maximum number of varyings */
  35827. maxVaryingVectors: number;
  35828. /** Maximum number of uniforms per vertex shader */
  35829. maxVertexUniformVectors: number;
  35830. /** Maximum number of uniforms per fragment shader */
  35831. maxFragmentUniformVectors: number;
  35832. /** Defines if standard derivates (dx/dy) are supported */
  35833. standardDerivatives: boolean;
  35834. /** Defines if s3tc texture compression is supported */
  35835. s3tc?: WEBGL_compressed_texture_s3tc;
  35836. /** Defines if pvrtc texture compression is supported */
  35837. pvrtc: any;
  35838. /** Defines if etc1 texture compression is supported */
  35839. etc1: any;
  35840. /** Defines if etc2 texture compression is supported */
  35841. etc2: any;
  35842. /** Defines if astc texture compression is supported */
  35843. astc: any;
  35844. /** Defines if float textures are supported */
  35845. textureFloat: boolean;
  35846. /** Defines if vertex array objects are supported */
  35847. vertexArrayObject: boolean;
  35848. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35849. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35850. /** Gets the maximum level of anisotropy supported */
  35851. maxAnisotropy: number;
  35852. /** Defines if instancing is supported */
  35853. instancedArrays: boolean;
  35854. /** Defines if 32 bits indices are supported */
  35855. uintIndices: boolean;
  35856. /** Defines if high precision shaders are supported */
  35857. highPrecisionShaderSupported: boolean;
  35858. /** Defines if depth reading in the fragment shader is supported */
  35859. fragmentDepthSupported: boolean;
  35860. /** Defines if float texture linear filtering is supported*/
  35861. textureFloatLinearFiltering: boolean;
  35862. /** Defines if rendering to float textures is supported */
  35863. textureFloatRender: boolean;
  35864. /** Defines if half float textures are supported*/
  35865. textureHalfFloat: boolean;
  35866. /** Defines if half float texture linear filtering is supported*/
  35867. textureHalfFloatLinearFiltering: boolean;
  35868. /** Defines if rendering to half float textures is supported */
  35869. textureHalfFloatRender: boolean;
  35870. /** Defines if textureLOD shader command is supported */
  35871. textureLOD: boolean;
  35872. /** Defines if draw buffers extension is supported */
  35873. drawBuffersExtension: boolean;
  35874. /** Defines if depth textures are supported */
  35875. depthTextureExtension: boolean;
  35876. /** Defines if float color buffer are supported */
  35877. colorBufferFloat: boolean;
  35878. /** Gets disjoint timer query extension (null if not supported) */
  35879. timerQuery?: EXT_disjoint_timer_query;
  35880. /** Defines if timestamp can be used with timer query */
  35881. canUseTimestampForTimerQuery: boolean;
  35882. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35883. multiview?: any;
  35884. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35885. oculusMultiview?: any;
  35886. /** Function used to let the system compiles shaders in background */
  35887. parallelShaderCompile?: {
  35888. COMPLETION_STATUS_KHR: number;
  35889. };
  35890. /** Max number of texture samples for MSAA */
  35891. maxMSAASamples: number;
  35892. /** Defines if the blend min max extension is supported */
  35893. blendMinMax: boolean;
  35894. }
  35895. }
  35896. declare module "babylonjs/States/depthCullingState" {
  35897. import { Nullable } from "babylonjs/types";
  35898. /**
  35899. * @hidden
  35900. **/
  35901. export class DepthCullingState {
  35902. private _isDepthTestDirty;
  35903. private _isDepthMaskDirty;
  35904. private _isDepthFuncDirty;
  35905. private _isCullFaceDirty;
  35906. private _isCullDirty;
  35907. private _isZOffsetDirty;
  35908. private _isFrontFaceDirty;
  35909. private _depthTest;
  35910. private _depthMask;
  35911. private _depthFunc;
  35912. private _cull;
  35913. private _cullFace;
  35914. private _zOffset;
  35915. private _frontFace;
  35916. /**
  35917. * Initializes the state.
  35918. */
  35919. constructor();
  35920. get isDirty(): boolean;
  35921. get zOffset(): number;
  35922. set zOffset(value: number);
  35923. get cullFace(): Nullable<number>;
  35924. set cullFace(value: Nullable<number>);
  35925. get cull(): Nullable<boolean>;
  35926. set cull(value: Nullable<boolean>);
  35927. get depthFunc(): Nullable<number>;
  35928. set depthFunc(value: Nullable<number>);
  35929. get depthMask(): boolean;
  35930. set depthMask(value: boolean);
  35931. get depthTest(): boolean;
  35932. set depthTest(value: boolean);
  35933. get frontFace(): Nullable<number>;
  35934. set frontFace(value: Nullable<number>);
  35935. reset(): void;
  35936. apply(gl: WebGLRenderingContext): void;
  35937. }
  35938. }
  35939. declare module "babylonjs/States/stencilState" {
  35940. /**
  35941. * @hidden
  35942. **/
  35943. export class StencilState {
  35944. /** 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 */
  35945. static readonly ALWAYS: number;
  35946. /** Passed to stencilOperation to specify that stencil value must be kept */
  35947. static readonly KEEP: number;
  35948. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35949. static readonly REPLACE: number;
  35950. private _isStencilTestDirty;
  35951. private _isStencilMaskDirty;
  35952. private _isStencilFuncDirty;
  35953. private _isStencilOpDirty;
  35954. private _stencilTest;
  35955. private _stencilMask;
  35956. private _stencilFunc;
  35957. private _stencilFuncRef;
  35958. private _stencilFuncMask;
  35959. private _stencilOpStencilFail;
  35960. private _stencilOpDepthFail;
  35961. private _stencilOpStencilDepthPass;
  35962. get isDirty(): boolean;
  35963. get stencilFunc(): number;
  35964. set stencilFunc(value: number);
  35965. get stencilFuncRef(): number;
  35966. set stencilFuncRef(value: number);
  35967. get stencilFuncMask(): number;
  35968. set stencilFuncMask(value: number);
  35969. get stencilOpStencilFail(): number;
  35970. set stencilOpStencilFail(value: number);
  35971. get stencilOpDepthFail(): number;
  35972. set stencilOpDepthFail(value: number);
  35973. get stencilOpStencilDepthPass(): number;
  35974. set stencilOpStencilDepthPass(value: number);
  35975. get stencilMask(): number;
  35976. set stencilMask(value: number);
  35977. get stencilTest(): boolean;
  35978. set stencilTest(value: boolean);
  35979. constructor();
  35980. reset(): void;
  35981. apply(gl: WebGLRenderingContext): void;
  35982. }
  35983. }
  35984. declare module "babylonjs/States/alphaCullingState" {
  35985. /**
  35986. * @hidden
  35987. **/
  35988. export class AlphaState {
  35989. private _isAlphaBlendDirty;
  35990. private _isBlendFunctionParametersDirty;
  35991. private _isBlendEquationParametersDirty;
  35992. private _isBlendConstantsDirty;
  35993. private _alphaBlend;
  35994. private _blendFunctionParameters;
  35995. private _blendEquationParameters;
  35996. private _blendConstants;
  35997. /**
  35998. * Initializes the state.
  35999. */
  36000. constructor();
  36001. get isDirty(): boolean;
  36002. get alphaBlend(): boolean;
  36003. set alphaBlend(value: boolean);
  36004. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36005. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36006. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36007. reset(): void;
  36008. apply(gl: WebGLRenderingContext): void;
  36009. }
  36010. }
  36011. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36012. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36013. /** @hidden */
  36014. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36015. attributeProcessor(attribute: string): string;
  36016. varyingProcessor(varying: string, isFragment: boolean): string;
  36017. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36018. }
  36019. }
  36020. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36021. /**
  36022. * Interface for attribute information associated with buffer instanciation
  36023. */
  36024. export interface InstancingAttributeInfo {
  36025. /**
  36026. * Name of the GLSL attribute
  36027. * if attribute index is not specified, this is used to retrieve the index from the effect
  36028. */
  36029. attributeName: string;
  36030. /**
  36031. * Index/offset of the attribute in the vertex shader
  36032. * if not specified, this will be computes from the name.
  36033. */
  36034. index?: number;
  36035. /**
  36036. * size of the attribute, 1, 2, 3 or 4
  36037. */
  36038. attributeSize: number;
  36039. /**
  36040. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36041. */
  36042. offset: number;
  36043. /**
  36044. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36045. * default to 1
  36046. */
  36047. divisor?: number;
  36048. /**
  36049. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36050. * default is FLOAT
  36051. */
  36052. attributeType?: number;
  36053. /**
  36054. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36055. */
  36056. normalized?: boolean;
  36057. }
  36058. }
  36059. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36061. import { Nullable } from "babylonjs/types";
  36062. module "babylonjs/Engines/thinEngine" {
  36063. interface ThinEngine {
  36064. /**
  36065. * Update a video texture
  36066. * @param texture defines the texture to update
  36067. * @param video defines the video element to use
  36068. * @param invertY defines if data must be stored with Y axis inverted
  36069. */
  36070. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36071. }
  36072. }
  36073. }
  36074. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36075. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36076. import { Nullable } from "babylonjs/types";
  36077. module "babylonjs/Engines/thinEngine" {
  36078. interface ThinEngine {
  36079. /**
  36080. * Creates a dynamic texture
  36081. * @param width defines the width of the texture
  36082. * @param height defines the height of the texture
  36083. * @param generateMipMaps defines if the engine should generate the mip levels
  36084. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36085. * @returns the dynamic texture inside an InternalTexture
  36086. */
  36087. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36088. /**
  36089. * Update the content of a dynamic texture
  36090. * @param texture defines the texture to update
  36091. * @param canvas defines the canvas containing the source
  36092. * @param invertY defines if data must be stored with Y axis inverted
  36093. * @param premulAlpha defines if alpha is stored as premultiplied
  36094. * @param format defines the format of the data
  36095. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36096. */
  36097. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36098. }
  36099. }
  36100. }
  36101. declare module "babylonjs/Materials/Textures/videoTexture" {
  36102. import { Observable } from "babylonjs/Misc/observable";
  36103. import { Nullable } from "babylonjs/types";
  36104. import { Scene } from "babylonjs/scene";
  36105. import { Texture } from "babylonjs/Materials/Textures/texture";
  36106. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36107. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36108. /**
  36109. * Settings for finer control over video usage
  36110. */
  36111. export interface VideoTextureSettings {
  36112. /**
  36113. * Applies `autoplay` to video, if specified
  36114. */
  36115. autoPlay?: boolean;
  36116. /**
  36117. * Applies `loop` to video, if specified
  36118. */
  36119. loop?: boolean;
  36120. /**
  36121. * Automatically updates internal texture from video at every frame in the render loop
  36122. */
  36123. autoUpdateTexture: boolean;
  36124. /**
  36125. * Image src displayed during the video loading or until the user interacts with the video.
  36126. */
  36127. poster?: string;
  36128. }
  36129. /**
  36130. * If you want to display a video in your scene, this is the special texture for that.
  36131. * This special texture works similar to other textures, with the exception of a few parameters.
  36132. * @see https://doc.babylonjs.com/how_to/video_texture
  36133. */
  36134. export class VideoTexture extends Texture {
  36135. /**
  36136. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36137. */
  36138. readonly autoUpdateTexture: boolean;
  36139. /**
  36140. * The video instance used by the texture internally
  36141. */
  36142. readonly video: HTMLVideoElement;
  36143. private _onUserActionRequestedObservable;
  36144. /**
  36145. * Event triggerd when a dom action is required by the user to play the video.
  36146. * This happens due to recent changes in browser policies preventing video to auto start.
  36147. */
  36148. get onUserActionRequestedObservable(): Observable<Texture>;
  36149. private _generateMipMaps;
  36150. private _stillImageCaptured;
  36151. private _displayingPosterTexture;
  36152. private _settings;
  36153. private _createInternalTextureOnEvent;
  36154. private _frameId;
  36155. private _currentSrc;
  36156. /**
  36157. * Creates a video texture.
  36158. * If you want to display a video in your scene, this is the special texture for that.
  36159. * This special texture works similar to other textures, with the exception of a few parameters.
  36160. * @see https://doc.babylonjs.com/how_to/video_texture
  36161. * @param name optional name, will detect from video source, if not defined
  36162. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36163. * @param scene is obviously the current scene.
  36164. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36165. * @param invertY is false by default but can be used to invert video on Y axis
  36166. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36167. * @param settings allows finer control over video usage
  36168. */
  36169. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36170. private _getName;
  36171. private _getVideo;
  36172. private _createInternalTexture;
  36173. private reset;
  36174. /**
  36175. * @hidden Internal method to initiate `update`.
  36176. */
  36177. _rebuild(): void;
  36178. /**
  36179. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36180. */
  36181. update(): void;
  36182. /**
  36183. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36184. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36185. */
  36186. updateTexture(isVisible: boolean): void;
  36187. protected _updateInternalTexture: () => void;
  36188. /**
  36189. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36190. * @param url New url.
  36191. */
  36192. updateURL(url: string): void;
  36193. /**
  36194. * Clones the texture.
  36195. * @returns the cloned texture
  36196. */
  36197. clone(): VideoTexture;
  36198. /**
  36199. * Dispose the texture and release its associated resources.
  36200. */
  36201. dispose(): void;
  36202. /**
  36203. * Creates a video texture straight from a stream.
  36204. * @param scene Define the scene the texture should be created in
  36205. * @param stream Define the stream the texture should be created from
  36206. * @returns The created video texture as a promise
  36207. */
  36208. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36209. /**
  36210. * Creates a video texture straight from your WebCam video feed.
  36211. * @param scene Define the scene the texture should be created in
  36212. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36213. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36214. * @returns The created video texture as a promise
  36215. */
  36216. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36217. minWidth: number;
  36218. maxWidth: number;
  36219. minHeight: number;
  36220. maxHeight: number;
  36221. deviceId: string;
  36222. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36223. /**
  36224. * Creates a video texture straight from your WebCam video feed.
  36225. * @param scene Define the scene the texture should be created in
  36226. * @param onReady Define a callback to triggered once the texture will be ready
  36227. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36228. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36229. */
  36230. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36231. minWidth: number;
  36232. maxWidth: number;
  36233. minHeight: number;
  36234. maxHeight: number;
  36235. deviceId: string;
  36236. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36237. }
  36238. }
  36239. declare module "babylonjs/Engines/thinEngine" {
  36240. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36241. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36242. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36243. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36244. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36245. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36246. import { Observable } from "babylonjs/Misc/observable";
  36247. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36248. import { StencilState } from "babylonjs/States/stencilState";
  36249. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36250. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36251. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36252. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36253. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36254. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36255. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36256. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36257. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36259. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36260. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36261. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36262. import { WebRequest } from "babylonjs/Misc/webRequest";
  36263. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36264. /**
  36265. * Defines the interface used by objects working like Scene
  36266. * @hidden
  36267. */
  36268. export interface ISceneLike {
  36269. _addPendingData(data: any): void;
  36270. _removePendingData(data: any): void;
  36271. offlineProvider: IOfflineProvider;
  36272. }
  36273. /** Interface defining initialization parameters for Engine class */
  36274. export interface EngineOptions extends WebGLContextAttributes {
  36275. /**
  36276. * Defines if the engine should no exceed a specified device ratio
  36277. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36278. */
  36279. limitDeviceRatio?: number;
  36280. /**
  36281. * Defines if webvr should be enabled automatically
  36282. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36283. */
  36284. autoEnableWebVR?: boolean;
  36285. /**
  36286. * Defines if webgl2 should be turned off even if supported
  36287. * @see https://doc.babylonjs.com/features/webgl2
  36288. */
  36289. disableWebGL2Support?: boolean;
  36290. /**
  36291. * Defines if webaudio should be initialized as well
  36292. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36293. */
  36294. audioEngine?: boolean;
  36295. /**
  36296. * Defines if animations should run using a deterministic lock step
  36297. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36298. */
  36299. deterministicLockstep?: boolean;
  36300. /** Defines the maximum steps to use with deterministic lock step mode */
  36301. lockstepMaxSteps?: number;
  36302. /** Defines the seconds between each deterministic lock step */
  36303. timeStep?: number;
  36304. /**
  36305. * Defines that engine should ignore context lost events
  36306. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36307. */
  36308. doNotHandleContextLost?: boolean;
  36309. /**
  36310. * Defines that engine should ignore modifying touch action attribute and style
  36311. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36312. */
  36313. doNotHandleTouchAction?: boolean;
  36314. /**
  36315. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36316. */
  36317. useHighPrecisionFloats?: boolean;
  36318. /**
  36319. * Make the canvas XR Compatible for XR sessions
  36320. */
  36321. xrCompatible?: boolean;
  36322. /**
  36323. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36324. */
  36325. useHighPrecisionMatrix?: boolean;
  36326. }
  36327. /**
  36328. * The base engine class (root of all engines)
  36329. */
  36330. export class ThinEngine {
  36331. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36332. static ExceptionList: ({
  36333. key: string;
  36334. capture: string;
  36335. captureConstraint: number;
  36336. targets: string[];
  36337. } | {
  36338. key: string;
  36339. capture: null;
  36340. captureConstraint: null;
  36341. targets: string[];
  36342. })[];
  36343. /** @hidden */
  36344. static _TextureLoaders: IInternalTextureLoader[];
  36345. /**
  36346. * Returns the current npm package of the sdk
  36347. */
  36348. static get NpmPackage(): string;
  36349. /**
  36350. * Returns the current version of the framework
  36351. */
  36352. static get Version(): string;
  36353. /**
  36354. * Returns a string describing the current engine
  36355. */
  36356. get description(): string;
  36357. /**
  36358. * Gets or sets the epsilon value used by collision engine
  36359. */
  36360. static CollisionsEpsilon: number;
  36361. /**
  36362. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36363. */
  36364. static get ShadersRepository(): string;
  36365. static set ShadersRepository(value: string);
  36366. /** @hidden */
  36367. _shaderProcessor: IShaderProcessor;
  36368. /**
  36369. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36370. */
  36371. forcePOTTextures: boolean;
  36372. /**
  36373. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36374. */
  36375. isFullscreen: boolean;
  36376. /**
  36377. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36378. */
  36379. cullBackFaces: boolean;
  36380. /**
  36381. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36382. */
  36383. renderEvenInBackground: boolean;
  36384. /**
  36385. * Gets or sets a boolean indicating that cache can be kept between frames
  36386. */
  36387. preventCacheWipeBetweenFrames: boolean;
  36388. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36389. validateShaderPrograms: boolean;
  36390. /**
  36391. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36392. * This can provide greater z depth for distant objects.
  36393. */
  36394. useReverseDepthBuffer: boolean;
  36395. /**
  36396. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36397. */
  36398. disableUniformBuffers: boolean;
  36399. /** @hidden */
  36400. _uniformBuffers: UniformBuffer[];
  36401. /**
  36402. * Gets a boolean indicating that the engine supports uniform buffers
  36403. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36404. */
  36405. get supportsUniformBuffers(): boolean;
  36406. /** @hidden */
  36407. _gl: WebGLRenderingContext;
  36408. /** @hidden */
  36409. _webGLVersion: number;
  36410. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36411. protected _windowIsBackground: boolean;
  36412. protected _creationOptions: EngineOptions;
  36413. protected _highPrecisionShadersAllowed: boolean;
  36414. /** @hidden */
  36415. get _shouldUseHighPrecisionShader(): boolean;
  36416. /**
  36417. * Gets a boolean indicating that only power of 2 textures are supported
  36418. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36419. */
  36420. get needPOTTextures(): boolean;
  36421. /** @hidden */
  36422. _badOS: boolean;
  36423. /** @hidden */
  36424. _badDesktopOS: boolean;
  36425. private _hardwareScalingLevel;
  36426. /** @hidden */
  36427. _caps: EngineCapabilities;
  36428. private _isStencilEnable;
  36429. private _glVersion;
  36430. private _glRenderer;
  36431. private _glVendor;
  36432. /** @hidden */
  36433. _videoTextureSupported: boolean;
  36434. protected _renderingQueueLaunched: boolean;
  36435. protected _activeRenderLoops: (() => void)[];
  36436. /**
  36437. * Observable signaled when a context lost event is raised
  36438. */
  36439. onContextLostObservable: Observable<ThinEngine>;
  36440. /**
  36441. * Observable signaled when a context restored event is raised
  36442. */
  36443. onContextRestoredObservable: Observable<ThinEngine>;
  36444. private _onContextLost;
  36445. private _onContextRestored;
  36446. protected _contextWasLost: boolean;
  36447. /** @hidden */
  36448. _doNotHandleContextLost: boolean;
  36449. /**
  36450. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36451. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36452. */
  36453. get doNotHandleContextLost(): boolean;
  36454. set doNotHandleContextLost(value: boolean);
  36455. /**
  36456. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36457. */
  36458. disableVertexArrayObjects: boolean;
  36459. /** @hidden */
  36460. protected _colorWrite: boolean;
  36461. /** @hidden */
  36462. protected _colorWriteChanged: boolean;
  36463. /** @hidden */
  36464. protected _depthCullingState: DepthCullingState;
  36465. /** @hidden */
  36466. protected _stencilState: StencilState;
  36467. /** @hidden */
  36468. _alphaState: AlphaState;
  36469. /** @hidden */
  36470. _alphaMode: number;
  36471. /** @hidden */
  36472. _alphaEquation: number;
  36473. /** @hidden */
  36474. _internalTexturesCache: InternalTexture[];
  36475. /** @hidden */
  36476. protected _activeChannel: number;
  36477. private _currentTextureChannel;
  36478. /** @hidden */
  36479. protected _boundTexturesCache: {
  36480. [key: string]: Nullable<InternalTexture>;
  36481. };
  36482. /** @hidden */
  36483. protected _currentEffect: Nullable<Effect>;
  36484. /** @hidden */
  36485. protected _currentProgram: Nullable<WebGLProgram>;
  36486. private _compiledEffects;
  36487. private _vertexAttribArraysEnabled;
  36488. /** @hidden */
  36489. protected _cachedViewport: Nullable<IViewportLike>;
  36490. private _cachedVertexArrayObject;
  36491. /** @hidden */
  36492. protected _cachedVertexBuffers: any;
  36493. /** @hidden */
  36494. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36495. /** @hidden */
  36496. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36497. /** @hidden */
  36498. _currentRenderTarget: Nullable<InternalTexture>;
  36499. private _uintIndicesCurrentlySet;
  36500. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36501. /** @hidden */
  36502. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36503. /** @hidden */
  36504. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36505. private _currentBufferPointers;
  36506. private _currentInstanceLocations;
  36507. private _currentInstanceBuffers;
  36508. private _textureUnits;
  36509. /** @hidden */
  36510. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36511. /** @hidden */
  36512. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36513. /** @hidden */
  36514. _boundRenderFunction: any;
  36515. private _vaoRecordInProgress;
  36516. private _mustWipeVertexAttributes;
  36517. private _emptyTexture;
  36518. private _emptyCubeTexture;
  36519. private _emptyTexture3D;
  36520. private _emptyTexture2DArray;
  36521. /** @hidden */
  36522. _frameHandler: number;
  36523. private _nextFreeTextureSlots;
  36524. private _maxSimultaneousTextures;
  36525. private _activeRequests;
  36526. /** @hidden */
  36527. _transformTextureUrl: Nullable<(url: string) => string>;
  36528. protected get _supportsHardwareTextureRescaling(): boolean;
  36529. private _framebufferDimensionsObject;
  36530. /**
  36531. * sets the object from which width and height will be taken from when getting render width and height
  36532. * Will fallback to the gl object
  36533. * @param dimensions the framebuffer width and height that will be used.
  36534. */
  36535. set framebufferDimensionsObject(dimensions: Nullable<{
  36536. framebufferWidth: number;
  36537. framebufferHeight: number;
  36538. }>);
  36539. /**
  36540. * Gets the current viewport
  36541. */
  36542. get currentViewport(): Nullable<IViewportLike>;
  36543. /**
  36544. * Gets the default empty texture
  36545. */
  36546. get emptyTexture(): InternalTexture;
  36547. /**
  36548. * Gets the default empty 3D texture
  36549. */
  36550. get emptyTexture3D(): InternalTexture;
  36551. /**
  36552. * Gets the default empty 2D array texture
  36553. */
  36554. get emptyTexture2DArray(): InternalTexture;
  36555. /**
  36556. * Gets the default empty cube texture
  36557. */
  36558. get emptyCubeTexture(): InternalTexture;
  36559. /**
  36560. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36561. */
  36562. readonly premultipliedAlpha: boolean;
  36563. /**
  36564. * Observable event triggered before each texture is initialized
  36565. */
  36566. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36567. /**
  36568. * Creates a new engine
  36569. * @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
  36570. * @param antialias defines enable antialiasing (default: false)
  36571. * @param options defines further options to be sent to the getContext() function
  36572. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36573. */
  36574. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36575. private _rebuildInternalTextures;
  36576. private _rebuildEffects;
  36577. /**
  36578. * Gets a boolean indicating if all created effects are ready
  36579. * @returns true if all effects are ready
  36580. */
  36581. areAllEffectsReady(): boolean;
  36582. protected _rebuildBuffers(): void;
  36583. protected _initGLContext(): void;
  36584. /**
  36585. * Gets version of the current webGL context
  36586. */
  36587. get webGLVersion(): number;
  36588. /**
  36589. * Gets a string idenfifying the name of the class
  36590. * @returns "Engine" string
  36591. */
  36592. getClassName(): string;
  36593. /**
  36594. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36595. */
  36596. get isStencilEnable(): boolean;
  36597. /** @hidden */
  36598. _prepareWorkingCanvas(): void;
  36599. /**
  36600. * Reset the texture cache to empty state
  36601. */
  36602. resetTextureCache(): void;
  36603. /**
  36604. * Gets an object containing information about the current webGL context
  36605. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36606. */
  36607. getGlInfo(): {
  36608. vendor: string;
  36609. renderer: string;
  36610. version: string;
  36611. };
  36612. /**
  36613. * Defines the hardware scaling level.
  36614. * By default the hardware scaling level is computed from the window device ratio.
  36615. * 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.
  36616. * @param level defines the level to use
  36617. */
  36618. setHardwareScalingLevel(level: number): void;
  36619. /**
  36620. * Gets the current hardware scaling level.
  36621. * By default the hardware scaling level is computed from the window device ratio.
  36622. * 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.
  36623. * @returns a number indicating the current hardware scaling level
  36624. */
  36625. getHardwareScalingLevel(): number;
  36626. /**
  36627. * Gets the list of loaded textures
  36628. * @returns an array containing all loaded textures
  36629. */
  36630. getLoadedTexturesCache(): InternalTexture[];
  36631. /**
  36632. * Gets the object containing all engine capabilities
  36633. * @returns the EngineCapabilities object
  36634. */
  36635. getCaps(): EngineCapabilities;
  36636. /**
  36637. * stop executing a render loop function and remove it from the execution array
  36638. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36639. */
  36640. stopRenderLoop(renderFunction?: () => void): void;
  36641. /** @hidden */
  36642. _renderLoop(): void;
  36643. /**
  36644. * Gets the HTML canvas attached with the current webGL context
  36645. * @returns a HTML canvas
  36646. */
  36647. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36648. /**
  36649. * Gets host window
  36650. * @returns the host window object
  36651. */
  36652. getHostWindow(): Nullable<Window>;
  36653. /**
  36654. * Gets the current render width
  36655. * @param useScreen defines if screen size must be used (or the current render target if any)
  36656. * @returns a number defining the current render width
  36657. */
  36658. getRenderWidth(useScreen?: boolean): number;
  36659. /**
  36660. * Gets the current render height
  36661. * @param useScreen defines if screen size must be used (or the current render target if any)
  36662. * @returns a number defining the current render height
  36663. */
  36664. getRenderHeight(useScreen?: boolean): number;
  36665. /**
  36666. * Can be used to override the current requestAnimationFrame requester.
  36667. * @hidden
  36668. */
  36669. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36670. /**
  36671. * Register and execute a render loop. The engine can have more than one render function
  36672. * @param renderFunction defines the function to continuously execute
  36673. */
  36674. runRenderLoop(renderFunction: () => void): void;
  36675. /**
  36676. * Clear the current render buffer or the current render target (if any is set up)
  36677. * @param color defines the color to use
  36678. * @param backBuffer defines if the back buffer must be cleared
  36679. * @param depth defines if the depth buffer must be cleared
  36680. * @param stencil defines if the stencil buffer must be cleared
  36681. */
  36682. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36683. private _viewportCached;
  36684. /** @hidden */
  36685. _viewport(x: number, y: number, width: number, height: number): void;
  36686. /**
  36687. * Set the WebGL's viewport
  36688. * @param viewport defines the viewport element to be used
  36689. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36690. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36691. */
  36692. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36693. /**
  36694. * Begin a new frame
  36695. */
  36696. beginFrame(): void;
  36697. /**
  36698. * Enf the current frame
  36699. */
  36700. endFrame(): void;
  36701. /**
  36702. * Resize the view according to the canvas' size
  36703. */
  36704. resize(): void;
  36705. /**
  36706. * Force a specific size of the canvas
  36707. * @param width defines the new canvas' width
  36708. * @param height defines the new canvas' height
  36709. * @returns true if the size was changed
  36710. */
  36711. setSize(width: number, height: number): boolean;
  36712. /**
  36713. * Binds the frame buffer to the specified texture.
  36714. * @param texture The texture to render to or null for the default canvas
  36715. * @param faceIndex The face of the texture to render to in case of cube texture
  36716. * @param requiredWidth The width of the target to render to
  36717. * @param requiredHeight The height of the target to render to
  36718. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36719. * @param lodLevel defines the lod level to bind to the frame buffer
  36720. * @param layer defines the 2d array index to bind to frame buffer to
  36721. */
  36722. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36723. /** @hidden */
  36724. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36725. /**
  36726. * Unbind the current render target texture from the webGL context
  36727. * @param texture defines the render target texture to unbind
  36728. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36729. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36730. */
  36731. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36732. /**
  36733. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36734. */
  36735. flushFramebuffer(): void;
  36736. /**
  36737. * Unbind the current render target and bind the default framebuffer
  36738. */
  36739. restoreDefaultFramebuffer(): void;
  36740. /** @hidden */
  36741. protected _resetVertexBufferBinding(): void;
  36742. /**
  36743. * Creates a vertex buffer
  36744. * @param data the data for the vertex buffer
  36745. * @returns the new WebGL static buffer
  36746. */
  36747. createVertexBuffer(data: DataArray): DataBuffer;
  36748. private _createVertexBuffer;
  36749. /**
  36750. * Creates a dynamic vertex buffer
  36751. * @param data the data for the dynamic vertex buffer
  36752. * @returns the new WebGL dynamic buffer
  36753. */
  36754. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36755. protected _resetIndexBufferBinding(): void;
  36756. /**
  36757. * Creates a new index buffer
  36758. * @param indices defines the content of the index buffer
  36759. * @param updatable defines if the index buffer must be updatable
  36760. * @returns a new webGL buffer
  36761. */
  36762. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36763. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36764. /**
  36765. * Bind a webGL buffer to the webGL context
  36766. * @param buffer defines the buffer to bind
  36767. */
  36768. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36769. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36770. private bindBuffer;
  36771. /**
  36772. * update the bound buffer with the given data
  36773. * @param data defines the data to update
  36774. */
  36775. updateArrayBuffer(data: Float32Array): void;
  36776. private _vertexAttribPointer;
  36777. /** @hidden */
  36778. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36779. private _bindVertexBuffersAttributes;
  36780. /**
  36781. * Records a vertex array object
  36782. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36783. * @param vertexBuffers defines the list of vertex buffers to store
  36784. * @param indexBuffer defines the index buffer to store
  36785. * @param effect defines the effect to store
  36786. * @returns the new vertex array object
  36787. */
  36788. recordVertexArrayObject(vertexBuffers: {
  36789. [key: string]: VertexBuffer;
  36790. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36791. /**
  36792. * Bind a specific vertex array object
  36793. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36794. * @param vertexArrayObject defines the vertex array object to bind
  36795. * @param indexBuffer defines the index buffer to bind
  36796. */
  36797. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36798. /**
  36799. * Bind webGl buffers directly to the webGL context
  36800. * @param vertexBuffer defines the vertex buffer to bind
  36801. * @param indexBuffer defines the index buffer to bind
  36802. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36803. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36804. * @param effect defines the effect associated with the vertex buffer
  36805. */
  36806. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36807. private _unbindVertexArrayObject;
  36808. /**
  36809. * Bind a list of vertex buffers to the webGL context
  36810. * @param vertexBuffers defines the list of vertex buffers to bind
  36811. * @param indexBuffer defines the index buffer to bind
  36812. * @param effect defines the effect associated with the vertex buffers
  36813. */
  36814. bindBuffers(vertexBuffers: {
  36815. [key: string]: Nullable<VertexBuffer>;
  36816. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36817. /**
  36818. * Unbind all instance attributes
  36819. */
  36820. unbindInstanceAttributes(): void;
  36821. /**
  36822. * Release and free the memory of a vertex array object
  36823. * @param vao defines the vertex array object to delete
  36824. */
  36825. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36826. /** @hidden */
  36827. _releaseBuffer(buffer: DataBuffer): boolean;
  36828. protected _deleteBuffer(buffer: DataBuffer): void;
  36829. /**
  36830. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36831. * @param instancesBuffer defines the webGL buffer to update and bind
  36832. * @param data defines the data to store in the buffer
  36833. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36834. */
  36835. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36836. /**
  36837. * Bind the content of a webGL buffer used with instantiation
  36838. * @param instancesBuffer defines the webGL buffer to bind
  36839. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36840. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36841. */
  36842. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36843. /**
  36844. * Disable the instance attribute corresponding to the name in parameter
  36845. * @param name defines the name of the attribute to disable
  36846. */
  36847. disableInstanceAttributeByName(name: string): void;
  36848. /**
  36849. * Disable the instance attribute corresponding to the location in parameter
  36850. * @param attributeLocation defines the attribute location of the attribute to disable
  36851. */
  36852. disableInstanceAttribute(attributeLocation: number): void;
  36853. /**
  36854. * Disable the attribute corresponding to the location in parameter
  36855. * @param attributeLocation defines the attribute location of the attribute to disable
  36856. */
  36857. disableAttributeByIndex(attributeLocation: number): void;
  36858. /**
  36859. * Send a draw order
  36860. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36861. * @param indexStart defines the starting index
  36862. * @param indexCount defines the number of index to draw
  36863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36864. */
  36865. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36866. /**
  36867. * Draw a list of points
  36868. * @param verticesStart defines the index of first vertex to draw
  36869. * @param verticesCount defines the count of vertices to draw
  36870. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36871. */
  36872. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36873. /**
  36874. * Draw a list of unindexed primitives
  36875. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36876. * @param verticesStart defines the index of first vertex to draw
  36877. * @param verticesCount defines the count of vertices to draw
  36878. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36879. */
  36880. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36881. /**
  36882. * Draw a list of indexed primitives
  36883. * @param fillMode defines the primitive to use
  36884. * @param indexStart defines the starting index
  36885. * @param indexCount defines the number of index to draw
  36886. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36887. */
  36888. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36889. /**
  36890. * Draw a list of unindexed primitives
  36891. * @param fillMode defines the primitive to use
  36892. * @param verticesStart defines the index of first vertex to draw
  36893. * @param verticesCount defines the count of vertices to draw
  36894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36895. */
  36896. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36897. private _drawMode;
  36898. /** @hidden */
  36899. protected _reportDrawCall(): void;
  36900. /** @hidden */
  36901. _releaseEffect(effect: Effect): void;
  36902. /** @hidden */
  36903. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36904. /**
  36905. * Create a new effect (used to store vertex/fragment shaders)
  36906. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36907. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36908. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36909. * @param samplers defines an array of string used to represent textures
  36910. * @param defines defines the string containing the defines to use to compile the shaders
  36911. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36912. * @param onCompiled defines a function to call when the effect creation is successful
  36913. * @param onError defines a function to call when the effect creation has failed
  36914. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36915. * @returns the new Effect
  36916. */
  36917. 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;
  36918. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36919. private _compileShader;
  36920. private _compileRawShader;
  36921. /** @hidden */
  36922. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36923. /**
  36924. * Directly creates a webGL program
  36925. * @param pipelineContext defines the pipeline context to attach to
  36926. * @param vertexCode defines the vertex shader code to use
  36927. * @param fragmentCode defines the fragment shader code to use
  36928. * @param context defines the webGL context to use (if not set, the current one will be used)
  36929. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36930. * @returns the new webGL program
  36931. */
  36932. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36933. /**
  36934. * Creates a webGL program
  36935. * @param pipelineContext defines the pipeline context to attach to
  36936. * @param vertexCode defines the vertex shader code to use
  36937. * @param fragmentCode defines the fragment shader code to use
  36938. * @param defines defines the string containing the defines to use to compile the shaders
  36939. * @param context defines the webGL context to use (if not set, the current one will be used)
  36940. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36941. * @returns the new webGL program
  36942. */
  36943. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36944. /**
  36945. * Creates a new pipeline context
  36946. * @returns the new pipeline
  36947. */
  36948. createPipelineContext(): IPipelineContext;
  36949. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36950. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36951. /** @hidden */
  36952. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36953. /** @hidden */
  36954. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36955. /** @hidden */
  36956. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36957. /**
  36958. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36959. * @param pipelineContext defines the pipeline context to use
  36960. * @param uniformsNames defines the list of uniform names
  36961. * @returns an array of webGL uniform locations
  36962. */
  36963. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36964. /**
  36965. * Gets the lsit of active attributes for a given webGL program
  36966. * @param pipelineContext defines the pipeline context to use
  36967. * @param attributesNames defines the list of attribute names to get
  36968. * @returns an array of indices indicating the offset of each attribute
  36969. */
  36970. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36971. /**
  36972. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36973. * @param effect defines the effect to activate
  36974. */
  36975. enableEffect(effect: Nullable<Effect>): void;
  36976. /**
  36977. * Set the value of an uniform to a number (int)
  36978. * @param uniform defines the webGL uniform location where to store the value
  36979. * @param value defines the int number to store
  36980. */
  36981. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36982. /**
  36983. * Set the value of an uniform to an array of int32
  36984. * @param uniform defines the webGL uniform location where to store the value
  36985. * @param array defines the array of int32 to store
  36986. */
  36987. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36988. /**
  36989. * Set the value of an uniform to an array of int32 (stored as vec2)
  36990. * @param uniform defines the webGL uniform location where to store the value
  36991. * @param array defines the array of int32 to store
  36992. */
  36993. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36994. /**
  36995. * Set the value of an uniform to an array of int32 (stored as vec3)
  36996. * @param uniform defines the webGL uniform location where to store the value
  36997. * @param array defines the array of int32 to store
  36998. */
  36999. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37000. /**
  37001. * Set the value of an uniform to an array of int32 (stored as vec4)
  37002. * @param uniform defines the webGL uniform location where to store the value
  37003. * @param array defines the array of int32 to store
  37004. */
  37005. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37006. /**
  37007. * Set the value of an uniform to an array of number
  37008. * @param uniform defines the webGL uniform location where to store the value
  37009. * @param array defines the array of number to store
  37010. */
  37011. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37012. /**
  37013. * Set the value of an uniform to an array of number (stored as vec2)
  37014. * @param uniform defines the webGL uniform location where to store the value
  37015. * @param array defines the array of number to store
  37016. */
  37017. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37018. /**
  37019. * Set the value of an uniform to an array of number (stored as vec3)
  37020. * @param uniform defines the webGL uniform location where to store the value
  37021. * @param array defines the array of number to store
  37022. */
  37023. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37024. /**
  37025. * Set the value of an uniform to an array of number (stored as vec4)
  37026. * @param uniform defines the webGL uniform location where to store the value
  37027. * @param array defines the array of number to store
  37028. */
  37029. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37030. /**
  37031. * Set the value of an uniform to an array of float32 (stored as matrices)
  37032. * @param uniform defines the webGL uniform location where to store the value
  37033. * @param matrices defines the array of float32 to store
  37034. */
  37035. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37036. /**
  37037. * Set the value of an uniform to a matrix (3x3)
  37038. * @param uniform defines the webGL uniform location where to store the value
  37039. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37040. */
  37041. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37042. /**
  37043. * Set the value of an uniform to a matrix (2x2)
  37044. * @param uniform defines the webGL uniform location where to store the value
  37045. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37046. */
  37047. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37048. /**
  37049. * Set the value of an uniform to a number (float)
  37050. * @param uniform defines the webGL uniform location where to store the value
  37051. * @param value defines the float number to store
  37052. */
  37053. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37054. /**
  37055. * Set the value of an uniform to a vec2
  37056. * @param uniform defines the webGL uniform location where to store the value
  37057. * @param x defines the 1st component of the value
  37058. * @param y defines the 2nd component of the value
  37059. */
  37060. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37061. /**
  37062. * Set the value of an uniform to a vec3
  37063. * @param uniform defines the webGL uniform location where to store the value
  37064. * @param x defines the 1st component of the value
  37065. * @param y defines the 2nd component of the value
  37066. * @param z defines the 3rd component of the value
  37067. */
  37068. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37069. /**
  37070. * Set the value of an uniform to a vec4
  37071. * @param uniform defines the webGL uniform location where to store the value
  37072. * @param x defines the 1st component of the value
  37073. * @param y defines the 2nd component of the value
  37074. * @param z defines the 3rd component of the value
  37075. * @param w defines the 4th component of the value
  37076. */
  37077. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37078. /**
  37079. * Apply all cached states (depth, culling, stencil and alpha)
  37080. */
  37081. applyStates(): void;
  37082. /**
  37083. * Enable or disable color writing
  37084. * @param enable defines the state to set
  37085. */
  37086. setColorWrite(enable: boolean): void;
  37087. /**
  37088. * Gets a boolean indicating if color writing is enabled
  37089. * @returns the current color writing state
  37090. */
  37091. getColorWrite(): boolean;
  37092. /**
  37093. * Gets the depth culling state manager
  37094. */
  37095. get depthCullingState(): DepthCullingState;
  37096. /**
  37097. * Gets the alpha state manager
  37098. */
  37099. get alphaState(): AlphaState;
  37100. /**
  37101. * Gets the stencil state manager
  37102. */
  37103. get stencilState(): StencilState;
  37104. /**
  37105. * Clears the list of texture accessible through engine.
  37106. * This can help preventing texture load conflict due to name collision.
  37107. */
  37108. clearInternalTexturesCache(): void;
  37109. /**
  37110. * Force the entire cache to be cleared
  37111. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37112. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37113. */
  37114. wipeCaches(bruteForce?: boolean): void;
  37115. /** @hidden */
  37116. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37117. min: number;
  37118. mag: number;
  37119. };
  37120. /** @hidden */
  37121. _createTexture(): WebGLTexture;
  37122. /**
  37123. * Usually called from Texture.ts.
  37124. * Passed information to create a WebGLTexture
  37125. * @param url defines a value which contains one of the following:
  37126. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37127. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37128. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37129. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37130. * @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)
  37131. * @param scene needed for loading to the correct scene
  37132. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37133. * @param onLoad optional callback to be called upon successful completion
  37134. * @param onError optional callback to be called upon failure
  37135. * @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
  37136. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37137. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37138. * @param forcedExtension defines the extension to use to pick the right loader
  37139. * @param mimeType defines an optional mime type
  37140. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37141. */
  37142. 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;
  37143. /**
  37144. * Loads an image as an HTMLImageElement.
  37145. * @param input url string, ArrayBuffer, or Blob to load
  37146. * @param onLoad callback called when the image successfully loads
  37147. * @param onError callback called when the image fails to load
  37148. * @param offlineProvider offline provider for caching
  37149. * @param mimeType optional mime type
  37150. * @returns the HTMLImageElement of the loaded image
  37151. * @hidden
  37152. */
  37153. 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>;
  37154. /**
  37155. * @hidden
  37156. */
  37157. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37158. private _unpackFlipYCached;
  37159. /**
  37160. * In case you are sharing the context with other applications, it might
  37161. * be interested to not cache the unpack flip y state to ensure a consistent
  37162. * value would be set.
  37163. */
  37164. enableUnpackFlipYCached: boolean;
  37165. /** @hidden */
  37166. _unpackFlipY(value: boolean): void;
  37167. /** @hidden */
  37168. _getUnpackAlignement(): number;
  37169. private _getTextureTarget;
  37170. /**
  37171. * Update the sampling mode of a given texture
  37172. * @param samplingMode defines the required sampling mode
  37173. * @param texture defines the texture to update
  37174. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37175. */
  37176. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37177. /**
  37178. * Update the sampling mode of a given texture
  37179. * @param texture defines the texture to update
  37180. * @param wrapU defines the texture wrap mode of the u coordinates
  37181. * @param wrapV defines the texture wrap mode of the v coordinates
  37182. * @param wrapR defines the texture wrap mode of the r coordinates
  37183. */
  37184. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37185. /** @hidden */
  37186. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37187. width: number;
  37188. height: number;
  37189. layers?: number;
  37190. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37191. /** @hidden */
  37192. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37193. /** @hidden */
  37194. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37195. /**
  37196. * Update a portion of an internal texture
  37197. * @param texture defines the texture to update
  37198. * @param imageData defines the data to store into the texture
  37199. * @param xOffset defines the x coordinates of the update rectangle
  37200. * @param yOffset defines the y coordinates of the update rectangle
  37201. * @param width defines the width of the update rectangle
  37202. * @param height defines the height of the update rectangle
  37203. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37204. * @param lod defines the lod level to update (0 by default)
  37205. */
  37206. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37207. /** @hidden */
  37208. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37209. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37210. private _prepareWebGLTexture;
  37211. /** @hidden */
  37212. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37213. private _getDepthStencilBuffer;
  37214. /** @hidden */
  37215. _releaseFramebufferObjects(texture: InternalTexture): void;
  37216. /** @hidden */
  37217. _releaseTexture(texture: InternalTexture): void;
  37218. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37219. protected _setProgram(program: WebGLProgram): void;
  37220. protected _boundUniforms: {
  37221. [key: number]: WebGLUniformLocation;
  37222. };
  37223. /**
  37224. * Binds an effect to the webGL context
  37225. * @param effect defines the effect to bind
  37226. */
  37227. bindSamplers(effect: Effect): void;
  37228. private _activateCurrentTexture;
  37229. /** @hidden */
  37230. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37231. /** @hidden */
  37232. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37233. /**
  37234. * Unbind all textures from the webGL context
  37235. */
  37236. unbindAllTextures(): void;
  37237. /**
  37238. * Sets a texture to the according uniform.
  37239. * @param channel The texture channel
  37240. * @param uniform The uniform to set
  37241. * @param texture The texture to apply
  37242. */
  37243. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37244. private _bindSamplerUniformToChannel;
  37245. private _getTextureWrapMode;
  37246. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37247. /**
  37248. * Sets an array of texture to the webGL context
  37249. * @param channel defines the channel where the texture array must be set
  37250. * @param uniform defines the associated uniform location
  37251. * @param textures defines the array of textures to bind
  37252. */
  37253. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37254. /** @hidden */
  37255. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37256. private _setTextureParameterFloat;
  37257. private _setTextureParameterInteger;
  37258. /**
  37259. * Unbind all vertex attributes from the webGL context
  37260. */
  37261. unbindAllAttributes(): void;
  37262. /**
  37263. * 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
  37264. */
  37265. releaseEffects(): void;
  37266. /**
  37267. * Dispose and release all associated resources
  37268. */
  37269. dispose(): void;
  37270. /**
  37271. * Attach a new callback raised when context lost event is fired
  37272. * @param callback defines the callback to call
  37273. */
  37274. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37275. /**
  37276. * Attach a new callback raised when context restored event is fired
  37277. * @param callback defines the callback to call
  37278. */
  37279. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37280. /**
  37281. * Get the current error code of the webGL context
  37282. * @returns the error code
  37283. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37284. */
  37285. getError(): number;
  37286. private _canRenderToFloatFramebuffer;
  37287. private _canRenderToHalfFloatFramebuffer;
  37288. private _canRenderToFramebuffer;
  37289. /** @hidden */
  37290. _getWebGLTextureType(type: number): number;
  37291. /** @hidden */
  37292. _getInternalFormat(format: number): number;
  37293. /** @hidden */
  37294. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37295. /** @hidden */
  37296. _getRGBAMultiSampleBufferFormat(type: number): number;
  37297. /** @hidden */
  37298. _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;
  37299. /**
  37300. * Loads a file from a url
  37301. * @param url url to load
  37302. * @param onSuccess callback called when the file successfully loads
  37303. * @param onProgress callback called while file is loading (if the server supports this mode)
  37304. * @param offlineProvider defines the offline provider for caching
  37305. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37306. * @param onError callback called when the file fails to load
  37307. * @returns a file request object
  37308. * @hidden
  37309. */
  37310. 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;
  37311. /**
  37312. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37313. * @param x defines the x coordinate of the rectangle where pixels must be read
  37314. * @param y defines the y coordinate of the rectangle where pixels must be read
  37315. * @param width defines the width of the rectangle where pixels must be read
  37316. * @param height defines the height of the rectangle where pixels must be read
  37317. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37318. * @returns a Uint8Array containing RGBA colors
  37319. */
  37320. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37321. private static _isSupported;
  37322. /**
  37323. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37324. * @returns true if the engine can be created
  37325. * @ignorenaming
  37326. */
  37327. static isSupported(): boolean;
  37328. /**
  37329. * Find the next highest power of two.
  37330. * @param x Number to start search from.
  37331. * @return Next highest power of two.
  37332. */
  37333. static CeilingPOT(x: number): number;
  37334. /**
  37335. * Find the next lowest power of two.
  37336. * @param x Number to start search from.
  37337. * @return Next lowest power of two.
  37338. */
  37339. static FloorPOT(x: number): number;
  37340. /**
  37341. * Find the nearest power of two.
  37342. * @param x Number to start search from.
  37343. * @return Next nearest power of two.
  37344. */
  37345. static NearestPOT(x: number): number;
  37346. /**
  37347. * Get the closest exponent of two
  37348. * @param value defines the value to approximate
  37349. * @param max defines the maximum value to return
  37350. * @param mode defines how to define the closest value
  37351. * @returns closest exponent of two of the given value
  37352. */
  37353. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37354. /**
  37355. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37356. * @param func - the function to be called
  37357. * @param requester - the object that will request the next frame. Falls back to window.
  37358. * @returns frame number
  37359. */
  37360. static QueueNewFrame(func: () => void, requester?: any): number;
  37361. /**
  37362. * Gets host document
  37363. * @returns the host document object
  37364. */
  37365. getHostDocument(): Nullable<Document>;
  37366. }
  37367. }
  37368. declare module "babylonjs/Maths/sphericalPolynomial" {
  37369. import { Vector3 } from "babylonjs/Maths/math.vector";
  37370. import { Color3 } from "babylonjs/Maths/math.color";
  37371. /**
  37372. * Class representing spherical harmonics coefficients to the 3rd degree
  37373. */
  37374. export class SphericalHarmonics {
  37375. /**
  37376. * Defines whether or not the harmonics have been prescaled for rendering.
  37377. */
  37378. preScaled: boolean;
  37379. /**
  37380. * The l0,0 coefficients of the spherical harmonics
  37381. */
  37382. l00: Vector3;
  37383. /**
  37384. * The l1,-1 coefficients of the spherical harmonics
  37385. */
  37386. l1_1: Vector3;
  37387. /**
  37388. * The l1,0 coefficients of the spherical harmonics
  37389. */
  37390. l10: Vector3;
  37391. /**
  37392. * The l1,1 coefficients of the spherical harmonics
  37393. */
  37394. l11: Vector3;
  37395. /**
  37396. * The l2,-2 coefficients of the spherical harmonics
  37397. */
  37398. l2_2: Vector3;
  37399. /**
  37400. * The l2,-1 coefficients of the spherical harmonics
  37401. */
  37402. l2_1: Vector3;
  37403. /**
  37404. * The l2,0 coefficients of the spherical harmonics
  37405. */
  37406. l20: Vector3;
  37407. /**
  37408. * The l2,1 coefficients of the spherical harmonics
  37409. */
  37410. l21: Vector3;
  37411. /**
  37412. * The l2,2 coefficients of the spherical harmonics
  37413. */
  37414. l22: Vector3;
  37415. /**
  37416. * Adds a light to the spherical harmonics
  37417. * @param direction the direction of the light
  37418. * @param color the color of the light
  37419. * @param deltaSolidAngle the delta solid angle of the light
  37420. */
  37421. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37422. /**
  37423. * Scales the spherical harmonics by the given amount
  37424. * @param scale the amount to scale
  37425. */
  37426. scaleInPlace(scale: number): void;
  37427. /**
  37428. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37429. *
  37430. * ```
  37431. * E_lm = A_l * L_lm
  37432. * ```
  37433. *
  37434. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37435. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37436. * the scaling factors are given in equation 9.
  37437. */
  37438. convertIncidentRadianceToIrradiance(): void;
  37439. /**
  37440. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37441. *
  37442. * ```
  37443. * L = (1/pi) * E * rho
  37444. * ```
  37445. *
  37446. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37447. */
  37448. convertIrradianceToLambertianRadiance(): void;
  37449. /**
  37450. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37451. * required operations at run time.
  37452. *
  37453. * This is simply done by scaling back the SH with Ylm constants parameter.
  37454. * The trigonometric part being applied by the shader at run time.
  37455. */
  37456. preScaleForRendering(): void;
  37457. /**
  37458. * Constructs a spherical harmonics from an array.
  37459. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37460. * @returns the spherical harmonics
  37461. */
  37462. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37463. /**
  37464. * Gets the spherical harmonics from polynomial
  37465. * @param polynomial the spherical polynomial
  37466. * @returns the spherical harmonics
  37467. */
  37468. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37469. }
  37470. /**
  37471. * Class representing spherical polynomial coefficients to the 3rd degree
  37472. */
  37473. export class SphericalPolynomial {
  37474. private _harmonics;
  37475. /**
  37476. * The spherical harmonics used to create the polynomials.
  37477. */
  37478. get preScaledHarmonics(): SphericalHarmonics;
  37479. /**
  37480. * The x coefficients of the spherical polynomial
  37481. */
  37482. x: Vector3;
  37483. /**
  37484. * The y coefficients of the spherical polynomial
  37485. */
  37486. y: Vector3;
  37487. /**
  37488. * The z coefficients of the spherical polynomial
  37489. */
  37490. z: Vector3;
  37491. /**
  37492. * The xx coefficients of the spherical polynomial
  37493. */
  37494. xx: Vector3;
  37495. /**
  37496. * The yy coefficients of the spherical polynomial
  37497. */
  37498. yy: Vector3;
  37499. /**
  37500. * The zz coefficients of the spherical polynomial
  37501. */
  37502. zz: Vector3;
  37503. /**
  37504. * The xy coefficients of the spherical polynomial
  37505. */
  37506. xy: Vector3;
  37507. /**
  37508. * The yz coefficients of the spherical polynomial
  37509. */
  37510. yz: Vector3;
  37511. /**
  37512. * The zx coefficients of the spherical polynomial
  37513. */
  37514. zx: Vector3;
  37515. /**
  37516. * Adds an ambient color to the spherical polynomial
  37517. * @param color the color to add
  37518. */
  37519. addAmbient(color: Color3): void;
  37520. /**
  37521. * Scales the spherical polynomial by the given amount
  37522. * @param scale the amount to scale
  37523. */
  37524. scaleInPlace(scale: number): void;
  37525. /**
  37526. * Gets the spherical polynomial from harmonics
  37527. * @param harmonics the spherical harmonics
  37528. * @returns the spherical polynomial
  37529. */
  37530. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37531. /**
  37532. * Constructs a spherical polynomial from an array.
  37533. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37534. * @returns the spherical polynomial
  37535. */
  37536. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37537. }
  37538. }
  37539. declare module "babylonjs/Materials/Textures/internalTexture" {
  37540. import { Observable } from "babylonjs/Misc/observable";
  37541. import { Nullable, int } from "babylonjs/types";
  37542. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37543. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37544. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37545. /**
  37546. * Defines the source of the internal texture
  37547. */
  37548. export enum InternalTextureSource {
  37549. /**
  37550. * The source of the texture data is unknown
  37551. */
  37552. Unknown = 0,
  37553. /**
  37554. * Texture data comes from an URL
  37555. */
  37556. Url = 1,
  37557. /**
  37558. * Texture data is only used for temporary storage
  37559. */
  37560. Temp = 2,
  37561. /**
  37562. * Texture data comes from raw data (ArrayBuffer)
  37563. */
  37564. Raw = 3,
  37565. /**
  37566. * Texture content is dynamic (video or dynamic texture)
  37567. */
  37568. Dynamic = 4,
  37569. /**
  37570. * Texture content is generated by rendering to it
  37571. */
  37572. RenderTarget = 5,
  37573. /**
  37574. * Texture content is part of a multi render target process
  37575. */
  37576. MultiRenderTarget = 6,
  37577. /**
  37578. * Texture data comes from a cube data file
  37579. */
  37580. Cube = 7,
  37581. /**
  37582. * Texture data comes from a raw cube data
  37583. */
  37584. CubeRaw = 8,
  37585. /**
  37586. * Texture data come from a prefiltered cube data file
  37587. */
  37588. CubePrefiltered = 9,
  37589. /**
  37590. * Texture content is raw 3D data
  37591. */
  37592. Raw3D = 10,
  37593. /**
  37594. * Texture content is raw 2D array data
  37595. */
  37596. Raw2DArray = 11,
  37597. /**
  37598. * Texture content is a depth texture
  37599. */
  37600. Depth = 12,
  37601. /**
  37602. * Texture data comes from a raw cube data encoded with RGBD
  37603. */
  37604. CubeRawRGBD = 13
  37605. }
  37606. /**
  37607. * Class used to store data associated with WebGL texture data for the engine
  37608. * This class should not be used directly
  37609. */
  37610. export class InternalTexture {
  37611. /** @hidden */
  37612. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37613. /**
  37614. * Defines if the texture is ready
  37615. */
  37616. isReady: boolean;
  37617. /**
  37618. * Defines if the texture is a cube texture
  37619. */
  37620. isCube: boolean;
  37621. /**
  37622. * Defines if the texture contains 3D data
  37623. */
  37624. is3D: boolean;
  37625. /**
  37626. * Defines if the texture contains 2D array data
  37627. */
  37628. is2DArray: boolean;
  37629. /**
  37630. * Defines if the texture contains multiview data
  37631. */
  37632. isMultiview: boolean;
  37633. /**
  37634. * Gets the URL used to load this texture
  37635. */
  37636. url: string;
  37637. /**
  37638. * Gets the sampling mode of the texture
  37639. */
  37640. samplingMode: number;
  37641. /**
  37642. * Gets a boolean indicating if the texture needs mipmaps generation
  37643. */
  37644. generateMipMaps: boolean;
  37645. /**
  37646. * Gets the number of samples used by the texture (WebGL2+ only)
  37647. */
  37648. samples: number;
  37649. /**
  37650. * Gets the type of the texture (int, float...)
  37651. */
  37652. type: number;
  37653. /**
  37654. * Gets the format of the texture (RGB, RGBA...)
  37655. */
  37656. format: number;
  37657. /**
  37658. * Observable called when the texture is loaded
  37659. */
  37660. onLoadedObservable: Observable<InternalTexture>;
  37661. /**
  37662. * Gets the width of the texture
  37663. */
  37664. width: number;
  37665. /**
  37666. * Gets the height of the texture
  37667. */
  37668. height: number;
  37669. /**
  37670. * Gets the depth of the texture
  37671. */
  37672. depth: number;
  37673. /**
  37674. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37675. */
  37676. baseWidth: number;
  37677. /**
  37678. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37679. */
  37680. baseHeight: number;
  37681. /**
  37682. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37683. */
  37684. baseDepth: number;
  37685. /**
  37686. * Gets a boolean indicating if the texture is inverted on Y axis
  37687. */
  37688. invertY: boolean;
  37689. /** @hidden */
  37690. _invertVScale: boolean;
  37691. /** @hidden */
  37692. _associatedChannel: number;
  37693. /** @hidden */
  37694. _source: InternalTextureSource;
  37695. /** @hidden */
  37696. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37697. /** @hidden */
  37698. _bufferView: Nullable<ArrayBufferView>;
  37699. /** @hidden */
  37700. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37701. /** @hidden */
  37702. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37703. /** @hidden */
  37704. _size: number;
  37705. /** @hidden */
  37706. _extension: string;
  37707. /** @hidden */
  37708. _files: Nullable<string[]>;
  37709. /** @hidden */
  37710. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37711. /** @hidden */
  37712. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37713. /** @hidden */
  37714. _framebuffer: Nullable<WebGLFramebuffer>;
  37715. /** @hidden */
  37716. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37717. /** @hidden */
  37718. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37719. /** @hidden */
  37720. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37721. /** @hidden */
  37722. _attachments: Nullable<number[]>;
  37723. /** @hidden */
  37724. _textureArray: Nullable<InternalTexture[]>;
  37725. /** @hidden */
  37726. _cachedCoordinatesMode: Nullable<number>;
  37727. /** @hidden */
  37728. _cachedWrapU: Nullable<number>;
  37729. /** @hidden */
  37730. _cachedWrapV: Nullable<number>;
  37731. /** @hidden */
  37732. _cachedWrapR: Nullable<number>;
  37733. /** @hidden */
  37734. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37735. /** @hidden */
  37736. _isDisabled: boolean;
  37737. /** @hidden */
  37738. _compression: Nullable<string>;
  37739. /** @hidden */
  37740. _generateStencilBuffer: boolean;
  37741. /** @hidden */
  37742. _generateDepthBuffer: boolean;
  37743. /** @hidden */
  37744. _comparisonFunction: number;
  37745. /** @hidden */
  37746. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37747. /** @hidden */
  37748. _lodGenerationScale: number;
  37749. /** @hidden */
  37750. _lodGenerationOffset: number;
  37751. /** @hidden */
  37752. _depthStencilTexture: Nullable<InternalTexture>;
  37753. /** @hidden */
  37754. _colorTextureArray: Nullable<WebGLTexture>;
  37755. /** @hidden */
  37756. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37757. /** @hidden */
  37758. _lodTextureHigh: Nullable<BaseTexture>;
  37759. /** @hidden */
  37760. _lodTextureMid: Nullable<BaseTexture>;
  37761. /** @hidden */
  37762. _lodTextureLow: Nullable<BaseTexture>;
  37763. /** @hidden */
  37764. _isRGBD: boolean;
  37765. /** @hidden */
  37766. _linearSpecularLOD: boolean;
  37767. /** @hidden */
  37768. _irradianceTexture: Nullable<BaseTexture>;
  37769. /** @hidden */
  37770. _webGLTexture: Nullable<WebGLTexture>;
  37771. /** @hidden */
  37772. _references: number;
  37773. private _engine;
  37774. /**
  37775. * Gets the Engine the texture belongs to.
  37776. * @returns The babylon engine
  37777. */
  37778. getEngine(): ThinEngine;
  37779. /**
  37780. * Gets the data source type of the texture
  37781. */
  37782. get source(): InternalTextureSource;
  37783. /**
  37784. * Creates a new InternalTexture
  37785. * @param engine defines the engine to use
  37786. * @param source defines the type of data that will be used
  37787. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37788. */
  37789. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37790. /**
  37791. * Increments the number of references (ie. the number of Texture that point to it)
  37792. */
  37793. incrementReferences(): void;
  37794. /**
  37795. * Change the size of the texture (not the size of the content)
  37796. * @param width defines the new width
  37797. * @param height defines the new height
  37798. * @param depth defines the new depth (1 by default)
  37799. */
  37800. updateSize(width: int, height: int, depth?: int): void;
  37801. /** @hidden */
  37802. _rebuild(): void;
  37803. /** @hidden */
  37804. _swapAndDie(target: InternalTexture): void;
  37805. /**
  37806. * Dispose the current allocated resources
  37807. */
  37808. dispose(): void;
  37809. }
  37810. }
  37811. declare module "babylonjs/Audio/analyser" {
  37812. import { Scene } from "babylonjs/scene";
  37813. /**
  37814. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37815. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37816. */
  37817. export class Analyser {
  37818. /**
  37819. * Gets or sets the smoothing
  37820. * @ignorenaming
  37821. */
  37822. SMOOTHING: number;
  37823. /**
  37824. * Gets or sets the FFT table size
  37825. * @ignorenaming
  37826. */
  37827. FFT_SIZE: number;
  37828. /**
  37829. * Gets or sets the bar graph amplitude
  37830. * @ignorenaming
  37831. */
  37832. BARGRAPHAMPLITUDE: number;
  37833. /**
  37834. * Gets or sets the position of the debug canvas
  37835. * @ignorenaming
  37836. */
  37837. DEBUGCANVASPOS: {
  37838. x: number;
  37839. y: number;
  37840. };
  37841. /**
  37842. * Gets or sets the debug canvas size
  37843. * @ignorenaming
  37844. */
  37845. DEBUGCANVASSIZE: {
  37846. width: number;
  37847. height: number;
  37848. };
  37849. private _byteFreqs;
  37850. private _byteTime;
  37851. private _floatFreqs;
  37852. private _webAudioAnalyser;
  37853. private _debugCanvas;
  37854. private _debugCanvasContext;
  37855. private _scene;
  37856. private _registerFunc;
  37857. private _audioEngine;
  37858. /**
  37859. * Creates a new analyser
  37860. * @param scene defines hosting scene
  37861. */
  37862. constructor(scene: Scene);
  37863. /**
  37864. * Get the number of data values you will have to play with for the visualization
  37865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37866. * @returns a number
  37867. */
  37868. getFrequencyBinCount(): number;
  37869. /**
  37870. * Gets the current frequency data as a byte array
  37871. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37872. * @returns a Uint8Array
  37873. */
  37874. getByteFrequencyData(): Uint8Array;
  37875. /**
  37876. * Gets the current waveform as a byte array
  37877. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37878. * @returns a Uint8Array
  37879. */
  37880. getByteTimeDomainData(): Uint8Array;
  37881. /**
  37882. * Gets the current frequency data as a float array
  37883. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37884. * @returns a Float32Array
  37885. */
  37886. getFloatFrequencyData(): Float32Array;
  37887. /**
  37888. * Renders the debug canvas
  37889. */
  37890. drawDebugCanvas(): void;
  37891. /**
  37892. * Stops rendering the debug canvas and removes it
  37893. */
  37894. stopDebugCanvas(): void;
  37895. /**
  37896. * Connects two audio nodes
  37897. * @param inputAudioNode defines first node to connect
  37898. * @param outputAudioNode defines second node to connect
  37899. */
  37900. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37901. /**
  37902. * Releases all associated resources
  37903. */
  37904. dispose(): void;
  37905. }
  37906. }
  37907. declare module "babylonjs/Audio/audioEngine" {
  37908. import { IDisposable } from "babylonjs/scene";
  37909. import { Analyser } from "babylonjs/Audio/analyser";
  37910. import { Nullable } from "babylonjs/types";
  37911. import { Observable } from "babylonjs/Misc/observable";
  37912. /**
  37913. * This represents an audio engine and it is responsible
  37914. * to play, synchronize and analyse sounds throughout the application.
  37915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37916. */
  37917. export interface IAudioEngine extends IDisposable {
  37918. /**
  37919. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37920. */
  37921. readonly canUseWebAudio: boolean;
  37922. /**
  37923. * Gets the current AudioContext if available.
  37924. */
  37925. readonly audioContext: Nullable<AudioContext>;
  37926. /**
  37927. * The master gain node defines the global audio volume of your audio engine.
  37928. */
  37929. readonly masterGain: GainNode;
  37930. /**
  37931. * Gets whether or not mp3 are supported by your browser.
  37932. */
  37933. readonly isMP3supported: boolean;
  37934. /**
  37935. * Gets whether or not ogg are supported by your browser.
  37936. */
  37937. readonly isOGGsupported: boolean;
  37938. /**
  37939. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37940. * @ignoreNaming
  37941. */
  37942. WarnedWebAudioUnsupported: boolean;
  37943. /**
  37944. * Defines if the audio engine relies on a custom unlocked button.
  37945. * In this case, the embedded button will not be displayed.
  37946. */
  37947. useCustomUnlockedButton: boolean;
  37948. /**
  37949. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37950. */
  37951. readonly unlocked: boolean;
  37952. /**
  37953. * Event raised when audio has been unlocked on the browser.
  37954. */
  37955. onAudioUnlockedObservable: Observable<AudioEngine>;
  37956. /**
  37957. * Event raised when audio has been locked on the browser.
  37958. */
  37959. onAudioLockedObservable: Observable<AudioEngine>;
  37960. /**
  37961. * Flags the audio engine in Locked state.
  37962. * This happens due to new browser policies preventing audio to autoplay.
  37963. */
  37964. lock(): void;
  37965. /**
  37966. * Unlocks the audio engine once a user action has been done on the dom.
  37967. * This is helpful to resume play once browser policies have been satisfied.
  37968. */
  37969. unlock(): void;
  37970. /**
  37971. * Gets the global volume sets on the master gain.
  37972. * @returns the global volume if set or -1 otherwise
  37973. */
  37974. getGlobalVolume(): number;
  37975. /**
  37976. * Sets the global volume of your experience (sets on the master gain).
  37977. * @param newVolume Defines the new global volume of the application
  37978. */
  37979. setGlobalVolume(newVolume: number): void;
  37980. /**
  37981. * Connect the audio engine to an audio analyser allowing some amazing
  37982. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37983. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37984. * @param analyser The analyser to connect to the engine
  37985. */
  37986. connectToAnalyser(analyser: Analyser): void;
  37987. }
  37988. /**
  37989. * This represents the default audio engine used in babylon.
  37990. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37991. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37992. */
  37993. export class AudioEngine implements IAudioEngine {
  37994. private _audioContext;
  37995. private _audioContextInitialized;
  37996. private _muteButton;
  37997. private _hostElement;
  37998. /**
  37999. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38000. */
  38001. canUseWebAudio: boolean;
  38002. /**
  38003. * The master gain node defines the global audio volume of your audio engine.
  38004. */
  38005. masterGain: GainNode;
  38006. /**
  38007. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38008. * @ignoreNaming
  38009. */
  38010. WarnedWebAudioUnsupported: boolean;
  38011. /**
  38012. * Gets whether or not mp3 are supported by your browser.
  38013. */
  38014. isMP3supported: boolean;
  38015. /**
  38016. * Gets whether or not ogg are supported by your browser.
  38017. */
  38018. isOGGsupported: boolean;
  38019. /**
  38020. * Gets whether audio has been unlocked on the device.
  38021. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38022. * a user interaction has happened.
  38023. */
  38024. unlocked: boolean;
  38025. /**
  38026. * Defines if the audio engine relies on a custom unlocked button.
  38027. * In this case, the embedded button will not be displayed.
  38028. */
  38029. useCustomUnlockedButton: boolean;
  38030. /**
  38031. * Event raised when audio has been unlocked on the browser.
  38032. */
  38033. onAudioUnlockedObservable: Observable<AudioEngine>;
  38034. /**
  38035. * Event raised when audio has been locked on the browser.
  38036. */
  38037. onAudioLockedObservable: Observable<AudioEngine>;
  38038. /**
  38039. * Gets the current AudioContext if available.
  38040. */
  38041. get audioContext(): Nullable<AudioContext>;
  38042. private _connectedAnalyser;
  38043. /**
  38044. * Instantiates a new audio engine.
  38045. *
  38046. * There should be only one per page as some browsers restrict the number
  38047. * of audio contexts you can create.
  38048. * @param hostElement defines the host element where to display the mute icon if necessary
  38049. */
  38050. constructor(hostElement?: Nullable<HTMLElement>);
  38051. /**
  38052. * Flags the audio engine in Locked state.
  38053. * This happens due to new browser policies preventing audio to autoplay.
  38054. */
  38055. lock(): void;
  38056. /**
  38057. * Unlocks the audio engine once a user action has been done on the dom.
  38058. * This is helpful to resume play once browser policies have been satisfied.
  38059. */
  38060. unlock(): void;
  38061. private _resumeAudioContext;
  38062. private _initializeAudioContext;
  38063. private _tryToRun;
  38064. private _triggerRunningState;
  38065. private _triggerSuspendedState;
  38066. private _displayMuteButton;
  38067. private _moveButtonToTopLeft;
  38068. private _onResize;
  38069. private _hideMuteButton;
  38070. /**
  38071. * Destroy and release the resources associated with the audio ccontext.
  38072. */
  38073. dispose(): void;
  38074. /**
  38075. * Gets the global volume sets on the master gain.
  38076. * @returns the global volume if set or -1 otherwise
  38077. */
  38078. getGlobalVolume(): number;
  38079. /**
  38080. * Sets the global volume of your experience (sets on the master gain).
  38081. * @param newVolume Defines the new global volume of the application
  38082. */
  38083. setGlobalVolume(newVolume: number): void;
  38084. /**
  38085. * Connect the audio engine to an audio analyser allowing some amazing
  38086. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38087. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38088. * @param analyser The analyser to connect to the engine
  38089. */
  38090. connectToAnalyser(analyser: Analyser): void;
  38091. }
  38092. }
  38093. declare module "babylonjs/Loading/loadingScreen" {
  38094. /**
  38095. * Interface used to present a loading screen while loading a scene
  38096. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38097. */
  38098. export interface ILoadingScreen {
  38099. /**
  38100. * Function called to display the loading screen
  38101. */
  38102. displayLoadingUI: () => void;
  38103. /**
  38104. * Function called to hide the loading screen
  38105. */
  38106. hideLoadingUI: () => void;
  38107. /**
  38108. * Gets or sets the color to use for the background
  38109. */
  38110. loadingUIBackgroundColor: string;
  38111. /**
  38112. * Gets or sets the text to display while loading
  38113. */
  38114. loadingUIText: string;
  38115. }
  38116. /**
  38117. * Class used for the default loading screen
  38118. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38119. */
  38120. export class DefaultLoadingScreen implements ILoadingScreen {
  38121. private _renderingCanvas;
  38122. private _loadingText;
  38123. private _loadingDivBackgroundColor;
  38124. private _loadingDiv;
  38125. private _loadingTextDiv;
  38126. /** Gets or sets the logo url to use for the default loading screen */
  38127. static DefaultLogoUrl: string;
  38128. /** Gets or sets the spinner url to use for the default loading screen */
  38129. static DefaultSpinnerUrl: string;
  38130. /**
  38131. * Creates a new default loading screen
  38132. * @param _renderingCanvas defines the canvas used to render the scene
  38133. * @param _loadingText defines the default text to display
  38134. * @param _loadingDivBackgroundColor defines the default background color
  38135. */
  38136. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38137. /**
  38138. * Function called to display the loading screen
  38139. */
  38140. displayLoadingUI(): void;
  38141. /**
  38142. * Function called to hide the loading screen
  38143. */
  38144. hideLoadingUI(): void;
  38145. /**
  38146. * Gets or sets the text to display while loading
  38147. */
  38148. set loadingUIText(text: string);
  38149. get loadingUIText(): string;
  38150. /**
  38151. * Gets or sets the color to use for the background
  38152. */
  38153. get loadingUIBackgroundColor(): string;
  38154. set loadingUIBackgroundColor(color: string);
  38155. private _resizeLoadingUI;
  38156. }
  38157. }
  38158. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38159. /**
  38160. * Interface for any object that can request an animation frame
  38161. */
  38162. export interface ICustomAnimationFrameRequester {
  38163. /**
  38164. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38165. */
  38166. renderFunction?: Function;
  38167. /**
  38168. * Called to request the next frame to render to
  38169. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38170. */
  38171. requestAnimationFrame: Function;
  38172. /**
  38173. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38174. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38175. */
  38176. requestID?: number;
  38177. }
  38178. }
  38179. declare module "babylonjs/Misc/performanceMonitor" {
  38180. /**
  38181. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38182. */
  38183. export class PerformanceMonitor {
  38184. private _enabled;
  38185. private _rollingFrameTime;
  38186. private _lastFrameTimeMs;
  38187. /**
  38188. * constructor
  38189. * @param frameSampleSize The number of samples required to saturate the sliding window
  38190. */
  38191. constructor(frameSampleSize?: number);
  38192. /**
  38193. * Samples current frame
  38194. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38195. */
  38196. sampleFrame(timeMs?: number): void;
  38197. /**
  38198. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38199. */
  38200. get averageFrameTime(): number;
  38201. /**
  38202. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38203. */
  38204. get averageFrameTimeVariance(): number;
  38205. /**
  38206. * Returns the frame time of the most recent frame
  38207. */
  38208. get instantaneousFrameTime(): number;
  38209. /**
  38210. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38211. */
  38212. get averageFPS(): number;
  38213. /**
  38214. * Returns the average framerate in frames per second using the most recent frame time
  38215. */
  38216. get instantaneousFPS(): number;
  38217. /**
  38218. * Returns true if enough samples have been taken to completely fill the sliding window
  38219. */
  38220. get isSaturated(): boolean;
  38221. /**
  38222. * Enables contributions to the sliding window sample set
  38223. */
  38224. enable(): void;
  38225. /**
  38226. * Disables contributions to the sliding window sample set
  38227. * Samples will not be interpolated over the disabled period
  38228. */
  38229. disable(): void;
  38230. /**
  38231. * Returns true if sampling is enabled
  38232. */
  38233. get isEnabled(): boolean;
  38234. /**
  38235. * Resets performance monitor
  38236. */
  38237. reset(): void;
  38238. }
  38239. /**
  38240. * RollingAverage
  38241. *
  38242. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38243. */
  38244. export class RollingAverage {
  38245. /**
  38246. * Current average
  38247. */
  38248. average: number;
  38249. /**
  38250. * Current variance
  38251. */
  38252. variance: number;
  38253. protected _samples: Array<number>;
  38254. protected _sampleCount: number;
  38255. protected _pos: number;
  38256. protected _m2: number;
  38257. /**
  38258. * constructor
  38259. * @param length The number of samples required to saturate the sliding window
  38260. */
  38261. constructor(length: number);
  38262. /**
  38263. * Adds a sample to the sample set
  38264. * @param v The sample value
  38265. */
  38266. add(v: number): void;
  38267. /**
  38268. * Returns previously added values or null if outside of history or outside the sliding window domain
  38269. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38270. * @return Value previously recorded with add() or null if outside of range
  38271. */
  38272. history(i: number): number;
  38273. /**
  38274. * Returns true if enough samples have been taken to completely fill the sliding window
  38275. * @return true if sample-set saturated
  38276. */
  38277. isSaturated(): boolean;
  38278. /**
  38279. * Resets the rolling average (equivalent to 0 samples taken so far)
  38280. */
  38281. reset(): void;
  38282. /**
  38283. * Wraps a value around the sample range boundaries
  38284. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38285. * @return Wrapped position in sample range
  38286. */
  38287. protected _wrapPosition(i: number): number;
  38288. }
  38289. }
  38290. declare module "babylonjs/Misc/perfCounter" {
  38291. /**
  38292. * This class is used to track a performance counter which is number based.
  38293. * The user has access to many properties which give statistics of different nature.
  38294. *
  38295. * The implementer can track two kinds of Performance Counter: time and count.
  38296. * 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.
  38297. * 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.
  38298. */
  38299. export class PerfCounter {
  38300. /**
  38301. * Gets or sets a global boolean to turn on and off all the counters
  38302. */
  38303. static Enabled: boolean;
  38304. /**
  38305. * Returns the smallest value ever
  38306. */
  38307. get min(): number;
  38308. /**
  38309. * Returns the biggest value ever
  38310. */
  38311. get max(): number;
  38312. /**
  38313. * Returns the average value since the performance counter is running
  38314. */
  38315. get average(): number;
  38316. /**
  38317. * Returns the average value of the last second the counter was monitored
  38318. */
  38319. get lastSecAverage(): number;
  38320. /**
  38321. * Returns the current value
  38322. */
  38323. get current(): number;
  38324. /**
  38325. * Gets the accumulated total
  38326. */
  38327. get total(): number;
  38328. /**
  38329. * Gets the total value count
  38330. */
  38331. get count(): number;
  38332. /**
  38333. * Creates a new counter
  38334. */
  38335. constructor();
  38336. /**
  38337. * Call this method to start monitoring a new frame.
  38338. * 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.
  38339. */
  38340. fetchNewFrame(): void;
  38341. /**
  38342. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38343. * @param newCount the count value to add to the monitored count
  38344. * @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.
  38345. */
  38346. addCount(newCount: number, fetchResult: boolean): void;
  38347. /**
  38348. * Start monitoring this performance counter
  38349. */
  38350. beginMonitoring(): void;
  38351. /**
  38352. * Compute the time lapsed since the previous beginMonitoring() call.
  38353. * @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
  38354. */
  38355. endMonitoring(newFrame?: boolean): void;
  38356. private _fetchResult;
  38357. private _startMonitoringTime;
  38358. private _min;
  38359. private _max;
  38360. private _average;
  38361. private _current;
  38362. private _totalValueCount;
  38363. private _totalAccumulated;
  38364. private _lastSecAverage;
  38365. private _lastSecAccumulated;
  38366. private _lastSecTime;
  38367. private _lastSecValueCount;
  38368. }
  38369. }
  38370. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  38371. module "babylonjs/Engines/thinEngine" {
  38372. interface ThinEngine {
  38373. /**
  38374. * Sets alpha constants used by some alpha blending modes
  38375. * @param r defines the red component
  38376. * @param g defines the green component
  38377. * @param b defines the blue component
  38378. * @param a defines the alpha component
  38379. */
  38380. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  38381. /**
  38382. * Sets the current alpha mode
  38383. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  38384. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  38385. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38386. */
  38387. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  38388. /**
  38389. * Gets the current alpha mode
  38390. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  38391. * @returns the current alpha mode
  38392. */
  38393. getAlphaMode(): number;
  38394. /**
  38395. * Sets the current alpha equation
  38396. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  38397. */
  38398. setAlphaEquation(equation: number): void;
  38399. /**
  38400. * Gets the current alpha equation.
  38401. * @returns the current alpha equation
  38402. */
  38403. getAlphaEquation(): number;
  38404. }
  38405. }
  38406. }
  38407. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38409. import { Nullable } from "babylonjs/types";
  38410. module "babylonjs/Engines/thinEngine" {
  38411. interface ThinEngine {
  38412. /** @hidden */
  38413. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38414. }
  38415. }
  38416. }
  38417. declare module "babylonjs/Engines/engine" {
  38418. import { Observable } from "babylonjs/Misc/observable";
  38419. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  38420. import { Scene } from "babylonjs/scene";
  38421. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38422. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38423. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38424. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38425. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38426. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38427. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38428. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38429. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38431. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38432. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38433. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38434. import "babylonjs/Engines/Extensions/engine.alpha";
  38435. import "babylonjs/Engines/Extensions/engine.readTexture";
  38436. import { Material } from "babylonjs/Materials/material";
  38437. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38438. /**
  38439. * Defines the interface used by display changed events
  38440. */
  38441. export interface IDisplayChangedEventArgs {
  38442. /** Gets the vrDisplay object (if any) */
  38443. vrDisplay: Nullable<any>;
  38444. /** Gets a boolean indicating if webVR is supported */
  38445. vrSupported: boolean;
  38446. }
  38447. /**
  38448. * Defines the interface used by objects containing a viewport (like a camera)
  38449. */
  38450. interface IViewportOwnerLike {
  38451. /**
  38452. * Gets or sets the viewport
  38453. */
  38454. viewport: IViewportLike;
  38455. }
  38456. /**
  38457. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38458. */
  38459. export class Engine extends ThinEngine {
  38460. /** Defines that alpha blending is disabled */
  38461. static readonly ALPHA_DISABLE: number;
  38462. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38463. static readonly ALPHA_ADD: number;
  38464. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38465. static readonly ALPHA_COMBINE: number;
  38466. /** Defines that alpha blending to DEST - SRC * DEST */
  38467. static readonly ALPHA_SUBTRACT: number;
  38468. /** Defines that alpha blending to SRC * DEST */
  38469. static readonly ALPHA_MULTIPLY: number;
  38470. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38471. static readonly ALPHA_MAXIMIZED: number;
  38472. /** Defines that alpha blending to SRC + DEST */
  38473. static readonly ALPHA_ONEONE: number;
  38474. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38475. static readonly ALPHA_PREMULTIPLIED: number;
  38476. /**
  38477. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38478. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38479. */
  38480. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38481. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38482. static readonly ALPHA_INTERPOLATE: number;
  38483. /**
  38484. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38485. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38486. */
  38487. static readonly ALPHA_SCREENMODE: number;
  38488. /** Defines that the ressource is not delayed*/
  38489. static readonly DELAYLOADSTATE_NONE: number;
  38490. /** Defines that the ressource was successfully delay loaded */
  38491. static readonly DELAYLOADSTATE_LOADED: number;
  38492. /** Defines that the ressource is currently delay loading */
  38493. static readonly DELAYLOADSTATE_LOADING: number;
  38494. /** Defines that the ressource is delayed and has not started loading */
  38495. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38496. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38497. static readonly NEVER: number;
  38498. /** 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 */
  38499. static readonly ALWAYS: number;
  38500. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38501. static readonly LESS: number;
  38502. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38503. static readonly EQUAL: number;
  38504. /** 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 */
  38505. static readonly LEQUAL: number;
  38506. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38507. static readonly GREATER: number;
  38508. /** 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 */
  38509. static readonly GEQUAL: number;
  38510. /** 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 */
  38511. static readonly NOTEQUAL: number;
  38512. /** Passed to stencilOperation to specify that stencil value must be kept */
  38513. static readonly KEEP: number;
  38514. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38515. static readonly REPLACE: number;
  38516. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38517. static readonly INCR: number;
  38518. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38519. static readonly DECR: number;
  38520. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38521. static readonly INVERT: number;
  38522. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38523. static readonly INCR_WRAP: number;
  38524. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38525. static readonly DECR_WRAP: number;
  38526. /** Texture is not repeating outside of 0..1 UVs */
  38527. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38528. /** Texture is repeating outside of 0..1 UVs */
  38529. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38530. /** Texture is repeating and mirrored */
  38531. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38532. /** ALPHA */
  38533. static readonly TEXTUREFORMAT_ALPHA: number;
  38534. /** LUMINANCE */
  38535. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38536. /** LUMINANCE_ALPHA */
  38537. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38538. /** RGB */
  38539. static readonly TEXTUREFORMAT_RGB: number;
  38540. /** RGBA */
  38541. static readonly TEXTUREFORMAT_RGBA: number;
  38542. /** RED */
  38543. static readonly TEXTUREFORMAT_RED: number;
  38544. /** RED (2nd reference) */
  38545. static readonly TEXTUREFORMAT_R: number;
  38546. /** RG */
  38547. static readonly TEXTUREFORMAT_RG: number;
  38548. /** RED_INTEGER */
  38549. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38550. /** RED_INTEGER (2nd reference) */
  38551. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38552. /** RG_INTEGER */
  38553. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38554. /** RGB_INTEGER */
  38555. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38556. /** RGBA_INTEGER */
  38557. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38558. /** UNSIGNED_BYTE */
  38559. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38560. /** UNSIGNED_BYTE (2nd reference) */
  38561. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38562. /** FLOAT */
  38563. static readonly TEXTURETYPE_FLOAT: number;
  38564. /** HALF_FLOAT */
  38565. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38566. /** BYTE */
  38567. static readonly TEXTURETYPE_BYTE: number;
  38568. /** SHORT */
  38569. static readonly TEXTURETYPE_SHORT: number;
  38570. /** UNSIGNED_SHORT */
  38571. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38572. /** INT */
  38573. static readonly TEXTURETYPE_INT: number;
  38574. /** UNSIGNED_INT */
  38575. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38576. /** UNSIGNED_SHORT_4_4_4_4 */
  38577. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38578. /** UNSIGNED_SHORT_5_5_5_1 */
  38579. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38580. /** UNSIGNED_SHORT_5_6_5 */
  38581. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38582. /** UNSIGNED_INT_2_10_10_10_REV */
  38583. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38584. /** UNSIGNED_INT_24_8 */
  38585. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38586. /** UNSIGNED_INT_10F_11F_11F_REV */
  38587. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38588. /** UNSIGNED_INT_5_9_9_9_REV */
  38589. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38590. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38591. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38592. /** nearest is mag = nearest and min = nearest and mip = linear */
  38593. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38594. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38595. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38596. /** Trilinear is mag = linear and min = linear and mip = linear */
  38597. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38598. /** nearest is mag = nearest and min = nearest and mip = linear */
  38599. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38600. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38601. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38602. /** Trilinear is mag = linear and min = linear and mip = linear */
  38603. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38604. /** mag = nearest and min = nearest and mip = nearest */
  38605. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38606. /** mag = nearest and min = linear and mip = nearest */
  38607. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38608. /** mag = nearest and min = linear and mip = linear */
  38609. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38610. /** mag = nearest and min = linear and mip = none */
  38611. static readonly TEXTURE_NEAREST_LINEAR: number;
  38612. /** mag = nearest and min = nearest and mip = none */
  38613. static readonly TEXTURE_NEAREST_NEAREST: number;
  38614. /** mag = linear and min = nearest and mip = nearest */
  38615. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38616. /** mag = linear and min = nearest and mip = linear */
  38617. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38618. /** mag = linear and min = linear and mip = none */
  38619. static readonly TEXTURE_LINEAR_LINEAR: number;
  38620. /** mag = linear and min = nearest and mip = none */
  38621. static readonly TEXTURE_LINEAR_NEAREST: number;
  38622. /** Explicit coordinates mode */
  38623. static readonly TEXTURE_EXPLICIT_MODE: number;
  38624. /** Spherical coordinates mode */
  38625. static readonly TEXTURE_SPHERICAL_MODE: number;
  38626. /** Planar coordinates mode */
  38627. static readonly TEXTURE_PLANAR_MODE: number;
  38628. /** Cubic coordinates mode */
  38629. static readonly TEXTURE_CUBIC_MODE: number;
  38630. /** Projection coordinates mode */
  38631. static readonly TEXTURE_PROJECTION_MODE: number;
  38632. /** Skybox coordinates mode */
  38633. static readonly TEXTURE_SKYBOX_MODE: number;
  38634. /** Inverse Cubic coordinates mode */
  38635. static readonly TEXTURE_INVCUBIC_MODE: number;
  38636. /** Equirectangular coordinates mode */
  38637. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38638. /** Equirectangular Fixed coordinates mode */
  38639. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38640. /** Equirectangular Fixed Mirrored coordinates mode */
  38641. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38642. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38643. static readonly SCALEMODE_FLOOR: number;
  38644. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38645. static readonly SCALEMODE_NEAREST: number;
  38646. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38647. static readonly SCALEMODE_CEILING: number;
  38648. /**
  38649. * Returns the current npm package of the sdk
  38650. */
  38651. static get NpmPackage(): string;
  38652. /**
  38653. * Returns the current version of the framework
  38654. */
  38655. static get Version(): string;
  38656. /** Gets the list of created engines */
  38657. static get Instances(): Engine[];
  38658. /**
  38659. * Gets the latest created engine
  38660. */
  38661. static get LastCreatedEngine(): Nullable<Engine>;
  38662. /**
  38663. * Gets the latest created scene
  38664. */
  38665. static get LastCreatedScene(): Nullable<Scene>;
  38666. /**
  38667. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38668. * @param flag defines which part of the materials must be marked as dirty
  38669. * @param predicate defines a predicate used to filter which materials should be affected
  38670. */
  38671. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38672. /**
  38673. * Method called to create the default loading screen.
  38674. * This can be overriden in your own app.
  38675. * @param canvas The rendering canvas element
  38676. * @returns The loading screen
  38677. */
  38678. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38679. /**
  38680. * Method called to create the default rescale post process on each engine.
  38681. */
  38682. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38683. /**
  38684. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38685. **/
  38686. enableOfflineSupport: boolean;
  38687. /**
  38688. * 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)
  38689. **/
  38690. disableManifestCheck: boolean;
  38691. /**
  38692. * Gets the list of created scenes
  38693. */
  38694. scenes: Scene[];
  38695. /**
  38696. * Event raised when a new scene is created
  38697. */
  38698. onNewSceneAddedObservable: Observable<Scene>;
  38699. /**
  38700. * Gets the list of created postprocesses
  38701. */
  38702. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38703. /**
  38704. * Gets a boolean indicating if the pointer is currently locked
  38705. */
  38706. isPointerLock: boolean;
  38707. /**
  38708. * Observable event triggered each time the rendering canvas is resized
  38709. */
  38710. onResizeObservable: Observable<Engine>;
  38711. /**
  38712. * Observable event triggered each time the canvas loses focus
  38713. */
  38714. onCanvasBlurObservable: Observable<Engine>;
  38715. /**
  38716. * Observable event triggered each time the canvas gains focus
  38717. */
  38718. onCanvasFocusObservable: Observable<Engine>;
  38719. /**
  38720. * Observable event triggered each time the canvas receives pointerout event
  38721. */
  38722. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38723. /**
  38724. * Observable raised when the engine begins a new frame
  38725. */
  38726. onBeginFrameObservable: Observable<Engine>;
  38727. /**
  38728. * If set, will be used to request the next animation frame for the render loop
  38729. */
  38730. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38731. /**
  38732. * Observable raised when the engine ends the current frame
  38733. */
  38734. onEndFrameObservable: Observable<Engine>;
  38735. /**
  38736. * Observable raised when the engine is about to compile a shader
  38737. */
  38738. onBeforeShaderCompilationObservable: Observable<Engine>;
  38739. /**
  38740. * Observable raised when the engine has jsut compiled a shader
  38741. */
  38742. onAfterShaderCompilationObservable: Observable<Engine>;
  38743. /**
  38744. * Gets the audio engine
  38745. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38746. * @ignorenaming
  38747. */
  38748. static audioEngine: IAudioEngine;
  38749. /**
  38750. * Default AudioEngine factory responsible of creating the Audio Engine.
  38751. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38752. */
  38753. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38754. /**
  38755. * Default offline support factory responsible of creating a tool used to store data locally.
  38756. * By default, this will create a Database object if the workload has been embedded.
  38757. */
  38758. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38759. private _loadingScreen;
  38760. private _pointerLockRequested;
  38761. private _rescalePostProcess;
  38762. private _deterministicLockstep;
  38763. private _lockstepMaxSteps;
  38764. private _timeStep;
  38765. protected get _supportsHardwareTextureRescaling(): boolean;
  38766. private _fps;
  38767. private _deltaTime;
  38768. /** @hidden */
  38769. _drawCalls: PerfCounter;
  38770. /** 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 */
  38771. canvasTabIndex: number;
  38772. /**
  38773. * Turn this value on if you want to pause FPS computation when in background
  38774. */
  38775. disablePerformanceMonitorInBackground: boolean;
  38776. private _performanceMonitor;
  38777. /**
  38778. * Gets the performance monitor attached to this engine
  38779. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38780. */
  38781. get performanceMonitor(): PerformanceMonitor;
  38782. private _onFocus;
  38783. private _onBlur;
  38784. private _onCanvasPointerOut;
  38785. private _onCanvasBlur;
  38786. private _onCanvasFocus;
  38787. private _onFullscreenChange;
  38788. private _onPointerLockChange;
  38789. /**
  38790. * Gets the HTML element used to attach event listeners
  38791. * @returns a HTML element
  38792. */
  38793. getInputElement(): Nullable<HTMLElement>;
  38794. /**
  38795. * Creates a new engine
  38796. * @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
  38797. * @param antialias defines enable antialiasing (default: false)
  38798. * @param options defines further options to be sent to the getContext() function
  38799. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38800. */
  38801. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38802. /**
  38803. * Gets current aspect ratio
  38804. * @param viewportOwner defines the camera to use to get the aspect ratio
  38805. * @param useScreen defines if screen size must be used (or the current render target if any)
  38806. * @returns a number defining the aspect ratio
  38807. */
  38808. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38809. /**
  38810. * Gets current screen aspect ratio
  38811. * @returns a number defining the aspect ratio
  38812. */
  38813. getScreenAspectRatio(): number;
  38814. /**
  38815. * Gets the client rect of the HTML canvas attached with the current webGL context
  38816. * @returns a client rectanglee
  38817. */
  38818. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38819. /**
  38820. * Gets the client rect of the HTML element used for events
  38821. * @returns a client rectanglee
  38822. */
  38823. getInputElementClientRect(): Nullable<ClientRect>;
  38824. /**
  38825. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38826. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38827. * @returns true if engine is in deterministic lock step mode
  38828. */
  38829. isDeterministicLockStep(): boolean;
  38830. /**
  38831. * Gets the max steps when engine is running in deterministic lock step
  38832. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38833. * @returns the max steps
  38834. */
  38835. getLockstepMaxSteps(): number;
  38836. /**
  38837. * Returns the time in ms between steps when using deterministic lock step.
  38838. * @returns time step in (ms)
  38839. */
  38840. getTimeStep(): number;
  38841. /**
  38842. * Force the mipmap generation for the given render target texture
  38843. * @param texture defines the render target texture to use
  38844. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38845. */
  38846. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38847. /** States */
  38848. /**
  38849. * Set various states to the webGL context
  38850. * @param culling defines backface culling state
  38851. * @param zOffset defines the value to apply to zOffset (0 by default)
  38852. * @param force defines if states must be applied even if cache is up to date
  38853. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38854. */
  38855. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38856. /**
  38857. * Set the z offset to apply to current rendering
  38858. * @param value defines the offset to apply
  38859. */
  38860. setZOffset(value: number): void;
  38861. /**
  38862. * Gets the current value of the zOffset
  38863. * @returns the current zOffset state
  38864. */
  38865. getZOffset(): number;
  38866. /**
  38867. * Enable or disable depth buffering
  38868. * @param enable defines the state to set
  38869. */
  38870. setDepthBuffer(enable: boolean): void;
  38871. /**
  38872. * Gets a boolean indicating if depth writing is enabled
  38873. * @returns the current depth writing state
  38874. */
  38875. getDepthWrite(): boolean;
  38876. /**
  38877. * Enable or disable depth writing
  38878. * @param enable defines the state to set
  38879. */
  38880. setDepthWrite(enable: boolean): void;
  38881. /**
  38882. * Gets a boolean indicating if stencil buffer is enabled
  38883. * @returns the current stencil buffer state
  38884. */
  38885. getStencilBuffer(): boolean;
  38886. /**
  38887. * Enable or disable the stencil buffer
  38888. * @param enable defines if the stencil buffer must be enabled or disabled
  38889. */
  38890. setStencilBuffer(enable: boolean): void;
  38891. /**
  38892. * Gets the current stencil mask
  38893. * @returns a number defining the new stencil mask to use
  38894. */
  38895. getStencilMask(): number;
  38896. /**
  38897. * Sets the current stencil mask
  38898. * @param mask defines the new stencil mask to use
  38899. */
  38900. setStencilMask(mask: number): void;
  38901. /**
  38902. * Gets the current stencil function
  38903. * @returns a number defining the stencil function to use
  38904. */
  38905. getStencilFunction(): number;
  38906. /**
  38907. * Gets the current stencil reference value
  38908. * @returns a number defining the stencil reference value to use
  38909. */
  38910. getStencilFunctionReference(): number;
  38911. /**
  38912. * Gets the current stencil mask
  38913. * @returns a number defining the stencil mask to use
  38914. */
  38915. getStencilFunctionMask(): number;
  38916. /**
  38917. * Sets the current stencil function
  38918. * @param stencilFunc defines the new stencil function to use
  38919. */
  38920. setStencilFunction(stencilFunc: number): void;
  38921. /**
  38922. * Sets the current stencil reference
  38923. * @param reference defines the new stencil reference to use
  38924. */
  38925. setStencilFunctionReference(reference: number): void;
  38926. /**
  38927. * Sets the current stencil mask
  38928. * @param mask defines the new stencil mask to use
  38929. */
  38930. setStencilFunctionMask(mask: number): void;
  38931. /**
  38932. * Gets the current stencil operation when stencil fails
  38933. * @returns a number defining stencil operation to use when stencil fails
  38934. */
  38935. getStencilOperationFail(): number;
  38936. /**
  38937. * Gets the current stencil operation when depth fails
  38938. * @returns a number defining stencil operation to use when depth fails
  38939. */
  38940. getStencilOperationDepthFail(): number;
  38941. /**
  38942. * Gets the current stencil operation when stencil passes
  38943. * @returns a number defining stencil operation to use when stencil passes
  38944. */
  38945. getStencilOperationPass(): number;
  38946. /**
  38947. * Sets the stencil operation to use when stencil fails
  38948. * @param operation defines the stencil operation to use when stencil fails
  38949. */
  38950. setStencilOperationFail(operation: number): void;
  38951. /**
  38952. * Sets the stencil operation to use when depth fails
  38953. * @param operation defines the stencil operation to use when depth fails
  38954. */
  38955. setStencilOperationDepthFail(operation: number): void;
  38956. /**
  38957. * Sets the stencil operation to use when stencil passes
  38958. * @param operation defines the stencil operation to use when stencil passes
  38959. */
  38960. setStencilOperationPass(operation: number): void;
  38961. /**
  38962. * Sets a boolean indicating if the dithering state is enabled or disabled
  38963. * @param value defines the dithering state
  38964. */
  38965. setDitheringState(value: boolean): void;
  38966. /**
  38967. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38968. * @param value defines the rasterizer state
  38969. */
  38970. setRasterizerState(value: boolean): void;
  38971. /**
  38972. * Gets the current depth function
  38973. * @returns a number defining the depth function
  38974. */
  38975. getDepthFunction(): Nullable<number>;
  38976. /**
  38977. * Sets the current depth function
  38978. * @param depthFunc defines the function to use
  38979. */
  38980. setDepthFunction(depthFunc: number): void;
  38981. /**
  38982. * Sets the current depth function to GREATER
  38983. */
  38984. setDepthFunctionToGreater(): void;
  38985. /**
  38986. * Sets the current depth function to GEQUAL
  38987. */
  38988. setDepthFunctionToGreaterOrEqual(): void;
  38989. /**
  38990. * Sets the current depth function to LESS
  38991. */
  38992. setDepthFunctionToLess(): void;
  38993. /**
  38994. * Sets the current depth function to LEQUAL
  38995. */
  38996. setDepthFunctionToLessOrEqual(): void;
  38997. private _cachedStencilBuffer;
  38998. private _cachedStencilFunction;
  38999. private _cachedStencilMask;
  39000. private _cachedStencilOperationPass;
  39001. private _cachedStencilOperationFail;
  39002. private _cachedStencilOperationDepthFail;
  39003. private _cachedStencilReference;
  39004. /**
  39005. * Caches the the state of the stencil buffer
  39006. */
  39007. cacheStencilState(): void;
  39008. /**
  39009. * Restores the state of the stencil buffer
  39010. */
  39011. restoreStencilState(): void;
  39012. /**
  39013. * Directly set the WebGL Viewport
  39014. * @param x defines the x coordinate of the viewport (in screen space)
  39015. * @param y defines the y coordinate of the viewport (in screen space)
  39016. * @param width defines the width of the viewport (in screen space)
  39017. * @param height defines the height of the viewport (in screen space)
  39018. * @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
  39019. */
  39020. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39021. /**
  39022. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39023. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39024. * @param y defines the y-coordinate of the corner of the clear rectangle
  39025. * @param width defines the width of the clear rectangle
  39026. * @param height defines the height of the clear rectangle
  39027. * @param clearColor defines the clear color
  39028. */
  39029. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39030. /**
  39031. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39032. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39033. * @param y defines the y-coordinate of the corner of the clear rectangle
  39034. * @param width defines the width of the clear rectangle
  39035. * @param height defines the height of the clear rectangle
  39036. */
  39037. enableScissor(x: number, y: number, width: number, height: number): void;
  39038. /**
  39039. * Disable previously set scissor test rectangle
  39040. */
  39041. disableScissor(): void;
  39042. protected _reportDrawCall(): void;
  39043. /**
  39044. * Initializes a webVR display and starts listening to display change events
  39045. * The onVRDisplayChangedObservable will be notified upon these changes
  39046. * @returns The onVRDisplayChangedObservable
  39047. */
  39048. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39049. /** @hidden */
  39050. _prepareVRComponent(): void;
  39051. /** @hidden */
  39052. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39053. /** @hidden */
  39054. _submitVRFrame(): void;
  39055. /**
  39056. * Call this function to leave webVR mode
  39057. * Will do nothing if webVR is not supported or if there is no webVR device
  39058. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39059. */
  39060. disableVR(): void;
  39061. /**
  39062. * Gets a boolean indicating that the system is in VR mode and is presenting
  39063. * @returns true if VR mode is engaged
  39064. */
  39065. isVRPresenting(): boolean;
  39066. /** @hidden */
  39067. _requestVRFrame(): void;
  39068. /** @hidden */
  39069. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39070. /**
  39071. * Gets the source code of the vertex shader associated with a specific webGL program
  39072. * @param program defines the program to use
  39073. * @returns a string containing the source code of the vertex shader associated with the program
  39074. */
  39075. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39076. /**
  39077. * Gets the source code of the fragment shader associated with a specific webGL program
  39078. * @param program defines the program to use
  39079. * @returns a string containing the source code of the fragment shader associated with the program
  39080. */
  39081. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39082. /**
  39083. * Sets a depth stencil texture from a render target to the according uniform.
  39084. * @param channel The texture channel
  39085. * @param uniform The uniform to set
  39086. * @param texture The render target texture containing the depth stencil texture to apply
  39087. */
  39088. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39089. /**
  39090. * Sets a texture to the webGL context from a postprocess
  39091. * @param channel defines the channel to use
  39092. * @param postProcess defines the source postprocess
  39093. */
  39094. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39095. /**
  39096. * Binds the output of the passed in post process to the texture channel specified
  39097. * @param channel The channel the texture should be bound to
  39098. * @param postProcess The post process which's output should be bound
  39099. */
  39100. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39101. protected _rebuildBuffers(): void;
  39102. /** @hidden */
  39103. _renderFrame(): void;
  39104. _renderLoop(): void;
  39105. /** @hidden */
  39106. _renderViews(): boolean;
  39107. /**
  39108. * Toggle full screen mode
  39109. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39110. */
  39111. switchFullscreen(requestPointerLock: boolean): void;
  39112. /**
  39113. * Enters full screen mode
  39114. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39115. */
  39116. enterFullscreen(requestPointerLock: boolean): void;
  39117. /**
  39118. * Exits full screen mode
  39119. */
  39120. exitFullscreen(): void;
  39121. /**
  39122. * Enters Pointerlock mode
  39123. */
  39124. enterPointerlock(): void;
  39125. /**
  39126. * Exits Pointerlock mode
  39127. */
  39128. exitPointerlock(): void;
  39129. /**
  39130. * Begin a new frame
  39131. */
  39132. beginFrame(): void;
  39133. /**
  39134. * Enf the current frame
  39135. */
  39136. endFrame(): void;
  39137. resize(): void;
  39138. /**
  39139. * Force a specific size of the canvas
  39140. * @param width defines the new canvas' width
  39141. * @param height defines the new canvas' height
  39142. * @returns true if the size was changed
  39143. */
  39144. setSize(width: number, height: number): boolean;
  39145. /**
  39146. * Updates a dynamic vertex buffer.
  39147. * @param vertexBuffer the vertex buffer to update
  39148. * @param data the data used to update the vertex buffer
  39149. * @param byteOffset the byte offset of the data
  39150. * @param byteLength the byte length of the data
  39151. */
  39152. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  39153. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39154. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39155. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39156. _releaseTexture(texture: InternalTexture): void;
  39157. /**
  39158. * @hidden
  39159. * Rescales a texture
  39160. * @param source input texutre
  39161. * @param destination destination texture
  39162. * @param scene scene to use to render the resize
  39163. * @param internalFormat format to use when resizing
  39164. * @param onComplete callback to be called when resize has completed
  39165. */
  39166. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39167. /**
  39168. * Gets the current framerate
  39169. * @returns a number representing the framerate
  39170. */
  39171. getFps(): number;
  39172. /**
  39173. * Gets the time spent between current and previous frame
  39174. * @returns a number representing the delta time in ms
  39175. */
  39176. getDeltaTime(): number;
  39177. private _measureFps;
  39178. /** @hidden */
  39179. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39180. /**
  39181. * Update a dynamic index buffer
  39182. * @param indexBuffer defines the target index buffer
  39183. * @param indices defines the data to update
  39184. * @param offset defines the offset in the target index buffer where update should start
  39185. */
  39186. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  39187. /**
  39188. * Updates the sample count of a render target texture
  39189. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39190. * @param texture defines the texture to update
  39191. * @param samples defines the sample count to set
  39192. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39193. */
  39194. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39195. /**
  39196. * Updates a depth texture Comparison Mode and Function.
  39197. * If the comparison Function is equal to 0, the mode will be set to none.
  39198. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39199. * @param texture The texture to set the comparison function for
  39200. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39201. */
  39202. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39203. /**
  39204. * Creates a webGL buffer to use with instanciation
  39205. * @param capacity defines the size of the buffer
  39206. * @returns the webGL buffer
  39207. */
  39208. createInstancesBuffer(capacity: number): DataBuffer;
  39209. /**
  39210. * Delete a webGL buffer used with instanciation
  39211. * @param buffer defines the webGL buffer to delete
  39212. */
  39213. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39214. private _clientWaitAsync;
  39215. /** @hidden */
  39216. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39217. dispose(): void;
  39218. private _disableTouchAction;
  39219. /**
  39220. * Display the loading screen
  39221. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39222. */
  39223. displayLoadingUI(): void;
  39224. /**
  39225. * Hide the loading screen
  39226. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39227. */
  39228. hideLoadingUI(): void;
  39229. /**
  39230. * Gets the current loading screen object
  39231. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39232. */
  39233. get loadingScreen(): ILoadingScreen;
  39234. /**
  39235. * Sets the current loading screen object
  39236. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39237. */
  39238. set loadingScreen(loadingScreen: ILoadingScreen);
  39239. /**
  39240. * Sets the current loading screen text
  39241. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39242. */
  39243. set loadingUIText(text: string);
  39244. /**
  39245. * Sets the current loading screen background color
  39246. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39247. */
  39248. set loadingUIBackgroundColor(color: string);
  39249. /** Pointerlock and fullscreen */
  39250. /**
  39251. * Ask the browser to promote the current element to pointerlock mode
  39252. * @param element defines the DOM element to promote
  39253. */
  39254. static _RequestPointerlock(element: HTMLElement): void;
  39255. /**
  39256. * Asks the browser to exit pointerlock mode
  39257. */
  39258. static _ExitPointerlock(): void;
  39259. /**
  39260. * Ask the browser to promote the current element to fullscreen rendering mode
  39261. * @param element defines the DOM element to promote
  39262. */
  39263. static _RequestFullscreen(element: HTMLElement): void;
  39264. /**
  39265. * Asks the browser to exit fullscreen mode
  39266. */
  39267. static _ExitFullscreen(): void;
  39268. }
  39269. }
  39270. declare module "babylonjs/Engines/engineStore" {
  39271. import { Nullable } from "babylonjs/types";
  39272. import { Engine } from "babylonjs/Engines/engine";
  39273. import { Scene } from "babylonjs/scene";
  39274. /**
  39275. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39276. * during the life time of the application.
  39277. */
  39278. export class EngineStore {
  39279. /** Gets the list of created engines */
  39280. static Instances: import("babylonjs/Engines/engine").Engine[];
  39281. /** @hidden */
  39282. static _LastCreatedScene: Nullable<Scene>;
  39283. /**
  39284. * Gets the latest created engine
  39285. */
  39286. static get LastCreatedEngine(): Nullable<Engine>;
  39287. /**
  39288. * Gets the latest created scene
  39289. */
  39290. static get LastCreatedScene(): Nullable<Scene>;
  39291. /**
  39292. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39293. * @ignorenaming
  39294. */
  39295. static UseFallbackTexture: boolean;
  39296. /**
  39297. * Texture content used if a texture cannot loaded
  39298. * @ignorenaming
  39299. */
  39300. static FallbackTexture: string;
  39301. }
  39302. }
  39303. declare module "babylonjs/Misc/promise" {
  39304. /**
  39305. * Helper class that provides a small promise polyfill
  39306. */
  39307. export class PromisePolyfill {
  39308. /**
  39309. * Static function used to check if the polyfill is required
  39310. * If this is the case then the function will inject the polyfill to window.Promise
  39311. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39312. */
  39313. static Apply(force?: boolean): void;
  39314. }
  39315. }
  39316. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39317. /**
  39318. * Interface for screenshot methods with describe argument called `size` as object with options
  39319. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39320. */
  39321. export interface IScreenshotSize {
  39322. /**
  39323. * number in pixels for canvas height
  39324. */
  39325. height?: number;
  39326. /**
  39327. * multiplier allowing render at a higher or lower resolution
  39328. * If value is defined then height and width will be ignored and taken from camera
  39329. */
  39330. precision?: number;
  39331. /**
  39332. * number in pixels for canvas width
  39333. */
  39334. width?: number;
  39335. }
  39336. }
  39337. declare module "babylonjs/Misc/tools" {
  39338. import { Nullable, float } from "babylonjs/types";
  39339. import { DomManagement } from "babylonjs/Misc/domManagement";
  39340. import { WebRequest } from "babylonjs/Misc/webRequest";
  39341. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39342. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39343. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39344. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39345. import { Camera } from "babylonjs/Cameras/camera";
  39346. import { Engine } from "babylonjs/Engines/engine";
  39347. interface IColor4Like {
  39348. r: float;
  39349. g: float;
  39350. b: float;
  39351. a: float;
  39352. }
  39353. /**
  39354. * Class containing a set of static utilities functions
  39355. */
  39356. export class Tools {
  39357. /**
  39358. * Gets or sets the base URL to use to load assets
  39359. */
  39360. static get BaseUrl(): string;
  39361. static set BaseUrl(value: string);
  39362. /**
  39363. * Enable/Disable Custom HTTP Request Headers globally.
  39364. * default = false
  39365. * @see CustomRequestHeaders
  39366. */
  39367. static UseCustomRequestHeaders: boolean;
  39368. /**
  39369. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39370. * i.e. when loading files, where the server/service expects an Authorization header
  39371. */
  39372. static CustomRequestHeaders: {
  39373. [key: string]: string;
  39374. };
  39375. /**
  39376. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39377. */
  39378. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39379. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39380. /**
  39381. * Default behaviour for cors in the application.
  39382. * It can be a string if the expected behavior is identical in the entire app.
  39383. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39384. */
  39385. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39386. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39387. /**
  39388. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39389. * @ignorenaming
  39390. */
  39391. static get UseFallbackTexture(): boolean;
  39392. static set UseFallbackTexture(value: boolean);
  39393. /**
  39394. * Use this object to register external classes like custom textures or material
  39395. * to allow the laoders to instantiate them
  39396. */
  39397. static get RegisteredExternalClasses(): {
  39398. [key: string]: Object;
  39399. };
  39400. static set RegisteredExternalClasses(classes: {
  39401. [key: string]: Object;
  39402. });
  39403. /**
  39404. * Texture content used if a texture cannot loaded
  39405. * @ignorenaming
  39406. */
  39407. static get fallbackTexture(): string;
  39408. static set fallbackTexture(value: string);
  39409. /**
  39410. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39411. * @param u defines the coordinate on X axis
  39412. * @param v defines the coordinate on Y axis
  39413. * @param width defines the width of the source data
  39414. * @param height defines the height of the source data
  39415. * @param pixels defines the source byte array
  39416. * @param color defines the output color
  39417. */
  39418. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39419. /**
  39420. * Interpolates between a and b via alpha
  39421. * @param a The lower value (returned when alpha = 0)
  39422. * @param b The upper value (returned when alpha = 1)
  39423. * @param alpha The interpolation-factor
  39424. * @return The mixed value
  39425. */
  39426. static Mix(a: number, b: number, alpha: number): number;
  39427. /**
  39428. * Tries to instantiate a new object from a given class name
  39429. * @param className defines the class name to instantiate
  39430. * @returns the new object or null if the system was not able to do the instantiation
  39431. */
  39432. static Instantiate(className: string): any;
  39433. /**
  39434. * Provides a slice function that will work even on IE
  39435. * @param data defines the array to slice
  39436. * @param start defines the start of the data (optional)
  39437. * @param end defines the end of the data (optional)
  39438. * @returns the new sliced array
  39439. */
  39440. static Slice<T>(data: T, start?: number, end?: number): T;
  39441. /**
  39442. * Polyfill for setImmediate
  39443. * @param action defines the action to execute after the current execution block
  39444. */
  39445. static SetImmediate(action: () => void): void;
  39446. /**
  39447. * Function indicating if a number is an exponent of 2
  39448. * @param value defines the value to test
  39449. * @returns true if the value is an exponent of 2
  39450. */
  39451. static IsExponentOfTwo(value: number): boolean;
  39452. private static _tmpFloatArray;
  39453. /**
  39454. * Returns the nearest 32-bit single precision float representation of a Number
  39455. * @param value A Number. If the parameter is of a different type, it will get converted
  39456. * to a number or to NaN if it cannot be converted
  39457. * @returns number
  39458. */
  39459. static FloatRound(value: number): number;
  39460. /**
  39461. * Extracts the filename from a path
  39462. * @param path defines the path to use
  39463. * @returns the filename
  39464. */
  39465. static GetFilename(path: string): string;
  39466. /**
  39467. * Extracts the "folder" part of a path (everything before the filename).
  39468. * @param uri The URI to extract the info from
  39469. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39470. * @returns The "folder" part of the path
  39471. */
  39472. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39473. /**
  39474. * Extracts text content from a DOM element hierarchy
  39475. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39476. */
  39477. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39478. /**
  39479. * Convert an angle in radians to degrees
  39480. * @param angle defines the angle to convert
  39481. * @returns the angle in degrees
  39482. */
  39483. static ToDegrees(angle: number): number;
  39484. /**
  39485. * Convert an angle in degrees to radians
  39486. * @param angle defines the angle to convert
  39487. * @returns the angle in radians
  39488. */
  39489. static ToRadians(angle: number): number;
  39490. /**
  39491. * Returns an array if obj is not an array
  39492. * @param obj defines the object to evaluate as an array
  39493. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39494. * @returns either obj directly if obj is an array or a new array containing obj
  39495. */
  39496. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39497. /**
  39498. * Gets the pointer prefix to use
  39499. * @param engine defines the engine we are finding the prefix for
  39500. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39501. */
  39502. static GetPointerPrefix(engine: Engine): string;
  39503. /**
  39504. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39505. * @param url define the url we are trying
  39506. * @param element define the dom element where to configure the cors policy
  39507. */
  39508. static SetCorsBehavior(url: string | string[], element: {
  39509. crossOrigin: string | null;
  39510. }): void;
  39511. /**
  39512. * Removes unwanted characters from an url
  39513. * @param url defines the url to clean
  39514. * @returns the cleaned url
  39515. */
  39516. static CleanUrl(url: string): string;
  39517. /**
  39518. * Gets or sets a function used to pre-process url before using them to load assets
  39519. */
  39520. static get PreprocessUrl(): (url: string) => string;
  39521. static set PreprocessUrl(processor: (url: string) => string);
  39522. /**
  39523. * Loads an image as an HTMLImageElement.
  39524. * @param input url string, ArrayBuffer, or Blob to load
  39525. * @param onLoad callback called when the image successfully loads
  39526. * @param onError callback called when the image fails to load
  39527. * @param offlineProvider offline provider for caching
  39528. * @param mimeType optional mime type
  39529. * @returns the HTMLImageElement of the loaded image
  39530. */
  39531. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39532. /**
  39533. * Loads a file from a url
  39534. * @param url url string, ArrayBuffer, or Blob to load
  39535. * @param onSuccess callback called when the file successfully loads
  39536. * @param onProgress callback called while file is loading (if the server supports this mode)
  39537. * @param offlineProvider defines the offline provider for caching
  39538. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39539. * @param onError callback called when the file fails to load
  39540. * @returns a file request object
  39541. */
  39542. 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;
  39543. /**
  39544. * Loads a file from a url
  39545. * @param url the file url to load
  39546. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39547. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39548. */
  39549. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39550. /**
  39551. * Load a script (identified by an url). When the url returns, the
  39552. * content of this file is added into a new script element, attached to the DOM (body element)
  39553. * @param scriptUrl defines the url of the script to laod
  39554. * @param onSuccess defines the callback called when the script is loaded
  39555. * @param onError defines the callback to call if an error occurs
  39556. * @param scriptId defines the id of the script element
  39557. */
  39558. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39559. /**
  39560. * Load an asynchronous script (identified by an url). When the url returns, the
  39561. * content of this file is added into a new script element, attached to the DOM (body element)
  39562. * @param scriptUrl defines the url of the script to laod
  39563. * @param scriptId defines the id of the script element
  39564. * @returns a promise request object
  39565. */
  39566. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39567. /**
  39568. * Loads a file from a blob
  39569. * @param fileToLoad defines the blob to use
  39570. * @param callback defines the callback to call when data is loaded
  39571. * @param progressCallback defines the callback to call during loading process
  39572. * @returns a file request object
  39573. */
  39574. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39575. /**
  39576. * Reads a file from a File object
  39577. * @param file defines the file to load
  39578. * @param onSuccess defines the callback to call when data is loaded
  39579. * @param onProgress defines the callback to call during loading process
  39580. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39581. * @param onError defines the callback to call when an error occurs
  39582. * @returns a file request object
  39583. */
  39584. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39585. /**
  39586. * Creates a data url from a given string content
  39587. * @param content defines the content to convert
  39588. * @returns the new data url link
  39589. */
  39590. static FileAsURL(content: string): string;
  39591. /**
  39592. * Format the given number to a specific decimal format
  39593. * @param value defines the number to format
  39594. * @param decimals defines the number of decimals to use
  39595. * @returns the formatted string
  39596. */
  39597. static Format(value: number, decimals?: number): string;
  39598. /**
  39599. * Tries to copy an object by duplicating every property
  39600. * @param source defines the source object
  39601. * @param destination defines the target object
  39602. * @param doNotCopyList defines a list of properties to avoid
  39603. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39604. */
  39605. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39606. /**
  39607. * Gets a boolean indicating if the given object has no own property
  39608. * @param obj defines the object to test
  39609. * @returns true if object has no own property
  39610. */
  39611. static IsEmpty(obj: any): boolean;
  39612. /**
  39613. * Function used to register events at window level
  39614. * @param windowElement defines the Window object to use
  39615. * @param events defines the events to register
  39616. */
  39617. static RegisterTopRootEvents(windowElement: Window, events: {
  39618. name: string;
  39619. handler: Nullable<(e: FocusEvent) => any>;
  39620. }[]): void;
  39621. /**
  39622. * Function used to unregister events from window level
  39623. * @param windowElement defines the Window object to use
  39624. * @param events defines the events to unregister
  39625. */
  39626. static UnregisterTopRootEvents(windowElement: Window, events: {
  39627. name: string;
  39628. handler: Nullable<(e: FocusEvent) => any>;
  39629. }[]): void;
  39630. /**
  39631. * @ignore
  39632. */
  39633. static _ScreenshotCanvas: HTMLCanvasElement;
  39634. /**
  39635. * Dumps the current bound framebuffer
  39636. * @param width defines the rendering width
  39637. * @param height defines the rendering height
  39638. * @param engine defines the hosting engine
  39639. * @param successCallback defines the callback triggered once the data are available
  39640. * @param mimeType defines the mime type of the result
  39641. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39642. */
  39643. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39644. /**
  39645. * Converts the canvas data to blob.
  39646. * This acts as a polyfill for browsers not supporting the to blob function.
  39647. * @param canvas Defines the canvas to extract the data from
  39648. * @param successCallback Defines the callback triggered once the data are available
  39649. * @param mimeType Defines the mime type of the result
  39650. */
  39651. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39652. /**
  39653. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39654. * @param successCallback defines the callback triggered once the data are available
  39655. * @param mimeType defines the mime type of the result
  39656. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39657. */
  39658. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39659. /**
  39660. * Downloads a blob in the browser
  39661. * @param blob defines the blob to download
  39662. * @param fileName defines the name of the downloaded file
  39663. */
  39664. static Download(blob: Blob, fileName: string): void;
  39665. /**
  39666. * Captures a screenshot of the current rendering
  39667. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39668. * @param engine defines the rendering engine
  39669. * @param camera defines the source camera
  39670. * @param size This parameter can be set to a single number or to an object with the
  39671. * following (optional) properties: precision, width, height. If a single number is passed,
  39672. * it will be used for both width and height. If an object is passed, the screenshot size
  39673. * will be derived from the parameters. The precision property is a multiplier allowing
  39674. * rendering at a higher or lower resolution
  39675. * @param successCallback defines the callback receives a single parameter which contains the
  39676. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39677. * src parameter of an <img> to display it
  39678. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39679. * Check your browser for supported MIME types
  39680. */
  39681. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39682. /**
  39683. * Captures a screenshot of the current rendering
  39684. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39685. * @param engine defines the rendering engine
  39686. * @param camera defines the source camera
  39687. * @param size This parameter can be set to a single number or to an object with the
  39688. * following (optional) properties: precision, width, height. If a single number is passed,
  39689. * it will be used for both width and height. If an object is passed, the screenshot size
  39690. * will be derived from the parameters. The precision property is a multiplier allowing
  39691. * rendering at a higher or lower resolution
  39692. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39693. * Check your browser for supported MIME types
  39694. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39695. * to the src parameter of an <img> to display it
  39696. */
  39697. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39698. /**
  39699. * Generates an image screenshot from the specified camera.
  39700. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39701. * @param engine The engine to use for rendering
  39702. * @param camera The camera to use for rendering
  39703. * @param size This parameter can be set to a single number or to an object with the
  39704. * following (optional) properties: precision, width, height. If a single number is passed,
  39705. * it will be used for both width and height. If an object is passed, the screenshot size
  39706. * will be derived from the parameters. The precision property is a multiplier allowing
  39707. * rendering at a higher or lower resolution
  39708. * @param successCallback The callback receives a single parameter which contains the
  39709. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39710. * src parameter of an <img> to display it
  39711. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39712. * Check your browser for supported MIME types
  39713. * @param samples Texture samples (default: 1)
  39714. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39715. * @param fileName A name for for the downloaded file.
  39716. */
  39717. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39718. /**
  39719. * Generates an image screenshot from the specified camera.
  39720. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39721. * @param engine The engine to use for rendering
  39722. * @param camera The camera to use for rendering
  39723. * @param size This parameter can be set to a single number or to an object with the
  39724. * following (optional) properties: precision, width, height. If a single number is passed,
  39725. * it will be used for both width and height. If an object is passed, the screenshot size
  39726. * will be derived from the parameters. The precision property is a multiplier allowing
  39727. * rendering at a higher or lower resolution
  39728. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39729. * Check your browser for supported MIME types
  39730. * @param samples Texture samples (default: 1)
  39731. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39732. * @param fileName A name for for the downloaded file.
  39733. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39734. * to the src parameter of an <img> to display it
  39735. */
  39736. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39737. /**
  39738. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39739. * Be aware Math.random() could cause collisions, but:
  39740. * "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"
  39741. * @returns a pseudo random id
  39742. */
  39743. static RandomId(): string;
  39744. /**
  39745. * Test if the given uri is a base64 string
  39746. * @param uri The uri to test
  39747. * @return True if the uri is a base64 string or false otherwise
  39748. */
  39749. static IsBase64(uri: string): boolean;
  39750. /**
  39751. * Decode the given base64 uri.
  39752. * @param uri The uri to decode
  39753. * @return The decoded base64 data.
  39754. */
  39755. static DecodeBase64(uri: string): ArrayBuffer;
  39756. /**
  39757. * Gets the absolute url.
  39758. * @param url the input url
  39759. * @return the absolute url
  39760. */
  39761. static GetAbsoluteUrl(url: string): string;
  39762. /**
  39763. * No log
  39764. */
  39765. static readonly NoneLogLevel: number;
  39766. /**
  39767. * Only message logs
  39768. */
  39769. static readonly MessageLogLevel: number;
  39770. /**
  39771. * Only warning logs
  39772. */
  39773. static readonly WarningLogLevel: number;
  39774. /**
  39775. * Only error logs
  39776. */
  39777. static readonly ErrorLogLevel: number;
  39778. /**
  39779. * All logs
  39780. */
  39781. static readonly AllLogLevel: number;
  39782. /**
  39783. * Gets a value indicating the number of loading errors
  39784. * @ignorenaming
  39785. */
  39786. static get errorsCount(): number;
  39787. /**
  39788. * Callback called when a new log is added
  39789. */
  39790. static OnNewCacheEntry: (entry: string) => void;
  39791. /**
  39792. * Log a message to the console
  39793. * @param message defines the message to log
  39794. */
  39795. static Log(message: string): void;
  39796. /**
  39797. * Write a warning message to the console
  39798. * @param message defines the message to log
  39799. */
  39800. static Warn(message: string): void;
  39801. /**
  39802. * Write an error message to the console
  39803. * @param message defines the message to log
  39804. */
  39805. static Error(message: string): void;
  39806. /**
  39807. * Gets current log cache (list of logs)
  39808. */
  39809. static get LogCache(): string;
  39810. /**
  39811. * Clears the log cache
  39812. */
  39813. static ClearLogCache(): void;
  39814. /**
  39815. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39816. */
  39817. static set LogLevels(level: number);
  39818. /**
  39819. * Checks if the window object exists
  39820. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39821. */
  39822. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39823. /**
  39824. * No performance log
  39825. */
  39826. static readonly PerformanceNoneLogLevel: number;
  39827. /**
  39828. * Use user marks to log performance
  39829. */
  39830. static readonly PerformanceUserMarkLogLevel: number;
  39831. /**
  39832. * Log performance to the console
  39833. */
  39834. static readonly PerformanceConsoleLogLevel: number;
  39835. private static _performance;
  39836. /**
  39837. * Sets the current performance log level
  39838. */
  39839. static set PerformanceLogLevel(level: number);
  39840. private static _StartPerformanceCounterDisabled;
  39841. private static _EndPerformanceCounterDisabled;
  39842. private static _StartUserMark;
  39843. private static _EndUserMark;
  39844. private static _StartPerformanceConsole;
  39845. private static _EndPerformanceConsole;
  39846. /**
  39847. * Starts a performance counter
  39848. */
  39849. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39850. /**
  39851. * Ends a specific performance coutner
  39852. */
  39853. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39854. /**
  39855. * Gets either window.performance.now() if supported or Date.now() else
  39856. */
  39857. static get Now(): number;
  39858. /**
  39859. * This method will return the name of the class used to create the instance of the given object.
  39860. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39861. * @param object the object to get the class name from
  39862. * @param isType defines if the object is actually a type
  39863. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39864. */
  39865. static GetClassName(object: any, isType?: boolean): string;
  39866. /**
  39867. * Gets the first element of an array satisfying a given predicate
  39868. * @param array defines the array to browse
  39869. * @param predicate defines the predicate to use
  39870. * @returns null if not found or the element
  39871. */
  39872. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39873. /**
  39874. * This method will return the name of the full name of the class, including its owning module (if any).
  39875. * 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).
  39876. * @param object the object to get the class name from
  39877. * @param isType defines if the object is actually a type
  39878. * @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.
  39879. * @ignorenaming
  39880. */
  39881. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39882. /**
  39883. * Returns a promise that resolves after the given amount of time.
  39884. * @param delay Number of milliseconds to delay
  39885. * @returns Promise that resolves after the given amount of time
  39886. */
  39887. static DelayAsync(delay: number): Promise<void>;
  39888. /**
  39889. * Utility function to detect if the current user agent is Safari
  39890. * @returns whether or not the current user agent is safari
  39891. */
  39892. static IsSafari(): boolean;
  39893. }
  39894. /**
  39895. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39896. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39897. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39898. * @param name The name of the class, case should be preserved
  39899. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39900. */
  39901. export function className(name: string, module?: string): (target: Object) => void;
  39902. /**
  39903. * An implementation of a loop for asynchronous functions.
  39904. */
  39905. export class AsyncLoop {
  39906. /**
  39907. * Defines the number of iterations for the loop
  39908. */
  39909. iterations: number;
  39910. /**
  39911. * Defines the current index of the loop.
  39912. */
  39913. index: number;
  39914. private _done;
  39915. private _fn;
  39916. private _successCallback;
  39917. /**
  39918. * Constructor.
  39919. * @param iterations the number of iterations.
  39920. * @param func the function to run each iteration
  39921. * @param successCallback the callback that will be called upon succesful execution
  39922. * @param offset starting offset.
  39923. */
  39924. constructor(
  39925. /**
  39926. * Defines the number of iterations for the loop
  39927. */
  39928. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39929. /**
  39930. * Execute the next iteration. Must be called after the last iteration was finished.
  39931. */
  39932. executeNext(): void;
  39933. /**
  39934. * Break the loop and run the success callback.
  39935. */
  39936. breakLoop(): void;
  39937. /**
  39938. * Create and run an async loop.
  39939. * @param iterations the number of iterations.
  39940. * @param fn the function to run each iteration
  39941. * @param successCallback the callback that will be called upon succesful execution
  39942. * @param offset starting offset.
  39943. * @returns the created async loop object
  39944. */
  39945. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39946. /**
  39947. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39948. * @param iterations total number of iterations
  39949. * @param syncedIterations number of synchronous iterations in each async iteration.
  39950. * @param fn the function to call each iteration.
  39951. * @param callback a success call back that will be called when iterating stops.
  39952. * @param breakFunction a break condition (optional)
  39953. * @param timeout timeout settings for the setTimeout function. default - 0.
  39954. * @returns the created async loop object
  39955. */
  39956. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39957. }
  39958. }
  39959. declare module "babylonjs/Misc/stringDictionary" {
  39960. import { Nullable } from "babylonjs/types";
  39961. /**
  39962. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39963. * The underlying implementation relies on an associative array to ensure the best performances.
  39964. * The value can be anything including 'null' but except 'undefined'
  39965. */
  39966. export class StringDictionary<T> {
  39967. /**
  39968. * This will clear this dictionary and copy the content from the 'source' one.
  39969. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39970. * @param source the dictionary to take the content from and copy to this dictionary
  39971. */
  39972. copyFrom(source: StringDictionary<T>): void;
  39973. /**
  39974. * Get a value based from its key
  39975. * @param key the given key to get the matching value from
  39976. * @return the value if found, otherwise undefined is returned
  39977. */
  39978. get(key: string): T | undefined;
  39979. /**
  39980. * Get a value from its key or add it if it doesn't exist.
  39981. * This method will ensure you that a given key/data will be present in the dictionary.
  39982. * @param key the given key to get the matching value from
  39983. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39984. * The factory will only be invoked if there's no data for the given key.
  39985. * @return the value corresponding to the key.
  39986. */
  39987. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39988. /**
  39989. * Get a value from its key if present in the dictionary otherwise add it
  39990. * @param key the key to get the value from
  39991. * @param val if there's no such key/value pair in the dictionary add it with this value
  39992. * @return the value corresponding to the key
  39993. */
  39994. getOrAdd(key: string, val: T): T;
  39995. /**
  39996. * Check if there's a given key in the dictionary
  39997. * @param key the key to check for
  39998. * @return true if the key is present, false otherwise
  39999. */
  40000. contains(key: string): boolean;
  40001. /**
  40002. * Add a new key and its corresponding value
  40003. * @param key the key to add
  40004. * @param value the value corresponding to the key
  40005. * @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
  40006. */
  40007. add(key: string, value: T): boolean;
  40008. /**
  40009. * Update a specific value associated to a key
  40010. * @param key defines the key to use
  40011. * @param value defines the value to store
  40012. * @returns true if the value was updated (or false if the key was not found)
  40013. */
  40014. set(key: string, value: T): boolean;
  40015. /**
  40016. * Get the element of the given key and remove it from the dictionary
  40017. * @param key defines the key to search
  40018. * @returns the value associated with the key or null if not found
  40019. */
  40020. getAndRemove(key: string): Nullable<T>;
  40021. /**
  40022. * Remove a key/value from the dictionary.
  40023. * @param key the key to remove
  40024. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40025. */
  40026. remove(key: string): boolean;
  40027. /**
  40028. * Clear the whole content of the dictionary
  40029. */
  40030. clear(): void;
  40031. /**
  40032. * Gets the current count
  40033. */
  40034. get count(): number;
  40035. /**
  40036. * Execute a callback on each key/val of the dictionary.
  40037. * Note that you can remove any element in this dictionary in the callback implementation
  40038. * @param callback the callback to execute on a given key/value pair
  40039. */
  40040. forEach(callback: (key: string, val: T) => void): void;
  40041. /**
  40042. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40043. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40044. * Note that you can remove any element in this dictionary in the callback implementation
  40045. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40046. * @returns the first item
  40047. */
  40048. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40049. private _count;
  40050. private _data;
  40051. }
  40052. }
  40053. declare module "babylonjs/Collisions/collisionCoordinator" {
  40054. import { Nullable } from "babylonjs/types";
  40055. import { Scene } from "babylonjs/scene";
  40056. import { Vector3 } from "babylonjs/Maths/math.vector";
  40057. import { Collider } from "babylonjs/Collisions/collider";
  40058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40059. /** @hidden */
  40060. export interface ICollisionCoordinator {
  40061. createCollider(): Collider;
  40062. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40063. init(scene: Scene): void;
  40064. }
  40065. /** @hidden */
  40066. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40067. private _scene;
  40068. private _scaledPosition;
  40069. private _scaledVelocity;
  40070. private _finalPosition;
  40071. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40072. createCollider(): Collider;
  40073. init(scene: Scene): void;
  40074. private _collideWithWorld;
  40075. }
  40076. }
  40077. declare module "babylonjs/Inputs/scene.inputManager" {
  40078. import { Nullable } from "babylonjs/types";
  40079. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40080. import { Vector2 } from "babylonjs/Maths/math.vector";
  40081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40082. import { Scene } from "babylonjs/scene";
  40083. /**
  40084. * Class used to manage all inputs for the scene.
  40085. */
  40086. export class InputManager {
  40087. /** The distance in pixel that you have to move to prevent some events */
  40088. static DragMovementThreshold: number;
  40089. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40090. static LongPressDelay: number;
  40091. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40092. static DoubleClickDelay: number;
  40093. /** If you need to check double click without raising a single click at first click, enable this flag */
  40094. static ExclusiveDoubleClickMode: boolean;
  40095. /** 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. */
  40096. private _alreadyAttached;
  40097. private _wheelEventName;
  40098. private _onPointerMove;
  40099. private _onPointerDown;
  40100. private _onPointerUp;
  40101. private _initClickEvent;
  40102. private _initActionManager;
  40103. private _delayedSimpleClick;
  40104. private _delayedSimpleClickTimeout;
  40105. private _previousDelayedSimpleClickTimeout;
  40106. private _meshPickProceed;
  40107. private _previousButtonPressed;
  40108. private _currentPickResult;
  40109. private _previousPickResult;
  40110. private _totalPointersPressed;
  40111. private _doubleClickOccured;
  40112. private _pointerOverMesh;
  40113. private _pickedDownMesh;
  40114. private _pickedUpMesh;
  40115. private _pointerX;
  40116. private _pointerY;
  40117. private _unTranslatedPointerX;
  40118. private _unTranslatedPointerY;
  40119. private _startingPointerPosition;
  40120. private _previousStartingPointerPosition;
  40121. private _startingPointerTime;
  40122. private _previousStartingPointerTime;
  40123. private _pointerCaptures;
  40124. private _onKeyDown;
  40125. private _onKeyUp;
  40126. private _onCanvasFocusObserver;
  40127. private _onCanvasBlurObserver;
  40128. private _scene;
  40129. /**
  40130. * Creates a new InputManager
  40131. * @param scene defines the hosting scene
  40132. */
  40133. constructor(scene: Scene);
  40134. /**
  40135. * Gets the mesh that is currently under the pointer
  40136. */
  40137. get meshUnderPointer(): Nullable<AbstractMesh>;
  40138. /**
  40139. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40140. */
  40141. get unTranslatedPointer(): Vector2;
  40142. /**
  40143. * Gets or sets the current on-screen X position of the pointer
  40144. */
  40145. get pointerX(): number;
  40146. set pointerX(value: number);
  40147. /**
  40148. * Gets or sets the current on-screen Y position of the pointer
  40149. */
  40150. get pointerY(): number;
  40151. set pointerY(value: number);
  40152. private _updatePointerPosition;
  40153. private _processPointerMove;
  40154. private _setRayOnPointerInfo;
  40155. private _checkPrePointerObservable;
  40156. /**
  40157. * Use this method to simulate a pointer move on a mesh
  40158. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40159. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40160. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40161. */
  40162. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40163. /**
  40164. * Use this method to simulate a pointer down on a mesh
  40165. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40166. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40167. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40168. */
  40169. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40170. private _processPointerDown;
  40171. /** @hidden */
  40172. _isPointerSwiping(): boolean;
  40173. /**
  40174. * Use this method to simulate a pointer up on a mesh
  40175. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40176. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40177. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40178. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40179. */
  40180. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40181. private _processPointerUp;
  40182. /**
  40183. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40184. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40185. * @returns true if the pointer was captured
  40186. */
  40187. isPointerCaptured(pointerId?: number): boolean;
  40188. /**
  40189. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40190. * @param attachUp defines if you want to attach events to pointerup
  40191. * @param attachDown defines if you want to attach events to pointerdown
  40192. * @param attachMove defines if you want to attach events to pointermove
  40193. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40194. */
  40195. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40196. /**
  40197. * Detaches all event handlers
  40198. */
  40199. detachControl(): void;
  40200. /**
  40201. * Force the value of meshUnderPointer
  40202. * @param mesh defines the mesh to use
  40203. */
  40204. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40205. /**
  40206. * Gets the mesh under the pointer
  40207. * @returns a Mesh or null if no mesh is under the pointer
  40208. */
  40209. getPointerOverMesh(): Nullable<AbstractMesh>;
  40210. }
  40211. }
  40212. declare module "babylonjs/Animations/animationGroup" {
  40213. import { Animatable } from "babylonjs/Animations/animatable";
  40214. import { Animation } from "babylonjs/Animations/animation";
  40215. import { Scene, IDisposable } from "babylonjs/scene";
  40216. import { Observable } from "babylonjs/Misc/observable";
  40217. import { Nullable } from "babylonjs/types";
  40218. import "babylonjs/Animations/animatable";
  40219. /**
  40220. * This class defines the direct association between an animation and a target
  40221. */
  40222. export class TargetedAnimation {
  40223. /**
  40224. * Animation to perform
  40225. */
  40226. animation: Animation;
  40227. /**
  40228. * Target to animate
  40229. */
  40230. target: any;
  40231. /**
  40232. * Returns the string "TargetedAnimation"
  40233. * @returns "TargetedAnimation"
  40234. */
  40235. getClassName(): string;
  40236. /**
  40237. * Serialize the object
  40238. * @returns the JSON object representing the current entity
  40239. */
  40240. serialize(): any;
  40241. }
  40242. /**
  40243. * Use this class to create coordinated animations on multiple targets
  40244. */
  40245. export class AnimationGroup implements IDisposable {
  40246. /** The name of the animation group */
  40247. name: string;
  40248. private _scene;
  40249. private _targetedAnimations;
  40250. private _animatables;
  40251. private _from;
  40252. private _to;
  40253. private _isStarted;
  40254. private _isPaused;
  40255. private _speedRatio;
  40256. private _loopAnimation;
  40257. private _isAdditive;
  40258. /**
  40259. * Gets or sets the unique id of the node
  40260. */
  40261. uniqueId: number;
  40262. /**
  40263. * This observable will notify when one animation have ended
  40264. */
  40265. onAnimationEndObservable: Observable<TargetedAnimation>;
  40266. /**
  40267. * Observer raised when one animation loops
  40268. */
  40269. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40270. /**
  40271. * Observer raised when all animations have looped
  40272. */
  40273. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40274. /**
  40275. * This observable will notify when all animations have ended.
  40276. */
  40277. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40278. /**
  40279. * This observable will notify when all animations have paused.
  40280. */
  40281. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40282. /**
  40283. * This observable will notify when all animations are playing.
  40284. */
  40285. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40286. /**
  40287. * Gets the first frame
  40288. */
  40289. get from(): number;
  40290. /**
  40291. * Gets the last frame
  40292. */
  40293. get to(): number;
  40294. /**
  40295. * Define if the animations are started
  40296. */
  40297. get isStarted(): boolean;
  40298. /**
  40299. * Gets a value indicating that the current group is playing
  40300. */
  40301. get isPlaying(): boolean;
  40302. /**
  40303. * Gets or sets the speed ratio to use for all animations
  40304. */
  40305. get speedRatio(): number;
  40306. /**
  40307. * Gets or sets the speed ratio to use for all animations
  40308. */
  40309. set speedRatio(value: number);
  40310. /**
  40311. * Gets or sets if all animations should loop or not
  40312. */
  40313. get loopAnimation(): boolean;
  40314. set loopAnimation(value: boolean);
  40315. /**
  40316. * Gets or sets if all animations should be evaluated additively
  40317. */
  40318. get isAdditive(): boolean;
  40319. set isAdditive(value: boolean);
  40320. /**
  40321. * Gets the targeted animations for this animation group
  40322. */
  40323. get targetedAnimations(): Array<TargetedAnimation>;
  40324. /**
  40325. * returning the list of animatables controlled by this animation group.
  40326. */
  40327. get animatables(): Array<Animatable>;
  40328. /**
  40329. * Gets the list of target animations
  40330. */
  40331. get children(): TargetedAnimation[];
  40332. /**
  40333. * Instantiates a new Animation Group.
  40334. * This helps managing several animations at once.
  40335. * @see https://doc.babylonjs.com/how_to/group
  40336. * @param name Defines the name of the group
  40337. * @param scene Defines the scene the group belongs to
  40338. */
  40339. constructor(
  40340. /** The name of the animation group */
  40341. name: string, scene?: Nullable<Scene>);
  40342. /**
  40343. * Add an animation (with its target) in the group
  40344. * @param animation defines the animation we want to add
  40345. * @param target defines the target of the animation
  40346. * @returns the TargetedAnimation object
  40347. */
  40348. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40349. /**
  40350. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40351. * It can add constant keys at begin or end
  40352. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40353. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40354. * @returns the animation group
  40355. */
  40356. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40357. private _animationLoopCount;
  40358. private _animationLoopFlags;
  40359. private _processLoop;
  40360. /**
  40361. * Start all animations on given targets
  40362. * @param loop defines if animations must loop
  40363. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40364. * @param from defines the from key (optional)
  40365. * @param to defines the to key (optional)
  40366. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40367. * @returns the current animation group
  40368. */
  40369. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40370. /**
  40371. * Pause all animations
  40372. * @returns the animation group
  40373. */
  40374. pause(): AnimationGroup;
  40375. /**
  40376. * Play all animations to initial state
  40377. * This function will start() the animations if they were not started or will restart() them if they were paused
  40378. * @param loop defines if animations must loop
  40379. * @returns the animation group
  40380. */
  40381. play(loop?: boolean): AnimationGroup;
  40382. /**
  40383. * Reset all animations to initial state
  40384. * @returns the animation group
  40385. */
  40386. reset(): AnimationGroup;
  40387. /**
  40388. * Restart animations from key 0
  40389. * @returns the animation group
  40390. */
  40391. restart(): AnimationGroup;
  40392. /**
  40393. * Stop all animations
  40394. * @returns the animation group
  40395. */
  40396. stop(): AnimationGroup;
  40397. /**
  40398. * Set animation weight for all animatables
  40399. * @param weight defines the weight to use
  40400. * @return the animationGroup
  40401. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40402. */
  40403. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40404. /**
  40405. * Synchronize and normalize all animatables with a source animatable
  40406. * @param root defines the root animatable to synchronize with
  40407. * @return the animationGroup
  40408. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40409. */
  40410. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40411. /**
  40412. * Goes to a specific frame in this animation group
  40413. * @param frame the frame number to go to
  40414. * @return the animationGroup
  40415. */
  40416. goToFrame(frame: number): AnimationGroup;
  40417. /**
  40418. * Dispose all associated resources
  40419. */
  40420. dispose(): void;
  40421. private _checkAnimationGroupEnded;
  40422. /**
  40423. * Clone the current animation group and returns a copy
  40424. * @param newName defines the name of the new group
  40425. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40426. * @returns the new aniamtion group
  40427. */
  40428. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40429. /**
  40430. * Serializes the animationGroup to an object
  40431. * @returns Serialized object
  40432. */
  40433. serialize(): any;
  40434. /**
  40435. * Returns a new AnimationGroup object parsed from the source provided.
  40436. * @param parsedAnimationGroup defines the source
  40437. * @param scene defines the scene that will receive the animationGroup
  40438. * @returns a new AnimationGroup
  40439. */
  40440. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40441. /**
  40442. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40443. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40444. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40445. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40446. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40447. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40448. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40449. */
  40450. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40451. /**
  40452. * Returns the string "AnimationGroup"
  40453. * @returns "AnimationGroup"
  40454. */
  40455. getClassName(): string;
  40456. /**
  40457. * Creates a detailled string about the object
  40458. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40459. * @returns a string representing the object
  40460. */
  40461. toString(fullDetails?: boolean): string;
  40462. }
  40463. }
  40464. declare module "babylonjs/scene" {
  40465. import { Nullable } from "babylonjs/types";
  40466. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40467. import { Observable } from "babylonjs/Misc/observable";
  40468. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40469. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40470. import { Geometry } from "babylonjs/Meshes/geometry";
  40471. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40472. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40474. import { Mesh } from "babylonjs/Meshes/mesh";
  40475. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40476. import { Bone } from "babylonjs/Bones/bone";
  40477. import { Skeleton } from "babylonjs/Bones/skeleton";
  40478. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40479. import { Camera } from "babylonjs/Cameras/camera";
  40480. import { AbstractScene } from "babylonjs/abstractScene";
  40481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40483. import { Material } from "babylonjs/Materials/material";
  40484. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40485. import { Effect } from "babylonjs/Materials/effect";
  40486. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40487. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40488. import { Light } from "babylonjs/Lights/light";
  40489. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40490. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40491. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40492. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40493. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40494. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40495. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40496. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40497. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40498. import { Engine } from "babylonjs/Engines/engine";
  40499. import { Node } from "babylonjs/node";
  40500. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40501. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40502. import { WebRequest } from "babylonjs/Misc/webRequest";
  40503. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40504. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40505. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40506. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40507. import { Plane } from "babylonjs/Maths/math.plane";
  40508. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40509. import { Ray } from "babylonjs/Culling/ray";
  40510. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40511. import { Animation } from "babylonjs/Animations/animation";
  40512. import { Animatable } from "babylonjs/Animations/animatable";
  40513. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40514. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40515. import { Collider } from "babylonjs/Collisions/collider";
  40516. /**
  40517. * Define an interface for all classes that will hold resources
  40518. */
  40519. export interface IDisposable {
  40520. /**
  40521. * Releases all held resources
  40522. */
  40523. dispose(): void;
  40524. }
  40525. /** Interface defining initialization parameters for Scene class */
  40526. export interface SceneOptions {
  40527. /**
  40528. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40529. * It will improve performance when the number of geometries becomes important.
  40530. */
  40531. useGeometryUniqueIdsMap?: boolean;
  40532. /**
  40533. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40534. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40535. */
  40536. useMaterialMeshMap?: boolean;
  40537. /**
  40538. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40539. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40540. */
  40541. useClonedMeshMap?: boolean;
  40542. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40543. virtual?: boolean;
  40544. }
  40545. /**
  40546. * Represents a scene to be rendered by the engine.
  40547. * @see https://doc.babylonjs.com/features/scene
  40548. */
  40549. export class Scene extends AbstractScene implements IAnimatable {
  40550. /** The fog is deactivated */
  40551. static readonly FOGMODE_NONE: number;
  40552. /** The fog density is following an exponential function */
  40553. static readonly FOGMODE_EXP: number;
  40554. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40555. static readonly FOGMODE_EXP2: number;
  40556. /** The fog density is following a linear function. */
  40557. static readonly FOGMODE_LINEAR: number;
  40558. /**
  40559. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40560. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40561. */
  40562. static MinDeltaTime: number;
  40563. /**
  40564. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40565. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40566. */
  40567. static MaxDeltaTime: number;
  40568. /**
  40569. * Factory used to create the default material.
  40570. * @param name The name of the material to create
  40571. * @param scene The scene to create the material for
  40572. * @returns The default material
  40573. */
  40574. static DefaultMaterialFactory(scene: Scene): Material;
  40575. /**
  40576. * Factory used to create the a collision coordinator.
  40577. * @returns The collision coordinator
  40578. */
  40579. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40580. /** @hidden */
  40581. _inputManager: InputManager;
  40582. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40583. cameraToUseForPointers: Nullable<Camera>;
  40584. /** @hidden */
  40585. readonly _isScene: boolean;
  40586. /** @hidden */
  40587. _blockEntityCollection: boolean;
  40588. /**
  40589. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40590. */
  40591. autoClear: boolean;
  40592. /**
  40593. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40594. */
  40595. autoClearDepthAndStencil: boolean;
  40596. /**
  40597. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40598. */
  40599. clearColor: Color4;
  40600. /**
  40601. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40602. */
  40603. ambientColor: Color3;
  40604. /**
  40605. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40606. * It should only be one of the following (if not the default embedded one):
  40607. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40608. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40609. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40610. * The material properties need to be setup according to the type of texture in use.
  40611. */
  40612. environmentBRDFTexture: BaseTexture;
  40613. /** @hidden */
  40614. protected _environmentTexture: Nullable<BaseTexture>;
  40615. /**
  40616. * Texture used in all pbr material as the reflection texture.
  40617. * As in the majority of the scene they are the same (exception for multi room and so on),
  40618. * this is easier to reference from here than from all the materials.
  40619. */
  40620. get environmentTexture(): Nullable<BaseTexture>;
  40621. /**
  40622. * Texture used in all pbr material as the reflection texture.
  40623. * As in the majority of the scene they are the same (exception for multi room and so on),
  40624. * this is easier to set here than in all the materials.
  40625. */
  40626. set environmentTexture(value: Nullable<BaseTexture>);
  40627. /** @hidden */
  40628. protected _environmentIntensity: number;
  40629. /**
  40630. * Intensity of the environment in all pbr material.
  40631. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40632. * As in the majority of the scene they are the same (exception for multi room and so on),
  40633. * this is easier to reference from here than from all the materials.
  40634. */
  40635. get environmentIntensity(): number;
  40636. /**
  40637. * Intensity of the environment in all pbr material.
  40638. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40639. * As in the majority of the scene they are the same (exception for multi room and so on),
  40640. * this is easier to set here than in all the materials.
  40641. */
  40642. set environmentIntensity(value: number);
  40643. /** @hidden */
  40644. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40645. /**
  40646. * Default image processing configuration used either in the rendering
  40647. * Forward main pass or through the imageProcessingPostProcess if present.
  40648. * As in the majority of the scene they are the same (exception for multi camera),
  40649. * this is easier to reference from here than from all the materials and post process.
  40650. *
  40651. * No setter as we it is a shared configuration, you can set the values instead.
  40652. */
  40653. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40654. private _forceWireframe;
  40655. /**
  40656. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40657. */
  40658. set forceWireframe(value: boolean);
  40659. get forceWireframe(): boolean;
  40660. private _skipFrustumClipping;
  40661. /**
  40662. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40663. */
  40664. set skipFrustumClipping(value: boolean);
  40665. get skipFrustumClipping(): boolean;
  40666. private _forcePointsCloud;
  40667. /**
  40668. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40669. */
  40670. set forcePointsCloud(value: boolean);
  40671. get forcePointsCloud(): boolean;
  40672. /**
  40673. * Gets or sets the active clipplane 1
  40674. */
  40675. clipPlane: Nullable<Plane>;
  40676. /**
  40677. * Gets or sets the active clipplane 2
  40678. */
  40679. clipPlane2: Nullable<Plane>;
  40680. /**
  40681. * Gets or sets the active clipplane 3
  40682. */
  40683. clipPlane3: Nullable<Plane>;
  40684. /**
  40685. * Gets or sets the active clipplane 4
  40686. */
  40687. clipPlane4: Nullable<Plane>;
  40688. /**
  40689. * Gets or sets the active clipplane 5
  40690. */
  40691. clipPlane5: Nullable<Plane>;
  40692. /**
  40693. * Gets or sets the active clipplane 6
  40694. */
  40695. clipPlane6: Nullable<Plane>;
  40696. /**
  40697. * Gets or sets a boolean indicating if animations are enabled
  40698. */
  40699. animationsEnabled: boolean;
  40700. private _animationPropertiesOverride;
  40701. /**
  40702. * Gets or sets the animation properties override
  40703. */
  40704. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40705. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40706. /**
  40707. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40708. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40709. */
  40710. useConstantAnimationDeltaTime: boolean;
  40711. /**
  40712. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40713. * Please note that it requires to run a ray cast through the scene on every frame
  40714. */
  40715. constantlyUpdateMeshUnderPointer: boolean;
  40716. /**
  40717. * Defines the HTML cursor to use when hovering over interactive elements
  40718. */
  40719. hoverCursor: string;
  40720. /**
  40721. * Defines the HTML default cursor to use (empty by default)
  40722. */
  40723. defaultCursor: string;
  40724. /**
  40725. * Defines whether cursors are handled by the scene.
  40726. */
  40727. doNotHandleCursors: boolean;
  40728. /**
  40729. * This is used to call preventDefault() on pointer down
  40730. * in order to block unwanted artifacts like system double clicks
  40731. */
  40732. preventDefaultOnPointerDown: boolean;
  40733. /**
  40734. * This is used to call preventDefault() on pointer up
  40735. * in order to block unwanted artifacts like system double clicks
  40736. */
  40737. preventDefaultOnPointerUp: boolean;
  40738. /**
  40739. * Gets or sets user defined metadata
  40740. */
  40741. metadata: any;
  40742. /**
  40743. * For internal use only. Please do not use.
  40744. */
  40745. reservedDataStore: any;
  40746. /**
  40747. * Gets the name of the plugin used to load this scene (null by default)
  40748. */
  40749. loadingPluginName: string;
  40750. /**
  40751. * Use this array to add regular expressions used to disable offline support for specific urls
  40752. */
  40753. disableOfflineSupportExceptionRules: RegExp[];
  40754. /**
  40755. * An event triggered when the scene is disposed.
  40756. */
  40757. onDisposeObservable: Observable<Scene>;
  40758. private _onDisposeObserver;
  40759. /** Sets a function to be executed when this scene is disposed. */
  40760. set onDispose(callback: () => void);
  40761. /**
  40762. * An event triggered before rendering the scene (right after animations and physics)
  40763. */
  40764. onBeforeRenderObservable: Observable<Scene>;
  40765. private _onBeforeRenderObserver;
  40766. /** Sets a function to be executed before rendering this scene */
  40767. set beforeRender(callback: Nullable<() => void>);
  40768. /**
  40769. * An event triggered after rendering the scene
  40770. */
  40771. onAfterRenderObservable: Observable<Scene>;
  40772. /**
  40773. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40774. */
  40775. onAfterRenderCameraObservable: Observable<Camera>;
  40776. private _onAfterRenderObserver;
  40777. /** Sets a function to be executed after rendering this scene */
  40778. set afterRender(callback: Nullable<() => void>);
  40779. /**
  40780. * An event triggered before animating the scene
  40781. */
  40782. onBeforeAnimationsObservable: Observable<Scene>;
  40783. /**
  40784. * An event triggered after animations processing
  40785. */
  40786. onAfterAnimationsObservable: Observable<Scene>;
  40787. /**
  40788. * An event triggered before draw calls are ready to be sent
  40789. */
  40790. onBeforeDrawPhaseObservable: Observable<Scene>;
  40791. /**
  40792. * An event triggered after draw calls have been sent
  40793. */
  40794. onAfterDrawPhaseObservable: Observable<Scene>;
  40795. /**
  40796. * An event triggered when the scene is ready
  40797. */
  40798. onReadyObservable: Observable<Scene>;
  40799. /**
  40800. * An event triggered before rendering a camera
  40801. */
  40802. onBeforeCameraRenderObservable: Observable<Camera>;
  40803. private _onBeforeCameraRenderObserver;
  40804. /** Sets a function to be executed before rendering a camera*/
  40805. set beforeCameraRender(callback: () => void);
  40806. /**
  40807. * An event triggered after rendering a camera
  40808. */
  40809. onAfterCameraRenderObservable: Observable<Camera>;
  40810. private _onAfterCameraRenderObserver;
  40811. /** Sets a function to be executed after rendering a camera*/
  40812. set afterCameraRender(callback: () => void);
  40813. /**
  40814. * An event triggered when active meshes evaluation is about to start
  40815. */
  40816. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40817. /**
  40818. * An event triggered when active meshes evaluation is done
  40819. */
  40820. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40821. /**
  40822. * An event triggered when particles rendering is about to start
  40823. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40824. */
  40825. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40826. /**
  40827. * An event triggered when particles rendering is done
  40828. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40829. */
  40830. onAfterParticlesRenderingObservable: Observable<Scene>;
  40831. /**
  40832. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40833. */
  40834. onDataLoadedObservable: Observable<Scene>;
  40835. /**
  40836. * An event triggered when a camera is created
  40837. */
  40838. onNewCameraAddedObservable: Observable<Camera>;
  40839. /**
  40840. * An event triggered when a camera is removed
  40841. */
  40842. onCameraRemovedObservable: Observable<Camera>;
  40843. /**
  40844. * An event triggered when a light is created
  40845. */
  40846. onNewLightAddedObservable: Observable<Light>;
  40847. /**
  40848. * An event triggered when a light is removed
  40849. */
  40850. onLightRemovedObservable: Observable<Light>;
  40851. /**
  40852. * An event triggered when a geometry is created
  40853. */
  40854. onNewGeometryAddedObservable: Observable<Geometry>;
  40855. /**
  40856. * An event triggered when a geometry is removed
  40857. */
  40858. onGeometryRemovedObservable: Observable<Geometry>;
  40859. /**
  40860. * An event triggered when a transform node is created
  40861. */
  40862. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40863. /**
  40864. * An event triggered when a transform node is removed
  40865. */
  40866. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40867. /**
  40868. * An event triggered when a mesh is created
  40869. */
  40870. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40871. /**
  40872. * An event triggered when a mesh is removed
  40873. */
  40874. onMeshRemovedObservable: Observable<AbstractMesh>;
  40875. /**
  40876. * An event triggered when a skeleton is created
  40877. */
  40878. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40879. /**
  40880. * An event triggered when a skeleton is removed
  40881. */
  40882. onSkeletonRemovedObservable: Observable<Skeleton>;
  40883. /**
  40884. * An event triggered when a material is created
  40885. */
  40886. onNewMaterialAddedObservable: Observable<Material>;
  40887. /**
  40888. * An event triggered when a material is removed
  40889. */
  40890. onMaterialRemovedObservable: Observable<Material>;
  40891. /**
  40892. * An event triggered when a texture is created
  40893. */
  40894. onNewTextureAddedObservable: Observable<BaseTexture>;
  40895. /**
  40896. * An event triggered when a texture is removed
  40897. */
  40898. onTextureRemovedObservable: Observable<BaseTexture>;
  40899. /**
  40900. * An event triggered when render targets are about to be rendered
  40901. * Can happen multiple times per frame.
  40902. */
  40903. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40904. /**
  40905. * An event triggered when render targets were rendered.
  40906. * Can happen multiple times per frame.
  40907. */
  40908. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40909. /**
  40910. * An event triggered before calculating deterministic simulation step
  40911. */
  40912. onBeforeStepObservable: Observable<Scene>;
  40913. /**
  40914. * An event triggered after calculating deterministic simulation step
  40915. */
  40916. onAfterStepObservable: Observable<Scene>;
  40917. /**
  40918. * An event triggered when the activeCamera property is updated
  40919. */
  40920. onActiveCameraChanged: Observable<Scene>;
  40921. /**
  40922. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40923. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40924. * 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)
  40925. */
  40926. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40927. /**
  40928. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40929. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40930. * 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)
  40931. */
  40932. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40933. /**
  40934. * This Observable will when a mesh has been imported into the scene.
  40935. */
  40936. onMeshImportedObservable: Observable<AbstractMesh>;
  40937. /**
  40938. * This Observable will when an animation file has been imported into the scene.
  40939. */
  40940. onAnimationFileImportedObservable: Observable<Scene>;
  40941. /**
  40942. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40943. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40944. */
  40945. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40946. /** @hidden */
  40947. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40948. /**
  40949. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40950. */
  40951. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40952. /**
  40953. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40954. */
  40955. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40956. /**
  40957. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40958. */
  40959. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40960. /** Callback called when a pointer move is detected */
  40961. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40962. /** Callback called when a pointer down is detected */
  40963. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40964. /** Callback called when a pointer up is detected */
  40965. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40966. /** Callback called when a pointer pick is detected */
  40967. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40968. /**
  40969. * 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).
  40970. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40971. */
  40972. onPrePointerObservable: Observable<PointerInfoPre>;
  40973. /**
  40974. * Observable event triggered each time an input event is received from the rendering canvas
  40975. */
  40976. onPointerObservable: Observable<PointerInfo>;
  40977. /**
  40978. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40979. */
  40980. get unTranslatedPointer(): Vector2;
  40981. /**
  40982. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40983. */
  40984. static get DragMovementThreshold(): number;
  40985. static set DragMovementThreshold(value: number);
  40986. /**
  40987. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40988. */
  40989. static get LongPressDelay(): number;
  40990. static set LongPressDelay(value: number);
  40991. /**
  40992. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40993. */
  40994. static get DoubleClickDelay(): number;
  40995. static set DoubleClickDelay(value: number);
  40996. /** If you need to check double click without raising a single click at first click, enable this flag */
  40997. static get ExclusiveDoubleClickMode(): boolean;
  40998. static set ExclusiveDoubleClickMode(value: boolean);
  40999. /** @hidden */
  41000. _mirroredCameraPosition: Nullable<Vector3>;
  41001. /**
  41002. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41003. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41004. */
  41005. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41006. /**
  41007. * Observable event triggered each time an keyboard event is received from the hosting window
  41008. */
  41009. onKeyboardObservable: Observable<KeyboardInfo>;
  41010. private _useRightHandedSystem;
  41011. /**
  41012. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41013. */
  41014. set useRightHandedSystem(value: boolean);
  41015. get useRightHandedSystem(): boolean;
  41016. private _timeAccumulator;
  41017. private _currentStepId;
  41018. private _currentInternalStep;
  41019. /**
  41020. * Sets the step Id used by deterministic lock step
  41021. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41022. * @param newStepId defines the step Id
  41023. */
  41024. setStepId(newStepId: number): void;
  41025. /**
  41026. * Gets the step Id used by deterministic lock step
  41027. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41028. * @returns the step Id
  41029. */
  41030. getStepId(): number;
  41031. /**
  41032. * Gets the internal step used by deterministic lock step
  41033. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41034. * @returns the internal step
  41035. */
  41036. getInternalStep(): number;
  41037. private _fogEnabled;
  41038. /**
  41039. * Gets or sets a boolean indicating if fog is enabled on this scene
  41040. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41041. * (Default is true)
  41042. */
  41043. set fogEnabled(value: boolean);
  41044. get fogEnabled(): boolean;
  41045. private _fogMode;
  41046. /**
  41047. * Gets or sets the fog mode to use
  41048. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41049. * | mode | value |
  41050. * | --- | --- |
  41051. * | FOGMODE_NONE | 0 |
  41052. * | FOGMODE_EXP | 1 |
  41053. * | FOGMODE_EXP2 | 2 |
  41054. * | FOGMODE_LINEAR | 3 |
  41055. */
  41056. set fogMode(value: number);
  41057. get fogMode(): number;
  41058. /**
  41059. * Gets or sets the fog color to use
  41060. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41061. * (Default is Color3(0.2, 0.2, 0.3))
  41062. */
  41063. fogColor: Color3;
  41064. /**
  41065. * Gets or sets the fog density to use
  41066. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41067. * (Default is 0.1)
  41068. */
  41069. fogDensity: number;
  41070. /**
  41071. * Gets or sets the fog start distance to use
  41072. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41073. * (Default is 0)
  41074. */
  41075. fogStart: number;
  41076. /**
  41077. * Gets or sets the fog end distance to use
  41078. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41079. * (Default is 1000)
  41080. */
  41081. fogEnd: number;
  41082. /**
  41083. * Flag indicating that the frame buffer binding is handled by another component
  41084. */
  41085. prePass: boolean;
  41086. private _shadowsEnabled;
  41087. /**
  41088. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41089. */
  41090. set shadowsEnabled(value: boolean);
  41091. get shadowsEnabled(): boolean;
  41092. private _lightsEnabled;
  41093. /**
  41094. * Gets or sets a boolean indicating if lights are enabled on this scene
  41095. */
  41096. set lightsEnabled(value: boolean);
  41097. get lightsEnabled(): boolean;
  41098. /** All of the active cameras added to this scene. */
  41099. activeCameras: Camera[];
  41100. /** @hidden */
  41101. _activeCamera: Nullable<Camera>;
  41102. /** Gets or sets the current active camera */
  41103. get activeCamera(): Nullable<Camera>;
  41104. set activeCamera(value: Nullable<Camera>);
  41105. private _defaultMaterial;
  41106. /** The default material used on meshes when no material is affected */
  41107. get defaultMaterial(): Material;
  41108. /** The default material used on meshes when no material is affected */
  41109. set defaultMaterial(value: Material);
  41110. private _texturesEnabled;
  41111. /**
  41112. * Gets or sets a boolean indicating if textures are enabled on this scene
  41113. */
  41114. set texturesEnabled(value: boolean);
  41115. get texturesEnabled(): boolean;
  41116. /**
  41117. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41118. */
  41119. physicsEnabled: boolean;
  41120. /**
  41121. * Gets or sets a boolean indicating if particles are enabled on this scene
  41122. */
  41123. particlesEnabled: boolean;
  41124. /**
  41125. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41126. */
  41127. spritesEnabled: boolean;
  41128. private _skeletonsEnabled;
  41129. /**
  41130. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41131. */
  41132. set skeletonsEnabled(value: boolean);
  41133. get skeletonsEnabled(): boolean;
  41134. /**
  41135. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41136. */
  41137. lensFlaresEnabled: boolean;
  41138. /**
  41139. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41140. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41141. */
  41142. collisionsEnabled: boolean;
  41143. private _collisionCoordinator;
  41144. /** @hidden */
  41145. get collisionCoordinator(): ICollisionCoordinator;
  41146. /**
  41147. * Defines the gravity applied to this scene (used only for collisions)
  41148. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41149. */
  41150. gravity: Vector3;
  41151. /**
  41152. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41153. */
  41154. postProcessesEnabled: boolean;
  41155. /**
  41156. * The list of postprocesses added to the scene
  41157. */
  41158. postProcesses: PostProcess[];
  41159. /**
  41160. * Gets the current postprocess manager
  41161. */
  41162. postProcessManager: PostProcessManager;
  41163. /**
  41164. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41165. */
  41166. renderTargetsEnabled: boolean;
  41167. /**
  41168. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41169. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41170. */
  41171. dumpNextRenderTargets: boolean;
  41172. /**
  41173. * The list of user defined render targets added to the scene
  41174. */
  41175. customRenderTargets: RenderTargetTexture[];
  41176. /**
  41177. * Defines if texture loading must be delayed
  41178. * If true, textures will only be loaded when they need to be rendered
  41179. */
  41180. useDelayedTextureLoading: boolean;
  41181. /**
  41182. * Gets the list of meshes imported to the scene through SceneLoader
  41183. */
  41184. importedMeshesFiles: String[];
  41185. /**
  41186. * Gets or sets a boolean indicating if probes are enabled on this scene
  41187. */
  41188. probesEnabled: boolean;
  41189. /**
  41190. * Gets or sets the current offline provider to use to store scene data
  41191. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41192. */
  41193. offlineProvider: IOfflineProvider;
  41194. /**
  41195. * Gets or sets the action manager associated with the scene
  41196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41197. */
  41198. actionManager: AbstractActionManager;
  41199. private _meshesForIntersections;
  41200. /**
  41201. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41202. */
  41203. proceduralTexturesEnabled: boolean;
  41204. private _engine;
  41205. private _totalVertices;
  41206. /** @hidden */
  41207. _activeIndices: PerfCounter;
  41208. /** @hidden */
  41209. _activeParticles: PerfCounter;
  41210. /** @hidden */
  41211. _activeBones: PerfCounter;
  41212. private _animationRatio;
  41213. /** @hidden */
  41214. _animationTimeLast: number;
  41215. /** @hidden */
  41216. _animationTime: number;
  41217. /**
  41218. * Gets or sets a general scale for animation speed
  41219. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41220. */
  41221. animationTimeScale: number;
  41222. /** @hidden */
  41223. _cachedMaterial: Nullable<Material>;
  41224. /** @hidden */
  41225. _cachedEffect: Nullable<Effect>;
  41226. /** @hidden */
  41227. _cachedVisibility: Nullable<number>;
  41228. private _renderId;
  41229. private _frameId;
  41230. private _executeWhenReadyTimeoutId;
  41231. private _intermediateRendering;
  41232. private _viewUpdateFlag;
  41233. private _projectionUpdateFlag;
  41234. /** @hidden */
  41235. _toBeDisposed: Nullable<IDisposable>[];
  41236. private _activeRequests;
  41237. /** @hidden */
  41238. _pendingData: any[];
  41239. private _isDisposed;
  41240. /**
  41241. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41242. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41243. */
  41244. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41245. private _activeMeshes;
  41246. private _processedMaterials;
  41247. private _renderTargets;
  41248. /** @hidden */
  41249. _activeParticleSystems: SmartArray<IParticleSystem>;
  41250. private _activeSkeletons;
  41251. private _softwareSkinnedMeshes;
  41252. private _renderingManager;
  41253. /** @hidden */
  41254. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41255. private _transformMatrix;
  41256. private _sceneUbo;
  41257. /** @hidden */
  41258. _viewMatrix: Matrix;
  41259. private _projectionMatrix;
  41260. /** @hidden */
  41261. _forcedViewPosition: Nullable<Vector3>;
  41262. /** @hidden */
  41263. _frustumPlanes: Plane[];
  41264. /**
  41265. * Gets the list of frustum planes (built from the active camera)
  41266. */
  41267. get frustumPlanes(): Plane[];
  41268. /**
  41269. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41270. * This is useful if there are more lights that the maximum simulteanous authorized
  41271. */
  41272. requireLightSorting: boolean;
  41273. /** @hidden */
  41274. readonly useMaterialMeshMap: boolean;
  41275. /** @hidden */
  41276. readonly useClonedMeshMap: boolean;
  41277. private _externalData;
  41278. private _uid;
  41279. /**
  41280. * @hidden
  41281. * Backing store of defined scene components.
  41282. */
  41283. _components: ISceneComponent[];
  41284. /**
  41285. * @hidden
  41286. * Backing store of defined scene components.
  41287. */
  41288. _serializableComponents: ISceneSerializableComponent[];
  41289. /**
  41290. * List of components to register on the next registration step.
  41291. */
  41292. private _transientComponents;
  41293. /**
  41294. * Registers the transient components if needed.
  41295. */
  41296. private _registerTransientComponents;
  41297. /**
  41298. * @hidden
  41299. * Add a component to the scene.
  41300. * Note that the ccomponent could be registered on th next frame if this is called after
  41301. * the register component stage.
  41302. * @param component Defines the component to add to the scene
  41303. */
  41304. _addComponent(component: ISceneComponent): void;
  41305. /**
  41306. * @hidden
  41307. * Gets a component from the scene.
  41308. * @param name defines the name of the component to retrieve
  41309. * @returns the component or null if not present
  41310. */
  41311. _getComponent(name: string): Nullable<ISceneComponent>;
  41312. /**
  41313. * @hidden
  41314. * Defines the actions happening before camera updates.
  41315. */
  41316. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41317. /**
  41318. * @hidden
  41319. * Defines the actions happening before clear the canvas.
  41320. */
  41321. _beforeClearStage: Stage<SimpleStageAction>;
  41322. /**
  41323. * @hidden
  41324. * Defines the actions when collecting render targets for the frame.
  41325. */
  41326. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41327. /**
  41328. * @hidden
  41329. * Defines the actions happening for one camera in the frame.
  41330. */
  41331. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41332. /**
  41333. * @hidden
  41334. * Defines the actions happening during the per mesh ready checks.
  41335. */
  41336. _isReadyForMeshStage: Stage<MeshStageAction>;
  41337. /**
  41338. * @hidden
  41339. * Defines the actions happening before evaluate active mesh checks.
  41340. */
  41341. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41342. /**
  41343. * @hidden
  41344. * Defines the actions happening during the evaluate sub mesh checks.
  41345. */
  41346. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41347. /**
  41348. * @hidden
  41349. * Defines the actions happening during the active mesh stage.
  41350. */
  41351. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41352. /**
  41353. * @hidden
  41354. * Defines the actions happening during the per camera render target step.
  41355. */
  41356. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41357. /**
  41358. * @hidden
  41359. * Defines the actions happening just before the active camera is drawing.
  41360. */
  41361. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41362. /**
  41363. * @hidden
  41364. * Defines the actions happening just before a render target is drawing.
  41365. */
  41366. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41367. /**
  41368. * @hidden
  41369. * Defines the actions happening just before a rendering group is drawing.
  41370. */
  41371. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41372. /**
  41373. * @hidden
  41374. * Defines the actions happening just before a mesh is drawing.
  41375. */
  41376. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41377. /**
  41378. * @hidden
  41379. * Defines the actions happening just after a mesh has been drawn.
  41380. */
  41381. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41382. /**
  41383. * @hidden
  41384. * Defines the actions happening just after a rendering group has been drawn.
  41385. */
  41386. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41387. /**
  41388. * @hidden
  41389. * Defines the actions happening just after the active camera has been drawn.
  41390. */
  41391. _afterCameraDrawStage: Stage<CameraStageAction>;
  41392. /**
  41393. * @hidden
  41394. * Defines the actions happening just after a render target has been drawn.
  41395. */
  41396. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41397. /**
  41398. * @hidden
  41399. * Defines the actions happening just after rendering all cameras and computing intersections.
  41400. */
  41401. _afterRenderStage: Stage<SimpleStageAction>;
  41402. /**
  41403. * @hidden
  41404. * Defines the actions happening when a pointer move event happens.
  41405. */
  41406. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41407. /**
  41408. * @hidden
  41409. * Defines the actions happening when a pointer down event happens.
  41410. */
  41411. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41412. /**
  41413. * @hidden
  41414. * Defines the actions happening when a pointer up event happens.
  41415. */
  41416. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41417. /**
  41418. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41419. */
  41420. private geometriesByUniqueId;
  41421. /**
  41422. * Creates a new Scene
  41423. * @param engine defines the engine to use to render this scene
  41424. * @param options defines the scene options
  41425. */
  41426. constructor(engine: Engine, options?: SceneOptions);
  41427. /**
  41428. * Gets a string idenfifying the name of the class
  41429. * @returns "Scene" string
  41430. */
  41431. getClassName(): string;
  41432. private _defaultMeshCandidates;
  41433. /**
  41434. * @hidden
  41435. */
  41436. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41437. private _defaultSubMeshCandidates;
  41438. /**
  41439. * @hidden
  41440. */
  41441. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41442. /**
  41443. * Sets the default candidate providers for the scene.
  41444. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41445. * and getCollidingSubMeshCandidates to their default function
  41446. */
  41447. setDefaultCandidateProviders(): void;
  41448. /**
  41449. * Gets the mesh that is currently under the pointer
  41450. */
  41451. get meshUnderPointer(): Nullable<AbstractMesh>;
  41452. /**
  41453. * Gets or sets the current on-screen X position of the pointer
  41454. */
  41455. get pointerX(): number;
  41456. set pointerX(value: number);
  41457. /**
  41458. * Gets or sets the current on-screen Y position of the pointer
  41459. */
  41460. get pointerY(): number;
  41461. set pointerY(value: number);
  41462. /**
  41463. * Gets the cached material (ie. the latest rendered one)
  41464. * @returns the cached material
  41465. */
  41466. getCachedMaterial(): Nullable<Material>;
  41467. /**
  41468. * Gets the cached effect (ie. the latest rendered one)
  41469. * @returns the cached effect
  41470. */
  41471. getCachedEffect(): Nullable<Effect>;
  41472. /**
  41473. * Gets the cached visibility state (ie. the latest rendered one)
  41474. * @returns the cached visibility state
  41475. */
  41476. getCachedVisibility(): Nullable<number>;
  41477. /**
  41478. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41479. * @param material defines the current material
  41480. * @param effect defines the current effect
  41481. * @param visibility defines the current visibility state
  41482. * @returns true if one parameter is not cached
  41483. */
  41484. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41485. /**
  41486. * Gets the engine associated with the scene
  41487. * @returns an Engine
  41488. */
  41489. getEngine(): Engine;
  41490. /**
  41491. * Gets the total number of vertices rendered per frame
  41492. * @returns the total number of vertices rendered per frame
  41493. */
  41494. getTotalVertices(): number;
  41495. /**
  41496. * Gets the performance counter for total vertices
  41497. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41498. */
  41499. get totalVerticesPerfCounter(): PerfCounter;
  41500. /**
  41501. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41502. * @returns the total number of active indices rendered per frame
  41503. */
  41504. getActiveIndices(): number;
  41505. /**
  41506. * Gets the performance counter for active indices
  41507. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41508. */
  41509. get totalActiveIndicesPerfCounter(): PerfCounter;
  41510. /**
  41511. * Gets the total number of active particles rendered per frame
  41512. * @returns the total number of active particles rendered per frame
  41513. */
  41514. getActiveParticles(): number;
  41515. /**
  41516. * Gets the performance counter for active particles
  41517. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41518. */
  41519. get activeParticlesPerfCounter(): PerfCounter;
  41520. /**
  41521. * Gets the total number of active bones rendered per frame
  41522. * @returns the total number of active bones rendered per frame
  41523. */
  41524. getActiveBones(): number;
  41525. /**
  41526. * Gets the performance counter for active bones
  41527. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41528. */
  41529. get activeBonesPerfCounter(): PerfCounter;
  41530. /**
  41531. * Gets the array of active meshes
  41532. * @returns an array of AbstractMesh
  41533. */
  41534. getActiveMeshes(): SmartArray<AbstractMesh>;
  41535. /**
  41536. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41537. * @returns a number
  41538. */
  41539. getAnimationRatio(): number;
  41540. /**
  41541. * Gets an unique Id for the current render phase
  41542. * @returns a number
  41543. */
  41544. getRenderId(): number;
  41545. /**
  41546. * Gets an unique Id for the current frame
  41547. * @returns a number
  41548. */
  41549. getFrameId(): number;
  41550. /** Call this function if you want to manually increment the render Id*/
  41551. incrementRenderId(): void;
  41552. private _createUbo;
  41553. /**
  41554. * Use this method to simulate a pointer move on a mesh
  41555. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41556. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41557. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41558. * @returns the current scene
  41559. */
  41560. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41561. /**
  41562. * Use this method to simulate a pointer down on a mesh
  41563. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41564. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41565. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41566. * @returns the current scene
  41567. */
  41568. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41569. /**
  41570. * Use this method to simulate a pointer up on a mesh
  41571. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41572. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41573. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41574. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41575. * @returns the current scene
  41576. */
  41577. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41578. /**
  41579. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41580. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41581. * @returns true if the pointer was captured
  41582. */
  41583. isPointerCaptured(pointerId?: number): boolean;
  41584. /**
  41585. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41586. * @param attachUp defines if you want to attach events to pointerup
  41587. * @param attachDown defines if you want to attach events to pointerdown
  41588. * @param attachMove defines if you want to attach events to pointermove
  41589. */
  41590. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41591. /** Detaches all event handlers*/
  41592. detachControl(): void;
  41593. /**
  41594. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41595. * Delay loaded resources are not taking in account
  41596. * @return true if all required resources are ready
  41597. */
  41598. isReady(): boolean;
  41599. /** Resets all cached information relative to material (including effect and visibility) */
  41600. resetCachedMaterial(): void;
  41601. /**
  41602. * Registers a function to be called before every frame render
  41603. * @param func defines the function to register
  41604. */
  41605. registerBeforeRender(func: () => void): void;
  41606. /**
  41607. * Unregisters a function called before every frame render
  41608. * @param func defines the function to unregister
  41609. */
  41610. unregisterBeforeRender(func: () => void): void;
  41611. /**
  41612. * Registers a function to be called after every frame render
  41613. * @param func defines the function to register
  41614. */
  41615. registerAfterRender(func: () => void): void;
  41616. /**
  41617. * Unregisters a function called after every frame render
  41618. * @param func defines the function to unregister
  41619. */
  41620. unregisterAfterRender(func: () => void): void;
  41621. private _executeOnceBeforeRender;
  41622. /**
  41623. * The provided function will run before render once and will be disposed afterwards.
  41624. * A timeout delay can be provided so that the function will be executed in N ms.
  41625. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41626. * @param func The function to be executed.
  41627. * @param timeout optional delay in ms
  41628. */
  41629. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41630. /** @hidden */
  41631. _addPendingData(data: any): void;
  41632. /** @hidden */
  41633. _removePendingData(data: any): void;
  41634. /**
  41635. * Returns the number of items waiting to be loaded
  41636. * @returns the number of items waiting to be loaded
  41637. */
  41638. getWaitingItemsCount(): number;
  41639. /**
  41640. * Returns a boolean indicating if the scene is still loading data
  41641. */
  41642. get isLoading(): boolean;
  41643. /**
  41644. * Registers a function to be executed when the scene is ready
  41645. * @param {Function} func - the function to be executed
  41646. */
  41647. executeWhenReady(func: () => void): void;
  41648. /**
  41649. * Returns a promise that resolves when the scene is ready
  41650. * @returns A promise that resolves when the scene is ready
  41651. */
  41652. whenReadyAsync(): Promise<void>;
  41653. /** @hidden */
  41654. _checkIsReady(): void;
  41655. /**
  41656. * Gets all animatable attached to the scene
  41657. */
  41658. get animatables(): Animatable[];
  41659. /**
  41660. * Resets the last animation time frame.
  41661. * Useful to override when animations start running when loading a scene for the first time.
  41662. */
  41663. resetLastAnimationTimeFrame(): void;
  41664. /**
  41665. * Gets the current view matrix
  41666. * @returns a Matrix
  41667. */
  41668. getViewMatrix(): Matrix;
  41669. /**
  41670. * Gets the current projection matrix
  41671. * @returns a Matrix
  41672. */
  41673. getProjectionMatrix(): Matrix;
  41674. /**
  41675. * Gets the current transform matrix
  41676. * @returns a Matrix made of View * Projection
  41677. */
  41678. getTransformMatrix(): Matrix;
  41679. /**
  41680. * Sets the current transform matrix
  41681. * @param viewL defines the View matrix to use
  41682. * @param projectionL defines the Projection matrix to use
  41683. * @param viewR defines the right View matrix to use (if provided)
  41684. * @param projectionR defines the right Projection matrix to use (if provided)
  41685. */
  41686. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41687. /**
  41688. * Gets the uniform buffer used to store scene data
  41689. * @returns a UniformBuffer
  41690. */
  41691. getSceneUniformBuffer(): UniformBuffer;
  41692. /**
  41693. * Gets an unique (relatively to the current scene) Id
  41694. * @returns an unique number for the scene
  41695. */
  41696. getUniqueId(): number;
  41697. /**
  41698. * Add a mesh to the list of scene's meshes
  41699. * @param newMesh defines the mesh to add
  41700. * @param recursive if all child meshes should also be added to the scene
  41701. */
  41702. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41703. /**
  41704. * Remove a mesh for the list of scene's meshes
  41705. * @param toRemove defines the mesh to remove
  41706. * @param recursive if all child meshes should also be removed from the scene
  41707. * @returns the index where the mesh was in the mesh list
  41708. */
  41709. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41710. /**
  41711. * Add a transform node to the list of scene's transform nodes
  41712. * @param newTransformNode defines the transform node to add
  41713. */
  41714. addTransformNode(newTransformNode: TransformNode): void;
  41715. /**
  41716. * Remove a transform node for the list of scene's transform nodes
  41717. * @param toRemove defines the transform node to remove
  41718. * @returns the index where the transform node was in the transform node list
  41719. */
  41720. removeTransformNode(toRemove: TransformNode): number;
  41721. /**
  41722. * Remove a skeleton for the list of scene's skeletons
  41723. * @param toRemove defines the skeleton to remove
  41724. * @returns the index where the skeleton was in the skeleton list
  41725. */
  41726. removeSkeleton(toRemove: Skeleton): number;
  41727. /**
  41728. * Remove a morph target for the list of scene's morph targets
  41729. * @param toRemove defines the morph target to remove
  41730. * @returns the index where the morph target was in the morph target list
  41731. */
  41732. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41733. /**
  41734. * Remove a light for the list of scene's lights
  41735. * @param toRemove defines the light to remove
  41736. * @returns the index where the light was in the light list
  41737. */
  41738. removeLight(toRemove: Light): number;
  41739. /**
  41740. * Remove a camera for the list of scene's cameras
  41741. * @param toRemove defines the camera to remove
  41742. * @returns the index where the camera was in the camera list
  41743. */
  41744. removeCamera(toRemove: Camera): number;
  41745. /**
  41746. * Remove a particle system for the list of scene's particle systems
  41747. * @param toRemove defines the particle system to remove
  41748. * @returns the index where the particle system was in the particle system list
  41749. */
  41750. removeParticleSystem(toRemove: IParticleSystem): number;
  41751. /**
  41752. * Remove a animation for the list of scene's animations
  41753. * @param toRemove defines the animation to remove
  41754. * @returns the index where the animation was in the animation list
  41755. */
  41756. removeAnimation(toRemove: Animation): number;
  41757. /**
  41758. * Will stop the animation of the given target
  41759. * @param target - the target
  41760. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41761. * @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)
  41762. */
  41763. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41764. /**
  41765. * Removes the given animation group from this scene.
  41766. * @param toRemove The animation group to remove
  41767. * @returns The index of the removed animation group
  41768. */
  41769. removeAnimationGroup(toRemove: AnimationGroup): number;
  41770. /**
  41771. * Removes the given multi-material from this scene.
  41772. * @param toRemove The multi-material to remove
  41773. * @returns The index of the removed multi-material
  41774. */
  41775. removeMultiMaterial(toRemove: MultiMaterial): number;
  41776. /**
  41777. * Removes the given material from this scene.
  41778. * @param toRemove The material to remove
  41779. * @returns The index of the removed material
  41780. */
  41781. removeMaterial(toRemove: Material): number;
  41782. /**
  41783. * Removes the given action manager from this scene.
  41784. * @param toRemove The action manager to remove
  41785. * @returns The index of the removed action manager
  41786. */
  41787. removeActionManager(toRemove: AbstractActionManager): number;
  41788. /**
  41789. * Removes the given texture from this scene.
  41790. * @param toRemove The texture to remove
  41791. * @returns The index of the removed texture
  41792. */
  41793. removeTexture(toRemove: BaseTexture): number;
  41794. /**
  41795. * Adds the given light to this scene
  41796. * @param newLight The light to add
  41797. */
  41798. addLight(newLight: Light): void;
  41799. /**
  41800. * Sorts the list list based on light priorities
  41801. */
  41802. sortLightsByPriority(): void;
  41803. /**
  41804. * Adds the given camera to this scene
  41805. * @param newCamera The camera to add
  41806. */
  41807. addCamera(newCamera: Camera): void;
  41808. /**
  41809. * Adds the given skeleton to this scene
  41810. * @param newSkeleton The skeleton to add
  41811. */
  41812. addSkeleton(newSkeleton: Skeleton): void;
  41813. /**
  41814. * Adds the given particle system to this scene
  41815. * @param newParticleSystem The particle system to add
  41816. */
  41817. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41818. /**
  41819. * Adds the given animation to this scene
  41820. * @param newAnimation The animation to add
  41821. */
  41822. addAnimation(newAnimation: Animation): void;
  41823. /**
  41824. * Adds the given animation group to this scene.
  41825. * @param newAnimationGroup The animation group to add
  41826. */
  41827. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41828. /**
  41829. * Adds the given multi-material to this scene
  41830. * @param newMultiMaterial The multi-material to add
  41831. */
  41832. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41833. /**
  41834. * Adds the given material to this scene
  41835. * @param newMaterial The material to add
  41836. */
  41837. addMaterial(newMaterial: Material): void;
  41838. /**
  41839. * Adds the given morph target to this scene
  41840. * @param newMorphTargetManager The morph target to add
  41841. */
  41842. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41843. /**
  41844. * Adds the given geometry to this scene
  41845. * @param newGeometry The geometry to add
  41846. */
  41847. addGeometry(newGeometry: Geometry): void;
  41848. /**
  41849. * Adds the given action manager to this scene
  41850. * @param newActionManager The action manager to add
  41851. */
  41852. addActionManager(newActionManager: AbstractActionManager): void;
  41853. /**
  41854. * Adds the given texture to this scene.
  41855. * @param newTexture The texture to add
  41856. */
  41857. addTexture(newTexture: BaseTexture): void;
  41858. /**
  41859. * Switch active camera
  41860. * @param newCamera defines the new active camera
  41861. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41862. */
  41863. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41864. /**
  41865. * sets the active camera of the scene using its ID
  41866. * @param id defines the camera's ID
  41867. * @return the new active camera or null if none found.
  41868. */
  41869. setActiveCameraByID(id: string): Nullable<Camera>;
  41870. /**
  41871. * sets the active camera of the scene using its name
  41872. * @param name defines the camera's name
  41873. * @returns the new active camera or null if none found.
  41874. */
  41875. setActiveCameraByName(name: string): Nullable<Camera>;
  41876. /**
  41877. * get an animation group using its name
  41878. * @param name defines the material's name
  41879. * @return the animation group or null if none found.
  41880. */
  41881. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41882. /**
  41883. * Get a material using its unique id
  41884. * @param uniqueId defines the material's unique id
  41885. * @return the material or null if none found.
  41886. */
  41887. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41888. /**
  41889. * get a material using its id
  41890. * @param id defines the material's ID
  41891. * @return the material or null if none found.
  41892. */
  41893. getMaterialByID(id: string): Nullable<Material>;
  41894. /**
  41895. * Gets a the last added material using a given id
  41896. * @param id defines the material's ID
  41897. * @return the last material with the given id or null if none found.
  41898. */
  41899. getLastMaterialByID(id: string): Nullable<Material>;
  41900. /**
  41901. * Gets a material using its name
  41902. * @param name defines the material's name
  41903. * @return the material or null if none found.
  41904. */
  41905. getMaterialByName(name: string): Nullable<Material>;
  41906. /**
  41907. * Get a texture using its unique id
  41908. * @param uniqueId defines the texture's unique id
  41909. * @return the texture or null if none found.
  41910. */
  41911. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41912. /**
  41913. * Gets a camera using its id
  41914. * @param id defines the id to look for
  41915. * @returns the camera or null if not found
  41916. */
  41917. getCameraByID(id: string): Nullable<Camera>;
  41918. /**
  41919. * Gets a camera using its unique id
  41920. * @param uniqueId defines the unique id to look for
  41921. * @returns the camera or null if not found
  41922. */
  41923. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41924. /**
  41925. * Gets a camera using its name
  41926. * @param name defines the camera's name
  41927. * @return the camera or null if none found.
  41928. */
  41929. getCameraByName(name: string): Nullable<Camera>;
  41930. /**
  41931. * Gets a bone using its id
  41932. * @param id defines the bone's id
  41933. * @return the bone or null if not found
  41934. */
  41935. getBoneByID(id: string): Nullable<Bone>;
  41936. /**
  41937. * Gets a bone using its id
  41938. * @param name defines the bone's name
  41939. * @return the bone or null if not found
  41940. */
  41941. getBoneByName(name: string): Nullable<Bone>;
  41942. /**
  41943. * Gets a light node using its name
  41944. * @param name defines the the light's name
  41945. * @return the light or null if none found.
  41946. */
  41947. getLightByName(name: string): Nullable<Light>;
  41948. /**
  41949. * Gets a light node using its id
  41950. * @param id defines the light's id
  41951. * @return the light or null if none found.
  41952. */
  41953. getLightByID(id: string): Nullable<Light>;
  41954. /**
  41955. * Gets a light node using its scene-generated unique ID
  41956. * @param uniqueId defines the light's unique id
  41957. * @return the light or null if none found.
  41958. */
  41959. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41960. /**
  41961. * Gets a particle system by id
  41962. * @param id defines the particle system id
  41963. * @return the corresponding system or null if none found
  41964. */
  41965. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41966. /**
  41967. * Gets a geometry using its ID
  41968. * @param id defines the geometry's id
  41969. * @return the geometry or null if none found.
  41970. */
  41971. getGeometryByID(id: string): Nullable<Geometry>;
  41972. private _getGeometryByUniqueID;
  41973. /**
  41974. * Add a new geometry to this scene
  41975. * @param geometry defines the geometry to be added to the scene.
  41976. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41977. * @return a boolean defining if the geometry was added or not
  41978. */
  41979. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41980. /**
  41981. * Removes an existing geometry
  41982. * @param geometry defines the geometry to be removed from the scene
  41983. * @return a boolean defining if the geometry was removed or not
  41984. */
  41985. removeGeometry(geometry: Geometry): boolean;
  41986. /**
  41987. * Gets the list of geometries attached to the scene
  41988. * @returns an array of Geometry
  41989. */
  41990. getGeometries(): Geometry[];
  41991. /**
  41992. * Gets the first added mesh found of a given ID
  41993. * @param id defines the id to search for
  41994. * @return the mesh found or null if not found at all
  41995. */
  41996. getMeshByID(id: string): Nullable<AbstractMesh>;
  41997. /**
  41998. * Gets a list of meshes using their id
  41999. * @param id defines the id to search for
  42000. * @returns a list of meshes
  42001. */
  42002. getMeshesByID(id: string): Array<AbstractMesh>;
  42003. /**
  42004. * Gets the first added transform node found of a given ID
  42005. * @param id defines the id to search for
  42006. * @return the found transform node or null if not found at all.
  42007. */
  42008. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42009. /**
  42010. * Gets a transform node with its auto-generated unique id
  42011. * @param uniqueId efines the unique id to search for
  42012. * @return the found transform node or null if not found at all.
  42013. */
  42014. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42015. /**
  42016. * Gets a list of transform nodes using their id
  42017. * @param id defines the id to search for
  42018. * @returns a list of transform nodes
  42019. */
  42020. getTransformNodesByID(id: string): Array<TransformNode>;
  42021. /**
  42022. * Gets a mesh with its auto-generated unique id
  42023. * @param uniqueId defines the unique id to search for
  42024. * @return the found mesh or null if not found at all.
  42025. */
  42026. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42027. /**
  42028. * Gets a the last added mesh using a given id
  42029. * @param id defines the id to search for
  42030. * @return the found mesh or null if not found at all.
  42031. */
  42032. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42033. /**
  42034. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42035. * @param id defines the id to search for
  42036. * @return the found node or null if not found at all
  42037. */
  42038. getLastEntryByID(id: string): Nullable<Node>;
  42039. /**
  42040. * Gets a node (Mesh, Camera, Light) using a given id
  42041. * @param id defines the id to search for
  42042. * @return the found node or null if not found at all
  42043. */
  42044. getNodeByID(id: string): Nullable<Node>;
  42045. /**
  42046. * Gets a node (Mesh, Camera, Light) using a given name
  42047. * @param name defines the name to search for
  42048. * @return the found node or null if not found at all.
  42049. */
  42050. getNodeByName(name: string): Nullable<Node>;
  42051. /**
  42052. * Gets a mesh using a given name
  42053. * @param name defines the name to search for
  42054. * @return the found mesh or null if not found at all.
  42055. */
  42056. getMeshByName(name: string): Nullable<AbstractMesh>;
  42057. /**
  42058. * Gets a transform node using a given name
  42059. * @param name defines the name to search for
  42060. * @return the found transform node or null if not found at all.
  42061. */
  42062. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42063. /**
  42064. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42065. * @param id defines the id to search for
  42066. * @return the found skeleton or null if not found at all.
  42067. */
  42068. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42069. /**
  42070. * Gets a skeleton using a given auto generated unique id
  42071. * @param uniqueId defines the unique id to search for
  42072. * @return the found skeleton or null if not found at all.
  42073. */
  42074. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42075. /**
  42076. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42077. * @param id defines the id to search for
  42078. * @return the found skeleton or null if not found at all.
  42079. */
  42080. getSkeletonById(id: string): Nullable<Skeleton>;
  42081. /**
  42082. * Gets a skeleton using a given name
  42083. * @param name defines the name to search for
  42084. * @return the found skeleton or null if not found at all.
  42085. */
  42086. getSkeletonByName(name: string): Nullable<Skeleton>;
  42087. /**
  42088. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42089. * @param id defines the id to search for
  42090. * @return the found morph target manager or null if not found at all.
  42091. */
  42092. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42093. /**
  42094. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42095. * @param id defines the id to search for
  42096. * @return the found morph target or null if not found at all.
  42097. */
  42098. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42099. /**
  42100. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42101. * @param name defines the name to search for
  42102. * @return the found morph target or null if not found at all.
  42103. */
  42104. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42105. /**
  42106. * Gets a boolean indicating if the given mesh is active
  42107. * @param mesh defines the mesh to look for
  42108. * @returns true if the mesh is in the active list
  42109. */
  42110. isActiveMesh(mesh: AbstractMesh): boolean;
  42111. /**
  42112. * Return a unique id as a string which can serve as an identifier for the scene
  42113. */
  42114. get uid(): string;
  42115. /**
  42116. * Add an externaly attached data from its key.
  42117. * This method call will fail and return false, if such key already exists.
  42118. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42119. * @param key the unique key that identifies the data
  42120. * @param data the data object to associate to the key for this Engine instance
  42121. * @return true if no such key were already present and the data was added successfully, false otherwise
  42122. */
  42123. addExternalData<T>(key: string, data: T): boolean;
  42124. /**
  42125. * Get an externaly attached data from its key
  42126. * @param key the unique key that identifies the data
  42127. * @return the associated data, if present (can be null), or undefined if not present
  42128. */
  42129. getExternalData<T>(key: string): Nullable<T>;
  42130. /**
  42131. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42132. * @param key the unique key that identifies the data
  42133. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42134. * @return the associated data, can be null if the factory returned null.
  42135. */
  42136. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42137. /**
  42138. * Remove an externaly attached data from the Engine instance
  42139. * @param key the unique key that identifies the data
  42140. * @return true if the data was successfully removed, false if it doesn't exist
  42141. */
  42142. removeExternalData(key: string): boolean;
  42143. private _evaluateSubMesh;
  42144. /**
  42145. * Clear the processed materials smart array preventing retention point in material dispose.
  42146. */
  42147. freeProcessedMaterials(): void;
  42148. private _preventFreeActiveMeshesAndRenderingGroups;
  42149. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42150. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42151. * when disposing several meshes in a row or a hierarchy of meshes.
  42152. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42153. */
  42154. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42155. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42156. /**
  42157. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42158. */
  42159. freeActiveMeshes(): void;
  42160. /**
  42161. * Clear the info related to rendering groups preventing retention points during dispose.
  42162. */
  42163. freeRenderingGroups(): void;
  42164. /** @hidden */
  42165. _isInIntermediateRendering(): boolean;
  42166. /**
  42167. * Lambda returning the list of potentially active meshes.
  42168. */
  42169. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42170. /**
  42171. * Lambda returning the list of potentially active sub meshes.
  42172. */
  42173. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42174. /**
  42175. * Lambda returning the list of potentially intersecting sub meshes.
  42176. */
  42177. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42178. /**
  42179. * Lambda returning the list of potentially colliding sub meshes.
  42180. */
  42181. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42182. private _activeMeshesFrozen;
  42183. private _skipEvaluateActiveMeshesCompletely;
  42184. /**
  42185. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42186. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42187. * @returns the current scene
  42188. */
  42189. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42190. /**
  42191. * Use this function to restart evaluating active meshes on every frame
  42192. * @returns the current scene
  42193. */
  42194. unfreezeActiveMeshes(): Scene;
  42195. private _evaluateActiveMeshes;
  42196. private _activeMesh;
  42197. /**
  42198. * Update the transform matrix to update from the current active camera
  42199. * @param force defines a boolean used to force the update even if cache is up to date
  42200. */
  42201. updateTransformMatrix(force?: boolean): void;
  42202. private _bindFrameBuffer;
  42203. /** @hidden */
  42204. _allowPostProcessClearColor: boolean;
  42205. /** @hidden */
  42206. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42207. private _processSubCameras;
  42208. private _checkIntersections;
  42209. /** @hidden */
  42210. _advancePhysicsEngineStep(step: number): void;
  42211. /**
  42212. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42213. */
  42214. getDeterministicFrameTime: () => number;
  42215. /** @hidden */
  42216. _animate(): void;
  42217. /** Execute all animations (for a frame) */
  42218. animate(): void;
  42219. /**
  42220. * Render the scene
  42221. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42222. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42223. */
  42224. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42225. /**
  42226. * Freeze all materials
  42227. * A frozen material will not be updatable but should be faster to render
  42228. */
  42229. freezeMaterials(): void;
  42230. /**
  42231. * Unfreeze all materials
  42232. * A frozen material will not be updatable but should be faster to render
  42233. */
  42234. unfreezeMaterials(): void;
  42235. /**
  42236. * Releases all held ressources
  42237. */
  42238. dispose(): void;
  42239. /**
  42240. * Gets if the scene is already disposed
  42241. */
  42242. get isDisposed(): boolean;
  42243. /**
  42244. * Call this function to reduce memory footprint of the scene.
  42245. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42246. */
  42247. clearCachedVertexData(): void;
  42248. /**
  42249. * This function will remove the local cached buffer data from texture.
  42250. * It will save memory but will prevent the texture from being rebuilt
  42251. */
  42252. cleanCachedTextureBuffer(): void;
  42253. /**
  42254. * Get the world extend vectors with an optional filter
  42255. *
  42256. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42257. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42258. */
  42259. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42260. min: Vector3;
  42261. max: Vector3;
  42262. };
  42263. /**
  42264. * Creates a ray that can be used to pick in the scene
  42265. * @param x defines the x coordinate of the origin (on-screen)
  42266. * @param y defines the y coordinate of the origin (on-screen)
  42267. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42268. * @param camera defines the camera to use for the picking
  42269. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42270. * @returns a Ray
  42271. */
  42272. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42273. /**
  42274. * Creates a ray that can be used to pick in the scene
  42275. * @param x defines the x coordinate of the origin (on-screen)
  42276. * @param y defines the y coordinate of the origin (on-screen)
  42277. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42278. * @param result defines the ray where to store the picking ray
  42279. * @param camera defines the camera to use for the picking
  42280. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42281. * @returns the current scene
  42282. */
  42283. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42284. /**
  42285. * Creates a ray that can be used to pick in the scene
  42286. * @param x defines the x coordinate of the origin (on-screen)
  42287. * @param y defines the y coordinate of the origin (on-screen)
  42288. * @param camera defines the camera to use for the picking
  42289. * @returns a Ray
  42290. */
  42291. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42292. /**
  42293. * Creates a ray that can be used to pick in the scene
  42294. * @param x defines the x coordinate of the origin (on-screen)
  42295. * @param y defines the y coordinate of the origin (on-screen)
  42296. * @param result defines the ray where to store the picking ray
  42297. * @param camera defines the camera to use for the picking
  42298. * @returns the current scene
  42299. */
  42300. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42301. /** Launch a ray to try to pick a mesh in the scene
  42302. * @param x position on screen
  42303. * @param y position on screen
  42304. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  42305. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42306. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42307. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42308. * @returns a PickingInfo
  42309. */
  42310. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42311. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42312. * @param x position on screen
  42313. * @param y position on screen
  42314. * @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
  42315. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42316. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42317. * @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)
  42318. */
  42319. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42320. /** Use the given ray to pick a mesh in the scene
  42321. * @param ray The ray to use to pick meshes
  42322. * @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
  42323. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42324. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42325. * @returns a PickingInfo
  42326. */
  42327. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42328. /**
  42329. * Launch a ray to try to pick a mesh in the scene
  42330. * @param x X position on screen
  42331. * @param y Y position on screen
  42332. * @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
  42333. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42334. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42335. * @returns an array of PickingInfo
  42336. */
  42337. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42338. /**
  42339. * Launch a ray to try to pick a mesh in the scene
  42340. * @param ray Ray to use
  42341. * @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
  42342. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42343. * @returns an array of PickingInfo
  42344. */
  42345. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42346. /**
  42347. * Force the value of meshUnderPointer
  42348. * @param mesh defines the mesh to use
  42349. */
  42350. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  42351. /**
  42352. * Gets the mesh under the pointer
  42353. * @returns a Mesh or null if no mesh is under the pointer
  42354. */
  42355. getPointerOverMesh(): Nullable<AbstractMesh>;
  42356. /** @hidden */
  42357. _rebuildGeometries(): void;
  42358. /** @hidden */
  42359. _rebuildTextures(): void;
  42360. private _getByTags;
  42361. /**
  42362. * Get a list of meshes by tags
  42363. * @param tagsQuery defines the tags query to use
  42364. * @param forEach defines a predicate used to filter results
  42365. * @returns an array of Mesh
  42366. */
  42367. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42368. /**
  42369. * Get a list of cameras by tags
  42370. * @param tagsQuery defines the tags query to use
  42371. * @param forEach defines a predicate used to filter results
  42372. * @returns an array of Camera
  42373. */
  42374. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42375. /**
  42376. * Get a list of lights by tags
  42377. * @param tagsQuery defines the tags query to use
  42378. * @param forEach defines a predicate used to filter results
  42379. * @returns an array of Light
  42380. */
  42381. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42382. /**
  42383. * Get a list of materials by tags
  42384. * @param tagsQuery defines the tags query to use
  42385. * @param forEach defines a predicate used to filter results
  42386. * @returns an array of Material
  42387. */
  42388. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42389. /**
  42390. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42391. * This allowed control for front to back rendering or reversly depending of the special needs.
  42392. *
  42393. * @param renderingGroupId The rendering group id corresponding to its index
  42394. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42395. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42396. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42397. */
  42398. 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;
  42399. /**
  42400. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42401. *
  42402. * @param renderingGroupId The rendering group id corresponding to its index
  42403. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42404. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42405. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42406. */
  42407. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42408. /**
  42409. * Gets the current auto clear configuration for one rendering group of the rendering
  42410. * manager.
  42411. * @param index the rendering group index to get the information for
  42412. * @returns The auto clear setup for the requested rendering group
  42413. */
  42414. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42415. private _blockMaterialDirtyMechanism;
  42416. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42417. get blockMaterialDirtyMechanism(): boolean;
  42418. set blockMaterialDirtyMechanism(value: boolean);
  42419. /**
  42420. * Will flag all materials as dirty to trigger new shader compilation
  42421. * @param flag defines the flag used to specify which material part must be marked as dirty
  42422. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42423. */
  42424. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42425. /** @hidden */
  42426. _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;
  42427. /** @hidden */
  42428. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42429. /** @hidden */
  42430. _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;
  42431. /** @hidden */
  42432. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42433. /** @hidden */
  42434. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42435. /** @hidden */
  42436. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42437. }
  42438. }
  42439. declare module "babylonjs/assetContainer" {
  42440. import { AbstractScene } from "babylonjs/abstractScene";
  42441. import { Scene } from "babylonjs/scene";
  42442. import { Mesh } from "babylonjs/Meshes/mesh";
  42443. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42444. import { Skeleton } from "babylonjs/Bones/skeleton";
  42445. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42446. import { Animatable } from "babylonjs/Animations/animatable";
  42447. import { Nullable } from "babylonjs/types";
  42448. import { Node } from "babylonjs/node";
  42449. /**
  42450. * Set of assets to keep when moving a scene into an asset container.
  42451. */
  42452. export class KeepAssets extends AbstractScene {
  42453. }
  42454. /**
  42455. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42456. */
  42457. export class InstantiatedEntries {
  42458. /**
  42459. * List of new root nodes (eg. nodes with no parent)
  42460. */
  42461. rootNodes: TransformNode[];
  42462. /**
  42463. * List of new skeletons
  42464. */
  42465. skeletons: Skeleton[];
  42466. /**
  42467. * List of new animation groups
  42468. */
  42469. animationGroups: AnimationGroup[];
  42470. }
  42471. /**
  42472. * Container with a set of assets that can be added or removed from a scene.
  42473. */
  42474. export class AssetContainer extends AbstractScene {
  42475. private _wasAddedToScene;
  42476. /**
  42477. * The scene the AssetContainer belongs to.
  42478. */
  42479. scene: Scene;
  42480. /**
  42481. * Instantiates an AssetContainer.
  42482. * @param scene The scene the AssetContainer belongs to.
  42483. */
  42484. constructor(scene: Scene);
  42485. /**
  42486. * Instantiate or clone all meshes and add the new ones to the scene.
  42487. * Skeletons and animation groups will all be cloned
  42488. * @param nameFunction defines an optional function used to get new names for clones
  42489. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42490. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42491. */
  42492. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42493. /**
  42494. * Adds all the assets from the container to the scene.
  42495. */
  42496. addAllToScene(): void;
  42497. /**
  42498. * Removes all the assets in the container from the scene
  42499. */
  42500. removeAllFromScene(): void;
  42501. /**
  42502. * Disposes all the assets in the container
  42503. */
  42504. dispose(): void;
  42505. private _moveAssets;
  42506. /**
  42507. * Removes all the assets contained in the scene and adds them to the container.
  42508. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42509. */
  42510. moveAllFromScene(keepAssets?: KeepAssets): void;
  42511. /**
  42512. * 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.
  42513. * @returns the root mesh
  42514. */
  42515. createRootMesh(): Mesh;
  42516. /**
  42517. * Merge animations (direct and animation groups) from this asset container into a scene
  42518. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42519. * @param animatables set of animatables to retarget to a node from the scene
  42520. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42521. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42522. */
  42523. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42524. }
  42525. }
  42526. declare module "babylonjs/abstractScene" {
  42527. import { Scene } from "babylonjs/scene";
  42528. import { Nullable } from "babylonjs/types";
  42529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42530. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42531. import { Geometry } from "babylonjs/Meshes/geometry";
  42532. import { Skeleton } from "babylonjs/Bones/skeleton";
  42533. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42534. import { AssetContainer } from "babylonjs/assetContainer";
  42535. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42536. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42538. import { Material } from "babylonjs/Materials/material";
  42539. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42540. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42541. import { Camera } from "babylonjs/Cameras/camera";
  42542. import { Light } from "babylonjs/Lights/light";
  42543. import { Node } from "babylonjs/node";
  42544. import { Animation } from "babylonjs/Animations/animation";
  42545. /**
  42546. * Defines how the parser contract is defined.
  42547. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42548. */
  42549. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42550. /**
  42551. * Defines how the individual parser contract is defined.
  42552. * These parser can parse an individual asset
  42553. */
  42554. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42555. /**
  42556. * Base class of the scene acting as a container for the different elements composing a scene.
  42557. * This class is dynamically extended by the different components of the scene increasing
  42558. * flexibility and reducing coupling
  42559. */
  42560. export abstract class AbstractScene {
  42561. /**
  42562. * Stores the list of available parsers in the application.
  42563. */
  42564. private static _BabylonFileParsers;
  42565. /**
  42566. * Stores the list of available individual parsers in the application.
  42567. */
  42568. private static _IndividualBabylonFileParsers;
  42569. /**
  42570. * Adds a parser in the list of available ones
  42571. * @param name Defines the name of the parser
  42572. * @param parser Defines the parser to add
  42573. */
  42574. static AddParser(name: string, parser: BabylonFileParser): void;
  42575. /**
  42576. * Gets a general parser from the list of avaialble ones
  42577. * @param name Defines the name of the parser
  42578. * @returns the requested parser or null
  42579. */
  42580. static GetParser(name: string): Nullable<BabylonFileParser>;
  42581. /**
  42582. * Adds n individual parser in the list of available ones
  42583. * @param name Defines the name of the parser
  42584. * @param parser Defines the parser to add
  42585. */
  42586. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42587. /**
  42588. * Gets an individual parser from the list of avaialble ones
  42589. * @param name Defines the name of the parser
  42590. * @returns the requested parser or null
  42591. */
  42592. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42593. /**
  42594. * Parser json data and populate both a scene and its associated container object
  42595. * @param jsonData Defines the data to parse
  42596. * @param scene Defines the scene to parse the data for
  42597. * @param container Defines the container attached to the parsing sequence
  42598. * @param rootUrl Defines the root url of the data
  42599. */
  42600. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42601. /**
  42602. * Gets the list of root nodes (ie. nodes with no parent)
  42603. */
  42604. rootNodes: Node[];
  42605. /** All of the cameras added to this scene
  42606. * @see https://doc.babylonjs.com/babylon101/cameras
  42607. */
  42608. cameras: Camera[];
  42609. /**
  42610. * All of the lights added to this scene
  42611. * @see https://doc.babylonjs.com/babylon101/lights
  42612. */
  42613. lights: Light[];
  42614. /**
  42615. * All of the (abstract) meshes added to this scene
  42616. */
  42617. meshes: AbstractMesh[];
  42618. /**
  42619. * The list of skeletons added to the scene
  42620. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42621. */
  42622. skeletons: Skeleton[];
  42623. /**
  42624. * All of the particle systems added to this scene
  42625. * @see https://doc.babylonjs.com/babylon101/particles
  42626. */
  42627. particleSystems: IParticleSystem[];
  42628. /**
  42629. * Gets a list of Animations associated with the scene
  42630. */
  42631. animations: Animation[];
  42632. /**
  42633. * All of the animation groups added to this scene
  42634. * @see https://doc.babylonjs.com/how_to/group
  42635. */
  42636. animationGroups: AnimationGroup[];
  42637. /**
  42638. * All of the multi-materials added to this scene
  42639. * @see https://doc.babylonjs.com/how_to/multi_materials
  42640. */
  42641. multiMaterials: MultiMaterial[];
  42642. /**
  42643. * All of the materials added to this scene
  42644. * In the context of a Scene, it is not supposed to be modified manually.
  42645. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42646. * Note also that the order of the Material within the array is not significant and might change.
  42647. * @see https://doc.babylonjs.com/babylon101/materials
  42648. */
  42649. materials: Material[];
  42650. /**
  42651. * The list of morph target managers added to the scene
  42652. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42653. */
  42654. morphTargetManagers: MorphTargetManager[];
  42655. /**
  42656. * The list of geometries used in the scene.
  42657. */
  42658. geometries: Geometry[];
  42659. /**
  42660. * All of the tranform nodes added to this scene
  42661. * In the context of a Scene, it is not supposed to be modified manually.
  42662. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42663. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42664. * @see https://doc.babylonjs.com/how_to/transformnode
  42665. */
  42666. transformNodes: TransformNode[];
  42667. /**
  42668. * ActionManagers available on the scene.
  42669. */
  42670. actionManagers: AbstractActionManager[];
  42671. /**
  42672. * Textures to keep.
  42673. */
  42674. textures: BaseTexture[];
  42675. /**
  42676. * Environment texture for the scene
  42677. */
  42678. environmentTexture: Nullable<BaseTexture>;
  42679. /**
  42680. * @returns all meshes, lights, cameras, transformNodes and bones
  42681. */
  42682. getNodes(): Array<Node>;
  42683. }
  42684. }
  42685. declare module "babylonjs/Audio/sound" {
  42686. import { Observable } from "babylonjs/Misc/observable";
  42687. import { Vector3 } from "babylonjs/Maths/math.vector";
  42688. import { Nullable } from "babylonjs/types";
  42689. import { Scene } from "babylonjs/scene";
  42690. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42691. /**
  42692. * Interface used to define options for Sound class
  42693. */
  42694. export interface ISoundOptions {
  42695. /**
  42696. * Does the sound autoplay once loaded.
  42697. */
  42698. autoplay?: boolean;
  42699. /**
  42700. * Does the sound loop after it finishes playing once.
  42701. */
  42702. loop?: boolean;
  42703. /**
  42704. * Sound's volume
  42705. */
  42706. volume?: number;
  42707. /**
  42708. * Is it a spatial sound?
  42709. */
  42710. spatialSound?: boolean;
  42711. /**
  42712. * Maximum distance to hear that sound
  42713. */
  42714. maxDistance?: number;
  42715. /**
  42716. * Uses user defined attenuation function
  42717. */
  42718. useCustomAttenuation?: boolean;
  42719. /**
  42720. * Define the roll off factor of spatial sounds.
  42721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42722. */
  42723. rolloffFactor?: number;
  42724. /**
  42725. * Define the reference distance the sound should be heard perfectly.
  42726. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42727. */
  42728. refDistance?: number;
  42729. /**
  42730. * Define the distance attenuation model the sound will follow.
  42731. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42732. */
  42733. distanceModel?: string;
  42734. /**
  42735. * Defines the playback speed (1 by default)
  42736. */
  42737. playbackRate?: number;
  42738. /**
  42739. * Defines if the sound is from a streaming source
  42740. */
  42741. streaming?: boolean;
  42742. /**
  42743. * Defines an optional length (in seconds) inside the sound file
  42744. */
  42745. length?: number;
  42746. /**
  42747. * Defines an optional offset (in seconds) inside the sound file
  42748. */
  42749. offset?: number;
  42750. /**
  42751. * If true, URLs will not be required to state the audio file codec to use.
  42752. */
  42753. skipCodecCheck?: boolean;
  42754. }
  42755. /**
  42756. * Defines a sound that can be played in the application.
  42757. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42759. */
  42760. export class Sound {
  42761. /**
  42762. * The name of the sound in the scene.
  42763. */
  42764. name: string;
  42765. /**
  42766. * Does the sound autoplay once loaded.
  42767. */
  42768. autoplay: boolean;
  42769. /**
  42770. * Does the sound loop after it finishes playing once.
  42771. */
  42772. loop: boolean;
  42773. /**
  42774. * Does the sound use a custom attenuation curve to simulate the falloff
  42775. * happening when the source gets further away from the camera.
  42776. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42777. */
  42778. useCustomAttenuation: boolean;
  42779. /**
  42780. * The sound track id this sound belongs to.
  42781. */
  42782. soundTrackId: number;
  42783. /**
  42784. * Is this sound currently played.
  42785. */
  42786. isPlaying: boolean;
  42787. /**
  42788. * Is this sound currently paused.
  42789. */
  42790. isPaused: boolean;
  42791. /**
  42792. * Does this sound enables spatial sound.
  42793. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42794. */
  42795. spatialSound: boolean;
  42796. /**
  42797. * Define the reference distance the sound should be heard perfectly.
  42798. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42799. */
  42800. refDistance: number;
  42801. /**
  42802. * Define the roll off factor of spatial sounds.
  42803. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42804. */
  42805. rolloffFactor: number;
  42806. /**
  42807. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42808. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42809. */
  42810. maxDistance: number;
  42811. /**
  42812. * Define the distance attenuation model the sound will follow.
  42813. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42814. */
  42815. distanceModel: string;
  42816. /**
  42817. * @hidden
  42818. * Back Compat
  42819. **/
  42820. onended: () => any;
  42821. /**
  42822. * Gets or sets an object used to store user defined information for the sound.
  42823. */
  42824. metadata: any;
  42825. /**
  42826. * Observable event when the current playing sound finishes.
  42827. */
  42828. onEndedObservable: Observable<Sound>;
  42829. private _panningModel;
  42830. private _playbackRate;
  42831. private _streaming;
  42832. private _startTime;
  42833. private _startOffset;
  42834. private _position;
  42835. /** @hidden */
  42836. _positionInEmitterSpace: boolean;
  42837. private _localDirection;
  42838. private _volume;
  42839. private _isReadyToPlay;
  42840. private _isDirectional;
  42841. private _readyToPlayCallback;
  42842. private _audioBuffer;
  42843. private _soundSource;
  42844. private _streamingSource;
  42845. private _soundPanner;
  42846. private _soundGain;
  42847. private _inputAudioNode;
  42848. private _outputAudioNode;
  42849. private _coneInnerAngle;
  42850. private _coneOuterAngle;
  42851. private _coneOuterGain;
  42852. private _scene;
  42853. private _connectedTransformNode;
  42854. private _customAttenuationFunction;
  42855. private _registerFunc;
  42856. private _isOutputConnected;
  42857. private _htmlAudioElement;
  42858. private _urlType;
  42859. private _length?;
  42860. private _offset?;
  42861. /** @hidden */
  42862. static _SceneComponentInitialization: (scene: Scene) => void;
  42863. /**
  42864. * Create a sound and attach it to a scene
  42865. * @param name Name of your sound
  42866. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42867. * @param scene defines the scene the sound belongs to
  42868. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42869. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42870. */
  42871. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42872. /**
  42873. * Release the sound and its associated resources
  42874. */
  42875. dispose(): void;
  42876. /**
  42877. * Gets if the sounds is ready to be played or not.
  42878. * @returns true if ready, otherwise false
  42879. */
  42880. isReady(): boolean;
  42881. private _soundLoaded;
  42882. /**
  42883. * Sets the data of the sound from an audiobuffer
  42884. * @param audioBuffer The audioBuffer containing the data
  42885. */
  42886. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42887. /**
  42888. * Updates the current sounds options such as maxdistance, loop...
  42889. * @param options A JSON object containing values named as the object properties
  42890. */
  42891. updateOptions(options: ISoundOptions): void;
  42892. private _createSpatialParameters;
  42893. private _updateSpatialParameters;
  42894. /**
  42895. * Switch the panning model to HRTF:
  42896. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42897. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42898. */
  42899. switchPanningModelToHRTF(): void;
  42900. /**
  42901. * Switch the panning model to Equal Power:
  42902. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42903. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42904. */
  42905. switchPanningModelToEqualPower(): void;
  42906. private _switchPanningModel;
  42907. /**
  42908. * Connect this sound to a sound track audio node like gain...
  42909. * @param soundTrackAudioNode the sound track audio node to connect to
  42910. */
  42911. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42912. /**
  42913. * Transform this sound into a directional source
  42914. * @param coneInnerAngle Size of the inner cone in degree
  42915. * @param coneOuterAngle Size of the outer cone in degree
  42916. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42917. */
  42918. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42919. /**
  42920. * Gets or sets the inner angle for the directional cone.
  42921. */
  42922. get directionalConeInnerAngle(): number;
  42923. /**
  42924. * Gets or sets the inner angle for the directional cone.
  42925. */
  42926. set directionalConeInnerAngle(value: number);
  42927. /**
  42928. * Gets or sets the outer angle for the directional cone.
  42929. */
  42930. get directionalConeOuterAngle(): number;
  42931. /**
  42932. * Gets or sets the outer angle for the directional cone.
  42933. */
  42934. set directionalConeOuterAngle(value: number);
  42935. /**
  42936. * Sets the position of the emitter if spatial sound is enabled
  42937. * @param newPosition Defines the new posisiton
  42938. */
  42939. setPosition(newPosition: Vector3): void;
  42940. /**
  42941. * Sets the local direction of the emitter if spatial sound is enabled
  42942. * @param newLocalDirection Defines the new local direction
  42943. */
  42944. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42945. private _updateDirection;
  42946. /** @hidden */
  42947. updateDistanceFromListener(): void;
  42948. /**
  42949. * Sets a new custom attenuation function for the sound.
  42950. * @param callback Defines the function used for the attenuation
  42951. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42952. */
  42953. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42954. /**
  42955. * Play the sound
  42956. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42957. * @param offset (optional) Start the sound at a specific time in seconds
  42958. * @param length (optional) Sound duration (in seconds)
  42959. */
  42960. play(time?: number, offset?: number, length?: number): void;
  42961. private _onended;
  42962. /**
  42963. * Stop the sound
  42964. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42965. */
  42966. stop(time?: number): void;
  42967. /**
  42968. * Put the sound in pause
  42969. */
  42970. pause(): void;
  42971. /**
  42972. * Sets a dedicated volume for this sounds
  42973. * @param newVolume Define the new volume of the sound
  42974. * @param time Define time for gradual change to new volume
  42975. */
  42976. setVolume(newVolume: number, time?: number): void;
  42977. /**
  42978. * Set the sound play back rate
  42979. * @param newPlaybackRate Define the playback rate the sound should be played at
  42980. */
  42981. setPlaybackRate(newPlaybackRate: number): void;
  42982. /**
  42983. * Gets the volume of the sound.
  42984. * @returns the volume of the sound
  42985. */
  42986. getVolume(): number;
  42987. /**
  42988. * Attach the sound to a dedicated mesh
  42989. * @param transformNode The transform node to connect the sound with
  42990. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42991. */
  42992. attachToMesh(transformNode: TransformNode): void;
  42993. /**
  42994. * Detach the sound from the previously attached mesh
  42995. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42996. */
  42997. detachFromMesh(): void;
  42998. private _onRegisterAfterWorldMatrixUpdate;
  42999. /**
  43000. * Clone the current sound in the scene.
  43001. * @returns the new sound clone
  43002. */
  43003. clone(): Nullable<Sound>;
  43004. /**
  43005. * Gets the current underlying audio buffer containing the data
  43006. * @returns the audio buffer
  43007. */
  43008. getAudioBuffer(): Nullable<AudioBuffer>;
  43009. /**
  43010. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43011. * @returns the source node
  43012. */
  43013. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43014. /**
  43015. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43016. * @returns the gain node
  43017. */
  43018. getSoundGain(): Nullable<GainNode>;
  43019. /**
  43020. * Serializes the Sound in a JSON representation
  43021. * @returns the JSON representation of the sound
  43022. */
  43023. serialize(): any;
  43024. /**
  43025. * Parse a JSON representation of a sound to innstantiate in a given scene
  43026. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43027. * @param scene Define the scene the new parsed sound should be created in
  43028. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43029. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43030. * @returns the newly parsed sound
  43031. */
  43032. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43033. }
  43034. }
  43035. declare module "babylonjs/Actions/directAudioActions" {
  43036. import { Action } from "babylonjs/Actions/action";
  43037. import { Condition } from "babylonjs/Actions/condition";
  43038. import { Sound } from "babylonjs/Audio/sound";
  43039. /**
  43040. * This defines an action helpful to play a defined sound on a triggered action.
  43041. */
  43042. export class PlaySoundAction extends Action {
  43043. private _sound;
  43044. /**
  43045. * Instantiate the action
  43046. * @param triggerOptions defines the trigger options
  43047. * @param sound defines the sound to play
  43048. * @param condition defines the trigger related conditions
  43049. */
  43050. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43051. /** @hidden */
  43052. _prepare(): void;
  43053. /**
  43054. * Execute the action and play the sound.
  43055. */
  43056. execute(): void;
  43057. /**
  43058. * Serializes the actions and its related information.
  43059. * @param parent defines the object to serialize in
  43060. * @returns the serialized object
  43061. */
  43062. serialize(parent: any): any;
  43063. }
  43064. /**
  43065. * This defines an action helpful to stop a defined sound on a triggered action.
  43066. */
  43067. export class StopSoundAction extends Action {
  43068. private _sound;
  43069. /**
  43070. * Instantiate the action
  43071. * @param triggerOptions defines the trigger options
  43072. * @param sound defines the sound to stop
  43073. * @param condition defines the trigger related conditions
  43074. */
  43075. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43076. /** @hidden */
  43077. _prepare(): void;
  43078. /**
  43079. * Execute the action and stop the sound.
  43080. */
  43081. execute(): void;
  43082. /**
  43083. * Serializes the actions and its related information.
  43084. * @param parent defines the object to serialize in
  43085. * @returns the serialized object
  43086. */
  43087. serialize(parent: any): any;
  43088. }
  43089. }
  43090. declare module "babylonjs/Actions/interpolateValueAction" {
  43091. import { Action } from "babylonjs/Actions/action";
  43092. import { Condition } from "babylonjs/Actions/condition";
  43093. import { Observable } from "babylonjs/Misc/observable";
  43094. /**
  43095. * This defines an action responsible to change the value of a property
  43096. * by interpolating between its current value and the newly set one once triggered.
  43097. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43098. */
  43099. export class InterpolateValueAction extends Action {
  43100. /**
  43101. * Defines the path of the property where the value should be interpolated
  43102. */
  43103. propertyPath: string;
  43104. /**
  43105. * Defines the target value at the end of the interpolation.
  43106. */
  43107. value: any;
  43108. /**
  43109. * Defines the time it will take for the property to interpolate to the value.
  43110. */
  43111. duration: number;
  43112. /**
  43113. * Defines if the other scene animations should be stopped when the action has been triggered
  43114. */
  43115. stopOtherAnimations?: boolean;
  43116. /**
  43117. * Defines a callback raised once the interpolation animation has been done.
  43118. */
  43119. onInterpolationDone?: () => void;
  43120. /**
  43121. * Observable triggered once the interpolation animation has been done.
  43122. */
  43123. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43124. private _target;
  43125. private _effectiveTarget;
  43126. private _property;
  43127. /**
  43128. * Instantiate the action
  43129. * @param triggerOptions defines the trigger options
  43130. * @param target defines the object containing the value to interpolate
  43131. * @param propertyPath defines the path to the property in the target object
  43132. * @param value defines the target value at the end of the interpolation
  43133. * @param duration deines the time it will take for the property to interpolate to the value.
  43134. * @param condition defines the trigger related conditions
  43135. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43136. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43137. */
  43138. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43139. /** @hidden */
  43140. _prepare(): void;
  43141. /**
  43142. * Execute the action starts the value interpolation.
  43143. */
  43144. execute(): void;
  43145. /**
  43146. * Serializes the actions and its related information.
  43147. * @param parent defines the object to serialize in
  43148. * @returns the serialized object
  43149. */
  43150. serialize(parent: any): any;
  43151. }
  43152. }
  43153. declare module "babylonjs/Actions/index" {
  43154. export * from "babylonjs/Actions/abstractActionManager";
  43155. export * from "babylonjs/Actions/action";
  43156. export * from "babylonjs/Actions/actionEvent";
  43157. export * from "babylonjs/Actions/actionManager";
  43158. export * from "babylonjs/Actions/condition";
  43159. export * from "babylonjs/Actions/directActions";
  43160. export * from "babylonjs/Actions/directAudioActions";
  43161. export * from "babylonjs/Actions/interpolateValueAction";
  43162. }
  43163. declare module "babylonjs/Animations/index" {
  43164. export * from "babylonjs/Animations/animatable";
  43165. export * from "babylonjs/Animations/animation";
  43166. export * from "babylonjs/Animations/animationGroup";
  43167. export * from "babylonjs/Animations/animationPropertiesOverride";
  43168. export * from "babylonjs/Animations/easing";
  43169. export * from "babylonjs/Animations/runtimeAnimation";
  43170. export * from "babylonjs/Animations/animationEvent";
  43171. export * from "babylonjs/Animations/animationGroup";
  43172. export * from "babylonjs/Animations/animationKey";
  43173. export * from "babylonjs/Animations/animationRange";
  43174. export * from "babylonjs/Animations/animatable.interface";
  43175. }
  43176. declare module "babylonjs/Audio/soundTrack" {
  43177. import { Sound } from "babylonjs/Audio/sound";
  43178. import { Analyser } from "babylonjs/Audio/analyser";
  43179. import { Scene } from "babylonjs/scene";
  43180. /**
  43181. * Options allowed during the creation of a sound track.
  43182. */
  43183. export interface ISoundTrackOptions {
  43184. /**
  43185. * The volume the sound track should take during creation
  43186. */
  43187. volume?: number;
  43188. /**
  43189. * Define if the sound track is the main sound track of the scene
  43190. */
  43191. mainTrack?: boolean;
  43192. }
  43193. /**
  43194. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43195. * It will be also used in a future release to apply effects on a specific track.
  43196. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43197. */
  43198. export class SoundTrack {
  43199. /**
  43200. * The unique identifier of the sound track in the scene.
  43201. */
  43202. id: number;
  43203. /**
  43204. * The list of sounds included in the sound track.
  43205. */
  43206. soundCollection: Array<Sound>;
  43207. private _outputAudioNode;
  43208. private _scene;
  43209. private _connectedAnalyser;
  43210. private _options;
  43211. private _isInitialized;
  43212. /**
  43213. * Creates a new sound track.
  43214. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43215. * @param scene Define the scene the sound track belongs to
  43216. * @param options
  43217. */
  43218. constructor(scene: Scene, options?: ISoundTrackOptions);
  43219. private _initializeSoundTrackAudioGraph;
  43220. /**
  43221. * Release the sound track and its associated resources
  43222. */
  43223. dispose(): void;
  43224. /**
  43225. * Adds a sound to this sound track
  43226. * @param sound define the cound to add
  43227. * @ignoreNaming
  43228. */
  43229. AddSound(sound: Sound): void;
  43230. /**
  43231. * Removes a sound to this sound track
  43232. * @param sound define the cound to remove
  43233. * @ignoreNaming
  43234. */
  43235. RemoveSound(sound: Sound): void;
  43236. /**
  43237. * Set a global volume for the full sound track.
  43238. * @param newVolume Define the new volume of the sound track
  43239. */
  43240. setVolume(newVolume: number): void;
  43241. /**
  43242. * Switch the panning model to HRTF:
  43243. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43245. */
  43246. switchPanningModelToHRTF(): void;
  43247. /**
  43248. * Switch the panning model to Equal Power:
  43249. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43250. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43251. */
  43252. switchPanningModelToEqualPower(): void;
  43253. /**
  43254. * Connect the sound track to an audio analyser allowing some amazing
  43255. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43256. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43257. * @param analyser The analyser to connect to the engine
  43258. */
  43259. connectToAnalyser(analyser: Analyser): void;
  43260. }
  43261. }
  43262. declare module "babylonjs/Audio/audioSceneComponent" {
  43263. import { Sound } from "babylonjs/Audio/sound";
  43264. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43265. import { Nullable } from "babylonjs/types";
  43266. import { Vector3 } from "babylonjs/Maths/math.vector";
  43267. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43268. import { Scene } from "babylonjs/scene";
  43269. import { AbstractScene } from "babylonjs/abstractScene";
  43270. import "babylonjs/Audio/audioEngine";
  43271. module "babylonjs/abstractScene" {
  43272. interface AbstractScene {
  43273. /**
  43274. * The list of sounds used in the scene.
  43275. */
  43276. sounds: Nullable<Array<Sound>>;
  43277. }
  43278. }
  43279. module "babylonjs/scene" {
  43280. interface Scene {
  43281. /**
  43282. * @hidden
  43283. * Backing field
  43284. */
  43285. _mainSoundTrack: SoundTrack;
  43286. /**
  43287. * The main sound track played by the scene.
  43288. * It cotains your primary collection of sounds.
  43289. */
  43290. mainSoundTrack: SoundTrack;
  43291. /**
  43292. * The list of sound tracks added to the scene
  43293. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43294. */
  43295. soundTracks: Nullable<Array<SoundTrack>>;
  43296. /**
  43297. * Gets a sound using a given name
  43298. * @param name defines the name to search for
  43299. * @return the found sound or null if not found at all.
  43300. */
  43301. getSoundByName(name: string): Nullable<Sound>;
  43302. /**
  43303. * Gets or sets if audio support is enabled
  43304. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43305. */
  43306. audioEnabled: boolean;
  43307. /**
  43308. * Gets or sets if audio will be output to headphones
  43309. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43310. */
  43311. headphone: boolean;
  43312. /**
  43313. * Gets or sets custom audio listener position provider
  43314. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43315. */
  43316. audioListenerPositionProvider: Nullable<() => Vector3>;
  43317. /**
  43318. * Gets or sets a refresh rate when using 3D audio positioning
  43319. */
  43320. audioPositioningRefreshRate: number;
  43321. }
  43322. }
  43323. /**
  43324. * Defines the sound scene component responsible to manage any sounds
  43325. * in a given scene.
  43326. */
  43327. export class AudioSceneComponent implements ISceneSerializableComponent {
  43328. /**
  43329. * The component name helpfull to identify the component in the list of scene components.
  43330. */
  43331. readonly name: string;
  43332. /**
  43333. * The scene the component belongs to.
  43334. */
  43335. scene: Scene;
  43336. private _audioEnabled;
  43337. /**
  43338. * Gets whether audio is enabled or not.
  43339. * Please use related enable/disable method to switch state.
  43340. */
  43341. get audioEnabled(): boolean;
  43342. private _headphone;
  43343. /**
  43344. * Gets whether audio is outputing to headphone or not.
  43345. * Please use the according Switch methods to change output.
  43346. */
  43347. get headphone(): boolean;
  43348. /**
  43349. * Gets or sets a refresh rate when using 3D audio positioning
  43350. */
  43351. audioPositioningRefreshRate: number;
  43352. private _audioListenerPositionProvider;
  43353. /**
  43354. * Gets the current audio listener position provider
  43355. */
  43356. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43357. /**
  43358. * Sets a custom listener position for all sounds in the scene
  43359. * By default, this is the position of the first active camera
  43360. */
  43361. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43362. /**
  43363. * Creates a new instance of the component for the given scene
  43364. * @param scene Defines the scene to register the component in
  43365. */
  43366. constructor(scene: Scene);
  43367. /**
  43368. * Registers the component in a given scene
  43369. */
  43370. register(): void;
  43371. /**
  43372. * Rebuilds the elements related to this component in case of
  43373. * context lost for instance.
  43374. */
  43375. rebuild(): void;
  43376. /**
  43377. * Serializes the component data to the specified json object
  43378. * @param serializationObject The object to serialize to
  43379. */
  43380. serialize(serializationObject: any): void;
  43381. /**
  43382. * Adds all the elements from the container to the scene
  43383. * @param container the container holding the elements
  43384. */
  43385. addFromContainer(container: AbstractScene): void;
  43386. /**
  43387. * Removes all the elements in the container from the scene
  43388. * @param container contains the elements to remove
  43389. * @param dispose if the removed element should be disposed (default: false)
  43390. */
  43391. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43392. /**
  43393. * Disposes the component and the associated ressources.
  43394. */
  43395. dispose(): void;
  43396. /**
  43397. * Disables audio in the associated scene.
  43398. */
  43399. disableAudio(): void;
  43400. /**
  43401. * Enables audio in the associated scene.
  43402. */
  43403. enableAudio(): void;
  43404. /**
  43405. * Switch audio to headphone output.
  43406. */
  43407. switchAudioModeForHeadphones(): void;
  43408. /**
  43409. * Switch audio to normal speakers.
  43410. */
  43411. switchAudioModeForNormalSpeakers(): void;
  43412. private _cachedCameraDirection;
  43413. private _cachedCameraPosition;
  43414. private _lastCheck;
  43415. private _afterRender;
  43416. }
  43417. }
  43418. declare module "babylonjs/Audio/weightedsound" {
  43419. import { Sound } from "babylonjs/Audio/sound";
  43420. /**
  43421. * Wraps one or more Sound objects and selects one with random weight for playback.
  43422. */
  43423. export class WeightedSound {
  43424. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43425. loop: boolean;
  43426. private _coneInnerAngle;
  43427. private _coneOuterAngle;
  43428. private _volume;
  43429. /** A Sound is currently playing. */
  43430. isPlaying: boolean;
  43431. /** A Sound is currently paused. */
  43432. isPaused: boolean;
  43433. private _sounds;
  43434. private _weights;
  43435. private _currentIndex?;
  43436. /**
  43437. * Creates a new WeightedSound from the list of sounds given.
  43438. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43439. * @param sounds Array of Sounds that will be selected from.
  43440. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43441. */
  43442. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43443. /**
  43444. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43445. */
  43446. get directionalConeInnerAngle(): number;
  43447. /**
  43448. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43449. */
  43450. set directionalConeInnerAngle(value: number);
  43451. /**
  43452. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43453. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43454. */
  43455. get directionalConeOuterAngle(): number;
  43456. /**
  43457. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43458. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43459. */
  43460. set directionalConeOuterAngle(value: number);
  43461. /**
  43462. * Playback volume.
  43463. */
  43464. get volume(): number;
  43465. /**
  43466. * Playback volume.
  43467. */
  43468. set volume(value: number);
  43469. private _onended;
  43470. /**
  43471. * Suspend playback
  43472. */
  43473. pause(): void;
  43474. /**
  43475. * Stop playback
  43476. */
  43477. stop(): void;
  43478. /**
  43479. * Start playback.
  43480. * @param startOffset Position the clip head at a specific time in seconds.
  43481. */
  43482. play(startOffset?: number): void;
  43483. }
  43484. }
  43485. declare module "babylonjs/Audio/index" {
  43486. export * from "babylonjs/Audio/analyser";
  43487. export * from "babylonjs/Audio/audioEngine";
  43488. export * from "babylonjs/Audio/audioSceneComponent";
  43489. export * from "babylonjs/Audio/sound";
  43490. export * from "babylonjs/Audio/soundTrack";
  43491. export * from "babylonjs/Audio/weightedsound";
  43492. }
  43493. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43494. import { Behavior } from "babylonjs/Behaviors/behavior";
  43495. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43496. import { BackEase } from "babylonjs/Animations/easing";
  43497. /**
  43498. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43499. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43500. */
  43501. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43502. /**
  43503. * Gets the name of the behavior.
  43504. */
  43505. get name(): string;
  43506. /**
  43507. * The easing function used by animations
  43508. */
  43509. static EasingFunction: BackEase;
  43510. /**
  43511. * The easing mode used by animations
  43512. */
  43513. static EasingMode: number;
  43514. /**
  43515. * The duration of the animation, in milliseconds
  43516. */
  43517. transitionDuration: number;
  43518. /**
  43519. * Length of the distance animated by the transition when lower radius is reached
  43520. */
  43521. lowerRadiusTransitionRange: number;
  43522. /**
  43523. * Length of the distance animated by the transition when upper radius is reached
  43524. */
  43525. upperRadiusTransitionRange: number;
  43526. private _autoTransitionRange;
  43527. /**
  43528. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43529. */
  43530. get autoTransitionRange(): boolean;
  43531. /**
  43532. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43533. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43534. */
  43535. set autoTransitionRange(value: boolean);
  43536. private _attachedCamera;
  43537. private _onAfterCheckInputsObserver;
  43538. private _onMeshTargetChangedObserver;
  43539. /**
  43540. * Initializes the behavior.
  43541. */
  43542. init(): void;
  43543. /**
  43544. * Attaches the behavior to its arc rotate camera.
  43545. * @param camera Defines the camera to attach the behavior to
  43546. */
  43547. attach(camera: ArcRotateCamera): void;
  43548. /**
  43549. * Detaches the behavior from its current arc rotate camera.
  43550. */
  43551. detach(): void;
  43552. private _radiusIsAnimating;
  43553. private _radiusBounceTransition;
  43554. private _animatables;
  43555. private _cachedWheelPrecision;
  43556. /**
  43557. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43558. * @param radiusLimit The limit to check against.
  43559. * @return Bool to indicate if at limit.
  43560. */
  43561. private _isRadiusAtLimit;
  43562. /**
  43563. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43564. * @param radiusDelta The delta by which to animate to. Can be negative.
  43565. */
  43566. private _applyBoundRadiusAnimation;
  43567. /**
  43568. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43569. */
  43570. protected _clearAnimationLocks(): void;
  43571. /**
  43572. * Stops and removes all animations that have been applied to the camera
  43573. */
  43574. stopAllAnimations(): void;
  43575. }
  43576. }
  43577. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43578. import { Behavior } from "babylonjs/Behaviors/behavior";
  43579. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43580. import { ExponentialEase } from "babylonjs/Animations/easing";
  43581. import { Nullable } from "babylonjs/types";
  43582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43583. import { Vector3 } from "babylonjs/Maths/math.vector";
  43584. /**
  43585. * 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.
  43586. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43587. */
  43588. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43589. /**
  43590. * Gets the name of the behavior.
  43591. */
  43592. get name(): string;
  43593. private _mode;
  43594. private _radiusScale;
  43595. private _positionScale;
  43596. private _defaultElevation;
  43597. private _elevationReturnTime;
  43598. private _elevationReturnWaitTime;
  43599. private _zoomStopsAnimation;
  43600. private _framingTime;
  43601. /**
  43602. * The easing function used by animations
  43603. */
  43604. static EasingFunction: ExponentialEase;
  43605. /**
  43606. * The easing mode used by animations
  43607. */
  43608. static EasingMode: number;
  43609. /**
  43610. * Sets the current mode used by the behavior
  43611. */
  43612. set mode(mode: number);
  43613. /**
  43614. * Gets current mode used by the behavior.
  43615. */
  43616. get mode(): number;
  43617. /**
  43618. * Sets the scale applied to the radius (1 by default)
  43619. */
  43620. set radiusScale(radius: number);
  43621. /**
  43622. * Gets the scale applied to the radius
  43623. */
  43624. get radiusScale(): number;
  43625. /**
  43626. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43627. */
  43628. set positionScale(scale: number);
  43629. /**
  43630. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43631. */
  43632. get positionScale(): number;
  43633. /**
  43634. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43635. * behaviour is triggered, in radians.
  43636. */
  43637. set defaultElevation(elevation: number);
  43638. /**
  43639. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43640. * behaviour is triggered, in radians.
  43641. */
  43642. get defaultElevation(): number;
  43643. /**
  43644. * Sets the time (in milliseconds) taken to return to the default beta position.
  43645. * Negative value indicates camera should not return to default.
  43646. */
  43647. set elevationReturnTime(speed: number);
  43648. /**
  43649. * Gets the time (in milliseconds) taken to return to the default beta position.
  43650. * Negative value indicates camera should not return to default.
  43651. */
  43652. get elevationReturnTime(): number;
  43653. /**
  43654. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43655. */
  43656. set elevationReturnWaitTime(time: number);
  43657. /**
  43658. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43659. */
  43660. get elevationReturnWaitTime(): number;
  43661. /**
  43662. * Sets the flag that indicates if user zooming should stop animation.
  43663. */
  43664. set zoomStopsAnimation(flag: boolean);
  43665. /**
  43666. * Gets the flag that indicates if user zooming should stop animation.
  43667. */
  43668. get zoomStopsAnimation(): boolean;
  43669. /**
  43670. * Sets the transition time when framing the mesh, in milliseconds
  43671. */
  43672. set framingTime(time: number);
  43673. /**
  43674. * Gets the transition time when framing the mesh, in milliseconds
  43675. */
  43676. get framingTime(): number;
  43677. /**
  43678. * Define if the behavior should automatically change the configured
  43679. * camera limits and sensibilities.
  43680. */
  43681. autoCorrectCameraLimitsAndSensibility: boolean;
  43682. private _onPrePointerObservableObserver;
  43683. private _onAfterCheckInputsObserver;
  43684. private _onMeshTargetChangedObserver;
  43685. private _attachedCamera;
  43686. private _isPointerDown;
  43687. private _lastInteractionTime;
  43688. /**
  43689. * Initializes the behavior.
  43690. */
  43691. init(): void;
  43692. /**
  43693. * Attaches the behavior to its arc rotate camera.
  43694. * @param camera Defines the camera to attach the behavior to
  43695. */
  43696. attach(camera: ArcRotateCamera): void;
  43697. /**
  43698. * Detaches the behavior from its current arc rotate camera.
  43699. */
  43700. detach(): void;
  43701. private _animatables;
  43702. private _betaIsAnimating;
  43703. private _betaTransition;
  43704. private _radiusTransition;
  43705. private _vectorTransition;
  43706. /**
  43707. * Targets the given mesh and updates zoom level accordingly.
  43708. * @param mesh The mesh to target.
  43709. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43710. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43711. */
  43712. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43713. /**
  43714. * Targets the given mesh with its children and updates zoom level accordingly.
  43715. * @param mesh The mesh to target.
  43716. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43717. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43718. */
  43719. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43720. /**
  43721. * Targets the given meshes with their children and updates zoom level accordingly.
  43722. * @param meshes The mesh to target.
  43723. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43724. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43725. */
  43726. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43727. /**
  43728. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43729. * @param minimumWorld Determines the smaller position of the bounding box extend
  43730. * @param maximumWorld Determines the bigger position of the bounding box extend
  43731. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43732. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43733. */
  43734. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43735. /**
  43736. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43737. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43738. * frustum width.
  43739. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43740. * to fully enclose the mesh in the viewing frustum.
  43741. */
  43742. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43743. /**
  43744. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43745. * is automatically returned to its default position (expected to be above ground plane).
  43746. */
  43747. private _maintainCameraAboveGround;
  43748. /**
  43749. * Returns the frustum slope based on the canvas ratio and camera FOV
  43750. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43751. */
  43752. private _getFrustumSlope;
  43753. /**
  43754. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43755. */
  43756. private _clearAnimationLocks;
  43757. /**
  43758. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43759. */
  43760. private _applyUserInteraction;
  43761. /**
  43762. * Stops and removes all animations that have been applied to the camera
  43763. */
  43764. stopAllAnimations(): void;
  43765. /**
  43766. * Gets a value indicating if the user is moving the camera
  43767. */
  43768. get isUserIsMoving(): boolean;
  43769. /**
  43770. * The camera can move all the way towards the mesh.
  43771. */
  43772. static IgnoreBoundsSizeMode: number;
  43773. /**
  43774. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43775. */
  43776. static FitFrustumSidesMode: number;
  43777. }
  43778. }
  43779. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43780. import { Nullable } from "babylonjs/types";
  43781. import { Camera } from "babylonjs/Cameras/camera";
  43782. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43783. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43784. /**
  43785. * Base class for Camera Pointer Inputs.
  43786. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43787. * for example usage.
  43788. */
  43789. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43790. /**
  43791. * Defines the camera the input is attached to.
  43792. */
  43793. abstract camera: Camera;
  43794. /**
  43795. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43796. */
  43797. protected _altKey: boolean;
  43798. protected _ctrlKey: boolean;
  43799. protected _metaKey: boolean;
  43800. protected _shiftKey: boolean;
  43801. /**
  43802. * Which mouse buttons were pressed at time of last mouse event.
  43803. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43804. */
  43805. protected _buttonsPressed: number;
  43806. /**
  43807. * Defines the buttons associated with the input to handle camera move.
  43808. */
  43809. buttons: number[];
  43810. /**
  43811. * Attach the input controls to a specific dom element to get the input from.
  43812. * @param element Defines the element the controls should be listened from
  43813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43814. */
  43815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43816. /**
  43817. * Detach the current controls from the specified dom element.
  43818. * @param element Defines the element to stop listening the inputs from
  43819. */
  43820. detachControl(element: Nullable<HTMLElement>): void;
  43821. /**
  43822. * Gets the class name of the current input.
  43823. * @returns the class name
  43824. */
  43825. getClassName(): string;
  43826. /**
  43827. * Get the friendly name associated with the input class.
  43828. * @returns the input friendly name
  43829. */
  43830. getSimpleName(): string;
  43831. /**
  43832. * Called on pointer POINTERDOUBLETAP event.
  43833. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43834. */
  43835. protected onDoubleTap(type: string): void;
  43836. /**
  43837. * Called on pointer POINTERMOVE event if only a single touch is active.
  43838. * Override this method to provide functionality.
  43839. */
  43840. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43841. /**
  43842. * Called on pointer POINTERMOVE event if multiple touches are active.
  43843. * Override this method to provide functionality.
  43844. */
  43845. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43846. /**
  43847. * Called on JS contextmenu event.
  43848. * Override this method to provide functionality.
  43849. */
  43850. protected onContextMenu(evt: PointerEvent): void;
  43851. /**
  43852. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43853. * press.
  43854. * Override this method to provide functionality.
  43855. */
  43856. protected onButtonDown(evt: PointerEvent): void;
  43857. /**
  43858. * Called each time a new POINTERUP event occurs. Ie, for each button
  43859. * release.
  43860. * Override this method to provide functionality.
  43861. */
  43862. protected onButtonUp(evt: PointerEvent): void;
  43863. /**
  43864. * Called when window becomes inactive.
  43865. * Override this method to provide functionality.
  43866. */
  43867. protected onLostFocus(): void;
  43868. private _pointerInput;
  43869. private _observer;
  43870. private _onLostFocus;
  43871. private pointA;
  43872. private pointB;
  43873. }
  43874. }
  43875. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43876. import { Nullable } from "babylonjs/types";
  43877. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43878. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43879. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43880. /**
  43881. * Manage the pointers inputs to control an arc rotate camera.
  43882. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43883. */
  43884. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43885. /**
  43886. * Defines the camera the input is attached to.
  43887. */
  43888. camera: ArcRotateCamera;
  43889. /**
  43890. * Gets the class name of the current input.
  43891. * @returns the class name
  43892. */
  43893. getClassName(): string;
  43894. /**
  43895. * Defines the buttons associated with the input to handle camera move.
  43896. */
  43897. buttons: number[];
  43898. /**
  43899. * Defines the pointer angular sensibility along the X axis or how fast is
  43900. * the camera rotating.
  43901. */
  43902. angularSensibilityX: number;
  43903. /**
  43904. * Defines the pointer angular sensibility along the Y axis or how fast is
  43905. * the camera rotating.
  43906. */
  43907. angularSensibilityY: number;
  43908. /**
  43909. * Defines the pointer pinch precision or how fast is the camera zooming.
  43910. */
  43911. pinchPrecision: number;
  43912. /**
  43913. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43914. * from 0.
  43915. * It defines the percentage of current camera.radius to use as delta when
  43916. * pinch zoom is used.
  43917. */
  43918. pinchDeltaPercentage: number;
  43919. /**
  43920. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43921. * that any object in the plane at the camera's target point will scale
  43922. * perfectly with finger motion.
  43923. * Overrides pinchDeltaPercentage and pinchPrecision.
  43924. */
  43925. useNaturalPinchZoom: boolean;
  43926. /**
  43927. * Defines the pointer panning sensibility or how fast is the camera moving.
  43928. */
  43929. panningSensibility: number;
  43930. /**
  43931. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43932. */
  43933. multiTouchPanning: boolean;
  43934. /**
  43935. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43936. * zoom (pinch) through multitouch.
  43937. */
  43938. multiTouchPanAndZoom: boolean;
  43939. /**
  43940. * Revers pinch action direction.
  43941. */
  43942. pinchInwards: boolean;
  43943. private _isPanClick;
  43944. private _twoFingerActivityCount;
  43945. private _isPinching;
  43946. /**
  43947. * Called on pointer POINTERMOVE event if only a single touch is active.
  43948. */
  43949. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43950. /**
  43951. * Called on pointer POINTERDOUBLETAP event.
  43952. */
  43953. protected onDoubleTap(type: string): void;
  43954. /**
  43955. * Called on pointer POINTERMOVE event if multiple touches are active.
  43956. */
  43957. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43958. /**
  43959. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43960. * press.
  43961. */
  43962. protected onButtonDown(evt: PointerEvent): void;
  43963. /**
  43964. * Called each time a new POINTERUP event occurs. Ie, for each button
  43965. * release.
  43966. */
  43967. protected onButtonUp(evt: PointerEvent): void;
  43968. /**
  43969. * Called when window becomes inactive.
  43970. */
  43971. protected onLostFocus(): void;
  43972. }
  43973. }
  43974. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43975. import { Nullable } from "babylonjs/types";
  43976. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43977. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43978. /**
  43979. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43980. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43981. */
  43982. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43983. /**
  43984. * Defines the camera the input is attached to.
  43985. */
  43986. camera: ArcRotateCamera;
  43987. /**
  43988. * Defines the list of key codes associated with the up action (increase alpha)
  43989. */
  43990. keysUp: number[];
  43991. /**
  43992. * Defines the list of key codes associated with the down action (decrease alpha)
  43993. */
  43994. keysDown: number[];
  43995. /**
  43996. * Defines the list of key codes associated with the left action (increase beta)
  43997. */
  43998. keysLeft: number[];
  43999. /**
  44000. * Defines the list of key codes associated with the right action (decrease beta)
  44001. */
  44002. keysRight: number[];
  44003. /**
  44004. * Defines the list of key codes associated with the reset action.
  44005. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44006. */
  44007. keysReset: number[];
  44008. /**
  44009. * Defines the panning sensibility of the inputs.
  44010. * (How fast is the camera panning)
  44011. */
  44012. panningSensibility: number;
  44013. /**
  44014. * Defines the zooming sensibility of the inputs.
  44015. * (How fast is the camera zooming)
  44016. */
  44017. zoomingSensibility: number;
  44018. /**
  44019. * Defines whether maintaining the alt key down switch the movement mode from
  44020. * orientation to zoom.
  44021. */
  44022. useAltToZoom: boolean;
  44023. /**
  44024. * Rotation speed of the camera
  44025. */
  44026. angularSpeed: number;
  44027. private _keys;
  44028. private _ctrlPressed;
  44029. private _altPressed;
  44030. private _onCanvasBlurObserver;
  44031. private _onKeyboardObserver;
  44032. private _engine;
  44033. private _scene;
  44034. /**
  44035. * Attach the input controls to a specific dom element to get the input from.
  44036. * @param element Defines the element the controls should be listened from
  44037. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44038. */
  44039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44040. /**
  44041. * Detach the current controls from the specified dom element.
  44042. * @param element Defines the element to stop listening the inputs from
  44043. */
  44044. detachControl(element: Nullable<HTMLElement>): void;
  44045. /**
  44046. * Update the current camera state depending on the inputs that have been used this frame.
  44047. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44048. */
  44049. checkInputs(): void;
  44050. /**
  44051. * Gets the class name of the current intput.
  44052. * @returns the class name
  44053. */
  44054. getClassName(): string;
  44055. /**
  44056. * Get the friendly name associated with the input class.
  44057. * @returns the input friendly name
  44058. */
  44059. getSimpleName(): string;
  44060. }
  44061. }
  44062. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44063. import { Nullable } from "babylonjs/types";
  44064. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44065. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44066. /**
  44067. * Manage the mouse wheel inputs to control an arc rotate camera.
  44068. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44069. */
  44070. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44071. /**
  44072. * Defines the camera the input is attached to.
  44073. */
  44074. camera: ArcRotateCamera;
  44075. /**
  44076. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44077. */
  44078. wheelPrecision: number;
  44079. /**
  44080. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44081. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44082. */
  44083. wheelDeltaPercentage: number;
  44084. private _wheel;
  44085. private _observer;
  44086. private computeDeltaFromMouseWheelLegacyEvent;
  44087. /**
  44088. * Attach the input controls to a specific dom element to get the input from.
  44089. * @param element Defines the element the controls should be listened from
  44090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44091. */
  44092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44093. /**
  44094. * Detach the current controls from the specified dom element.
  44095. * @param element Defines the element to stop listening the inputs from
  44096. */
  44097. detachControl(element: Nullable<HTMLElement>): void;
  44098. /**
  44099. * Gets the class name of the current intput.
  44100. * @returns the class name
  44101. */
  44102. getClassName(): string;
  44103. /**
  44104. * Get the friendly name associated with the input class.
  44105. * @returns the input friendly name
  44106. */
  44107. getSimpleName(): string;
  44108. }
  44109. }
  44110. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44111. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44112. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44113. /**
  44114. * Default Inputs manager for the ArcRotateCamera.
  44115. * It groups all the default supported inputs for ease of use.
  44116. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44117. */
  44118. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44119. /**
  44120. * Instantiates a new ArcRotateCameraInputsManager.
  44121. * @param camera Defines the camera the inputs belong to
  44122. */
  44123. constructor(camera: ArcRotateCamera);
  44124. /**
  44125. * Add mouse wheel input support to the input manager.
  44126. * @returns the current input manager
  44127. */
  44128. addMouseWheel(): ArcRotateCameraInputsManager;
  44129. /**
  44130. * Add pointers input support to the input manager.
  44131. * @returns the current input manager
  44132. */
  44133. addPointers(): ArcRotateCameraInputsManager;
  44134. /**
  44135. * Add keyboard input support to the input manager.
  44136. * @returns the current input manager
  44137. */
  44138. addKeyboard(): ArcRotateCameraInputsManager;
  44139. }
  44140. }
  44141. declare module "babylonjs/Cameras/arcRotateCamera" {
  44142. import { Observable } from "babylonjs/Misc/observable";
  44143. import { Nullable } from "babylonjs/types";
  44144. import { Scene } from "babylonjs/scene";
  44145. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44147. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44148. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44149. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44150. import { Camera } from "babylonjs/Cameras/camera";
  44151. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44152. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44153. import { Collider } from "babylonjs/Collisions/collider";
  44154. /**
  44155. * This represents an orbital type of camera.
  44156. *
  44157. * 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.
  44158. * 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.
  44159. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44160. */
  44161. export class ArcRotateCamera extends TargetCamera {
  44162. /**
  44163. * Defines the rotation angle of the camera along the longitudinal axis.
  44164. */
  44165. alpha: number;
  44166. /**
  44167. * Defines the rotation angle of the camera along the latitudinal axis.
  44168. */
  44169. beta: number;
  44170. /**
  44171. * Defines the radius of the camera from it s target point.
  44172. */
  44173. radius: number;
  44174. protected _target: Vector3;
  44175. protected _targetHost: Nullable<AbstractMesh>;
  44176. /**
  44177. * Defines the target point of the camera.
  44178. * The camera looks towards it form the radius distance.
  44179. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44180. */
  44181. get target(): Vector3;
  44182. set target(value: Vector3);
  44183. /**
  44184. * Define the current local position of the camera in the scene
  44185. */
  44186. get position(): Vector3;
  44187. set position(newPosition: Vector3);
  44188. protected _upVector: Vector3;
  44189. protected _upToYMatrix: Matrix;
  44190. protected _YToUpMatrix: Matrix;
  44191. /**
  44192. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44193. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44194. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44195. */
  44196. set upVector(vec: Vector3);
  44197. get upVector(): Vector3;
  44198. /**
  44199. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44200. */
  44201. setMatUp(): void;
  44202. /**
  44203. * Current inertia value on the longitudinal axis.
  44204. * The bigger this number the longer it will take for the camera to stop.
  44205. */
  44206. inertialAlphaOffset: number;
  44207. /**
  44208. * Current inertia value on the latitudinal axis.
  44209. * The bigger this number the longer it will take for the camera to stop.
  44210. */
  44211. inertialBetaOffset: number;
  44212. /**
  44213. * Current inertia value on the radius axis.
  44214. * The bigger this number the longer it will take for the camera to stop.
  44215. */
  44216. inertialRadiusOffset: number;
  44217. /**
  44218. * Minimum allowed angle on the longitudinal axis.
  44219. * This can help limiting how the Camera is able to move in the scene.
  44220. */
  44221. lowerAlphaLimit: Nullable<number>;
  44222. /**
  44223. * Maximum allowed angle on the longitudinal axis.
  44224. * This can help limiting how the Camera is able to move in the scene.
  44225. */
  44226. upperAlphaLimit: Nullable<number>;
  44227. /**
  44228. * Minimum allowed angle on the latitudinal axis.
  44229. * This can help limiting how the Camera is able to move in the scene.
  44230. */
  44231. lowerBetaLimit: number;
  44232. /**
  44233. * Maximum allowed angle on the latitudinal axis.
  44234. * This can help limiting how the Camera is able to move in the scene.
  44235. */
  44236. upperBetaLimit: number;
  44237. /**
  44238. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44239. * This can help limiting how the Camera is able to move in the scene.
  44240. */
  44241. lowerRadiusLimit: Nullable<number>;
  44242. /**
  44243. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44244. * This can help limiting how the Camera is able to move in the scene.
  44245. */
  44246. upperRadiusLimit: Nullable<number>;
  44247. /**
  44248. * Defines the current inertia value used during panning of the camera along the X axis.
  44249. */
  44250. inertialPanningX: number;
  44251. /**
  44252. * Defines the current inertia value used during panning of the camera along the Y axis.
  44253. */
  44254. inertialPanningY: number;
  44255. /**
  44256. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44257. * Basically if your fingers moves away from more than this distance you will be considered
  44258. * in pinch mode.
  44259. */
  44260. pinchToPanMaxDistance: number;
  44261. /**
  44262. * Defines the maximum distance the camera can pan.
  44263. * This could help keeping the cammera always in your scene.
  44264. */
  44265. panningDistanceLimit: Nullable<number>;
  44266. /**
  44267. * Defines the target of the camera before paning.
  44268. */
  44269. panningOriginTarget: Vector3;
  44270. /**
  44271. * Defines the value of the inertia used during panning.
  44272. * 0 would mean stop inertia and one would mean no decelleration at all.
  44273. */
  44274. panningInertia: number;
  44275. /**
  44276. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44277. */
  44278. get angularSensibilityX(): number;
  44279. set angularSensibilityX(value: number);
  44280. /**
  44281. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44282. */
  44283. get angularSensibilityY(): number;
  44284. set angularSensibilityY(value: number);
  44285. /**
  44286. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44287. */
  44288. get pinchPrecision(): number;
  44289. set pinchPrecision(value: number);
  44290. /**
  44291. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44292. * It will be used instead of pinchDeltaPrecision if different from 0.
  44293. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44294. */
  44295. get pinchDeltaPercentage(): number;
  44296. set pinchDeltaPercentage(value: number);
  44297. /**
  44298. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44299. * and pinch delta percentage.
  44300. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44301. * that any object in the plane at the camera's target point will scale
  44302. * perfectly with finger motion.
  44303. */
  44304. get useNaturalPinchZoom(): boolean;
  44305. set useNaturalPinchZoom(value: boolean);
  44306. /**
  44307. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44308. */
  44309. get panningSensibility(): number;
  44310. set panningSensibility(value: number);
  44311. /**
  44312. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44313. */
  44314. get keysUp(): number[];
  44315. set keysUp(value: number[]);
  44316. /**
  44317. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44318. */
  44319. get keysDown(): number[];
  44320. set keysDown(value: number[]);
  44321. /**
  44322. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44323. */
  44324. get keysLeft(): number[];
  44325. set keysLeft(value: number[]);
  44326. /**
  44327. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44328. */
  44329. get keysRight(): number[];
  44330. set keysRight(value: number[]);
  44331. /**
  44332. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44333. */
  44334. get wheelPrecision(): number;
  44335. set wheelPrecision(value: number);
  44336. /**
  44337. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44338. * It will be used instead of pinchDeltaPrecision if different from 0.
  44339. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44340. */
  44341. get wheelDeltaPercentage(): number;
  44342. set wheelDeltaPercentage(value: number);
  44343. /**
  44344. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44345. */
  44346. zoomOnFactor: number;
  44347. /**
  44348. * Defines a screen offset for the camera position.
  44349. */
  44350. targetScreenOffset: Vector2;
  44351. /**
  44352. * Allows the camera to be completely reversed.
  44353. * If false the camera can not arrive upside down.
  44354. */
  44355. allowUpsideDown: boolean;
  44356. /**
  44357. * Define if double tap/click is used to restore the previously saved state of the camera.
  44358. */
  44359. useInputToRestoreState: boolean;
  44360. /** @hidden */
  44361. _viewMatrix: Matrix;
  44362. /** @hidden */
  44363. _useCtrlForPanning: boolean;
  44364. /** @hidden */
  44365. _panningMouseButton: number;
  44366. /**
  44367. * Defines the input associated to the camera.
  44368. */
  44369. inputs: ArcRotateCameraInputsManager;
  44370. /** @hidden */
  44371. _reset: () => void;
  44372. /**
  44373. * Defines the allowed panning axis.
  44374. */
  44375. panningAxis: Vector3;
  44376. protected _localDirection: Vector3;
  44377. protected _transformedDirection: Vector3;
  44378. private _bouncingBehavior;
  44379. /**
  44380. * Gets the bouncing behavior of the camera if it has been enabled.
  44381. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44382. */
  44383. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44384. /**
  44385. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44386. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44387. */
  44388. get useBouncingBehavior(): boolean;
  44389. set useBouncingBehavior(value: boolean);
  44390. private _framingBehavior;
  44391. /**
  44392. * Gets the framing behavior of the camera if it has been enabled.
  44393. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44394. */
  44395. get framingBehavior(): Nullable<FramingBehavior>;
  44396. /**
  44397. * Defines if the framing behavior of the camera is enabled on the camera.
  44398. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44399. */
  44400. get useFramingBehavior(): boolean;
  44401. set useFramingBehavior(value: boolean);
  44402. private _autoRotationBehavior;
  44403. /**
  44404. * Gets the auto rotation behavior of the camera if it has been enabled.
  44405. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44406. */
  44407. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44408. /**
  44409. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44410. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44411. */
  44412. get useAutoRotationBehavior(): boolean;
  44413. set useAutoRotationBehavior(value: boolean);
  44414. /**
  44415. * Observable triggered when the mesh target has been changed on the camera.
  44416. */
  44417. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44418. /**
  44419. * Event raised when the camera is colliding with a mesh.
  44420. */
  44421. onCollide: (collidedMesh: AbstractMesh) => void;
  44422. /**
  44423. * Defines whether the camera should check collision with the objects oh the scene.
  44424. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44425. */
  44426. checkCollisions: boolean;
  44427. /**
  44428. * Defines the collision radius of the camera.
  44429. * This simulates a sphere around the camera.
  44430. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44431. */
  44432. collisionRadius: Vector3;
  44433. protected _collider: Collider;
  44434. protected _previousPosition: Vector3;
  44435. protected _collisionVelocity: Vector3;
  44436. protected _newPosition: Vector3;
  44437. protected _previousAlpha: number;
  44438. protected _previousBeta: number;
  44439. protected _previousRadius: number;
  44440. protected _collisionTriggered: boolean;
  44441. protected _targetBoundingCenter: Nullable<Vector3>;
  44442. private _computationVector;
  44443. /**
  44444. * Instantiates a new ArcRotateCamera in a given scene
  44445. * @param name Defines the name of the camera
  44446. * @param alpha Defines the camera rotation along the logitudinal axis
  44447. * @param beta Defines the camera rotation along the latitudinal axis
  44448. * @param radius Defines the camera distance from its target
  44449. * @param target Defines the camera target
  44450. * @param scene Defines the scene the camera belongs to
  44451. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44452. */
  44453. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44454. /** @hidden */
  44455. _initCache(): void;
  44456. /** @hidden */
  44457. _updateCache(ignoreParentClass?: boolean): void;
  44458. protected _getTargetPosition(): Vector3;
  44459. private _storedAlpha;
  44460. private _storedBeta;
  44461. private _storedRadius;
  44462. private _storedTarget;
  44463. private _storedTargetScreenOffset;
  44464. /**
  44465. * Stores the current state of the camera (alpha, beta, radius and target)
  44466. * @returns the camera itself
  44467. */
  44468. storeState(): Camera;
  44469. /**
  44470. * @hidden
  44471. * Restored camera state. You must call storeState() first
  44472. */
  44473. _restoreStateValues(): boolean;
  44474. /** @hidden */
  44475. _isSynchronizedViewMatrix(): boolean;
  44476. /**
  44477. * Attached controls to the current camera.
  44478. * @param element Defines the element the controls should be listened from
  44479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44480. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44481. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44482. */
  44483. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44484. /**
  44485. * Detach the current controls from the camera.
  44486. * The camera will stop reacting to inputs.
  44487. * @param element Defines the element to stop listening the inputs from
  44488. */
  44489. detachControl(element: HTMLElement): void;
  44490. /** @hidden */
  44491. _checkInputs(): void;
  44492. protected _checkLimits(): void;
  44493. /**
  44494. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44495. */
  44496. rebuildAnglesAndRadius(): void;
  44497. /**
  44498. * Use a position to define the current camera related information like alpha, beta and radius
  44499. * @param position Defines the position to set the camera at
  44500. */
  44501. setPosition(position: Vector3): void;
  44502. /**
  44503. * Defines the target the camera should look at.
  44504. * This will automatically adapt alpha beta and radius to fit within the new target.
  44505. * @param target Defines the new target as a Vector or a mesh
  44506. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44507. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44508. */
  44509. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44510. /** @hidden */
  44511. _getViewMatrix(): Matrix;
  44512. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44513. /**
  44514. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44515. * @param meshes Defines the mesh to zoom on
  44516. * @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)
  44517. */
  44518. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44519. /**
  44520. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44521. * The target will be changed but the radius
  44522. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44523. * @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)
  44524. */
  44525. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44526. min: Vector3;
  44527. max: Vector3;
  44528. distance: number;
  44529. }, doNotUpdateMaxZ?: boolean): void;
  44530. /**
  44531. * @override
  44532. * Override Camera.createRigCamera
  44533. */
  44534. createRigCamera(name: string, cameraIndex: number): Camera;
  44535. /**
  44536. * @hidden
  44537. * @override
  44538. * Override Camera._updateRigCameras
  44539. */
  44540. _updateRigCameras(): void;
  44541. /**
  44542. * Destroy the camera and release the current resources hold by it.
  44543. */
  44544. dispose(): void;
  44545. /**
  44546. * Gets the current object class name.
  44547. * @return the class name
  44548. */
  44549. getClassName(): string;
  44550. }
  44551. }
  44552. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44553. import { Behavior } from "babylonjs/Behaviors/behavior";
  44554. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44555. /**
  44556. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44557. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44558. */
  44559. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44560. /**
  44561. * Gets the name of the behavior.
  44562. */
  44563. get name(): string;
  44564. private _zoomStopsAnimation;
  44565. private _idleRotationSpeed;
  44566. private _idleRotationWaitTime;
  44567. private _idleRotationSpinupTime;
  44568. /**
  44569. * Sets the flag that indicates if user zooming should stop animation.
  44570. */
  44571. set zoomStopsAnimation(flag: boolean);
  44572. /**
  44573. * Gets the flag that indicates if user zooming should stop animation.
  44574. */
  44575. get zoomStopsAnimation(): boolean;
  44576. /**
  44577. * Sets the default speed at which the camera rotates around the model.
  44578. */
  44579. set idleRotationSpeed(speed: number);
  44580. /**
  44581. * Gets the default speed at which the camera rotates around the model.
  44582. */
  44583. get idleRotationSpeed(): number;
  44584. /**
  44585. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44586. */
  44587. set idleRotationWaitTime(time: number);
  44588. /**
  44589. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44590. */
  44591. get idleRotationWaitTime(): number;
  44592. /**
  44593. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44594. */
  44595. set idleRotationSpinupTime(time: number);
  44596. /**
  44597. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44598. */
  44599. get idleRotationSpinupTime(): number;
  44600. /**
  44601. * Gets a value indicating if the camera is currently rotating because of this behavior
  44602. */
  44603. get rotationInProgress(): boolean;
  44604. private _onPrePointerObservableObserver;
  44605. private _onAfterCheckInputsObserver;
  44606. private _attachedCamera;
  44607. private _isPointerDown;
  44608. private _lastFrameTime;
  44609. private _lastInteractionTime;
  44610. private _cameraRotationSpeed;
  44611. /**
  44612. * Initializes the behavior.
  44613. */
  44614. init(): void;
  44615. /**
  44616. * Attaches the behavior to its arc rotate camera.
  44617. * @param camera Defines the camera to attach the behavior to
  44618. */
  44619. attach(camera: ArcRotateCamera): void;
  44620. /**
  44621. * Detaches the behavior from its current arc rotate camera.
  44622. */
  44623. detach(): void;
  44624. /**
  44625. * Returns true if user is scrolling.
  44626. * @return true if user is scrolling.
  44627. */
  44628. private _userIsZooming;
  44629. private _lastFrameRadius;
  44630. private _shouldAnimationStopForInteraction;
  44631. /**
  44632. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44633. */
  44634. private _applyUserInteraction;
  44635. private _userIsMoving;
  44636. }
  44637. }
  44638. declare module "babylonjs/Behaviors/Cameras/index" {
  44639. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44640. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44641. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44642. }
  44643. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44644. import { Mesh } from "babylonjs/Meshes/mesh";
  44645. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44646. import { Behavior } from "babylonjs/Behaviors/behavior";
  44647. /**
  44648. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44649. */
  44650. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44651. private ui;
  44652. /**
  44653. * The name of the behavior
  44654. */
  44655. name: string;
  44656. /**
  44657. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44658. */
  44659. distanceAwayFromFace: number;
  44660. /**
  44661. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44662. */
  44663. distanceAwayFromBottomOfFace: number;
  44664. private _faceVectors;
  44665. private _target;
  44666. private _scene;
  44667. private _onRenderObserver;
  44668. private _tmpMatrix;
  44669. private _tmpVector;
  44670. /**
  44671. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44672. * @param ui The transform node that should be attched to the mesh
  44673. */
  44674. constructor(ui: TransformNode);
  44675. /**
  44676. * Initializes the behavior
  44677. */
  44678. init(): void;
  44679. private _closestFace;
  44680. private _zeroVector;
  44681. private _lookAtTmpMatrix;
  44682. private _lookAtToRef;
  44683. /**
  44684. * Attaches the AttachToBoxBehavior to the passed in mesh
  44685. * @param target The mesh that the specified node will be attached to
  44686. */
  44687. attach(target: Mesh): void;
  44688. /**
  44689. * Detaches the behavior from the mesh
  44690. */
  44691. detach(): void;
  44692. }
  44693. }
  44694. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44695. import { Behavior } from "babylonjs/Behaviors/behavior";
  44696. import { Mesh } from "babylonjs/Meshes/mesh";
  44697. /**
  44698. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44699. */
  44700. export class FadeInOutBehavior implements Behavior<Mesh> {
  44701. /**
  44702. * Time in milliseconds to delay before fading in (Default: 0)
  44703. */
  44704. delay: number;
  44705. /**
  44706. * Time in milliseconds for the mesh to fade in (Default: 300)
  44707. */
  44708. fadeInTime: number;
  44709. private _millisecondsPerFrame;
  44710. private _hovered;
  44711. private _hoverValue;
  44712. private _ownerNode;
  44713. /**
  44714. * Instatiates the FadeInOutBehavior
  44715. */
  44716. constructor();
  44717. /**
  44718. * The name of the behavior
  44719. */
  44720. get name(): string;
  44721. /**
  44722. * Initializes the behavior
  44723. */
  44724. init(): void;
  44725. /**
  44726. * Attaches the fade behavior on the passed in mesh
  44727. * @param ownerNode The mesh that will be faded in/out once attached
  44728. */
  44729. attach(ownerNode: Mesh): void;
  44730. /**
  44731. * Detaches the behavior from the mesh
  44732. */
  44733. detach(): void;
  44734. /**
  44735. * Triggers the mesh to begin fading in or out
  44736. * @param value if the object should fade in or out (true to fade in)
  44737. */
  44738. fadeIn(value: boolean): void;
  44739. private _update;
  44740. private _setAllVisibility;
  44741. }
  44742. }
  44743. declare module "babylonjs/Misc/pivotTools" {
  44744. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44745. /**
  44746. * Class containing a set of static utilities functions for managing Pivots
  44747. * @hidden
  44748. */
  44749. export class PivotTools {
  44750. private static _PivotCached;
  44751. private static _OldPivotPoint;
  44752. private static _PivotTranslation;
  44753. private static _PivotTmpVector;
  44754. /** @hidden */
  44755. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44756. /** @hidden */
  44757. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44758. }
  44759. }
  44760. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44761. import { Scene } from "babylonjs/scene";
  44762. import { Vector4 } from "babylonjs/Maths/math.vector";
  44763. import { Mesh } from "babylonjs/Meshes/mesh";
  44764. import { Nullable } from "babylonjs/types";
  44765. import { Plane } from "babylonjs/Maths/math.plane";
  44766. /**
  44767. * Class containing static functions to help procedurally build meshes
  44768. */
  44769. export class PlaneBuilder {
  44770. /**
  44771. * Creates a plane mesh
  44772. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44773. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44774. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44778. * @param name defines the name of the mesh
  44779. * @param options defines the options used to create the mesh
  44780. * @param scene defines the hosting scene
  44781. * @returns the plane mesh
  44782. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44783. */
  44784. static CreatePlane(name: string, options: {
  44785. size?: number;
  44786. width?: number;
  44787. height?: number;
  44788. sideOrientation?: number;
  44789. frontUVs?: Vector4;
  44790. backUVs?: Vector4;
  44791. updatable?: boolean;
  44792. sourcePlane?: Plane;
  44793. }, scene?: Nullable<Scene>): Mesh;
  44794. }
  44795. }
  44796. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44797. import { Behavior } from "babylonjs/Behaviors/behavior";
  44798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44799. import { Observable } from "babylonjs/Misc/observable";
  44800. import { Vector3 } from "babylonjs/Maths/math.vector";
  44801. import { Ray } from "babylonjs/Culling/ray";
  44802. import "babylonjs/Meshes/Builders/planeBuilder";
  44803. /**
  44804. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44805. */
  44806. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44807. private static _AnyMouseID;
  44808. /**
  44809. * Abstract mesh the behavior is set on
  44810. */
  44811. attachedNode: AbstractMesh;
  44812. private _dragPlane;
  44813. private _scene;
  44814. private _pointerObserver;
  44815. private _beforeRenderObserver;
  44816. private static _planeScene;
  44817. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44818. /**
  44819. * 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)
  44820. */
  44821. maxDragAngle: number;
  44822. /**
  44823. * @hidden
  44824. */
  44825. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44826. /**
  44827. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44828. */
  44829. currentDraggingPointerID: number;
  44830. /**
  44831. * The last position where the pointer hit the drag plane in world space
  44832. */
  44833. lastDragPosition: Vector3;
  44834. /**
  44835. * If the behavior is currently in a dragging state
  44836. */
  44837. dragging: boolean;
  44838. /**
  44839. * 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)
  44840. */
  44841. dragDeltaRatio: number;
  44842. /**
  44843. * If the drag plane orientation should be updated during the dragging (Default: true)
  44844. */
  44845. updateDragPlane: boolean;
  44846. private _debugMode;
  44847. private _moving;
  44848. /**
  44849. * Fires each time the attached mesh is dragged with the pointer
  44850. * * delta between last drag position and current drag position in world space
  44851. * * dragDistance along the drag axis
  44852. * * dragPlaneNormal normal of the current drag plane used during the drag
  44853. * * dragPlanePoint in world space where the drag intersects the drag plane
  44854. */
  44855. onDragObservable: Observable<{
  44856. delta: Vector3;
  44857. dragPlanePoint: Vector3;
  44858. dragPlaneNormal: Vector3;
  44859. dragDistance: number;
  44860. pointerId: number;
  44861. }>;
  44862. /**
  44863. * Fires each time a drag begins (eg. mouse down on mesh)
  44864. */
  44865. onDragStartObservable: Observable<{
  44866. dragPlanePoint: Vector3;
  44867. pointerId: number;
  44868. }>;
  44869. /**
  44870. * Fires each time a drag ends (eg. mouse release after drag)
  44871. */
  44872. onDragEndObservable: Observable<{
  44873. dragPlanePoint: Vector3;
  44874. pointerId: number;
  44875. }>;
  44876. /**
  44877. * If the attached mesh should be moved when dragged
  44878. */
  44879. moveAttached: boolean;
  44880. /**
  44881. * If the drag behavior will react to drag events (Default: true)
  44882. */
  44883. enabled: boolean;
  44884. /**
  44885. * If pointer events should start and release the drag (Default: true)
  44886. */
  44887. startAndReleaseDragOnPointerEvents: boolean;
  44888. /**
  44889. * If camera controls should be detached during the drag
  44890. */
  44891. detachCameraControls: boolean;
  44892. /**
  44893. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44894. */
  44895. useObjectOrientationForDragging: boolean;
  44896. private _options;
  44897. /**
  44898. * Gets the options used by the behavior
  44899. */
  44900. get options(): {
  44901. dragAxis?: Vector3;
  44902. dragPlaneNormal?: Vector3;
  44903. };
  44904. /**
  44905. * Sets the options used by the behavior
  44906. */
  44907. set options(options: {
  44908. dragAxis?: Vector3;
  44909. dragPlaneNormal?: Vector3;
  44910. });
  44911. /**
  44912. * Creates a pointer drag behavior that can be attached to a mesh
  44913. * @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)
  44914. */
  44915. constructor(options?: {
  44916. dragAxis?: Vector3;
  44917. dragPlaneNormal?: Vector3;
  44918. });
  44919. /**
  44920. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44921. */
  44922. validateDrag: (targetPosition: Vector3) => boolean;
  44923. /**
  44924. * The name of the behavior
  44925. */
  44926. get name(): string;
  44927. /**
  44928. * Initializes the behavior
  44929. */
  44930. init(): void;
  44931. private _tmpVector;
  44932. private _alternatePickedPoint;
  44933. private _worldDragAxis;
  44934. private _targetPosition;
  44935. private _attachedElement;
  44936. /**
  44937. * Attaches the drag behavior the passed in mesh
  44938. * @param ownerNode The mesh that will be dragged around once attached
  44939. * @param predicate Predicate to use for pick filtering
  44940. */
  44941. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44942. /**
  44943. * Force relase the drag action by code.
  44944. */
  44945. releaseDrag(): void;
  44946. private _startDragRay;
  44947. private _lastPointerRay;
  44948. /**
  44949. * Simulates the start of a pointer drag event on the behavior
  44950. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44951. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44952. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44953. */
  44954. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44955. private _startDrag;
  44956. private _dragDelta;
  44957. private _moveDrag;
  44958. private _pickWithRayOnDragPlane;
  44959. private _pointA;
  44960. private _pointC;
  44961. private _localAxis;
  44962. private _lookAt;
  44963. private _updateDragPlanePosition;
  44964. /**
  44965. * Detaches the behavior from the mesh
  44966. */
  44967. detach(): void;
  44968. }
  44969. }
  44970. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44971. import { Mesh } from "babylonjs/Meshes/mesh";
  44972. import { Behavior } from "babylonjs/Behaviors/behavior";
  44973. /**
  44974. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44975. */
  44976. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44977. private _dragBehaviorA;
  44978. private _dragBehaviorB;
  44979. private _startDistance;
  44980. private _initialScale;
  44981. private _targetScale;
  44982. private _ownerNode;
  44983. private _sceneRenderObserver;
  44984. /**
  44985. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44986. */
  44987. constructor();
  44988. /**
  44989. * The name of the behavior
  44990. */
  44991. get name(): string;
  44992. /**
  44993. * Initializes the behavior
  44994. */
  44995. init(): void;
  44996. private _getCurrentDistance;
  44997. /**
  44998. * Attaches the scale behavior the passed in mesh
  44999. * @param ownerNode The mesh that will be scaled around once attached
  45000. */
  45001. attach(ownerNode: Mesh): void;
  45002. /**
  45003. * Detaches the behavior from the mesh
  45004. */
  45005. detach(): void;
  45006. }
  45007. }
  45008. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45009. import { Behavior } from "babylonjs/Behaviors/behavior";
  45010. import { Mesh } from "babylonjs/Meshes/mesh";
  45011. import { Observable } from "babylonjs/Misc/observable";
  45012. /**
  45013. * 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
  45014. */
  45015. export class SixDofDragBehavior implements Behavior<Mesh> {
  45016. private static _virtualScene;
  45017. private _ownerNode;
  45018. private _sceneRenderObserver;
  45019. private _scene;
  45020. private _targetPosition;
  45021. private _virtualOriginMesh;
  45022. private _virtualDragMesh;
  45023. private _pointerObserver;
  45024. private _moving;
  45025. private _startingOrientation;
  45026. private _attachedElement;
  45027. /**
  45028. * 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)
  45029. */
  45030. private zDragFactor;
  45031. /**
  45032. * If the object should rotate to face the drag origin
  45033. */
  45034. rotateDraggedObject: boolean;
  45035. /**
  45036. * If the behavior is currently in a dragging state
  45037. */
  45038. dragging: boolean;
  45039. /**
  45040. * 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)
  45041. */
  45042. dragDeltaRatio: number;
  45043. /**
  45044. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45045. */
  45046. currentDraggingPointerID: number;
  45047. /**
  45048. * If camera controls should be detached during the drag
  45049. */
  45050. detachCameraControls: boolean;
  45051. /**
  45052. * Fires each time a drag starts
  45053. */
  45054. onDragStartObservable: Observable<{}>;
  45055. /**
  45056. * Fires each time a drag ends (eg. mouse release after drag)
  45057. */
  45058. onDragEndObservable: Observable<{}>;
  45059. /**
  45060. * 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
  45061. */
  45062. constructor();
  45063. /**
  45064. * The name of the behavior
  45065. */
  45066. get name(): string;
  45067. /**
  45068. * Initializes the behavior
  45069. */
  45070. init(): void;
  45071. /**
  45072. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45073. */
  45074. private get _pointerCamera();
  45075. /**
  45076. * Attaches the scale behavior the passed in mesh
  45077. * @param ownerNode The mesh that will be scaled around once attached
  45078. */
  45079. attach(ownerNode: Mesh): void;
  45080. /**
  45081. * Detaches the behavior from the mesh
  45082. */
  45083. detach(): void;
  45084. }
  45085. }
  45086. declare module "babylonjs/Behaviors/Meshes/index" {
  45087. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45088. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45089. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45090. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45091. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45092. }
  45093. declare module "babylonjs/Behaviors/index" {
  45094. export * from "babylonjs/Behaviors/behavior";
  45095. export * from "babylonjs/Behaviors/Cameras/index";
  45096. export * from "babylonjs/Behaviors/Meshes/index";
  45097. }
  45098. declare module "babylonjs/Bones/boneIKController" {
  45099. import { Bone } from "babylonjs/Bones/bone";
  45100. import { Vector3 } from "babylonjs/Maths/math.vector";
  45101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45102. import { Nullable } from "babylonjs/types";
  45103. /**
  45104. * Class used to apply inverse kinematics to bones
  45105. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45106. */
  45107. export class BoneIKController {
  45108. private static _tmpVecs;
  45109. private static _tmpQuat;
  45110. private static _tmpMats;
  45111. /**
  45112. * Gets or sets the target mesh
  45113. */
  45114. targetMesh: AbstractMesh;
  45115. /** Gets or sets the mesh used as pole */
  45116. poleTargetMesh: AbstractMesh;
  45117. /**
  45118. * Gets or sets the bone used as pole
  45119. */
  45120. poleTargetBone: Nullable<Bone>;
  45121. /**
  45122. * Gets or sets the target position
  45123. */
  45124. targetPosition: Vector3;
  45125. /**
  45126. * Gets or sets the pole target position
  45127. */
  45128. poleTargetPosition: Vector3;
  45129. /**
  45130. * Gets or sets the pole target local offset
  45131. */
  45132. poleTargetLocalOffset: Vector3;
  45133. /**
  45134. * Gets or sets the pole angle
  45135. */
  45136. poleAngle: number;
  45137. /**
  45138. * Gets or sets the mesh associated with the controller
  45139. */
  45140. mesh: AbstractMesh;
  45141. /**
  45142. * 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)
  45143. */
  45144. slerpAmount: number;
  45145. private _bone1Quat;
  45146. private _bone1Mat;
  45147. private _bone2Ang;
  45148. private _bone1;
  45149. private _bone2;
  45150. private _bone1Length;
  45151. private _bone2Length;
  45152. private _maxAngle;
  45153. private _maxReach;
  45154. private _rightHandedSystem;
  45155. private _bendAxis;
  45156. private _slerping;
  45157. private _adjustRoll;
  45158. /**
  45159. * Gets or sets maximum allowed angle
  45160. */
  45161. get maxAngle(): number;
  45162. set maxAngle(value: number);
  45163. /**
  45164. * Creates a new BoneIKController
  45165. * @param mesh defines the mesh to control
  45166. * @param bone defines the bone to control
  45167. * @param options defines options to set up the controller
  45168. */
  45169. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45170. targetMesh?: AbstractMesh;
  45171. poleTargetMesh?: AbstractMesh;
  45172. poleTargetBone?: Bone;
  45173. poleTargetLocalOffset?: Vector3;
  45174. poleAngle?: number;
  45175. bendAxis?: Vector3;
  45176. maxAngle?: number;
  45177. slerpAmount?: number;
  45178. });
  45179. private _setMaxAngle;
  45180. /**
  45181. * Force the controller to update the bones
  45182. */
  45183. update(): void;
  45184. }
  45185. }
  45186. declare module "babylonjs/Bones/boneLookController" {
  45187. import { Vector3 } from "babylonjs/Maths/math.vector";
  45188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45189. import { Bone } from "babylonjs/Bones/bone";
  45190. import { Space } from "babylonjs/Maths/math.axis";
  45191. /**
  45192. * Class used to make a bone look toward a point in space
  45193. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45194. */
  45195. export class BoneLookController {
  45196. private static _tmpVecs;
  45197. private static _tmpQuat;
  45198. private static _tmpMats;
  45199. /**
  45200. * The target Vector3 that the bone will look at
  45201. */
  45202. target: Vector3;
  45203. /**
  45204. * The mesh that the bone is attached to
  45205. */
  45206. mesh: AbstractMesh;
  45207. /**
  45208. * The bone that will be looking to the target
  45209. */
  45210. bone: Bone;
  45211. /**
  45212. * The up axis of the coordinate system that is used when the bone is rotated
  45213. */
  45214. upAxis: Vector3;
  45215. /**
  45216. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45217. */
  45218. upAxisSpace: Space;
  45219. /**
  45220. * Used to make an adjustment to the yaw of the bone
  45221. */
  45222. adjustYaw: number;
  45223. /**
  45224. * Used to make an adjustment to the pitch of the bone
  45225. */
  45226. adjustPitch: number;
  45227. /**
  45228. * Used to make an adjustment to the roll of the bone
  45229. */
  45230. adjustRoll: number;
  45231. /**
  45232. * 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)
  45233. */
  45234. slerpAmount: number;
  45235. private _minYaw;
  45236. private _maxYaw;
  45237. private _minPitch;
  45238. private _maxPitch;
  45239. private _minYawSin;
  45240. private _minYawCos;
  45241. private _maxYawSin;
  45242. private _maxYawCos;
  45243. private _midYawConstraint;
  45244. private _minPitchTan;
  45245. private _maxPitchTan;
  45246. private _boneQuat;
  45247. private _slerping;
  45248. private _transformYawPitch;
  45249. private _transformYawPitchInv;
  45250. private _firstFrameSkipped;
  45251. private _yawRange;
  45252. private _fowardAxis;
  45253. /**
  45254. * Gets or sets the minimum yaw angle that the bone can look to
  45255. */
  45256. get minYaw(): number;
  45257. set minYaw(value: number);
  45258. /**
  45259. * Gets or sets the maximum yaw angle that the bone can look to
  45260. */
  45261. get maxYaw(): number;
  45262. set maxYaw(value: number);
  45263. /**
  45264. * Gets or sets the minimum pitch angle that the bone can look to
  45265. */
  45266. get minPitch(): number;
  45267. set minPitch(value: number);
  45268. /**
  45269. * Gets or sets the maximum pitch angle that the bone can look to
  45270. */
  45271. get maxPitch(): number;
  45272. set maxPitch(value: number);
  45273. /**
  45274. * Create a BoneLookController
  45275. * @param mesh the mesh that the bone belongs to
  45276. * @param bone the bone that will be looking to the target
  45277. * @param target the target Vector3 to look at
  45278. * @param options optional settings:
  45279. * * maxYaw: the maximum angle the bone will yaw to
  45280. * * minYaw: the minimum angle the bone will yaw to
  45281. * * maxPitch: the maximum angle the bone will pitch to
  45282. * * minPitch: the minimum angle the bone will yaw to
  45283. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45284. * * upAxis: the up axis of the coordinate system
  45285. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45286. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45287. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45288. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45289. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45290. * * adjustRoll: used to make an adjustment to the roll of the bone
  45291. **/
  45292. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45293. maxYaw?: number;
  45294. minYaw?: number;
  45295. maxPitch?: number;
  45296. minPitch?: number;
  45297. slerpAmount?: number;
  45298. upAxis?: Vector3;
  45299. upAxisSpace?: Space;
  45300. yawAxis?: Vector3;
  45301. pitchAxis?: Vector3;
  45302. adjustYaw?: number;
  45303. adjustPitch?: number;
  45304. adjustRoll?: number;
  45305. });
  45306. /**
  45307. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45308. */
  45309. update(): void;
  45310. private _getAngleDiff;
  45311. private _getAngleBetween;
  45312. private _isAngleBetween;
  45313. }
  45314. }
  45315. declare module "babylonjs/Bones/index" {
  45316. export * from "babylonjs/Bones/bone";
  45317. export * from "babylonjs/Bones/boneIKController";
  45318. export * from "babylonjs/Bones/boneLookController";
  45319. export * from "babylonjs/Bones/skeleton";
  45320. }
  45321. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45322. import { Nullable } from "babylonjs/types";
  45323. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45324. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45325. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45326. /**
  45327. * Manage the gamepad inputs to control an arc rotate camera.
  45328. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45329. */
  45330. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45331. /**
  45332. * Defines the camera the input is attached to.
  45333. */
  45334. camera: ArcRotateCamera;
  45335. /**
  45336. * Defines the gamepad the input is gathering event from.
  45337. */
  45338. gamepad: Nullable<Gamepad>;
  45339. /**
  45340. * Defines the gamepad rotation sensiblity.
  45341. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45342. */
  45343. gamepadRotationSensibility: number;
  45344. /**
  45345. * Defines the gamepad move sensiblity.
  45346. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45347. */
  45348. gamepadMoveSensibility: number;
  45349. private _yAxisScale;
  45350. /**
  45351. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45352. */
  45353. get invertYAxis(): boolean;
  45354. set invertYAxis(value: boolean);
  45355. private _onGamepadConnectedObserver;
  45356. private _onGamepadDisconnectedObserver;
  45357. /**
  45358. * Attach the input controls to a specific dom element to get the input from.
  45359. * @param element Defines the element the controls should be listened from
  45360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45361. */
  45362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45363. /**
  45364. * Detach the current controls from the specified dom element.
  45365. * @param element Defines the element to stop listening the inputs from
  45366. */
  45367. detachControl(element: Nullable<HTMLElement>): void;
  45368. /**
  45369. * Update the current camera state depending on the inputs that have been used this frame.
  45370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45371. */
  45372. checkInputs(): void;
  45373. /**
  45374. * Gets the class name of the current intput.
  45375. * @returns the class name
  45376. */
  45377. getClassName(): string;
  45378. /**
  45379. * Get the friendly name associated with the input class.
  45380. * @returns the input friendly name
  45381. */
  45382. getSimpleName(): string;
  45383. }
  45384. }
  45385. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45386. import { Nullable } from "babylonjs/types";
  45387. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45388. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45389. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45390. interface ArcRotateCameraInputsManager {
  45391. /**
  45392. * Add orientation input support to the input manager.
  45393. * @returns the current input manager
  45394. */
  45395. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45396. }
  45397. }
  45398. /**
  45399. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45400. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45401. */
  45402. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45403. /**
  45404. * Defines the camera the input is attached to.
  45405. */
  45406. camera: ArcRotateCamera;
  45407. /**
  45408. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45409. */
  45410. alphaCorrection: number;
  45411. /**
  45412. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45413. */
  45414. gammaCorrection: number;
  45415. private _alpha;
  45416. private _gamma;
  45417. private _dirty;
  45418. private _deviceOrientationHandler;
  45419. /**
  45420. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45421. */
  45422. constructor();
  45423. /**
  45424. * Attach the input controls to a specific dom element to get the input from.
  45425. * @param element Defines the element the controls should be listened from
  45426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45427. */
  45428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45429. /** @hidden */
  45430. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45431. /**
  45432. * Update the current camera state depending on the inputs that have been used this frame.
  45433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45434. */
  45435. checkInputs(): void;
  45436. /**
  45437. * Detach the current controls from the specified dom element.
  45438. * @param element Defines the element to stop listening the inputs from
  45439. */
  45440. detachControl(element: Nullable<HTMLElement>): void;
  45441. /**
  45442. * Gets the class name of the current intput.
  45443. * @returns the class name
  45444. */
  45445. getClassName(): string;
  45446. /**
  45447. * Get the friendly name associated with the input class.
  45448. * @returns the input friendly name
  45449. */
  45450. getSimpleName(): string;
  45451. }
  45452. }
  45453. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45454. import { Nullable } from "babylonjs/types";
  45455. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45456. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45457. /**
  45458. * Listen to mouse events to control the camera.
  45459. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45460. */
  45461. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45462. /**
  45463. * Defines the camera the input is attached to.
  45464. */
  45465. camera: FlyCamera;
  45466. /**
  45467. * Defines if touch is enabled. (Default is true.)
  45468. */
  45469. touchEnabled: boolean;
  45470. /**
  45471. * Defines the buttons associated with the input to handle camera rotation.
  45472. */
  45473. buttons: number[];
  45474. /**
  45475. * Assign buttons for Yaw control.
  45476. */
  45477. buttonsYaw: number[];
  45478. /**
  45479. * Assign buttons for Pitch control.
  45480. */
  45481. buttonsPitch: number[];
  45482. /**
  45483. * Assign buttons for Roll control.
  45484. */
  45485. buttonsRoll: number[];
  45486. /**
  45487. * Detect if any button is being pressed while mouse is moved.
  45488. * -1 = Mouse locked.
  45489. * 0 = Left button.
  45490. * 1 = Middle Button.
  45491. * 2 = Right Button.
  45492. */
  45493. activeButton: number;
  45494. /**
  45495. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45496. * Higher values reduce its sensitivity.
  45497. */
  45498. angularSensibility: number;
  45499. private _mousemoveCallback;
  45500. private _observer;
  45501. private _rollObserver;
  45502. private previousPosition;
  45503. private noPreventDefault;
  45504. private element;
  45505. /**
  45506. * Listen to mouse events to control the camera.
  45507. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45508. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45509. */
  45510. constructor(touchEnabled?: boolean);
  45511. /**
  45512. * Attach the mouse control to the HTML DOM element.
  45513. * @param element Defines the element that listens to the input events.
  45514. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45515. */
  45516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45517. /**
  45518. * Detach the current controls from the specified dom element.
  45519. * @param element Defines the element to stop listening the inputs from
  45520. */
  45521. detachControl(element: Nullable<HTMLElement>): void;
  45522. /**
  45523. * Gets the class name of the current input.
  45524. * @returns the class name.
  45525. */
  45526. getClassName(): string;
  45527. /**
  45528. * Get the friendly name associated with the input class.
  45529. * @returns the input's friendly name.
  45530. */
  45531. getSimpleName(): string;
  45532. private _pointerInput;
  45533. private _onMouseMove;
  45534. /**
  45535. * Rotate camera by mouse offset.
  45536. */
  45537. private rotateCamera;
  45538. }
  45539. }
  45540. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45541. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45542. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45543. /**
  45544. * Default Inputs manager for the FlyCamera.
  45545. * It groups all the default supported inputs for ease of use.
  45546. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45547. */
  45548. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45549. /**
  45550. * Instantiates a new FlyCameraInputsManager.
  45551. * @param camera Defines the camera the inputs belong to.
  45552. */
  45553. constructor(camera: FlyCamera);
  45554. /**
  45555. * Add keyboard input support to the input manager.
  45556. * @returns the new FlyCameraKeyboardMoveInput().
  45557. */
  45558. addKeyboard(): FlyCameraInputsManager;
  45559. /**
  45560. * Add mouse input support to the input manager.
  45561. * @param touchEnabled Enable touch screen support.
  45562. * @returns the new FlyCameraMouseInput().
  45563. */
  45564. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45565. }
  45566. }
  45567. declare module "babylonjs/Cameras/flyCamera" {
  45568. import { Scene } from "babylonjs/scene";
  45569. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45571. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45572. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45573. /**
  45574. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45575. * such as in a 3D Space Shooter or a Flight Simulator.
  45576. */
  45577. export class FlyCamera extends TargetCamera {
  45578. /**
  45579. * Define the collision ellipsoid of the camera.
  45580. * This is helpful for simulating a camera body, like a player's body.
  45581. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45582. */
  45583. ellipsoid: Vector3;
  45584. /**
  45585. * Define an offset for the position of the ellipsoid around the camera.
  45586. * This can be helpful if the camera is attached away from the player's body center,
  45587. * such as at its head.
  45588. */
  45589. ellipsoidOffset: Vector3;
  45590. /**
  45591. * Enable or disable collisions of the camera with the rest of the scene objects.
  45592. */
  45593. checkCollisions: boolean;
  45594. /**
  45595. * Enable or disable gravity on the camera.
  45596. */
  45597. applyGravity: boolean;
  45598. /**
  45599. * Define the current direction the camera is moving to.
  45600. */
  45601. cameraDirection: Vector3;
  45602. /**
  45603. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45604. * This overrides and empties cameraRotation.
  45605. */
  45606. rotationQuaternion: Quaternion;
  45607. /**
  45608. * Track Roll to maintain the wanted Rolling when looking around.
  45609. */
  45610. _trackRoll: number;
  45611. /**
  45612. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45613. */
  45614. rollCorrect: number;
  45615. /**
  45616. * Mimic a banked turn, Rolling the camera when Yawing.
  45617. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45618. */
  45619. bankedTurn: boolean;
  45620. /**
  45621. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45622. */
  45623. bankedTurnLimit: number;
  45624. /**
  45625. * Value of 0 disables the banked Roll.
  45626. * Value of 1 is equal to the Yaw angle in radians.
  45627. */
  45628. bankedTurnMultiplier: number;
  45629. /**
  45630. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45631. */
  45632. inputs: FlyCameraInputsManager;
  45633. /**
  45634. * Gets the input sensibility for mouse input.
  45635. * Higher values reduce sensitivity.
  45636. */
  45637. get angularSensibility(): number;
  45638. /**
  45639. * Sets the input sensibility for a mouse input.
  45640. * Higher values reduce sensitivity.
  45641. */
  45642. set angularSensibility(value: number);
  45643. /**
  45644. * Get the keys for camera movement forward.
  45645. */
  45646. get keysForward(): number[];
  45647. /**
  45648. * Set the keys for camera movement forward.
  45649. */
  45650. set keysForward(value: number[]);
  45651. /**
  45652. * Get the keys for camera movement backward.
  45653. */
  45654. get keysBackward(): number[];
  45655. set keysBackward(value: number[]);
  45656. /**
  45657. * Get the keys for camera movement up.
  45658. */
  45659. get keysUp(): number[];
  45660. /**
  45661. * Set the keys for camera movement up.
  45662. */
  45663. set keysUp(value: number[]);
  45664. /**
  45665. * Get the keys for camera movement down.
  45666. */
  45667. get keysDown(): number[];
  45668. /**
  45669. * Set the keys for camera movement down.
  45670. */
  45671. set keysDown(value: number[]);
  45672. /**
  45673. * Get the keys for camera movement left.
  45674. */
  45675. get keysLeft(): number[];
  45676. /**
  45677. * Set the keys for camera movement left.
  45678. */
  45679. set keysLeft(value: number[]);
  45680. /**
  45681. * Set the keys for camera movement right.
  45682. */
  45683. get keysRight(): number[];
  45684. /**
  45685. * Set the keys for camera movement right.
  45686. */
  45687. set keysRight(value: number[]);
  45688. /**
  45689. * Event raised when the camera collides with a mesh in the scene.
  45690. */
  45691. onCollide: (collidedMesh: AbstractMesh) => void;
  45692. private _collider;
  45693. private _needMoveForGravity;
  45694. private _oldPosition;
  45695. private _diffPosition;
  45696. private _newPosition;
  45697. /** @hidden */
  45698. _localDirection: Vector3;
  45699. /** @hidden */
  45700. _transformedDirection: Vector3;
  45701. /**
  45702. * Instantiates a FlyCamera.
  45703. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45704. * such as in a 3D Space Shooter or a Flight Simulator.
  45705. * @param name Define the name of the camera in the scene.
  45706. * @param position Define the starting position of the camera in the scene.
  45707. * @param scene Define the scene the camera belongs to.
  45708. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45709. */
  45710. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45711. /**
  45712. * Attach a control to the HTML DOM element.
  45713. * @param element Defines the element that listens to the input events.
  45714. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45715. */
  45716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45717. /**
  45718. * Detach a control from the HTML DOM element.
  45719. * The camera will stop reacting to that input.
  45720. * @param element Defines the element that listens to the input events.
  45721. */
  45722. detachControl(element: HTMLElement): void;
  45723. private _collisionMask;
  45724. /**
  45725. * Get the mask that the camera ignores in collision events.
  45726. */
  45727. get collisionMask(): number;
  45728. /**
  45729. * Set the mask that the camera ignores in collision events.
  45730. */
  45731. set collisionMask(mask: number);
  45732. /** @hidden */
  45733. _collideWithWorld(displacement: Vector3): void;
  45734. /** @hidden */
  45735. private _onCollisionPositionChange;
  45736. /** @hidden */
  45737. _checkInputs(): void;
  45738. /** @hidden */
  45739. _decideIfNeedsToMove(): boolean;
  45740. /** @hidden */
  45741. _updatePosition(): void;
  45742. /**
  45743. * Restore the Roll to its target value at the rate specified.
  45744. * @param rate - Higher means slower restoring.
  45745. * @hidden
  45746. */
  45747. restoreRoll(rate: number): void;
  45748. /**
  45749. * Destroy the camera and release the current resources held by it.
  45750. */
  45751. dispose(): void;
  45752. /**
  45753. * Get the current object class name.
  45754. * @returns the class name.
  45755. */
  45756. getClassName(): string;
  45757. }
  45758. }
  45759. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45760. import { Nullable } from "babylonjs/types";
  45761. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45762. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45763. /**
  45764. * Listen to keyboard events to control the camera.
  45765. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45766. */
  45767. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45768. /**
  45769. * Defines the camera the input is attached to.
  45770. */
  45771. camera: FlyCamera;
  45772. /**
  45773. * The list of keyboard keys used to control the forward move of the camera.
  45774. */
  45775. keysForward: number[];
  45776. /**
  45777. * The list of keyboard keys used to control the backward move of the camera.
  45778. */
  45779. keysBackward: number[];
  45780. /**
  45781. * The list of keyboard keys used to control the forward move of the camera.
  45782. */
  45783. keysUp: number[];
  45784. /**
  45785. * The list of keyboard keys used to control the backward move of the camera.
  45786. */
  45787. keysDown: number[];
  45788. /**
  45789. * The list of keyboard keys used to control the right strafe move of the camera.
  45790. */
  45791. keysRight: number[];
  45792. /**
  45793. * The list of keyboard keys used to control the left strafe move of the camera.
  45794. */
  45795. keysLeft: number[];
  45796. private _keys;
  45797. private _onCanvasBlurObserver;
  45798. private _onKeyboardObserver;
  45799. private _engine;
  45800. private _scene;
  45801. /**
  45802. * Attach the input controls to a specific dom element to get the input from.
  45803. * @param element Defines the element the controls should be listened from
  45804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45805. */
  45806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45807. /**
  45808. * Detach the current controls from the specified dom element.
  45809. * @param element Defines the element to stop listening the inputs from
  45810. */
  45811. detachControl(element: Nullable<HTMLElement>): void;
  45812. /**
  45813. * Gets the class name of the current intput.
  45814. * @returns the class name
  45815. */
  45816. getClassName(): string;
  45817. /** @hidden */
  45818. _onLostFocus(e: FocusEvent): void;
  45819. /**
  45820. * Get the friendly name associated with the input class.
  45821. * @returns the input friendly name
  45822. */
  45823. getSimpleName(): string;
  45824. /**
  45825. * Update the current camera state depending on the inputs that have been used this frame.
  45826. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45827. */
  45828. checkInputs(): void;
  45829. }
  45830. }
  45831. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45832. import { Nullable } from "babylonjs/types";
  45833. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45834. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45835. /**
  45836. * Manage the mouse wheel inputs to control a follow camera.
  45837. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45838. */
  45839. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45840. /**
  45841. * Defines the camera the input is attached to.
  45842. */
  45843. camera: FollowCamera;
  45844. /**
  45845. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45846. */
  45847. axisControlRadius: boolean;
  45848. /**
  45849. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45850. */
  45851. axisControlHeight: boolean;
  45852. /**
  45853. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45854. */
  45855. axisControlRotation: boolean;
  45856. /**
  45857. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45858. * relation to mouseWheel events.
  45859. */
  45860. wheelPrecision: number;
  45861. /**
  45862. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45863. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45864. */
  45865. wheelDeltaPercentage: number;
  45866. private _wheel;
  45867. private _observer;
  45868. /**
  45869. * Attach the input controls to a specific dom element to get the input from.
  45870. * @param element Defines the element the controls should be listened from
  45871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45872. */
  45873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45874. /**
  45875. * Detach the current controls from the specified dom element.
  45876. * @param element Defines the element to stop listening the inputs from
  45877. */
  45878. detachControl(element: Nullable<HTMLElement>): void;
  45879. /**
  45880. * Gets the class name of the current intput.
  45881. * @returns the class name
  45882. */
  45883. getClassName(): string;
  45884. /**
  45885. * Get the friendly name associated with the input class.
  45886. * @returns the input friendly name
  45887. */
  45888. getSimpleName(): string;
  45889. }
  45890. }
  45891. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45892. import { Nullable } from "babylonjs/types";
  45893. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45894. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45895. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45896. /**
  45897. * Manage the pointers inputs to control an follow camera.
  45898. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45899. */
  45900. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45901. /**
  45902. * Defines the camera the input is attached to.
  45903. */
  45904. camera: FollowCamera;
  45905. /**
  45906. * Gets the class name of the current input.
  45907. * @returns the class name
  45908. */
  45909. getClassName(): string;
  45910. /**
  45911. * Defines the pointer angular sensibility along the X axis or how fast is
  45912. * the camera rotating.
  45913. * A negative number will reverse the axis direction.
  45914. */
  45915. angularSensibilityX: number;
  45916. /**
  45917. * Defines the pointer angular sensibility along the Y axis or how fast is
  45918. * the camera rotating.
  45919. * A negative number will reverse the axis direction.
  45920. */
  45921. angularSensibilityY: number;
  45922. /**
  45923. * Defines the pointer pinch precision or how fast is the camera zooming.
  45924. * A negative number will reverse the axis direction.
  45925. */
  45926. pinchPrecision: number;
  45927. /**
  45928. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45929. * from 0.
  45930. * It defines the percentage of current camera.radius to use as delta when
  45931. * pinch zoom is used.
  45932. */
  45933. pinchDeltaPercentage: number;
  45934. /**
  45935. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45936. */
  45937. axisXControlRadius: boolean;
  45938. /**
  45939. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45940. */
  45941. axisXControlHeight: boolean;
  45942. /**
  45943. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45944. */
  45945. axisXControlRotation: boolean;
  45946. /**
  45947. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45948. */
  45949. axisYControlRadius: boolean;
  45950. /**
  45951. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45952. */
  45953. axisYControlHeight: boolean;
  45954. /**
  45955. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45956. */
  45957. axisYControlRotation: boolean;
  45958. /**
  45959. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45960. */
  45961. axisPinchControlRadius: boolean;
  45962. /**
  45963. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45964. */
  45965. axisPinchControlHeight: boolean;
  45966. /**
  45967. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45968. */
  45969. axisPinchControlRotation: boolean;
  45970. /**
  45971. * Log error messages if basic misconfiguration has occurred.
  45972. */
  45973. warningEnable: boolean;
  45974. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45975. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45976. private _warningCounter;
  45977. private _warning;
  45978. }
  45979. }
  45980. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45981. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45982. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45983. /**
  45984. * Default Inputs manager for the FollowCamera.
  45985. * It groups all the default supported inputs for ease of use.
  45986. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45987. */
  45988. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45989. /**
  45990. * Instantiates a new FollowCameraInputsManager.
  45991. * @param camera Defines the camera the inputs belong to
  45992. */
  45993. constructor(camera: FollowCamera);
  45994. /**
  45995. * Add keyboard input support to the input manager.
  45996. * @returns the current input manager
  45997. */
  45998. addKeyboard(): FollowCameraInputsManager;
  45999. /**
  46000. * Add mouse wheel input support to the input manager.
  46001. * @returns the current input manager
  46002. */
  46003. addMouseWheel(): FollowCameraInputsManager;
  46004. /**
  46005. * Add pointers input support to the input manager.
  46006. * @returns the current input manager
  46007. */
  46008. addPointers(): FollowCameraInputsManager;
  46009. /**
  46010. * Add orientation input support to the input manager.
  46011. * @returns the current input manager
  46012. */
  46013. addVRDeviceOrientation(): FollowCameraInputsManager;
  46014. }
  46015. }
  46016. declare module "babylonjs/Cameras/followCamera" {
  46017. import { Nullable } from "babylonjs/types";
  46018. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46019. import { Scene } from "babylonjs/scene";
  46020. import { Vector3 } from "babylonjs/Maths/math.vector";
  46021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46022. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46023. /**
  46024. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46025. * an arc rotate version arcFollowCamera are available.
  46026. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46027. */
  46028. export class FollowCamera extends TargetCamera {
  46029. /**
  46030. * Distance the follow camera should follow an object at
  46031. */
  46032. radius: number;
  46033. /**
  46034. * Minimum allowed distance of the camera to the axis of rotation
  46035. * (The camera can not get closer).
  46036. * This can help limiting how the Camera is able to move in the scene.
  46037. */
  46038. lowerRadiusLimit: Nullable<number>;
  46039. /**
  46040. * Maximum allowed distance of the camera to the axis of rotation
  46041. * (The camera can not get further).
  46042. * This can help limiting how the Camera is able to move in the scene.
  46043. */
  46044. upperRadiusLimit: Nullable<number>;
  46045. /**
  46046. * Define a rotation offset between the camera and the object it follows
  46047. */
  46048. rotationOffset: number;
  46049. /**
  46050. * Minimum allowed angle to camera position relative to target object.
  46051. * This can help limiting how the Camera is able to move in the scene.
  46052. */
  46053. lowerRotationOffsetLimit: Nullable<number>;
  46054. /**
  46055. * Maximum allowed angle to camera position relative to target object.
  46056. * This can help limiting how the Camera is able to move in the scene.
  46057. */
  46058. upperRotationOffsetLimit: Nullable<number>;
  46059. /**
  46060. * Define a height offset between the camera and the object it follows.
  46061. * It can help following an object from the top (like a car chaing a plane)
  46062. */
  46063. heightOffset: number;
  46064. /**
  46065. * Minimum allowed height of camera position relative to target object.
  46066. * This can help limiting how the Camera is able to move in the scene.
  46067. */
  46068. lowerHeightOffsetLimit: Nullable<number>;
  46069. /**
  46070. * Maximum allowed height of camera position relative to target object.
  46071. * This can help limiting how the Camera is able to move in the scene.
  46072. */
  46073. upperHeightOffsetLimit: Nullable<number>;
  46074. /**
  46075. * Define how fast the camera can accelerate to follow it s target.
  46076. */
  46077. cameraAcceleration: number;
  46078. /**
  46079. * Define the speed limit of the camera following an object.
  46080. */
  46081. maxCameraSpeed: number;
  46082. /**
  46083. * Define the target of the camera.
  46084. */
  46085. lockedTarget: Nullable<AbstractMesh>;
  46086. /**
  46087. * Defines the input associated with the camera.
  46088. */
  46089. inputs: FollowCameraInputsManager;
  46090. /**
  46091. * Instantiates the follow camera.
  46092. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46093. * @param name Define the name of the camera in the scene
  46094. * @param position Define the position of the camera
  46095. * @param scene Define the scene the camera belong to
  46096. * @param lockedTarget Define the target of the camera
  46097. */
  46098. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46099. private _follow;
  46100. /**
  46101. * Attached controls to the current camera.
  46102. * @param element Defines the element the controls should be listened from
  46103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46104. */
  46105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46106. /**
  46107. * Detach the current controls from the camera.
  46108. * The camera will stop reacting to inputs.
  46109. * @param element Defines the element to stop listening the inputs from
  46110. */
  46111. detachControl(element: HTMLElement): void;
  46112. /** @hidden */
  46113. _checkInputs(): void;
  46114. private _checkLimits;
  46115. /**
  46116. * Gets the camera class name.
  46117. * @returns the class name
  46118. */
  46119. getClassName(): string;
  46120. }
  46121. /**
  46122. * Arc Rotate version of the follow camera.
  46123. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46124. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46125. */
  46126. export class ArcFollowCamera extends TargetCamera {
  46127. /** The longitudinal angle of the camera */
  46128. alpha: number;
  46129. /** The latitudinal angle of the camera */
  46130. beta: number;
  46131. /** The radius of the camera from its target */
  46132. radius: number;
  46133. private _cartesianCoordinates;
  46134. /** Define the camera target (the mesh it should follow) */
  46135. private _meshTarget;
  46136. /**
  46137. * Instantiates a new ArcFollowCamera
  46138. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46139. * @param name Define the name of the camera
  46140. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46141. * @param beta Define the rotation angle of the camera around the elevation axis
  46142. * @param radius Define the radius of the camera from its target point
  46143. * @param target Define the target of the camera
  46144. * @param scene Define the scene the camera belongs to
  46145. */
  46146. constructor(name: string,
  46147. /** The longitudinal angle of the camera */
  46148. alpha: number,
  46149. /** The latitudinal angle of the camera */
  46150. beta: number,
  46151. /** The radius of the camera from its target */
  46152. radius: number,
  46153. /** Define the camera target (the mesh it should follow) */
  46154. target: Nullable<AbstractMesh>, scene: Scene);
  46155. private _follow;
  46156. /** @hidden */
  46157. _checkInputs(): void;
  46158. /**
  46159. * Returns the class name of the object.
  46160. * It is mostly used internally for serialization purposes.
  46161. */
  46162. getClassName(): string;
  46163. }
  46164. }
  46165. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46166. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46167. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46168. import { Nullable } from "babylonjs/types";
  46169. /**
  46170. * Manage the keyboard inputs to control the movement of a follow camera.
  46171. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46172. */
  46173. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46174. /**
  46175. * Defines the camera the input is attached to.
  46176. */
  46177. camera: FollowCamera;
  46178. /**
  46179. * Defines the list of key codes associated with the up action (increase heightOffset)
  46180. */
  46181. keysHeightOffsetIncr: number[];
  46182. /**
  46183. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46184. */
  46185. keysHeightOffsetDecr: number[];
  46186. /**
  46187. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46188. */
  46189. keysHeightOffsetModifierAlt: boolean;
  46190. /**
  46191. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46192. */
  46193. keysHeightOffsetModifierCtrl: boolean;
  46194. /**
  46195. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46196. */
  46197. keysHeightOffsetModifierShift: boolean;
  46198. /**
  46199. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46200. */
  46201. keysRotationOffsetIncr: number[];
  46202. /**
  46203. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46204. */
  46205. keysRotationOffsetDecr: number[];
  46206. /**
  46207. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46208. */
  46209. keysRotationOffsetModifierAlt: boolean;
  46210. /**
  46211. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46212. */
  46213. keysRotationOffsetModifierCtrl: boolean;
  46214. /**
  46215. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46216. */
  46217. keysRotationOffsetModifierShift: boolean;
  46218. /**
  46219. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46220. */
  46221. keysRadiusIncr: number[];
  46222. /**
  46223. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46224. */
  46225. keysRadiusDecr: number[];
  46226. /**
  46227. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46228. */
  46229. keysRadiusModifierAlt: boolean;
  46230. /**
  46231. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46232. */
  46233. keysRadiusModifierCtrl: boolean;
  46234. /**
  46235. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46236. */
  46237. keysRadiusModifierShift: boolean;
  46238. /**
  46239. * Defines the rate of change of heightOffset.
  46240. */
  46241. heightSensibility: number;
  46242. /**
  46243. * Defines the rate of change of rotationOffset.
  46244. */
  46245. rotationSensibility: number;
  46246. /**
  46247. * Defines the rate of change of radius.
  46248. */
  46249. radiusSensibility: number;
  46250. private _keys;
  46251. private _ctrlPressed;
  46252. private _altPressed;
  46253. private _shiftPressed;
  46254. private _onCanvasBlurObserver;
  46255. private _onKeyboardObserver;
  46256. private _engine;
  46257. private _scene;
  46258. /**
  46259. * Attach the input controls to a specific dom element to get the input from.
  46260. * @param element Defines the element the controls should be listened from
  46261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46262. */
  46263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46264. /**
  46265. * Detach the current controls from the specified dom element.
  46266. * @param element Defines the element to stop listening the inputs from
  46267. */
  46268. detachControl(element: Nullable<HTMLElement>): void;
  46269. /**
  46270. * Update the current camera state depending on the inputs that have been used this frame.
  46271. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46272. */
  46273. checkInputs(): void;
  46274. /**
  46275. * Gets the class name of the current input.
  46276. * @returns the class name
  46277. */
  46278. getClassName(): string;
  46279. /**
  46280. * Get the friendly name associated with the input class.
  46281. * @returns the input friendly name
  46282. */
  46283. getSimpleName(): string;
  46284. /**
  46285. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46286. * allow modification of the heightOffset value.
  46287. */
  46288. private _modifierHeightOffset;
  46289. /**
  46290. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46291. * allow modification of the rotationOffset value.
  46292. */
  46293. private _modifierRotationOffset;
  46294. /**
  46295. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46296. * allow modification of the radius value.
  46297. */
  46298. private _modifierRadius;
  46299. }
  46300. }
  46301. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46302. import { Nullable } from "babylonjs/types";
  46303. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46304. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46305. import { Observable } from "babylonjs/Misc/observable";
  46306. module "babylonjs/Cameras/freeCameraInputsManager" {
  46307. interface FreeCameraInputsManager {
  46308. /**
  46309. * @hidden
  46310. */
  46311. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46312. /**
  46313. * Add orientation input support to the input manager.
  46314. * @returns the current input manager
  46315. */
  46316. addDeviceOrientation(): FreeCameraInputsManager;
  46317. }
  46318. }
  46319. /**
  46320. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46321. * Screen rotation is taken into account.
  46322. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46323. */
  46324. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46325. private _camera;
  46326. private _screenOrientationAngle;
  46327. private _constantTranform;
  46328. private _screenQuaternion;
  46329. private _alpha;
  46330. private _beta;
  46331. private _gamma;
  46332. /**
  46333. * Can be used to detect if a device orientation sensor is available on a device
  46334. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46335. * @returns a promise that will resolve on orientation change
  46336. */
  46337. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46338. /**
  46339. * @hidden
  46340. */
  46341. _onDeviceOrientationChangedObservable: Observable<void>;
  46342. /**
  46343. * Instantiates a new input
  46344. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46345. */
  46346. constructor();
  46347. /**
  46348. * Define the camera controlled by the input.
  46349. */
  46350. get camera(): FreeCamera;
  46351. set camera(camera: FreeCamera);
  46352. /**
  46353. * Attach the input controls to a specific dom element to get the input from.
  46354. * @param element Defines the element the controls should be listened from
  46355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46356. */
  46357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46358. private _orientationChanged;
  46359. private _deviceOrientation;
  46360. /**
  46361. * Detach the current controls from the specified dom element.
  46362. * @param element Defines the element to stop listening the inputs from
  46363. */
  46364. detachControl(element: Nullable<HTMLElement>): void;
  46365. /**
  46366. * Update the current camera state depending on the inputs that have been used this frame.
  46367. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46368. */
  46369. checkInputs(): void;
  46370. /**
  46371. * Gets the class name of the current intput.
  46372. * @returns the class name
  46373. */
  46374. getClassName(): string;
  46375. /**
  46376. * Get the friendly name associated with the input class.
  46377. * @returns the input friendly name
  46378. */
  46379. getSimpleName(): string;
  46380. }
  46381. }
  46382. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46383. import { Nullable } from "babylonjs/types";
  46384. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46385. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46386. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46387. /**
  46388. * Manage the gamepad inputs to control a free camera.
  46389. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46390. */
  46391. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46392. /**
  46393. * Define the camera the input is attached to.
  46394. */
  46395. camera: FreeCamera;
  46396. /**
  46397. * Define the Gamepad controlling the input
  46398. */
  46399. gamepad: Nullable<Gamepad>;
  46400. /**
  46401. * Defines the gamepad rotation sensiblity.
  46402. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46403. */
  46404. gamepadAngularSensibility: number;
  46405. /**
  46406. * Defines the gamepad move sensiblity.
  46407. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46408. */
  46409. gamepadMoveSensibility: number;
  46410. private _yAxisScale;
  46411. /**
  46412. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46413. */
  46414. get invertYAxis(): boolean;
  46415. set invertYAxis(value: boolean);
  46416. private _onGamepadConnectedObserver;
  46417. private _onGamepadDisconnectedObserver;
  46418. private _cameraTransform;
  46419. private _deltaTransform;
  46420. private _vector3;
  46421. private _vector2;
  46422. /**
  46423. * Attach the input controls to a specific dom element to get the input from.
  46424. * @param element Defines the element the controls should be listened from
  46425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46426. */
  46427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46428. /**
  46429. * Detach the current controls from the specified dom element.
  46430. * @param element Defines the element to stop listening the inputs from
  46431. */
  46432. detachControl(element: Nullable<HTMLElement>): void;
  46433. /**
  46434. * Update the current camera state depending on the inputs that have been used this frame.
  46435. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46436. */
  46437. checkInputs(): void;
  46438. /**
  46439. * Gets the class name of the current intput.
  46440. * @returns the class name
  46441. */
  46442. getClassName(): string;
  46443. /**
  46444. * Get the friendly name associated with the input class.
  46445. * @returns the input friendly name
  46446. */
  46447. getSimpleName(): string;
  46448. }
  46449. }
  46450. declare module "babylonjs/Misc/virtualJoystick" {
  46451. import { Nullable } from "babylonjs/types";
  46452. import { Vector3 } from "babylonjs/Maths/math.vector";
  46453. /**
  46454. * Defines the potential axis of a Joystick
  46455. */
  46456. export enum JoystickAxis {
  46457. /** X axis */
  46458. X = 0,
  46459. /** Y axis */
  46460. Y = 1,
  46461. /** Z axis */
  46462. Z = 2
  46463. }
  46464. /**
  46465. * Represents the different customization options available
  46466. * for VirtualJoystick
  46467. */
  46468. interface VirtualJoystickCustomizations {
  46469. /**
  46470. * Size of the joystick's puck
  46471. */
  46472. puckSize: number;
  46473. /**
  46474. * Size of the joystick's container
  46475. */
  46476. containerSize: number;
  46477. /**
  46478. * Color of the joystick && puck
  46479. */
  46480. color: string;
  46481. /**
  46482. * Image URL for the joystick's puck
  46483. */
  46484. puckImage?: string;
  46485. /**
  46486. * Image URL for the joystick's container
  46487. */
  46488. containerImage?: string;
  46489. /**
  46490. * Defines the unmoving position of the joystick container
  46491. */
  46492. position?: {
  46493. x: number;
  46494. y: number;
  46495. };
  46496. /**
  46497. * Defines whether or not the joystick container is always visible
  46498. */
  46499. alwaysVisible: boolean;
  46500. /**
  46501. * Defines whether or not to limit the movement of the puck to the joystick's container
  46502. */
  46503. limitToContainer: boolean;
  46504. }
  46505. /**
  46506. * Class used to define virtual joystick (used in touch mode)
  46507. */
  46508. export class VirtualJoystick {
  46509. /**
  46510. * Gets or sets a boolean indicating that left and right values must be inverted
  46511. */
  46512. reverseLeftRight: boolean;
  46513. /**
  46514. * Gets or sets a boolean indicating that up and down values must be inverted
  46515. */
  46516. reverseUpDown: boolean;
  46517. /**
  46518. * Gets the offset value for the position (ie. the change of the position value)
  46519. */
  46520. deltaPosition: Vector3;
  46521. /**
  46522. * Gets a boolean indicating if the virtual joystick was pressed
  46523. */
  46524. pressed: boolean;
  46525. /**
  46526. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46527. */
  46528. static Canvas: Nullable<HTMLCanvasElement>;
  46529. /**
  46530. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46531. */
  46532. limitToContainer: boolean;
  46533. private static _globalJoystickIndex;
  46534. private static _alwaysVisibleSticks;
  46535. private static vjCanvasContext;
  46536. private static vjCanvasWidth;
  46537. private static vjCanvasHeight;
  46538. private static halfWidth;
  46539. private static _GetDefaultOptions;
  46540. private _action;
  46541. private _axisTargetedByLeftAndRight;
  46542. private _axisTargetedByUpAndDown;
  46543. private _joystickSensibility;
  46544. private _inversedSensibility;
  46545. private _joystickPointerID;
  46546. private _joystickColor;
  46547. private _joystickPointerPos;
  46548. private _joystickPreviousPointerPos;
  46549. private _joystickPointerStartPos;
  46550. private _deltaJoystickVector;
  46551. private _leftJoystick;
  46552. private _touches;
  46553. private _joystickPosition;
  46554. private _alwaysVisible;
  46555. private _puckImage;
  46556. private _containerImage;
  46557. private _joystickPuckSize;
  46558. private _joystickContainerSize;
  46559. private _clearPuckSize;
  46560. private _clearContainerSize;
  46561. private _clearPuckSizeOffset;
  46562. private _clearContainerSizeOffset;
  46563. private _onPointerDownHandlerRef;
  46564. private _onPointerMoveHandlerRef;
  46565. private _onPointerUpHandlerRef;
  46566. private _onResize;
  46567. /**
  46568. * Creates a new virtual joystick
  46569. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46570. * @param customizations Defines the options we want to customize the VirtualJoystick
  46571. */
  46572. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46573. /**
  46574. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46575. * @param newJoystickSensibility defines the new sensibility
  46576. */
  46577. setJoystickSensibility(newJoystickSensibility: number): void;
  46578. private _onPointerDown;
  46579. private _onPointerMove;
  46580. private _onPointerUp;
  46581. /**
  46582. * Change the color of the virtual joystick
  46583. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46584. */
  46585. setJoystickColor(newColor: string): void;
  46586. /**
  46587. * Size of the joystick's container
  46588. */
  46589. set containerSize(newSize: number);
  46590. get containerSize(): number;
  46591. /**
  46592. * Size of the joystick's puck
  46593. */
  46594. set puckSize(newSize: number);
  46595. get puckSize(): number;
  46596. /**
  46597. * Clears the set position of the joystick
  46598. */
  46599. clearPosition(): void;
  46600. /**
  46601. * Defines whether or not the joystick container is always visible
  46602. */
  46603. set alwaysVisible(value: boolean);
  46604. get alwaysVisible(): boolean;
  46605. /**
  46606. * Sets the constant position of the Joystick container
  46607. * @param x X axis coordinate
  46608. * @param y Y axis coordinate
  46609. */
  46610. setPosition(x: number, y: number): void;
  46611. /**
  46612. * Defines a callback to call when the joystick is touched
  46613. * @param action defines the callback
  46614. */
  46615. setActionOnTouch(action: () => any): void;
  46616. /**
  46617. * Defines which axis you'd like to control for left & right
  46618. * @param axis defines the axis to use
  46619. */
  46620. setAxisForLeftRight(axis: JoystickAxis): void;
  46621. /**
  46622. * Defines which axis you'd like to control for up & down
  46623. * @param axis defines the axis to use
  46624. */
  46625. setAxisForUpDown(axis: JoystickAxis): void;
  46626. /**
  46627. * Clears the canvas from the previous puck / container draw
  46628. */
  46629. private _clearPreviousDraw;
  46630. /**
  46631. * Loads `urlPath` to be used for the container's image
  46632. * @param urlPath defines the urlPath of an image to use
  46633. */
  46634. setContainerImage(urlPath: string): void;
  46635. /**
  46636. * Loads `urlPath` to be used for the puck's image
  46637. * @param urlPath defines the urlPath of an image to use
  46638. */
  46639. setPuckImage(urlPath: string): void;
  46640. /**
  46641. * Draws the Virtual Joystick's container
  46642. */
  46643. private _drawContainer;
  46644. /**
  46645. * Draws the Virtual Joystick's puck
  46646. */
  46647. private _drawPuck;
  46648. private _drawVirtualJoystick;
  46649. /**
  46650. * Release internal HTML canvas
  46651. */
  46652. releaseCanvas(): void;
  46653. }
  46654. }
  46655. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46656. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46657. import { Nullable } from "babylonjs/types";
  46658. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46659. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46660. module "babylonjs/Cameras/freeCameraInputsManager" {
  46661. interface FreeCameraInputsManager {
  46662. /**
  46663. * Add virtual joystick input support to the input manager.
  46664. * @returns the current input manager
  46665. */
  46666. addVirtualJoystick(): FreeCameraInputsManager;
  46667. }
  46668. }
  46669. /**
  46670. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46671. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46672. */
  46673. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46674. /**
  46675. * Defines the camera the input is attached to.
  46676. */
  46677. camera: FreeCamera;
  46678. private _leftjoystick;
  46679. private _rightjoystick;
  46680. /**
  46681. * Gets the left stick of the virtual joystick.
  46682. * @returns The virtual Joystick
  46683. */
  46684. getLeftJoystick(): VirtualJoystick;
  46685. /**
  46686. * Gets the right stick of the virtual joystick.
  46687. * @returns The virtual Joystick
  46688. */
  46689. getRightJoystick(): VirtualJoystick;
  46690. /**
  46691. * Update the current camera state depending on the inputs that have been used this frame.
  46692. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46693. */
  46694. checkInputs(): void;
  46695. /**
  46696. * Attach the input controls to a specific dom element to get the input from.
  46697. * @param element Defines the element the controls should be listened from
  46698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46699. */
  46700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46701. /**
  46702. * Detach the current controls from the specified dom element.
  46703. * @param element Defines the element to stop listening the inputs from
  46704. */
  46705. detachControl(element: Nullable<HTMLElement>): void;
  46706. /**
  46707. * Gets the class name of the current intput.
  46708. * @returns the class name
  46709. */
  46710. getClassName(): string;
  46711. /**
  46712. * Get the friendly name associated with the input class.
  46713. * @returns the input friendly name
  46714. */
  46715. getSimpleName(): string;
  46716. }
  46717. }
  46718. declare module "babylonjs/Cameras/Inputs/index" {
  46719. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46720. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46721. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46722. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46723. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46724. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46725. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46726. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46727. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46728. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46729. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46730. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46731. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46732. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46733. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46734. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46735. }
  46736. declare module "babylonjs/Cameras/touchCamera" {
  46737. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46738. import { Scene } from "babylonjs/scene";
  46739. import { Vector3 } from "babylonjs/Maths/math.vector";
  46740. /**
  46741. * This represents a FPS type of camera controlled by touch.
  46742. * This is like a universal camera minus the Gamepad controls.
  46743. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46744. */
  46745. export class TouchCamera extends FreeCamera {
  46746. /**
  46747. * Defines the touch sensibility for rotation.
  46748. * The higher the faster.
  46749. */
  46750. get touchAngularSensibility(): number;
  46751. set touchAngularSensibility(value: number);
  46752. /**
  46753. * Defines the touch sensibility for move.
  46754. * The higher the faster.
  46755. */
  46756. get touchMoveSensibility(): number;
  46757. set touchMoveSensibility(value: number);
  46758. /**
  46759. * Instantiates a new touch camera.
  46760. * This represents a FPS type of camera controlled by touch.
  46761. * This is like a universal camera minus the Gamepad controls.
  46762. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46763. * @param name Define the name of the camera in the scene
  46764. * @param position Define the start position of the camera in the scene
  46765. * @param scene Define the scene the camera belongs to
  46766. */
  46767. constructor(name: string, position: Vector3, scene: Scene);
  46768. /**
  46769. * Gets the current object class name.
  46770. * @return the class name
  46771. */
  46772. getClassName(): string;
  46773. /** @hidden */
  46774. _setupInputs(): void;
  46775. }
  46776. }
  46777. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46778. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46779. import { Scene } from "babylonjs/scene";
  46780. import { Vector3 } from "babylonjs/Maths/math.vector";
  46781. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46782. import { Axis } from "babylonjs/Maths/math.axis";
  46783. /**
  46784. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46785. * being tilted forward or back and left or right.
  46786. */
  46787. export class DeviceOrientationCamera extends FreeCamera {
  46788. private _initialQuaternion;
  46789. private _quaternionCache;
  46790. private _tmpDragQuaternion;
  46791. private _disablePointerInputWhenUsingDeviceOrientation;
  46792. /**
  46793. * Creates a new device orientation camera
  46794. * @param name The name of the camera
  46795. * @param position The start position camera
  46796. * @param scene The scene the camera belongs to
  46797. */
  46798. constructor(name: string, position: Vector3, scene: Scene);
  46799. /**
  46800. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46801. */
  46802. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46803. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46804. private _dragFactor;
  46805. /**
  46806. * Enabled turning on the y axis when the orientation sensor is active
  46807. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46808. */
  46809. enableHorizontalDragging(dragFactor?: number): void;
  46810. /**
  46811. * Gets the current instance class name ("DeviceOrientationCamera").
  46812. * This helps avoiding instanceof at run time.
  46813. * @returns the class name
  46814. */
  46815. getClassName(): string;
  46816. /**
  46817. * @hidden
  46818. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46819. */
  46820. _checkInputs(): void;
  46821. /**
  46822. * Reset the camera to its default orientation on the specified axis only.
  46823. * @param axis The axis to reset
  46824. */
  46825. resetToCurrentRotation(axis?: Axis): void;
  46826. }
  46827. }
  46828. declare module "babylonjs/Gamepads/xboxGamepad" {
  46829. import { Observable } from "babylonjs/Misc/observable";
  46830. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46831. /**
  46832. * Defines supported buttons for XBox360 compatible gamepads
  46833. */
  46834. export enum Xbox360Button {
  46835. /** A */
  46836. A = 0,
  46837. /** B */
  46838. B = 1,
  46839. /** X */
  46840. X = 2,
  46841. /** Y */
  46842. Y = 3,
  46843. /** Left button */
  46844. LB = 4,
  46845. /** Right button */
  46846. RB = 5,
  46847. /** Back */
  46848. Back = 8,
  46849. /** Start */
  46850. Start = 9,
  46851. /** Left stick */
  46852. LeftStick = 10,
  46853. /** Right stick */
  46854. RightStick = 11
  46855. }
  46856. /** Defines values for XBox360 DPad */
  46857. export enum Xbox360Dpad {
  46858. /** Up */
  46859. Up = 12,
  46860. /** Down */
  46861. Down = 13,
  46862. /** Left */
  46863. Left = 14,
  46864. /** Right */
  46865. Right = 15
  46866. }
  46867. /**
  46868. * Defines a XBox360 gamepad
  46869. */
  46870. export class Xbox360Pad extends Gamepad {
  46871. private _leftTrigger;
  46872. private _rightTrigger;
  46873. private _onlefttriggerchanged;
  46874. private _onrighttriggerchanged;
  46875. private _onbuttondown;
  46876. private _onbuttonup;
  46877. private _ondpaddown;
  46878. private _ondpadup;
  46879. /** Observable raised when a button is pressed */
  46880. onButtonDownObservable: Observable<Xbox360Button>;
  46881. /** Observable raised when a button is released */
  46882. onButtonUpObservable: Observable<Xbox360Button>;
  46883. /** Observable raised when a pad is pressed */
  46884. onPadDownObservable: Observable<Xbox360Dpad>;
  46885. /** Observable raised when a pad is released */
  46886. onPadUpObservable: Observable<Xbox360Dpad>;
  46887. private _buttonA;
  46888. private _buttonB;
  46889. private _buttonX;
  46890. private _buttonY;
  46891. private _buttonBack;
  46892. private _buttonStart;
  46893. private _buttonLB;
  46894. private _buttonRB;
  46895. private _buttonLeftStick;
  46896. private _buttonRightStick;
  46897. private _dPadUp;
  46898. private _dPadDown;
  46899. private _dPadLeft;
  46900. private _dPadRight;
  46901. private _isXboxOnePad;
  46902. /**
  46903. * Creates a new XBox360 gamepad object
  46904. * @param id defines the id of this gamepad
  46905. * @param index defines its index
  46906. * @param gamepad defines the internal HTML gamepad object
  46907. * @param xboxOne defines if it is a XBox One gamepad
  46908. */
  46909. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46910. /**
  46911. * Defines the callback to call when left trigger is pressed
  46912. * @param callback defines the callback to use
  46913. */
  46914. onlefttriggerchanged(callback: (value: number) => void): void;
  46915. /**
  46916. * Defines the callback to call when right trigger is pressed
  46917. * @param callback defines the callback to use
  46918. */
  46919. onrighttriggerchanged(callback: (value: number) => void): void;
  46920. /**
  46921. * Gets the left trigger value
  46922. */
  46923. get leftTrigger(): number;
  46924. /**
  46925. * Sets the left trigger value
  46926. */
  46927. set leftTrigger(newValue: number);
  46928. /**
  46929. * Gets the right trigger value
  46930. */
  46931. get rightTrigger(): number;
  46932. /**
  46933. * Sets the right trigger value
  46934. */
  46935. set rightTrigger(newValue: number);
  46936. /**
  46937. * Defines the callback to call when a button is pressed
  46938. * @param callback defines the callback to use
  46939. */
  46940. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46941. /**
  46942. * Defines the callback to call when a button is released
  46943. * @param callback defines the callback to use
  46944. */
  46945. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46946. /**
  46947. * Defines the callback to call when a pad is pressed
  46948. * @param callback defines the callback to use
  46949. */
  46950. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46951. /**
  46952. * Defines the callback to call when a pad is released
  46953. * @param callback defines the callback to use
  46954. */
  46955. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46956. private _setButtonValue;
  46957. private _setDPadValue;
  46958. /**
  46959. * Gets the value of the `A` button
  46960. */
  46961. get buttonA(): number;
  46962. /**
  46963. * Sets the value of the `A` button
  46964. */
  46965. set buttonA(value: number);
  46966. /**
  46967. * Gets the value of the `B` button
  46968. */
  46969. get buttonB(): number;
  46970. /**
  46971. * Sets the value of the `B` button
  46972. */
  46973. set buttonB(value: number);
  46974. /**
  46975. * Gets the value of the `X` button
  46976. */
  46977. get buttonX(): number;
  46978. /**
  46979. * Sets the value of the `X` button
  46980. */
  46981. set buttonX(value: number);
  46982. /**
  46983. * Gets the value of the `Y` button
  46984. */
  46985. get buttonY(): number;
  46986. /**
  46987. * Sets the value of the `Y` button
  46988. */
  46989. set buttonY(value: number);
  46990. /**
  46991. * Gets the value of the `Start` button
  46992. */
  46993. get buttonStart(): number;
  46994. /**
  46995. * Sets the value of the `Start` button
  46996. */
  46997. set buttonStart(value: number);
  46998. /**
  46999. * Gets the value of the `Back` button
  47000. */
  47001. get buttonBack(): number;
  47002. /**
  47003. * Sets the value of the `Back` button
  47004. */
  47005. set buttonBack(value: number);
  47006. /**
  47007. * Gets the value of the `Left` button
  47008. */
  47009. get buttonLB(): number;
  47010. /**
  47011. * Sets the value of the `Left` button
  47012. */
  47013. set buttonLB(value: number);
  47014. /**
  47015. * Gets the value of the `Right` button
  47016. */
  47017. get buttonRB(): number;
  47018. /**
  47019. * Sets the value of the `Right` button
  47020. */
  47021. set buttonRB(value: number);
  47022. /**
  47023. * Gets the value of the Left joystick
  47024. */
  47025. get buttonLeftStick(): number;
  47026. /**
  47027. * Sets the value of the Left joystick
  47028. */
  47029. set buttonLeftStick(value: number);
  47030. /**
  47031. * Gets the value of the Right joystick
  47032. */
  47033. get buttonRightStick(): number;
  47034. /**
  47035. * Sets the value of the Right joystick
  47036. */
  47037. set buttonRightStick(value: number);
  47038. /**
  47039. * Gets the value of D-pad up
  47040. */
  47041. get dPadUp(): number;
  47042. /**
  47043. * Sets the value of D-pad up
  47044. */
  47045. set dPadUp(value: number);
  47046. /**
  47047. * Gets the value of D-pad down
  47048. */
  47049. get dPadDown(): number;
  47050. /**
  47051. * Sets the value of D-pad down
  47052. */
  47053. set dPadDown(value: number);
  47054. /**
  47055. * Gets the value of D-pad left
  47056. */
  47057. get dPadLeft(): number;
  47058. /**
  47059. * Sets the value of D-pad left
  47060. */
  47061. set dPadLeft(value: number);
  47062. /**
  47063. * Gets the value of D-pad right
  47064. */
  47065. get dPadRight(): number;
  47066. /**
  47067. * Sets the value of D-pad right
  47068. */
  47069. set dPadRight(value: number);
  47070. /**
  47071. * Force the gamepad to synchronize with device values
  47072. */
  47073. update(): void;
  47074. /**
  47075. * Disposes the gamepad
  47076. */
  47077. dispose(): void;
  47078. }
  47079. }
  47080. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47081. import { Observable } from "babylonjs/Misc/observable";
  47082. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47083. /**
  47084. * Defines supported buttons for DualShock compatible gamepads
  47085. */
  47086. export enum DualShockButton {
  47087. /** Cross */
  47088. Cross = 0,
  47089. /** Circle */
  47090. Circle = 1,
  47091. /** Square */
  47092. Square = 2,
  47093. /** Triangle */
  47094. Triangle = 3,
  47095. /** L1 */
  47096. L1 = 4,
  47097. /** R1 */
  47098. R1 = 5,
  47099. /** Share */
  47100. Share = 8,
  47101. /** Options */
  47102. Options = 9,
  47103. /** Left stick */
  47104. LeftStick = 10,
  47105. /** Right stick */
  47106. RightStick = 11
  47107. }
  47108. /** Defines values for DualShock DPad */
  47109. export enum DualShockDpad {
  47110. /** Up */
  47111. Up = 12,
  47112. /** Down */
  47113. Down = 13,
  47114. /** Left */
  47115. Left = 14,
  47116. /** Right */
  47117. Right = 15
  47118. }
  47119. /**
  47120. * Defines a DualShock gamepad
  47121. */
  47122. export class DualShockPad extends Gamepad {
  47123. private _leftTrigger;
  47124. private _rightTrigger;
  47125. private _onlefttriggerchanged;
  47126. private _onrighttriggerchanged;
  47127. private _onbuttondown;
  47128. private _onbuttonup;
  47129. private _ondpaddown;
  47130. private _ondpadup;
  47131. /** Observable raised when a button is pressed */
  47132. onButtonDownObservable: Observable<DualShockButton>;
  47133. /** Observable raised when a button is released */
  47134. onButtonUpObservable: Observable<DualShockButton>;
  47135. /** Observable raised when a pad is pressed */
  47136. onPadDownObservable: Observable<DualShockDpad>;
  47137. /** Observable raised when a pad is released */
  47138. onPadUpObservable: Observable<DualShockDpad>;
  47139. private _buttonCross;
  47140. private _buttonCircle;
  47141. private _buttonSquare;
  47142. private _buttonTriangle;
  47143. private _buttonShare;
  47144. private _buttonOptions;
  47145. private _buttonL1;
  47146. private _buttonR1;
  47147. private _buttonLeftStick;
  47148. private _buttonRightStick;
  47149. private _dPadUp;
  47150. private _dPadDown;
  47151. private _dPadLeft;
  47152. private _dPadRight;
  47153. /**
  47154. * Creates a new DualShock gamepad object
  47155. * @param id defines the id of this gamepad
  47156. * @param index defines its index
  47157. * @param gamepad defines the internal HTML gamepad object
  47158. */
  47159. constructor(id: string, index: number, gamepad: any);
  47160. /**
  47161. * Defines the callback to call when left trigger is pressed
  47162. * @param callback defines the callback to use
  47163. */
  47164. onlefttriggerchanged(callback: (value: number) => void): void;
  47165. /**
  47166. * Defines the callback to call when right trigger is pressed
  47167. * @param callback defines the callback to use
  47168. */
  47169. onrighttriggerchanged(callback: (value: number) => void): void;
  47170. /**
  47171. * Gets the left trigger value
  47172. */
  47173. get leftTrigger(): number;
  47174. /**
  47175. * Sets the left trigger value
  47176. */
  47177. set leftTrigger(newValue: number);
  47178. /**
  47179. * Gets the right trigger value
  47180. */
  47181. get rightTrigger(): number;
  47182. /**
  47183. * Sets the right trigger value
  47184. */
  47185. set rightTrigger(newValue: number);
  47186. /**
  47187. * Defines the callback to call when a button is pressed
  47188. * @param callback defines the callback to use
  47189. */
  47190. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47191. /**
  47192. * Defines the callback to call when a button is released
  47193. * @param callback defines the callback to use
  47194. */
  47195. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47196. /**
  47197. * Defines the callback to call when a pad is pressed
  47198. * @param callback defines the callback to use
  47199. */
  47200. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47201. /**
  47202. * Defines the callback to call when a pad is released
  47203. * @param callback defines the callback to use
  47204. */
  47205. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47206. private _setButtonValue;
  47207. private _setDPadValue;
  47208. /**
  47209. * Gets the value of the `Cross` button
  47210. */
  47211. get buttonCross(): number;
  47212. /**
  47213. * Sets the value of the `Cross` button
  47214. */
  47215. set buttonCross(value: number);
  47216. /**
  47217. * Gets the value of the `Circle` button
  47218. */
  47219. get buttonCircle(): number;
  47220. /**
  47221. * Sets the value of the `Circle` button
  47222. */
  47223. set buttonCircle(value: number);
  47224. /**
  47225. * Gets the value of the `Square` button
  47226. */
  47227. get buttonSquare(): number;
  47228. /**
  47229. * Sets the value of the `Square` button
  47230. */
  47231. set buttonSquare(value: number);
  47232. /**
  47233. * Gets the value of the `Triangle` button
  47234. */
  47235. get buttonTriangle(): number;
  47236. /**
  47237. * Sets the value of the `Triangle` button
  47238. */
  47239. set buttonTriangle(value: number);
  47240. /**
  47241. * Gets the value of the `Options` button
  47242. */
  47243. get buttonOptions(): number;
  47244. /**
  47245. * Sets the value of the `Options` button
  47246. */
  47247. set buttonOptions(value: number);
  47248. /**
  47249. * Gets the value of the `Share` button
  47250. */
  47251. get buttonShare(): number;
  47252. /**
  47253. * Sets the value of the `Share` button
  47254. */
  47255. set buttonShare(value: number);
  47256. /**
  47257. * Gets the value of the `L1` button
  47258. */
  47259. get buttonL1(): number;
  47260. /**
  47261. * Sets the value of the `L1` button
  47262. */
  47263. set buttonL1(value: number);
  47264. /**
  47265. * Gets the value of the `R1` button
  47266. */
  47267. get buttonR1(): number;
  47268. /**
  47269. * Sets the value of the `R1` button
  47270. */
  47271. set buttonR1(value: number);
  47272. /**
  47273. * Gets the value of the Left joystick
  47274. */
  47275. get buttonLeftStick(): number;
  47276. /**
  47277. * Sets the value of the Left joystick
  47278. */
  47279. set buttonLeftStick(value: number);
  47280. /**
  47281. * Gets the value of the Right joystick
  47282. */
  47283. get buttonRightStick(): number;
  47284. /**
  47285. * Sets the value of the Right joystick
  47286. */
  47287. set buttonRightStick(value: number);
  47288. /**
  47289. * Gets the value of D-pad up
  47290. */
  47291. get dPadUp(): number;
  47292. /**
  47293. * Sets the value of D-pad up
  47294. */
  47295. set dPadUp(value: number);
  47296. /**
  47297. * Gets the value of D-pad down
  47298. */
  47299. get dPadDown(): number;
  47300. /**
  47301. * Sets the value of D-pad down
  47302. */
  47303. set dPadDown(value: number);
  47304. /**
  47305. * Gets the value of D-pad left
  47306. */
  47307. get dPadLeft(): number;
  47308. /**
  47309. * Sets the value of D-pad left
  47310. */
  47311. set dPadLeft(value: number);
  47312. /**
  47313. * Gets the value of D-pad right
  47314. */
  47315. get dPadRight(): number;
  47316. /**
  47317. * Sets the value of D-pad right
  47318. */
  47319. set dPadRight(value: number);
  47320. /**
  47321. * Force the gamepad to synchronize with device values
  47322. */
  47323. update(): void;
  47324. /**
  47325. * Disposes the gamepad
  47326. */
  47327. dispose(): void;
  47328. }
  47329. }
  47330. declare module "babylonjs/Gamepads/gamepadManager" {
  47331. import { Observable } from "babylonjs/Misc/observable";
  47332. import { Nullable } from "babylonjs/types";
  47333. import { Scene } from "babylonjs/scene";
  47334. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47335. /**
  47336. * Manager for handling gamepads
  47337. */
  47338. export class GamepadManager {
  47339. private _scene?;
  47340. private _babylonGamepads;
  47341. private _oneGamepadConnected;
  47342. /** @hidden */
  47343. _isMonitoring: boolean;
  47344. private _gamepadEventSupported;
  47345. private _gamepadSupport?;
  47346. /**
  47347. * observable to be triggered when the gamepad controller has been connected
  47348. */
  47349. onGamepadConnectedObservable: Observable<Gamepad>;
  47350. /**
  47351. * observable to be triggered when the gamepad controller has been disconnected
  47352. */
  47353. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47354. private _onGamepadConnectedEvent;
  47355. private _onGamepadDisconnectedEvent;
  47356. /**
  47357. * Initializes the gamepad manager
  47358. * @param _scene BabylonJS scene
  47359. */
  47360. constructor(_scene?: Scene | undefined);
  47361. /**
  47362. * The gamepads in the game pad manager
  47363. */
  47364. get gamepads(): Gamepad[];
  47365. /**
  47366. * Get the gamepad controllers based on type
  47367. * @param type The type of gamepad controller
  47368. * @returns Nullable gamepad
  47369. */
  47370. getGamepadByType(type?: number): Nullable<Gamepad>;
  47371. /**
  47372. * Disposes the gamepad manager
  47373. */
  47374. dispose(): void;
  47375. private _addNewGamepad;
  47376. private _startMonitoringGamepads;
  47377. private _stopMonitoringGamepads;
  47378. /** @hidden */
  47379. _checkGamepadsStatus(): void;
  47380. private _updateGamepadObjects;
  47381. }
  47382. }
  47383. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47384. import { Nullable } from "babylonjs/types";
  47385. import { Scene } from "babylonjs/scene";
  47386. import { ISceneComponent } from "babylonjs/sceneComponent";
  47387. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47388. module "babylonjs/scene" {
  47389. interface Scene {
  47390. /** @hidden */
  47391. _gamepadManager: Nullable<GamepadManager>;
  47392. /**
  47393. * Gets the gamepad manager associated with the scene
  47394. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47395. */
  47396. gamepadManager: GamepadManager;
  47397. }
  47398. }
  47399. module "babylonjs/Cameras/freeCameraInputsManager" {
  47400. /**
  47401. * Interface representing a free camera inputs manager
  47402. */
  47403. interface FreeCameraInputsManager {
  47404. /**
  47405. * Adds gamepad input support to the FreeCameraInputsManager.
  47406. * @returns the FreeCameraInputsManager
  47407. */
  47408. addGamepad(): FreeCameraInputsManager;
  47409. }
  47410. }
  47411. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47412. /**
  47413. * Interface representing an arc rotate camera inputs manager
  47414. */
  47415. interface ArcRotateCameraInputsManager {
  47416. /**
  47417. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47418. * @returns the camera inputs manager
  47419. */
  47420. addGamepad(): ArcRotateCameraInputsManager;
  47421. }
  47422. }
  47423. /**
  47424. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47425. */
  47426. export class GamepadSystemSceneComponent implements ISceneComponent {
  47427. /**
  47428. * The component name helpfull to identify the component in the list of scene components.
  47429. */
  47430. readonly name: string;
  47431. /**
  47432. * The scene the component belongs to.
  47433. */
  47434. scene: Scene;
  47435. /**
  47436. * Creates a new instance of the component for the given scene
  47437. * @param scene Defines the scene to register the component in
  47438. */
  47439. constructor(scene: Scene);
  47440. /**
  47441. * Registers the component in a given scene
  47442. */
  47443. register(): void;
  47444. /**
  47445. * Rebuilds the elements related to this component in case of
  47446. * context lost for instance.
  47447. */
  47448. rebuild(): void;
  47449. /**
  47450. * Disposes the component and the associated ressources
  47451. */
  47452. dispose(): void;
  47453. private _beforeCameraUpdate;
  47454. }
  47455. }
  47456. declare module "babylonjs/Cameras/universalCamera" {
  47457. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47458. import { Scene } from "babylonjs/scene";
  47459. import { Vector3 } from "babylonjs/Maths/math.vector";
  47460. import "babylonjs/Gamepads/gamepadSceneComponent";
  47461. /**
  47462. * 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,
  47463. * which still works and will still be found in many Playgrounds.
  47464. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47465. */
  47466. export class UniversalCamera extends TouchCamera {
  47467. /**
  47468. * Defines the gamepad rotation sensiblity.
  47469. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47470. */
  47471. get gamepadAngularSensibility(): number;
  47472. set gamepadAngularSensibility(value: number);
  47473. /**
  47474. * Defines the gamepad move sensiblity.
  47475. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47476. */
  47477. get gamepadMoveSensibility(): number;
  47478. set gamepadMoveSensibility(value: number);
  47479. /**
  47480. * 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,
  47481. * which still works and will still be found in many Playgrounds.
  47482. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47483. * @param name Define the name of the camera in the scene
  47484. * @param position Define the start position of the camera in the scene
  47485. * @param scene Define the scene the camera belongs to
  47486. */
  47487. constructor(name: string, position: Vector3, scene: Scene);
  47488. /**
  47489. * Gets the current object class name.
  47490. * @return the class name
  47491. */
  47492. getClassName(): string;
  47493. }
  47494. }
  47495. declare module "babylonjs/Cameras/gamepadCamera" {
  47496. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47497. import { Scene } from "babylonjs/scene";
  47498. import { Vector3 } from "babylonjs/Maths/math.vector";
  47499. /**
  47500. * This represents a FPS type of camera. This is only here for back compat purpose.
  47501. * Please use the UniversalCamera instead as both are identical.
  47502. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47503. */
  47504. export class GamepadCamera extends UniversalCamera {
  47505. /**
  47506. * Instantiates a new Gamepad Camera
  47507. * This represents a FPS type of camera. This is only here for back compat purpose.
  47508. * Please use the UniversalCamera instead as both are identical.
  47509. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47510. * @param name Define the name of the camera in the scene
  47511. * @param position Define the start position of the camera in the scene
  47512. * @param scene Define the scene the camera belongs to
  47513. */
  47514. constructor(name: string, position: Vector3, scene: Scene);
  47515. /**
  47516. * Gets the current object class name.
  47517. * @return the class name
  47518. */
  47519. getClassName(): string;
  47520. }
  47521. }
  47522. declare module "babylonjs/Shaders/pass.fragment" {
  47523. /** @hidden */
  47524. export var passPixelShader: {
  47525. name: string;
  47526. shader: string;
  47527. };
  47528. }
  47529. declare module "babylonjs/Shaders/passCube.fragment" {
  47530. /** @hidden */
  47531. export var passCubePixelShader: {
  47532. name: string;
  47533. shader: string;
  47534. };
  47535. }
  47536. declare module "babylonjs/PostProcesses/passPostProcess" {
  47537. import { Nullable } from "babylonjs/types";
  47538. import { Camera } from "babylonjs/Cameras/camera";
  47539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47540. import { Engine } from "babylonjs/Engines/engine";
  47541. import "babylonjs/Shaders/pass.fragment";
  47542. import "babylonjs/Shaders/passCube.fragment";
  47543. /**
  47544. * PassPostProcess which produces an output the same as it's input
  47545. */
  47546. export class PassPostProcess extends PostProcess {
  47547. /**
  47548. * Creates the PassPostProcess
  47549. * @param name The name of the effect.
  47550. * @param options The required width/height ratio to downsize to before computing the render pass.
  47551. * @param camera The camera to apply the render pass to.
  47552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47553. * @param engine The engine which the post process will be applied. (default: current engine)
  47554. * @param reusable If the post process can be reused on the same frame. (default: false)
  47555. * @param textureType The type of texture to be used when performing the post processing.
  47556. * @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)
  47557. */
  47558. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47559. }
  47560. /**
  47561. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47562. */
  47563. export class PassCubePostProcess extends PostProcess {
  47564. private _face;
  47565. /**
  47566. * Gets or sets the cube face to display.
  47567. * * 0 is +X
  47568. * * 1 is -X
  47569. * * 2 is +Y
  47570. * * 3 is -Y
  47571. * * 4 is +Z
  47572. * * 5 is -Z
  47573. */
  47574. get face(): number;
  47575. set face(value: number);
  47576. /**
  47577. * Creates the PassCubePostProcess
  47578. * @param name The name of the effect.
  47579. * @param options The required width/height ratio to downsize to before computing the render pass.
  47580. * @param camera The camera to apply the render pass to.
  47581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47582. * @param engine The engine which the post process will be applied. (default: current engine)
  47583. * @param reusable If the post process can be reused on the same frame. (default: false)
  47584. * @param textureType The type of texture to be used when performing the post processing.
  47585. * @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)
  47586. */
  47587. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47588. }
  47589. }
  47590. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47591. /** @hidden */
  47592. export var anaglyphPixelShader: {
  47593. name: string;
  47594. shader: string;
  47595. };
  47596. }
  47597. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47598. import { Engine } from "babylonjs/Engines/engine";
  47599. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47600. import { Camera } from "babylonjs/Cameras/camera";
  47601. import "babylonjs/Shaders/anaglyph.fragment";
  47602. /**
  47603. * Postprocess used to generate anaglyphic rendering
  47604. */
  47605. export class AnaglyphPostProcess extends PostProcess {
  47606. private _passedProcess;
  47607. /**
  47608. * Creates a new AnaglyphPostProcess
  47609. * @param name defines postprocess name
  47610. * @param options defines creation options or target ratio scale
  47611. * @param rigCameras defines cameras using this postprocess
  47612. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47613. * @param engine defines hosting engine
  47614. * @param reusable defines if the postprocess will be reused multiple times per frame
  47615. */
  47616. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47617. }
  47618. }
  47619. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47620. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47621. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47622. import { Scene } from "babylonjs/scene";
  47623. import { Vector3 } from "babylonjs/Maths/math.vector";
  47624. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47625. /**
  47626. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47627. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47628. */
  47629. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47630. /**
  47631. * Creates a new AnaglyphArcRotateCamera
  47632. * @param name defines camera name
  47633. * @param alpha defines alpha angle (in radians)
  47634. * @param beta defines beta angle (in radians)
  47635. * @param radius defines radius
  47636. * @param target defines camera target
  47637. * @param interaxialDistance defines distance between each color axis
  47638. * @param scene defines the hosting scene
  47639. */
  47640. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47641. /**
  47642. * Gets camera class name
  47643. * @returns AnaglyphArcRotateCamera
  47644. */
  47645. getClassName(): string;
  47646. }
  47647. }
  47648. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47649. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47650. import { Scene } from "babylonjs/scene";
  47651. import { Vector3 } from "babylonjs/Maths/math.vector";
  47652. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47653. /**
  47654. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47655. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47656. */
  47657. export class AnaglyphFreeCamera extends FreeCamera {
  47658. /**
  47659. * Creates a new AnaglyphFreeCamera
  47660. * @param name defines camera name
  47661. * @param position defines initial position
  47662. * @param interaxialDistance defines distance between each color axis
  47663. * @param scene defines the hosting scene
  47664. */
  47665. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47666. /**
  47667. * Gets camera class name
  47668. * @returns AnaglyphFreeCamera
  47669. */
  47670. getClassName(): string;
  47671. }
  47672. }
  47673. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47674. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47675. import { Scene } from "babylonjs/scene";
  47676. import { Vector3 } from "babylonjs/Maths/math.vector";
  47677. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47678. /**
  47679. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47680. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47681. */
  47682. export class AnaglyphGamepadCamera extends GamepadCamera {
  47683. /**
  47684. * Creates a new AnaglyphGamepadCamera
  47685. * @param name defines camera name
  47686. * @param position defines initial position
  47687. * @param interaxialDistance defines distance between each color axis
  47688. * @param scene defines the hosting scene
  47689. */
  47690. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47691. /**
  47692. * Gets camera class name
  47693. * @returns AnaglyphGamepadCamera
  47694. */
  47695. getClassName(): string;
  47696. }
  47697. }
  47698. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47699. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47700. import { Scene } from "babylonjs/scene";
  47701. import { Vector3 } from "babylonjs/Maths/math.vector";
  47702. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47703. /**
  47704. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47705. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47706. */
  47707. export class AnaglyphUniversalCamera extends UniversalCamera {
  47708. /**
  47709. * Creates a new AnaglyphUniversalCamera
  47710. * @param name defines camera name
  47711. * @param position defines initial position
  47712. * @param interaxialDistance defines distance between each color axis
  47713. * @param scene defines the hosting scene
  47714. */
  47715. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47716. /**
  47717. * Gets camera class name
  47718. * @returns AnaglyphUniversalCamera
  47719. */
  47720. getClassName(): string;
  47721. }
  47722. }
  47723. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47724. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47725. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47726. import { Scene } from "babylonjs/scene";
  47727. import { Vector3 } from "babylonjs/Maths/math.vector";
  47728. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47729. /**
  47730. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47731. * @see https://doc.babylonjs.com/features/cameras
  47732. */
  47733. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47734. /**
  47735. * Creates a new StereoscopicArcRotateCamera
  47736. * @param name defines camera name
  47737. * @param alpha defines alpha angle (in radians)
  47738. * @param beta defines beta angle (in radians)
  47739. * @param radius defines radius
  47740. * @param target defines camera target
  47741. * @param interaxialDistance defines distance between each color axis
  47742. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47743. * @param scene defines the hosting scene
  47744. */
  47745. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47746. /**
  47747. * Gets camera class name
  47748. * @returns StereoscopicArcRotateCamera
  47749. */
  47750. getClassName(): string;
  47751. }
  47752. }
  47753. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47754. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47755. import { Scene } from "babylonjs/scene";
  47756. import { Vector3 } from "babylonjs/Maths/math.vector";
  47757. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47758. /**
  47759. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47760. * @see https://doc.babylonjs.com/features/cameras
  47761. */
  47762. export class StereoscopicFreeCamera extends FreeCamera {
  47763. /**
  47764. * Creates a new StereoscopicFreeCamera
  47765. * @param name defines camera name
  47766. * @param position defines initial position
  47767. * @param interaxialDistance defines distance between each color axis
  47768. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47769. * @param scene defines the hosting scene
  47770. */
  47771. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47772. /**
  47773. * Gets camera class name
  47774. * @returns StereoscopicFreeCamera
  47775. */
  47776. getClassName(): string;
  47777. }
  47778. }
  47779. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47780. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47781. import { Scene } from "babylonjs/scene";
  47782. import { Vector3 } from "babylonjs/Maths/math.vector";
  47783. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47784. /**
  47785. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47786. * @see https://doc.babylonjs.com/features/cameras
  47787. */
  47788. export class StereoscopicGamepadCamera extends GamepadCamera {
  47789. /**
  47790. * Creates a new StereoscopicGamepadCamera
  47791. * @param name defines camera name
  47792. * @param position defines initial position
  47793. * @param interaxialDistance defines distance between each color axis
  47794. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47795. * @param scene defines the hosting scene
  47796. */
  47797. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47798. /**
  47799. * Gets camera class name
  47800. * @returns StereoscopicGamepadCamera
  47801. */
  47802. getClassName(): string;
  47803. }
  47804. }
  47805. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47806. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47807. import { Scene } from "babylonjs/scene";
  47808. import { Vector3 } from "babylonjs/Maths/math.vector";
  47809. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47810. /**
  47811. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47812. * @see https://doc.babylonjs.com/features/cameras
  47813. */
  47814. export class StereoscopicUniversalCamera extends UniversalCamera {
  47815. /**
  47816. * Creates a new StereoscopicUniversalCamera
  47817. * @param name defines camera name
  47818. * @param position defines initial position
  47819. * @param interaxialDistance defines distance between each color axis
  47820. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47821. * @param scene defines the hosting scene
  47822. */
  47823. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47824. /**
  47825. * Gets camera class name
  47826. * @returns StereoscopicUniversalCamera
  47827. */
  47828. getClassName(): string;
  47829. }
  47830. }
  47831. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47832. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47833. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47834. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47835. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47836. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47837. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47838. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47839. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47840. }
  47841. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47842. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47843. import { Scene } from "babylonjs/scene";
  47844. import { Vector3 } from "babylonjs/Maths/math.vector";
  47845. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47846. /**
  47847. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47848. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47849. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47850. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47851. */
  47852. export class VirtualJoysticksCamera extends FreeCamera {
  47853. /**
  47854. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47855. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47856. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47857. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47858. * @param name Define the name of the camera in the scene
  47859. * @param position Define the start position of the camera in the scene
  47860. * @param scene Define the scene the camera belongs to
  47861. */
  47862. constructor(name: string, position: Vector3, scene: Scene);
  47863. /**
  47864. * Gets the current object class name.
  47865. * @return the class name
  47866. */
  47867. getClassName(): string;
  47868. }
  47869. }
  47870. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47871. import { Matrix } from "babylonjs/Maths/math.vector";
  47872. /**
  47873. * This represents all the required metrics to create a VR camera.
  47874. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47875. */
  47876. export class VRCameraMetrics {
  47877. /**
  47878. * Define the horizontal resolution off the screen.
  47879. */
  47880. hResolution: number;
  47881. /**
  47882. * Define the vertical resolution off the screen.
  47883. */
  47884. vResolution: number;
  47885. /**
  47886. * Define the horizontal screen size.
  47887. */
  47888. hScreenSize: number;
  47889. /**
  47890. * Define the vertical screen size.
  47891. */
  47892. vScreenSize: number;
  47893. /**
  47894. * Define the vertical screen center position.
  47895. */
  47896. vScreenCenter: number;
  47897. /**
  47898. * Define the distance of the eyes to the screen.
  47899. */
  47900. eyeToScreenDistance: number;
  47901. /**
  47902. * Define the distance between both lenses
  47903. */
  47904. lensSeparationDistance: number;
  47905. /**
  47906. * Define the distance between both viewer's eyes.
  47907. */
  47908. interpupillaryDistance: number;
  47909. /**
  47910. * Define the distortion factor of the VR postprocess.
  47911. * Please, touch with care.
  47912. */
  47913. distortionK: number[];
  47914. /**
  47915. * Define the chromatic aberration correction factors for the VR post process.
  47916. */
  47917. chromaAbCorrection: number[];
  47918. /**
  47919. * Define the scale factor of the post process.
  47920. * The smaller the better but the slower.
  47921. */
  47922. postProcessScaleFactor: number;
  47923. /**
  47924. * Define an offset for the lens center.
  47925. */
  47926. lensCenterOffset: number;
  47927. /**
  47928. * Define if the current vr camera should compensate the distortion of the lense or not.
  47929. */
  47930. compensateDistortion: boolean;
  47931. /**
  47932. * Defines if multiview should be enabled when rendering (Default: false)
  47933. */
  47934. multiviewEnabled: boolean;
  47935. /**
  47936. * Gets the rendering aspect ratio based on the provided resolutions.
  47937. */
  47938. get aspectRatio(): number;
  47939. /**
  47940. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47941. */
  47942. get aspectRatioFov(): number;
  47943. /**
  47944. * @hidden
  47945. */
  47946. get leftHMatrix(): Matrix;
  47947. /**
  47948. * @hidden
  47949. */
  47950. get rightHMatrix(): Matrix;
  47951. /**
  47952. * @hidden
  47953. */
  47954. get leftPreViewMatrix(): Matrix;
  47955. /**
  47956. * @hidden
  47957. */
  47958. get rightPreViewMatrix(): Matrix;
  47959. /**
  47960. * Get the default VRMetrics based on the most generic setup.
  47961. * @returns the default vr metrics
  47962. */
  47963. static GetDefault(): VRCameraMetrics;
  47964. }
  47965. }
  47966. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47967. /** @hidden */
  47968. export var vrDistortionCorrectionPixelShader: {
  47969. name: string;
  47970. shader: string;
  47971. };
  47972. }
  47973. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47974. import { Camera } from "babylonjs/Cameras/camera";
  47975. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47976. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47977. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47978. /**
  47979. * VRDistortionCorrectionPostProcess used for mobile VR
  47980. */
  47981. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47982. private _isRightEye;
  47983. private _distortionFactors;
  47984. private _postProcessScaleFactor;
  47985. private _lensCenterOffset;
  47986. private _scaleIn;
  47987. private _scaleFactor;
  47988. private _lensCenter;
  47989. /**
  47990. * Initializes the VRDistortionCorrectionPostProcess
  47991. * @param name The name of the effect.
  47992. * @param camera The camera to apply the render pass to.
  47993. * @param isRightEye If this is for the right eye distortion
  47994. * @param vrMetrics All the required metrics for the VR camera
  47995. */
  47996. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47997. }
  47998. }
  47999. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48000. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48001. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48002. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48003. import { Scene } from "babylonjs/scene";
  48004. import { Vector3 } from "babylonjs/Maths/math.vector";
  48005. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48006. import "babylonjs/Cameras/RigModes/vrRigMode";
  48007. /**
  48008. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48009. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48010. */
  48011. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48012. /**
  48013. * Creates a new VRDeviceOrientationArcRotateCamera
  48014. * @param name defines camera name
  48015. * @param alpha defines the camera rotation along the logitudinal axis
  48016. * @param beta defines the camera rotation along the latitudinal axis
  48017. * @param radius defines the camera distance from its target
  48018. * @param target defines the camera target
  48019. * @param scene defines the scene the camera belongs to
  48020. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48021. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48022. */
  48023. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48024. /**
  48025. * Gets camera class name
  48026. * @returns VRDeviceOrientationArcRotateCamera
  48027. */
  48028. getClassName(): string;
  48029. }
  48030. }
  48031. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48032. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48033. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48034. import { Scene } from "babylonjs/scene";
  48035. import { Vector3 } from "babylonjs/Maths/math.vector";
  48036. import "babylonjs/Cameras/RigModes/vrRigMode";
  48037. /**
  48038. * Camera used to simulate VR rendering (based on FreeCamera)
  48039. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48040. */
  48041. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48042. /**
  48043. * Creates a new VRDeviceOrientationFreeCamera
  48044. * @param name defines camera name
  48045. * @param position defines the start position of the camera
  48046. * @param scene defines the scene the camera belongs to
  48047. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48048. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48049. */
  48050. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48051. /**
  48052. * Gets camera class name
  48053. * @returns VRDeviceOrientationFreeCamera
  48054. */
  48055. getClassName(): string;
  48056. }
  48057. }
  48058. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48059. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48060. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48061. import { Scene } from "babylonjs/scene";
  48062. import { Vector3 } from "babylonjs/Maths/math.vector";
  48063. import "babylonjs/Gamepads/gamepadSceneComponent";
  48064. /**
  48065. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48066. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48067. */
  48068. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48069. /**
  48070. * Creates a new VRDeviceOrientationGamepadCamera
  48071. * @param name defines camera name
  48072. * @param position defines the start position of the camera
  48073. * @param scene defines the scene the camera belongs to
  48074. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48075. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48076. */
  48077. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48078. /**
  48079. * Gets camera class name
  48080. * @returns VRDeviceOrientationGamepadCamera
  48081. */
  48082. getClassName(): string;
  48083. }
  48084. }
  48085. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48086. import { Scene } from "babylonjs/scene";
  48087. import { Texture } from "babylonjs/Materials/Textures/texture";
  48088. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48089. /**
  48090. * A class extending Texture allowing drawing on a texture
  48091. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48092. */
  48093. export class DynamicTexture extends Texture {
  48094. private _generateMipMaps;
  48095. private _canvas;
  48096. private _context;
  48097. /**
  48098. * Creates a DynamicTexture
  48099. * @param name defines the name of the texture
  48100. * @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
  48101. * @param scene defines the scene where you want the texture
  48102. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48103. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48104. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48105. */
  48106. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48107. /**
  48108. * Get the current class name of the texture useful for serialization or dynamic coding.
  48109. * @returns "DynamicTexture"
  48110. */
  48111. getClassName(): string;
  48112. /**
  48113. * Gets the current state of canRescale
  48114. */
  48115. get canRescale(): boolean;
  48116. private _recreate;
  48117. /**
  48118. * Scales the texture
  48119. * @param ratio the scale factor to apply to both width and height
  48120. */
  48121. scale(ratio: number): void;
  48122. /**
  48123. * Resizes the texture
  48124. * @param width the new width
  48125. * @param height the new height
  48126. */
  48127. scaleTo(width: number, height: number): void;
  48128. /**
  48129. * Gets the context of the canvas used by the texture
  48130. * @returns the canvas context of the dynamic texture
  48131. */
  48132. getContext(): CanvasRenderingContext2D;
  48133. /**
  48134. * Clears the texture
  48135. */
  48136. clear(): void;
  48137. /**
  48138. * Updates the texture
  48139. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48140. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48141. */
  48142. update(invertY?: boolean, premulAlpha?: boolean): void;
  48143. /**
  48144. * Draws text onto the texture
  48145. * @param text defines the text to be drawn
  48146. * @param x defines the placement of the text from the left
  48147. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48148. * @param font defines the font to be used with font-style, font-size, font-name
  48149. * @param color defines the color used for the text
  48150. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48151. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48152. * @param update defines whether texture is immediately update (default is true)
  48153. */
  48154. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48155. /**
  48156. * Clones the texture
  48157. * @returns the clone of the texture.
  48158. */
  48159. clone(): DynamicTexture;
  48160. /**
  48161. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48162. * @returns a serialized dynamic texture object
  48163. */
  48164. serialize(): any;
  48165. private _IsCanvasElement;
  48166. /** @hidden */
  48167. _rebuild(): void;
  48168. }
  48169. }
  48170. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48171. import { Scene } from "babylonjs/scene";
  48172. import { Color3 } from "babylonjs/Maths/math.color";
  48173. import { Mesh } from "babylonjs/Meshes/mesh";
  48174. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48175. import { Nullable } from "babylonjs/types";
  48176. /**
  48177. * Class containing static functions to help procedurally build meshes
  48178. */
  48179. export class GroundBuilder {
  48180. /**
  48181. * Creates a ground mesh
  48182. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48183. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48185. * @param name defines the name of the mesh
  48186. * @param options defines the options used to create the mesh
  48187. * @param scene defines the hosting scene
  48188. * @returns the ground mesh
  48189. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48190. */
  48191. static CreateGround(name: string, options: {
  48192. width?: number;
  48193. height?: number;
  48194. subdivisions?: number;
  48195. subdivisionsX?: number;
  48196. subdivisionsY?: number;
  48197. updatable?: boolean;
  48198. }, scene: any): Mesh;
  48199. /**
  48200. * Creates a tiled ground mesh
  48201. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48202. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48203. * * 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
  48204. * * 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
  48205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48206. * @param name defines the name of the mesh
  48207. * @param options defines the options used to create the mesh
  48208. * @param scene defines the hosting scene
  48209. * @returns the tiled ground mesh
  48210. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48211. */
  48212. static CreateTiledGround(name: string, options: {
  48213. xmin: number;
  48214. zmin: number;
  48215. xmax: number;
  48216. zmax: number;
  48217. subdivisions?: {
  48218. w: number;
  48219. h: number;
  48220. };
  48221. precision?: {
  48222. w: number;
  48223. h: number;
  48224. };
  48225. updatable?: boolean;
  48226. }, scene?: Nullable<Scene>): Mesh;
  48227. /**
  48228. * Creates a ground mesh from a height map
  48229. * * The parameter `url` sets the URL of the height map image resource.
  48230. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48231. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48232. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48233. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48234. * * 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.
  48235. * * 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).
  48236. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48238. * @param name defines the name of the mesh
  48239. * @param url defines the url to the height map
  48240. * @param options defines the options used to create the mesh
  48241. * @param scene defines the hosting scene
  48242. * @returns the ground mesh
  48243. * @see https://doc.babylonjs.com/babylon101/height_map
  48244. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48245. */
  48246. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48247. width?: number;
  48248. height?: number;
  48249. subdivisions?: number;
  48250. minHeight?: number;
  48251. maxHeight?: number;
  48252. colorFilter?: Color3;
  48253. alphaFilter?: number;
  48254. updatable?: boolean;
  48255. onReady?: (mesh: GroundMesh) => void;
  48256. }, scene?: Nullable<Scene>): GroundMesh;
  48257. }
  48258. }
  48259. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48260. import { Vector4 } from "babylonjs/Maths/math.vector";
  48261. import { Mesh } from "babylonjs/Meshes/mesh";
  48262. /**
  48263. * Class containing static functions to help procedurally build meshes
  48264. */
  48265. export class TorusBuilder {
  48266. /**
  48267. * Creates a torus mesh
  48268. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48269. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48270. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48274. * @param name defines the name of the mesh
  48275. * @param options defines the options used to create the mesh
  48276. * @param scene defines the hosting scene
  48277. * @returns the torus mesh
  48278. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48279. */
  48280. static CreateTorus(name: string, options: {
  48281. diameter?: number;
  48282. thickness?: number;
  48283. tessellation?: number;
  48284. updatable?: boolean;
  48285. sideOrientation?: number;
  48286. frontUVs?: Vector4;
  48287. backUVs?: Vector4;
  48288. }, scene: any): Mesh;
  48289. }
  48290. }
  48291. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48292. import { Vector4 } from "babylonjs/Maths/math.vector";
  48293. import { Color4 } from "babylonjs/Maths/math.color";
  48294. import { Mesh } from "babylonjs/Meshes/mesh";
  48295. /**
  48296. * Class containing static functions to help procedurally build meshes
  48297. */
  48298. export class CylinderBuilder {
  48299. /**
  48300. * Creates a cylinder or a cone mesh
  48301. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48302. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48303. * * 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.
  48304. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48305. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48306. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48307. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48308. * * 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).
  48309. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48310. * * 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).
  48311. * * 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
  48312. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48313. * * 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
  48314. * * 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.
  48315. * * If `enclose` is false, a ring surface is one element.
  48316. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48317. * * 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
  48318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48321. * @param name defines the name of the mesh
  48322. * @param options defines the options used to create the mesh
  48323. * @param scene defines the hosting scene
  48324. * @returns the cylinder mesh
  48325. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48326. */
  48327. static CreateCylinder(name: string, options: {
  48328. height?: number;
  48329. diameterTop?: number;
  48330. diameterBottom?: number;
  48331. diameter?: number;
  48332. tessellation?: number;
  48333. subdivisions?: number;
  48334. arc?: number;
  48335. faceColors?: Color4[];
  48336. faceUV?: Vector4[];
  48337. updatable?: boolean;
  48338. hasRings?: boolean;
  48339. enclose?: boolean;
  48340. cap?: number;
  48341. sideOrientation?: number;
  48342. frontUVs?: Vector4;
  48343. backUVs?: Vector4;
  48344. }, scene: any): Mesh;
  48345. }
  48346. }
  48347. declare module "babylonjs/XR/webXRTypes" {
  48348. import { Nullable } from "babylonjs/types";
  48349. import { IDisposable } from "babylonjs/scene";
  48350. /**
  48351. * States of the webXR experience
  48352. */
  48353. export enum WebXRState {
  48354. /**
  48355. * Transitioning to being in XR mode
  48356. */
  48357. ENTERING_XR = 0,
  48358. /**
  48359. * Transitioning to non XR mode
  48360. */
  48361. EXITING_XR = 1,
  48362. /**
  48363. * In XR mode and presenting
  48364. */
  48365. IN_XR = 2,
  48366. /**
  48367. * Not entered XR mode
  48368. */
  48369. NOT_IN_XR = 3
  48370. }
  48371. /**
  48372. * Abstraction of the XR render target
  48373. */
  48374. export interface WebXRRenderTarget extends IDisposable {
  48375. /**
  48376. * xrpresent context of the canvas which can be used to display/mirror xr content
  48377. */
  48378. canvasContext: WebGLRenderingContext;
  48379. /**
  48380. * xr layer for the canvas
  48381. */
  48382. xrLayer: Nullable<XRWebGLLayer>;
  48383. /**
  48384. * Initializes the xr layer for the session
  48385. * @param xrSession xr session
  48386. * @returns a promise that will resolve once the XR Layer has been created
  48387. */
  48388. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48389. }
  48390. }
  48391. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48392. import { Nullable } from "babylonjs/types";
  48393. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48394. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48395. import { Observable } from "babylonjs/Misc/observable";
  48396. /**
  48397. * COnfiguration object for WebXR output canvas
  48398. */
  48399. export class WebXRManagedOutputCanvasOptions {
  48400. /**
  48401. * An optional canvas in case you wish to create it yourself and provide it here.
  48402. * If not provided, a new canvas will be created
  48403. */
  48404. canvasElement?: HTMLCanvasElement;
  48405. /**
  48406. * Options for this XR Layer output
  48407. */
  48408. canvasOptions?: XRWebGLLayerOptions;
  48409. /**
  48410. * CSS styling for a newly created canvas (if not provided)
  48411. */
  48412. newCanvasCssStyle?: string;
  48413. /**
  48414. * Get the default values of the configuration object
  48415. * @returns default values of this configuration object
  48416. */
  48417. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  48418. }
  48419. /**
  48420. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48421. */
  48422. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48423. private _options;
  48424. private _canvas;
  48425. private _engine;
  48426. private _originalCanvasSize;
  48427. /**
  48428. * Rendering context of the canvas which can be used to display/mirror xr content
  48429. */
  48430. canvasContext: WebGLRenderingContext;
  48431. /**
  48432. * xr layer for the canvas
  48433. */
  48434. xrLayer: Nullable<XRWebGLLayer>;
  48435. /**
  48436. * Obseervers registered here will be triggered when the xr layer was initialized
  48437. */
  48438. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48439. /**
  48440. * Initializes the canvas to be added/removed upon entering/exiting xr
  48441. * @param _xrSessionManager The XR Session manager
  48442. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48443. */
  48444. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48445. /**
  48446. * Disposes of the object
  48447. */
  48448. dispose(): void;
  48449. /**
  48450. * Initializes the xr layer for the session
  48451. * @param xrSession xr session
  48452. * @returns a promise that will resolve once the XR Layer has been created
  48453. */
  48454. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48455. private _addCanvas;
  48456. private _removeCanvas;
  48457. private _setCanvasSize;
  48458. private _setManagedOutputCanvas;
  48459. }
  48460. }
  48461. declare module "babylonjs/XR/webXRSessionManager" {
  48462. import { Observable } from "babylonjs/Misc/observable";
  48463. import { Nullable } from "babylonjs/types";
  48464. import { IDisposable, Scene } from "babylonjs/scene";
  48465. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48466. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48467. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48468. /**
  48469. * Manages an XRSession to work with Babylon's engine
  48470. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48471. */
  48472. export class WebXRSessionManager implements IDisposable {
  48473. /** The scene which the session should be created for */
  48474. scene: Scene;
  48475. private _referenceSpace;
  48476. private _rttProvider;
  48477. private _sessionEnded;
  48478. private _xrNavigator;
  48479. private baseLayer;
  48480. /**
  48481. * The base reference space from which the session started. good if you want to reset your
  48482. * reference space
  48483. */
  48484. baseReferenceSpace: XRReferenceSpace;
  48485. /**
  48486. * Current XR frame
  48487. */
  48488. currentFrame: Nullable<XRFrame>;
  48489. /** WebXR timestamp updated every frame */
  48490. currentTimestamp: number;
  48491. /**
  48492. * Used just in case of a failure to initialize an immersive session.
  48493. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48494. */
  48495. defaultHeightCompensation: number;
  48496. /**
  48497. * Fires every time a new xrFrame arrives which can be used to update the camera
  48498. */
  48499. onXRFrameObservable: Observable<XRFrame>;
  48500. /**
  48501. * Fires when the reference space changed
  48502. */
  48503. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48504. /**
  48505. * Fires when the xr session is ended either by the device or manually done
  48506. */
  48507. onXRSessionEnded: Observable<any>;
  48508. /**
  48509. * Fires when the xr session is ended either by the device or manually done
  48510. */
  48511. onXRSessionInit: Observable<XRSession>;
  48512. /**
  48513. * Underlying xr session
  48514. */
  48515. session: XRSession;
  48516. /**
  48517. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48518. * or get the offset the player is currently at.
  48519. */
  48520. viewerReferenceSpace: XRReferenceSpace;
  48521. /**
  48522. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48523. * @param scene The scene which the session should be created for
  48524. */
  48525. constructor(
  48526. /** The scene which the session should be created for */
  48527. scene: Scene);
  48528. /**
  48529. * The current reference space used in this session. This reference space can constantly change!
  48530. * It is mainly used to offset the camera's position.
  48531. */
  48532. get referenceSpace(): XRReferenceSpace;
  48533. /**
  48534. * Set a new reference space and triggers the observable
  48535. */
  48536. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48537. /**
  48538. * Disposes of the session manager
  48539. */
  48540. dispose(): void;
  48541. /**
  48542. * Stops the xrSession and restores the render loop
  48543. * @returns Promise which resolves after it exits XR
  48544. */
  48545. exitXRAsync(): Promise<void>;
  48546. /**
  48547. * Gets the correct render target texture to be rendered this frame for this eye
  48548. * @param eye the eye for which to get the render target
  48549. * @returns the render target for the specified eye
  48550. */
  48551. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48552. /**
  48553. * Creates a WebXRRenderTarget object for the XR session
  48554. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48555. * @param options optional options to provide when creating a new render target
  48556. * @returns a WebXR render target to which the session can render
  48557. */
  48558. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48559. /**
  48560. * Initializes the manager
  48561. * After initialization enterXR can be called to start an XR session
  48562. * @returns Promise which resolves after it is initialized
  48563. */
  48564. initializeAsync(): Promise<void>;
  48565. /**
  48566. * Initializes an xr session
  48567. * @param xrSessionMode mode to initialize
  48568. * @param xrSessionInit defines optional and required values to pass to the session builder
  48569. * @returns a promise which will resolve once the session has been initialized
  48570. */
  48571. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48572. /**
  48573. * Checks if a session would be supported for the creation options specified
  48574. * @param sessionMode session mode to check if supported eg. immersive-vr
  48575. * @returns A Promise that resolves to true if supported and false if not
  48576. */
  48577. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48578. /**
  48579. * Resets the reference space to the one started the session
  48580. */
  48581. resetReferenceSpace(): void;
  48582. /**
  48583. * Starts rendering to the xr layer
  48584. */
  48585. runXRRenderLoop(): void;
  48586. /**
  48587. * Sets the reference space on the xr session
  48588. * @param referenceSpaceType space to set
  48589. * @returns a promise that will resolve once the reference space has been set
  48590. */
  48591. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48592. /**
  48593. * Updates the render state of the session
  48594. * @param state state to set
  48595. * @returns a promise that resolves once the render state has been updated
  48596. */
  48597. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48598. /**
  48599. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48600. * @param sessionMode defines the session to test
  48601. * @returns a promise with boolean as final value
  48602. */
  48603. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48604. private _createRenderTargetTexture;
  48605. }
  48606. }
  48607. declare module "babylonjs/XR/webXRCamera" {
  48608. import { Vector3 } from "babylonjs/Maths/math.vector";
  48609. import { Scene } from "babylonjs/scene";
  48610. import { Camera } from "babylonjs/Cameras/camera";
  48611. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48612. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48613. import { Observable } from "babylonjs/Misc/observable";
  48614. /**
  48615. * WebXR Camera which holds the views for the xrSession
  48616. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48617. */
  48618. export class WebXRCamera extends FreeCamera {
  48619. private _xrSessionManager;
  48620. private _firstFrame;
  48621. private _referenceQuaternion;
  48622. private _referencedPosition;
  48623. private _xrInvPositionCache;
  48624. private _xrInvQuaternionCache;
  48625. /**
  48626. * Observable raised before camera teleportation
  48627. */
  48628. onBeforeCameraTeleport: Observable<Vector3>;
  48629. /**
  48630. * Observable raised after camera teleportation
  48631. */
  48632. onAfterCameraTeleport: Observable<Vector3>;
  48633. /**
  48634. * Should position compensation execute on first frame.
  48635. * This is used when copying the position from a native (non XR) camera
  48636. */
  48637. compensateOnFirstFrame: boolean;
  48638. /**
  48639. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48640. * @param name the name of the camera
  48641. * @param scene the scene to add the camera to
  48642. * @param _xrSessionManager a constructed xr session manager
  48643. */
  48644. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48645. /**
  48646. * Return the user's height, unrelated to the current ground.
  48647. * This will be the y position of this camera, when ground level is 0.
  48648. */
  48649. get realWorldHeight(): number;
  48650. /** @hidden */
  48651. _updateForDualEyeDebugging(): void;
  48652. /**
  48653. * Sets this camera's transformation based on a non-vr camera
  48654. * @param otherCamera the non-vr camera to copy the transformation from
  48655. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48656. */
  48657. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48658. /**
  48659. * Gets the current instance class name ("WebXRCamera").
  48660. * @returns the class name
  48661. */
  48662. getClassName(): string;
  48663. private _rotate180;
  48664. private _updateFromXRSession;
  48665. private _updateNumberOfRigCameras;
  48666. private _updateReferenceSpace;
  48667. private _updateReferenceSpaceOffset;
  48668. }
  48669. }
  48670. declare module "babylonjs/XR/webXRFeaturesManager" {
  48671. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48672. import { IDisposable } from "babylonjs/scene";
  48673. /**
  48674. * Defining the interface required for a (webxr) feature
  48675. */
  48676. export interface IWebXRFeature extends IDisposable {
  48677. /**
  48678. * Is this feature attached
  48679. */
  48680. attached: boolean;
  48681. /**
  48682. * Should auto-attach be disabled?
  48683. */
  48684. disableAutoAttach: boolean;
  48685. /**
  48686. * Attach the feature to the session
  48687. * Will usually be called by the features manager
  48688. *
  48689. * @param force should attachment be forced (even when already attached)
  48690. * @returns true if successful.
  48691. */
  48692. attach(force?: boolean): boolean;
  48693. /**
  48694. * Detach the feature from the session
  48695. * Will usually be called by the features manager
  48696. *
  48697. * @returns true if successful.
  48698. */
  48699. detach(): boolean;
  48700. /**
  48701. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48702. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48703. *
  48704. * @returns whether or not the feature is compatible in this environment
  48705. */
  48706. isCompatible(): boolean;
  48707. /**
  48708. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48709. */
  48710. xrNativeFeatureName?: string;
  48711. }
  48712. /**
  48713. * A list of the currently available features without referencing them
  48714. */
  48715. export class WebXRFeatureName {
  48716. /**
  48717. * The name of the anchor system feature
  48718. */
  48719. static ANCHOR_SYSTEM: string;
  48720. /**
  48721. * The name of the background remover feature
  48722. */
  48723. static BACKGROUND_REMOVER: string;
  48724. /**
  48725. * The name of the hit test feature
  48726. */
  48727. static HIT_TEST: string;
  48728. /**
  48729. * physics impostors for xr controllers feature
  48730. */
  48731. static PHYSICS_CONTROLLERS: string;
  48732. /**
  48733. * The name of the plane detection feature
  48734. */
  48735. static PLANE_DETECTION: string;
  48736. /**
  48737. * The name of the pointer selection feature
  48738. */
  48739. static POINTER_SELECTION: string;
  48740. /**
  48741. * The name of the teleportation feature
  48742. */
  48743. static TELEPORTATION: string;
  48744. }
  48745. /**
  48746. * Defining the constructor of a feature. Used to register the modules.
  48747. */
  48748. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48749. /**
  48750. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48751. * It is mainly used in AR sessions.
  48752. *
  48753. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48754. */
  48755. export class WebXRFeaturesManager implements IDisposable {
  48756. private _xrSessionManager;
  48757. private static readonly _AvailableFeatures;
  48758. private _features;
  48759. /**
  48760. * constructs a new features manages.
  48761. *
  48762. * @param _xrSessionManager an instance of WebXRSessionManager
  48763. */
  48764. constructor(_xrSessionManager: WebXRSessionManager);
  48765. /**
  48766. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48767. * Mainly used internally.
  48768. *
  48769. * @param featureName the name of the feature to register
  48770. * @param constructorFunction the function used to construct the module
  48771. * @param version the (babylon) version of the module
  48772. * @param stable is that a stable version of this module
  48773. */
  48774. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48775. /**
  48776. * Returns a constructor of a specific feature.
  48777. *
  48778. * @param featureName the name of the feature to construct
  48779. * @param version the version of the feature to load
  48780. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48781. * @param options optional options provided to the module.
  48782. * @returns a function that, when called, will return a new instance of this feature
  48783. */
  48784. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  48785. /**
  48786. * Can be used to return the list of features currently registered
  48787. *
  48788. * @returns an Array of available features
  48789. */
  48790. static GetAvailableFeatures(): string[];
  48791. /**
  48792. * Gets the versions available for a specific feature
  48793. * @param featureName the name of the feature
  48794. * @returns an array with the available versions
  48795. */
  48796. static GetAvailableVersions(featureName: string): string[];
  48797. /**
  48798. * Return the latest unstable version of this feature
  48799. * @param featureName the name of the feature to search
  48800. * @returns the version number. if not found will return -1
  48801. */
  48802. static GetLatestVersionOfFeature(featureName: string): number;
  48803. /**
  48804. * Return the latest stable version of this feature
  48805. * @param featureName the name of the feature to search
  48806. * @returns the version number. if not found will return -1
  48807. */
  48808. static GetStableVersionOfFeature(featureName: string): number;
  48809. /**
  48810. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48811. * Can be used during a session to start a feature
  48812. * @param featureName the name of feature to attach
  48813. */
  48814. attachFeature(featureName: string): void;
  48815. /**
  48816. * Can be used inside a session or when the session ends to detach a specific feature
  48817. * @param featureName the name of the feature to detach
  48818. */
  48819. detachFeature(featureName: string): void;
  48820. /**
  48821. * Used to disable an already-enabled feature
  48822. * The feature will be disposed and will be recreated once enabled.
  48823. * @param featureName the feature to disable
  48824. * @returns true if disable was successful
  48825. */
  48826. disableFeature(featureName: string | {
  48827. Name: string;
  48828. }): boolean;
  48829. /**
  48830. * dispose this features manager
  48831. */
  48832. dispose(): void;
  48833. /**
  48834. * 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.
  48835. * 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.
  48836. *
  48837. * @param featureName the name of the feature to load or the class of the feature
  48838. * @param version optional version to load. if not provided the latest version will be enabled
  48839. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48840. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48841. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  48842. * @returns a new constructed feature or throws an error if feature not found.
  48843. */
  48844. enableFeature(featureName: string | {
  48845. Name: string;
  48846. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  48847. /**
  48848. * get the implementation of an enabled feature.
  48849. * @param featureName the name of the feature to load
  48850. * @returns the feature class, if found
  48851. */
  48852. getEnabledFeature(featureName: string): IWebXRFeature;
  48853. /**
  48854. * Get the list of enabled features
  48855. * @returns an array of enabled features
  48856. */
  48857. getEnabledFeatures(): string[];
  48858. /**
  48859. * This function will exten the session creation configuration object with enabled features.
  48860. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  48861. * according to the defined "required" variable, provided during enableFeature call
  48862. * @param xrSessionInit the xr Session init object to extend
  48863. *
  48864. * @returns an extended XRSessionInit object
  48865. */
  48866. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  48867. }
  48868. }
  48869. declare module "babylonjs/XR/webXRExperienceHelper" {
  48870. import { Observable } from "babylonjs/Misc/observable";
  48871. import { IDisposable, Scene } from "babylonjs/scene";
  48872. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48873. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48874. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48875. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48876. /**
  48877. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48878. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48879. */
  48880. export class WebXRExperienceHelper implements IDisposable {
  48881. private scene;
  48882. private _nonVRCamera;
  48883. private _originalSceneAutoClear;
  48884. private _supported;
  48885. /**
  48886. * Camera used to render xr content
  48887. */
  48888. camera: WebXRCamera;
  48889. /** A features manager for this xr session */
  48890. featuresManager: WebXRFeaturesManager;
  48891. /**
  48892. * Observers registered here will be triggered after the camera's initial transformation is set
  48893. * This can be used to set a different ground level or an extra rotation.
  48894. *
  48895. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48896. * to the position set after this observable is done executing.
  48897. */
  48898. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48899. /**
  48900. * Fires when the state of the experience helper has changed
  48901. */
  48902. onStateChangedObservable: Observable<WebXRState>;
  48903. /** Session manager used to keep track of xr session */
  48904. sessionManager: WebXRSessionManager;
  48905. /**
  48906. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48907. */
  48908. state: WebXRState;
  48909. /**
  48910. * Creates a WebXRExperienceHelper
  48911. * @param scene The scene the helper should be created in
  48912. */
  48913. private constructor();
  48914. /**
  48915. * Creates the experience helper
  48916. * @param scene the scene to attach the experience helper to
  48917. * @returns a promise for the experience helper
  48918. */
  48919. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48920. /**
  48921. * Disposes of the experience helper
  48922. */
  48923. dispose(): void;
  48924. /**
  48925. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48926. * @param sessionMode options for the XR session
  48927. * @param referenceSpaceType frame of reference of the XR session
  48928. * @param renderTarget the output canvas that will be used to enter XR mode
  48929. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48930. * @returns promise that resolves after xr mode has entered
  48931. */
  48932. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48933. /**
  48934. * Exits XR mode and returns the scene to its original state
  48935. * @returns promise that resolves after xr mode has exited
  48936. */
  48937. exitXRAsync(): Promise<void>;
  48938. private _nonXRToXRCamera;
  48939. private _setState;
  48940. }
  48941. }
  48942. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48943. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48944. import { Observable } from "babylonjs/Misc/observable";
  48945. import { IDisposable } from "babylonjs/scene";
  48946. /**
  48947. * X-Y values for axes in WebXR
  48948. */
  48949. export interface IWebXRMotionControllerAxesValue {
  48950. /**
  48951. * The value of the x axis
  48952. */
  48953. x: number;
  48954. /**
  48955. * The value of the y-axis
  48956. */
  48957. y: number;
  48958. }
  48959. /**
  48960. * changed / previous values for the values of this component
  48961. */
  48962. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48963. /**
  48964. * current (this frame) value
  48965. */
  48966. current: T;
  48967. /**
  48968. * previous (last change) value
  48969. */
  48970. previous: T;
  48971. }
  48972. /**
  48973. * Represents changes in the component between current frame and last values recorded
  48974. */
  48975. export interface IWebXRMotionControllerComponentChanges {
  48976. /**
  48977. * will be populated with previous and current values if axes changed
  48978. */
  48979. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48980. /**
  48981. * will be populated with previous and current values if pressed changed
  48982. */
  48983. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48984. /**
  48985. * will be populated with previous and current values if touched changed
  48986. */
  48987. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48988. /**
  48989. * will be populated with previous and current values if value changed
  48990. */
  48991. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48992. }
  48993. /**
  48994. * This class represents a single component (for example button or thumbstick) of a motion controller
  48995. */
  48996. export class WebXRControllerComponent implements IDisposable {
  48997. /**
  48998. * the id of this component
  48999. */
  49000. id: string;
  49001. /**
  49002. * the type of the component
  49003. */
  49004. type: MotionControllerComponentType;
  49005. private _buttonIndex;
  49006. private _axesIndices;
  49007. private _axes;
  49008. private _changes;
  49009. private _currentValue;
  49010. private _hasChanges;
  49011. private _pressed;
  49012. private _touched;
  49013. /**
  49014. * button component type
  49015. */
  49016. static BUTTON_TYPE: MotionControllerComponentType;
  49017. /**
  49018. * squeeze component type
  49019. */
  49020. static SQUEEZE_TYPE: MotionControllerComponentType;
  49021. /**
  49022. * Thumbstick component type
  49023. */
  49024. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49025. /**
  49026. * Touchpad component type
  49027. */
  49028. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49029. /**
  49030. * trigger component type
  49031. */
  49032. static TRIGGER_TYPE: MotionControllerComponentType;
  49033. /**
  49034. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49035. * the axes data changes
  49036. */
  49037. onAxisValueChangedObservable: Observable<{
  49038. x: number;
  49039. y: number;
  49040. }>;
  49041. /**
  49042. * Observers registered here will be triggered when the state of a button changes
  49043. * State change is either pressed / touched / value
  49044. */
  49045. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49046. /**
  49047. * Creates a new component for a motion controller.
  49048. * It is created by the motion controller itself
  49049. *
  49050. * @param id the id of this component
  49051. * @param type the type of the component
  49052. * @param _buttonIndex index in the buttons array of the gamepad
  49053. * @param _axesIndices indices of the values in the axes array of the gamepad
  49054. */
  49055. constructor(
  49056. /**
  49057. * the id of this component
  49058. */
  49059. id: string,
  49060. /**
  49061. * the type of the component
  49062. */
  49063. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49064. /**
  49065. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49066. */
  49067. get axes(): IWebXRMotionControllerAxesValue;
  49068. /**
  49069. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49070. */
  49071. get changes(): IWebXRMotionControllerComponentChanges;
  49072. /**
  49073. * Return whether or not the component changed the last frame
  49074. */
  49075. get hasChanges(): boolean;
  49076. /**
  49077. * is the button currently pressed
  49078. */
  49079. get pressed(): boolean;
  49080. /**
  49081. * is the button currently touched
  49082. */
  49083. get touched(): boolean;
  49084. /**
  49085. * Get the current value of this component
  49086. */
  49087. get value(): number;
  49088. /**
  49089. * Dispose this component
  49090. */
  49091. dispose(): void;
  49092. /**
  49093. * Are there axes correlating to this component
  49094. * @return true is axes data is available
  49095. */
  49096. isAxes(): boolean;
  49097. /**
  49098. * Is this component a button (hence - pressable)
  49099. * @returns true if can be pressed
  49100. */
  49101. isButton(): boolean;
  49102. /**
  49103. * update this component using the gamepad object it is in. Called on every frame
  49104. * @param nativeController the native gamepad controller object
  49105. */
  49106. update(nativeController: IMinimalMotionControllerObject): void;
  49107. }
  49108. }
  49109. declare module "babylonjs/Loading/sceneLoader" {
  49110. import { Observable } from "babylonjs/Misc/observable";
  49111. import { Nullable } from "babylonjs/types";
  49112. import { Scene } from "babylonjs/scene";
  49113. import { Engine } from "babylonjs/Engines/engine";
  49114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49115. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49116. import { AssetContainer } from "babylonjs/assetContainer";
  49117. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49118. import { Skeleton } from "babylonjs/Bones/skeleton";
  49119. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49120. import { WebRequest } from "babylonjs/Misc/webRequest";
  49121. /**
  49122. * Interface used to represent data loading progression
  49123. */
  49124. export interface ISceneLoaderProgressEvent {
  49125. /**
  49126. * Defines if data length to load can be evaluated
  49127. */
  49128. readonly lengthComputable: boolean;
  49129. /**
  49130. * Defines the loaded data length
  49131. */
  49132. readonly loaded: number;
  49133. /**
  49134. * Defines the data length to load
  49135. */
  49136. readonly total: number;
  49137. }
  49138. /**
  49139. * Interface used by SceneLoader plugins to define supported file extensions
  49140. */
  49141. export interface ISceneLoaderPluginExtensions {
  49142. /**
  49143. * Defines the list of supported extensions
  49144. */
  49145. [extension: string]: {
  49146. isBinary: boolean;
  49147. };
  49148. }
  49149. /**
  49150. * Interface used by SceneLoader plugin factory
  49151. */
  49152. export interface ISceneLoaderPluginFactory {
  49153. /**
  49154. * Defines the name of the factory
  49155. */
  49156. name: string;
  49157. /**
  49158. * Function called to create a new plugin
  49159. * @return the new plugin
  49160. */
  49161. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49162. /**
  49163. * The callback that returns true if the data can be directly loaded.
  49164. * @param data string containing the file data
  49165. * @returns if the data can be loaded directly
  49166. */
  49167. canDirectLoad?(data: string): boolean;
  49168. }
  49169. /**
  49170. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49171. */
  49172. export interface ISceneLoaderPluginBase {
  49173. /**
  49174. * The friendly name of this plugin.
  49175. */
  49176. name: string;
  49177. /**
  49178. * The file extensions supported by this plugin.
  49179. */
  49180. extensions: string | ISceneLoaderPluginExtensions;
  49181. /**
  49182. * The callback called when loading from a url.
  49183. * @param scene scene loading this url
  49184. * @param url url to load
  49185. * @param onSuccess callback called when the file successfully loads
  49186. * @param onProgress callback called while file is loading (if the server supports this mode)
  49187. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49188. * @param onError callback called when the file fails to load
  49189. * @returns a file request object
  49190. */
  49191. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49192. /**
  49193. * The callback called when loading from a file object.
  49194. * @param scene scene loading this file
  49195. * @param file defines the file to load
  49196. * @param onSuccess defines the callback to call when data is loaded
  49197. * @param onProgress defines the callback to call during loading process
  49198. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49199. * @param onError defines the callback to call when an error occurs
  49200. * @returns a file request object
  49201. */
  49202. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49203. /**
  49204. * The callback that returns true if the data can be directly loaded.
  49205. * @param data string containing the file data
  49206. * @returns if the data can be loaded directly
  49207. */
  49208. canDirectLoad?(data: string): boolean;
  49209. /**
  49210. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49211. * @param scene scene loading this data
  49212. * @param data string containing the data
  49213. * @returns data to pass to the plugin
  49214. */
  49215. directLoad?(scene: Scene, data: string): any;
  49216. /**
  49217. * The callback that allows custom handling of the root url based on the response url.
  49218. * @param rootUrl the original root url
  49219. * @param responseURL the response url if available
  49220. * @returns the new root url
  49221. */
  49222. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49223. }
  49224. /**
  49225. * Interface used to define a SceneLoader plugin
  49226. */
  49227. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49228. /**
  49229. * Import meshes into a scene.
  49230. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49231. * @param scene The scene to import into
  49232. * @param data The data to import
  49233. * @param rootUrl The root url for scene and resources
  49234. * @param meshes The meshes array to import into
  49235. * @param particleSystems The particle systems array to import into
  49236. * @param skeletons The skeletons array to import into
  49237. * @param onError The callback when import fails
  49238. * @returns True if successful or false otherwise
  49239. */
  49240. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49241. /**
  49242. * Load into a scene.
  49243. * @param scene The scene to load into
  49244. * @param data The data to import
  49245. * @param rootUrl The root url for scene and resources
  49246. * @param onError The callback when import fails
  49247. * @returns True if successful or false otherwise
  49248. */
  49249. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49250. /**
  49251. * Load into an asset container.
  49252. * @param scene The scene to load into
  49253. * @param data The data to import
  49254. * @param rootUrl The root url for scene and resources
  49255. * @param onError The callback when import fails
  49256. * @returns The loaded asset container
  49257. */
  49258. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49259. }
  49260. /**
  49261. * Interface used to define an async SceneLoader plugin
  49262. */
  49263. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49264. /**
  49265. * Import meshes into a scene.
  49266. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49267. * @param scene The scene to import into
  49268. * @param data The data to import
  49269. * @param rootUrl The root url for scene and resources
  49270. * @param onProgress The callback when the load progresses
  49271. * @param fileName Defines the name of the file to load
  49272. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49273. */
  49274. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49275. meshes: AbstractMesh[];
  49276. particleSystems: IParticleSystem[];
  49277. skeletons: Skeleton[];
  49278. animationGroups: AnimationGroup[];
  49279. }>;
  49280. /**
  49281. * Load into a scene.
  49282. * @param scene The scene to load into
  49283. * @param data The data to import
  49284. * @param rootUrl The root url for scene and resources
  49285. * @param onProgress The callback when the load progresses
  49286. * @param fileName Defines the name of the file to load
  49287. * @returns Nothing
  49288. */
  49289. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49290. /**
  49291. * Load into an asset container.
  49292. * @param scene The scene to load into
  49293. * @param data The data to import
  49294. * @param rootUrl The root url for scene and resources
  49295. * @param onProgress The callback when the load progresses
  49296. * @param fileName Defines the name of the file to load
  49297. * @returns The loaded asset container
  49298. */
  49299. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49300. }
  49301. /**
  49302. * Mode that determines how to handle old animation groups before loading new ones.
  49303. */
  49304. export enum SceneLoaderAnimationGroupLoadingMode {
  49305. /**
  49306. * Reset all old animations to initial state then dispose them.
  49307. */
  49308. Clean = 0,
  49309. /**
  49310. * Stop all old animations.
  49311. */
  49312. Stop = 1,
  49313. /**
  49314. * Restart old animations from first frame.
  49315. */
  49316. Sync = 2,
  49317. /**
  49318. * Old animations remains untouched.
  49319. */
  49320. NoSync = 3
  49321. }
  49322. /**
  49323. * Defines a plugin registered by the SceneLoader
  49324. */
  49325. interface IRegisteredPlugin {
  49326. /**
  49327. * Defines the plugin to use
  49328. */
  49329. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49330. /**
  49331. * Defines if the plugin supports binary data
  49332. */
  49333. isBinary: boolean;
  49334. }
  49335. /**
  49336. * Class used to load scene from various file formats using registered plugins
  49337. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49338. */
  49339. export class SceneLoader {
  49340. /**
  49341. * No logging while loading
  49342. */
  49343. static readonly NO_LOGGING: number;
  49344. /**
  49345. * Minimal logging while loading
  49346. */
  49347. static readonly MINIMAL_LOGGING: number;
  49348. /**
  49349. * Summary logging while loading
  49350. */
  49351. static readonly SUMMARY_LOGGING: number;
  49352. /**
  49353. * Detailled logging while loading
  49354. */
  49355. static readonly DETAILED_LOGGING: number;
  49356. /**
  49357. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49358. */
  49359. static get ForceFullSceneLoadingForIncremental(): boolean;
  49360. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49361. /**
  49362. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49363. */
  49364. static get ShowLoadingScreen(): boolean;
  49365. static set ShowLoadingScreen(value: boolean);
  49366. /**
  49367. * Defines the current logging level (while loading the scene)
  49368. * @ignorenaming
  49369. */
  49370. static get loggingLevel(): number;
  49371. static set loggingLevel(value: number);
  49372. /**
  49373. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49374. */
  49375. static get CleanBoneMatrixWeights(): boolean;
  49376. static set CleanBoneMatrixWeights(value: boolean);
  49377. /**
  49378. * Event raised when a plugin is used to load a scene
  49379. */
  49380. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49381. private static _registeredPlugins;
  49382. private static _showingLoadingScreen;
  49383. /**
  49384. * Gets the default plugin (used to load Babylon files)
  49385. * @returns the .babylon plugin
  49386. */
  49387. static GetDefaultPlugin(): IRegisteredPlugin;
  49388. private static _GetPluginForExtension;
  49389. private static _GetPluginForDirectLoad;
  49390. private static _GetPluginForFilename;
  49391. private static _GetDirectLoad;
  49392. private static _LoadData;
  49393. private static _GetFileInfo;
  49394. /**
  49395. * Gets a plugin that can load the given extension
  49396. * @param extension defines the extension to load
  49397. * @returns a plugin or null if none works
  49398. */
  49399. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49400. /**
  49401. * Gets a boolean indicating that the given extension can be loaded
  49402. * @param extension defines the extension to load
  49403. * @returns true if the extension is supported
  49404. */
  49405. static IsPluginForExtensionAvailable(extension: string): boolean;
  49406. /**
  49407. * Adds a new plugin to the list of registered plugins
  49408. * @param plugin defines the plugin to add
  49409. */
  49410. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49411. /**
  49412. * Import meshes into a scene
  49413. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49414. * @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)
  49415. * @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)
  49416. * @param scene the instance of BABYLON.Scene to append to
  49417. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49418. * @param onProgress a callback with a progress event for each file being loaded
  49419. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49420. * @param pluginExtension the extension used to determine the plugin
  49421. * @returns The loaded plugin
  49422. */
  49423. 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>;
  49424. /**
  49425. * Import meshes into a scene
  49426. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49427. * @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)
  49428. * @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)
  49429. * @param scene the instance of BABYLON.Scene to append to
  49430. * @param onProgress a callback with a progress event for each file being loaded
  49431. * @param pluginExtension the extension used to determine the plugin
  49432. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49433. */
  49434. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49435. meshes: AbstractMesh[];
  49436. particleSystems: IParticleSystem[];
  49437. skeletons: Skeleton[];
  49438. animationGroups: AnimationGroup[];
  49439. }>;
  49440. /**
  49441. * Load a scene
  49442. * @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)
  49443. * @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)
  49444. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49445. * @param onSuccess a callback with the scene when import succeeds
  49446. * @param onProgress a callback with a progress event for each file being loaded
  49447. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49448. * @param pluginExtension the extension used to determine the plugin
  49449. * @returns The loaded plugin
  49450. */
  49451. 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>;
  49452. /**
  49453. * Load a scene
  49454. * @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)
  49455. * @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)
  49456. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49457. * @param onProgress a callback with a progress event for each file being loaded
  49458. * @param pluginExtension the extension used to determine the plugin
  49459. * @returns The loaded scene
  49460. */
  49461. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49462. /**
  49463. * Append a scene
  49464. * @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)
  49465. * @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)
  49466. * @param scene is the instance of BABYLON.Scene to append to
  49467. * @param onSuccess a callback with the scene when import succeeds
  49468. * @param onProgress a callback with a progress event for each file being loaded
  49469. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49470. * @param pluginExtension the extension used to determine the plugin
  49471. * @returns The loaded plugin
  49472. */
  49473. 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>;
  49474. /**
  49475. * Append a scene
  49476. * @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)
  49477. * @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)
  49478. * @param scene is the instance of BABYLON.Scene to append to
  49479. * @param onProgress a callback with a progress event for each file being loaded
  49480. * @param pluginExtension the extension used to determine the plugin
  49481. * @returns The given scene
  49482. */
  49483. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49484. /**
  49485. * Load a scene into an asset container
  49486. * @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)
  49487. * @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)
  49488. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49489. * @param onSuccess a callback with the scene when import succeeds
  49490. * @param onProgress a callback with a progress event for each file being loaded
  49491. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49492. * @param pluginExtension the extension used to determine the plugin
  49493. * @returns The loaded plugin
  49494. */
  49495. 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>;
  49496. /**
  49497. * Load a scene into an asset container
  49498. * @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)
  49499. * @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)
  49500. * @param scene is the instance of Scene to append to
  49501. * @param onProgress a callback with a progress event for each file being loaded
  49502. * @param pluginExtension the extension used to determine the plugin
  49503. * @returns The loaded asset container
  49504. */
  49505. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49506. /**
  49507. * Import animations from a file into a scene
  49508. * @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)
  49509. * @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)
  49510. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49511. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49512. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49513. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49514. * @param onSuccess a callback with the scene when import succeeds
  49515. * @param onProgress a callback with a progress event for each file being loaded
  49516. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49517. * @param pluginExtension the extension used to determine the plugin
  49518. */
  49519. 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;
  49520. /**
  49521. * Import animations from a file into a scene
  49522. * @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)
  49523. * @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)
  49524. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49525. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49526. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49527. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49528. * @param onSuccess a callback with the scene when import succeeds
  49529. * @param onProgress a callback with a progress event for each file being loaded
  49530. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49531. * @param pluginExtension the extension used to determine the plugin
  49532. * @returns the updated scene with imported animations
  49533. */
  49534. 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>;
  49535. }
  49536. }
  49537. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49538. import { IDisposable, Scene } from "babylonjs/scene";
  49539. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49540. import { Observable } from "babylonjs/Misc/observable";
  49541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49542. import { Nullable } from "babylonjs/types";
  49543. /**
  49544. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49545. */
  49546. export type MotionControllerHandedness = "none" | "left" | "right";
  49547. /**
  49548. * The type of components available in motion controllers.
  49549. * This is not the name of the component.
  49550. */
  49551. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49552. /**
  49553. * The state of a controller component
  49554. */
  49555. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49556. /**
  49557. * The schema of motion controller layout.
  49558. * No object will be initialized using this interface
  49559. * This is used just to define the profile.
  49560. */
  49561. export interface IMotionControllerLayout {
  49562. /**
  49563. * Path to load the assets. Usually relative to the base path
  49564. */
  49565. assetPath: string;
  49566. /**
  49567. * Available components (unsorted)
  49568. */
  49569. components: {
  49570. /**
  49571. * A map of component Ids
  49572. */
  49573. [componentId: string]: {
  49574. /**
  49575. * The type of input the component outputs
  49576. */
  49577. type: MotionControllerComponentType;
  49578. /**
  49579. * The indices of this component in the gamepad object
  49580. */
  49581. gamepadIndices: {
  49582. /**
  49583. * Index of button
  49584. */
  49585. button?: number;
  49586. /**
  49587. * If available, index of x-axis
  49588. */
  49589. xAxis?: number;
  49590. /**
  49591. * If available, index of y-axis
  49592. */
  49593. yAxis?: number;
  49594. };
  49595. /**
  49596. * The mesh's root node name
  49597. */
  49598. rootNodeName: string;
  49599. /**
  49600. * Animation definitions for this model
  49601. */
  49602. visualResponses: {
  49603. [stateKey: string]: {
  49604. /**
  49605. * What property will be animated
  49606. */
  49607. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49608. /**
  49609. * What states influence this visual response
  49610. */
  49611. states: MotionControllerComponentStateType[];
  49612. /**
  49613. * Type of animation - movement or visibility
  49614. */
  49615. valueNodeProperty: "transform" | "visibility";
  49616. /**
  49617. * Base node name to move. Its position will be calculated according to the min and max nodes
  49618. */
  49619. valueNodeName?: string;
  49620. /**
  49621. * Minimum movement node
  49622. */
  49623. minNodeName?: string;
  49624. /**
  49625. * Max movement node
  49626. */
  49627. maxNodeName?: string;
  49628. };
  49629. };
  49630. /**
  49631. * If touch enabled, what is the name of node to display user feedback
  49632. */
  49633. touchPointNodeName?: string;
  49634. };
  49635. };
  49636. /**
  49637. * Is it xr standard mapping or not
  49638. */
  49639. gamepadMapping: "" | "xr-standard";
  49640. /**
  49641. * Base root node of this entire model
  49642. */
  49643. rootNodeName: string;
  49644. /**
  49645. * Defines the main button component id
  49646. */
  49647. selectComponentId: string;
  49648. }
  49649. /**
  49650. * A definition for the layout map in the input profile
  49651. */
  49652. export interface IMotionControllerLayoutMap {
  49653. /**
  49654. * Layouts with handedness type as a key
  49655. */
  49656. [handedness: string]: IMotionControllerLayout;
  49657. }
  49658. /**
  49659. * The XR Input profile schema
  49660. * Profiles can be found here:
  49661. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49662. */
  49663. export interface IMotionControllerProfile {
  49664. /**
  49665. * fallback profiles for this profileId
  49666. */
  49667. fallbackProfileIds: string[];
  49668. /**
  49669. * The layout map, with handedness as key
  49670. */
  49671. layouts: IMotionControllerLayoutMap;
  49672. /**
  49673. * The id of this profile
  49674. * correlates to the profile(s) in the xrInput.profiles array
  49675. */
  49676. profileId: string;
  49677. }
  49678. /**
  49679. * A helper-interface for the 3 meshes needed for controller button animation
  49680. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49681. */
  49682. export interface IMotionControllerButtonMeshMap {
  49683. /**
  49684. * the mesh that defines the pressed value mesh position.
  49685. * This is used to find the max-position of this button
  49686. */
  49687. pressedMesh: AbstractMesh;
  49688. /**
  49689. * the mesh that defines the unpressed value mesh position.
  49690. * This is used to find the min (or initial) position of this button
  49691. */
  49692. unpressedMesh: AbstractMesh;
  49693. /**
  49694. * The mesh that will be changed when value changes
  49695. */
  49696. valueMesh: AbstractMesh;
  49697. }
  49698. /**
  49699. * A helper-interface for the 3 meshes needed for controller axis animation.
  49700. * This will be expanded when touchpad animations are fully supported
  49701. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49702. */
  49703. export interface IMotionControllerMeshMap {
  49704. /**
  49705. * the mesh that defines the maximum value mesh position.
  49706. */
  49707. maxMesh?: AbstractMesh;
  49708. /**
  49709. * the mesh that defines the minimum value mesh position.
  49710. */
  49711. minMesh?: AbstractMesh;
  49712. /**
  49713. * The mesh that will be changed when axis value changes
  49714. */
  49715. valueMesh: AbstractMesh;
  49716. }
  49717. /**
  49718. * The elements needed for change-detection of the gamepad objects in motion controllers
  49719. */
  49720. export interface IMinimalMotionControllerObject {
  49721. /**
  49722. * Available axes of this controller
  49723. */
  49724. axes: number[];
  49725. /**
  49726. * An array of available buttons
  49727. */
  49728. buttons: Array<{
  49729. /**
  49730. * Value of the button/trigger
  49731. */
  49732. value: number;
  49733. /**
  49734. * If the button/trigger is currently touched
  49735. */
  49736. touched: boolean;
  49737. /**
  49738. * If the button/trigger is currently pressed
  49739. */
  49740. pressed: boolean;
  49741. }>;
  49742. /**
  49743. * EXPERIMENTAL haptic support.
  49744. */
  49745. hapticActuators?: Array<{
  49746. pulse: (value: number, duration: number) => Promise<boolean>;
  49747. }>;
  49748. }
  49749. /**
  49750. * An Abstract Motion controller
  49751. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49752. * Each component has an observable to check for changes in value and state
  49753. */
  49754. export abstract class WebXRAbstractMotionController implements IDisposable {
  49755. protected scene: Scene;
  49756. protected layout: IMotionControllerLayout;
  49757. /**
  49758. * The gamepad object correlating to this controller
  49759. */
  49760. gamepadObject: IMinimalMotionControllerObject;
  49761. /**
  49762. * handedness (left/right/none) of this controller
  49763. */
  49764. handedness: MotionControllerHandedness;
  49765. private _initComponent;
  49766. private _modelReady;
  49767. /**
  49768. * A map of components (WebXRControllerComponent) in this motion controller
  49769. * Components have a ComponentType and can also have both button and axis definitions
  49770. */
  49771. readonly components: {
  49772. [id: string]: WebXRControllerComponent;
  49773. };
  49774. /**
  49775. * Disable the model's animation. Can be set at any time.
  49776. */
  49777. disableAnimation: boolean;
  49778. /**
  49779. * Observers registered here will be triggered when the model of this controller is done loading
  49780. */
  49781. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49782. /**
  49783. * The profile id of this motion controller
  49784. */
  49785. abstract profileId: string;
  49786. /**
  49787. * The root mesh of the model. It is null if the model was not yet initialized
  49788. */
  49789. rootMesh: Nullable<AbstractMesh>;
  49790. /**
  49791. * constructs a new abstract motion controller
  49792. * @param scene the scene to which the model of the controller will be added
  49793. * @param layout The profile layout to load
  49794. * @param gamepadObject The gamepad object correlating to this controller
  49795. * @param handedness handedness (left/right/none) of this controller
  49796. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49797. */
  49798. constructor(scene: Scene, layout: IMotionControllerLayout,
  49799. /**
  49800. * The gamepad object correlating to this controller
  49801. */
  49802. gamepadObject: IMinimalMotionControllerObject,
  49803. /**
  49804. * handedness (left/right/none) of this controller
  49805. */
  49806. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49807. /**
  49808. * Dispose this controller, the model mesh and all its components
  49809. */
  49810. dispose(): void;
  49811. /**
  49812. * Returns all components of specific type
  49813. * @param type the type to search for
  49814. * @return an array of components with this type
  49815. */
  49816. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49817. /**
  49818. * get a component based an its component id as defined in layout.components
  49819. * @param id the id of the component
  49820. * @returns the component correlates to the id or undefined if not found
  49821. */
  49822. getComponent(id: string): WebXRControllerComponent;
  49823. /**
  49824. * Get the list of components available in this motion controller
  49825. * @returns an array of strings correlating to available components
  49826. */
  49827. getComponentIds(): string[];
  49828. /**
  49829. * Get the first component of specific type
  49830. * @param type type of component to find
  49831. * @return a controller component or null if not found
  49832. */
  49833. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49834. /**
  49835. * Get the main (Select) component of this controller as defined in the layout
  49836. * @returns the main component of this controller
  49837. */
  49838. getMainComponent(): WebXRControllerComponent;
  49839. /**
  49840. * Loads the model correlating to this controller
  49841. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49842. * @returns A promise fulfilled with the result of the model loading
  49843. */
  49844. loadModel(): Promise<boolean>;
  49845. /**
  49846. * Update this model using the current XRFrame
  49847. * @param xrFrame the current xr frame to use and update the model
  49848. */
  49849. updateFromXRFrame(xrFrame: XRFrame): void;
  49850. /**
  49851. * Backwards compatibility due to a deeply-integrated typo
  49852. */
  49853. get handness(): XREye;
  49854. /**
  49855. * Pulse (vibrate) this controller
  49856. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49857. * Consecutive calls to this function will cancel the last pulse call
  49858. *
  49859. * @param value the strength of the pulse in 0.0...1.0 range
  49860. * @param duration Duration of the pulse in milliseconds
  49861. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49862. * @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
  49863. */
  49864. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49865. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49866. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49867. /**
  49868. * Moves the axis on the controller mesh based on its current state
  49869. * @param axis the index of the axis
  49870. * @param axisValue the value of the axis which determines the meshes new position
  49871. * @hidden
  49872. */
  49873. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49874. /**
  49875. * Update the model itself with the current frame data
  49876. * @param xrFrame the frame to use for updating the model mesh
  49877. */
  49878. protected updateModel(xrFrame: XRFrame): void;
  49879. /**
  49880. * Get the filename and path for this controller's model
  49881. * @returns a map of filename and path
  49882. */
  49883. protected abstract _getFilenameAndPath(): {
  49884. filename: string;
  49885. path: string;
  49886. };
  49887. /**
  49888. * This function is called before the mesh is loaded. It checks for loading constraints.
  49889. * For example, this function can check if the GLB loader is available
  49890. * If this function returns false, the generic controller will be loaded instead
  49891. * @returns Is the client ready to load the mesh
  49892. */
  49893. protected abstract _getModelLoadingConstraints(): boolean;
  49894. /**
  49895. * This function will be called after the model was successfully loaded and can be used
  49896. * for mesh transformations before it is available for the user
  49897. * @param meshes the loaded meshes
  49898. */
  49899. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49900. /**
  49901. * Set the root mesh for this controller. Important for the WebXR controller class
  49902. * @param meshes the loaded meshes
  49903. */
  49904. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49905. /**
  49906. * A function executed each frame that updates the mesh (if needed)
  49907. * @param xrFrame the current xrFrame
  49908. */
  49909. protected abstract _updateModel(xrFrame: XRFrame): void;
  49910. private _getGenericFilenameAndPath;
  49911. private _getGenericParentMesh;
  49912. }
  49913. }
  49914. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49915. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49917. import { Scene } from "babylonjs/scene";
  49918. /**
  49919. * A generic trigger-only motion controller for WebXR
  49920. */
  49921. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49922. /**
  49923. * Static version of the profile id of this controller
  49924. */
  49925. static ProfileId: string;
  49926. profileId: string;
  49927. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49928. protected _getFilenameAndPath(): {
  49929. filename: string;
  49930. path: string;
  49931. };
  49932. protected _getModelLoadingConstraints(): boolean;
  49933. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49934. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49935. protected _updateModel(): void;
  49936. }
  49937. }
  49938. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49939. import { Vector4 } from "babylonjs/Maths/math.vector";
  49940. import { Mesh } from "babylonjs/Meshes/mesh";
  49941. import { Scene } from "babylonjs/scene";
  49942. import { Nullable } from "babylonjs/types";
  49943. /**
  49944. * Class containing static functions to help procedurally build meshes
  49945. */
  49946. export class SphereBuilder {
  49947. /**
  49948. * Creates a sphere mesh
  49949. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49950. * * 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`)
  49951. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49952. * * 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
  49953. * * 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)
  49954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49957. * @param name defines the name of the mesh
  49958. * @param options defines the options used to create the mesh
  49959. * @param scene defines the hosting scene
  49960. * @returns the sphere mesh
  49961. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49962. */
  49963. static CreateSphere(name: string, options: {
  49964. segments?: number;
  49965. diameter?: number;
  49966. diameterX?: number;
  49967. diameterY?: number;
  49968. diameterZ?: number;
  49969. arc?: number;
  49970. slice?: number;
  49971. sideOrientation?: number;
  49972. frontUVs?: Vector4;
  49973. backUVs?: Vector4;
  49974. updatable?: boolean;
  49975. }, scene?: Nullable<Scene>): Mesh;
  49976. }
  49977. }
  49978. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49980. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49981. import { Scene } from "babylonjs/scene";
  49982. /**
  49983. * A profiled motion controller has its profile loaded from an online repository.
  49984. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49985. */
  49986. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49987. private _repositoryUrl;
  49988. private _buttonMeshMapping;
  49989. private _touchDots;
  49990. /**
  49991. * The profile ID of this controller. Will be populated when the controller initializes.
  49992. */
  49993. profileId: string;
  49994. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49995. dispose(): void;
  49996. protected _getFilenameAndPath(): {
  49997. filename: string;
  49998. path: string;
  49999. };
  50000. protected _getModelLoadingConstraints(): boolean;
  50001. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50002. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50003. protected _updateModel(_xrFrame: XRFrame): void;
  50004. }
  50005. }
  50006. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50007. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50008. import { Scene } from "babylonjs/scene";
  50009. /**
  50010. * A construction function type to create a new controller based on an xrInput object
  50011. */
  50012. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50013. /**
  50014. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50015. *
  50016. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50017. * it should be replaced with auto-loaded controllers.
  50018. *
  50019. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50020. */
  50021. export class WebXRMotionControllerManager {
  50022. private static _AvailableControllers;
  50023. private static _Fallbacks;
  50024. private static _ProfileLoadingPromises;
  50025. private static _ProfilesList;
  50026. /**
  50027. * The base URL of the online controller repository. Can be changed at any time.
  50028. */
  50029. static BaseRepositoryUrl: string;
  50030. /**
  50031. * Which repository gets priority - local or online
  50032. */
  50033. static PrioritizeOnlineRepository: boolean;
  50034. /**
  50035. * Use the online repository, or use only locally-defined controllers
  50036. */
  50037. static UseOnlineRepository: boolean;
  50038. /**
  50039. * Clear the cache used for profile loading and reload when requested again
  50040. */
  50041. static ClearProfilesCache(): void;
  50042. /**
  50043. * Register the default fallbacks.
  50044. * This function is called automatically when this file is imported.
  50045. */
  50046. static DefaultFallbacks(): void;
  50047. /**
  50048. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50049. * @param profileId the profile to which a fallback needs to be found
  50050. * @return an array with corresponding fallback profiles
  50051. */
  50052. static FindFallbackWithProfileId(profileId: string): string[];
  50053. /**
  50054. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50055. * The order of search:
  50056. *
  50057. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50058. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50059. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50060. * 4) return the generic trigger controller if none were found
  50061. *
  50062. * @param xrInput the xrInput to which a new controller is initialized
  50063. * @param scene the scene to which the model will be added
  50064. * @param forceProfile force a certain profile for this controller
  50065. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50066. */
  50067. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50068. /**
  50069. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50070. *
  50071. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50072. *
  50073. * @param type the profile type to register
  50074. * @param constructFunction the function to be called when loading this profile
  50075. */
  50076. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50077. /**
  50078. * Register a fallback to a specific profile.
  50079. * @param profileId the profileId that will receive the fallbacks
  50080. * @param fallbacks A list of fallback profiles
  50081. */
  50082. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50083. /**
  50084. * Will update the list of profiles available in the repository
  50085. * @return a promise that resolves to a map of profiles available online
  50086. */
  50087. static UpdateProfilesList(): Promise<{
  50088. [profile: string]: string;
  50089. }>;
  50090. private static _LoadProfileFromRepository;
  50091. private static _LoadProfilesFromAvailableControllers;
  50092. }
  50093. }
  50094. declare module "babylonjs/XR/webXRInputSource" {
  50095. import { Observable } from "babylonjs/Misc/observable";
  50096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50097. import { Ray } from "babylonjs/Culling/ray";
  50098. import { Scene } from "babylonjs/scene";
  50099. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50100. /**
  50101. * Configuration options for the WebXR controller creation
  50102. */
  50103. export interface IWebXRControllerOptions {
  50104. /**
  50105. * Should the controller mesh be animated when a user interacts with it
  50106. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50107. */
  50108. disableMotionControllerAnimation?: boolean;
  50109. /**
  50110. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50111. */
  50112. doNotLoadControllerMesh?: boolean;
  50113. /**
  50114. * Force a specific controller type for this controller.
  50115. * This can be used when creating your own profile or when testing different controllers
  50116. */
  50117. forceControllerProfile?: string;
  50118. /**
  50119. * Defines a rendering group ID for meshes that will be loaded.
  50120. * This is for the default controllers only.
  50121. */
  50122. renderingGroupId?: number;
  50123. }
  50124. /**
  50125. * Represents an XR controller
  50126. */
  50127. export class WebXRInputSource {
  50128. private _scene;
  50129. /** The underlying input source for the controller */
  50130. inputSource: XRInputSource;
  50131. private _options;
  50132. private _tmpVector;
  50133. private _uniqueId;
  50134. /**
  50135. * 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
  50136. */
  50137. grip?: AbstractMesh;
  50138. /**
  50139. * If available, this is the gamepad object related to this controller.
  50140. * Using this object it is possible to get click events and trackpad changes of the
  50141. * webxr controller that is currently being used.
  50142. */
  50143. motionController?: WebXRAbstractMotionController;
  50144. /**
  50145. * Event that fires when the controller is removed/disposed.
  50146. * The object provided as event data is this controller, after associated assets were disposed.
  50147. * uniqueId is still available.
  50148. */
  50149. onDisposeObservable: Observable<WebXRInputSource>;
  50150. /**
  50151. * Will be triggered when the mesh associated with the motion controller is done loading.
  50152. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50153. * A shortened version of controller -> motion controller -> on mesh loaded.
  50154. */
  50155. onMeshLoadedObservable: Observable<AbstractMesh>;
  50156. /**
  50157. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50158. */
  50159. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50160. /**
  50161. * Pointer which can be used to select objects or attach a visible laser to
  50162. */
  50163. pointer: AbstractMesh;
  50164. /**
  50165. * Creates the input source object
  50166. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50167. * @param _scene the scene which the controller should be associated to
  50168. * @param inputSource the underlying input source for the controller
  50169. * @param _options options for this controller creation
  50170. */
  50171. constructor(_scene: Scene,
  50172. /** The underlying input source for the controller */
  50173. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50174. /**
  50175. * Get this controllers unique id
  50176. */
  50177. get uniqueId(): string;
  50178. /**
  50179. * Disposes of the object
  50180. */
  50181. dispose(): void;
  50182. /**
  50183. * Gets a world space ray coming from the pointer or grip
  50184. * @param result the resulting ray
  50185. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50186. */
  50187. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50188. /**
  50189. * Updates the controller pose based on the given XRFrame
  50190. * @param xrFrame xr frame to update the pose with
  50191. * @param referenceSpace reference space to use
  50192. */
  50193. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50194. }
  50195. }
  50196. declare module "babylonjs/XR/webXRInput" {
  50197. import { Observable } from "babylonjs/Misc/observable";
  50198. import { IDisposable } from "babylonjs/scene";
  50199. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50200. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50201. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50202. /**
  50203. * The schema for initialization options of the XR Input class
  50204. */
  50205. export interface IWebXRInputOptions {
  50206. /**
  50207. * If set to true no model will be automatically loaded
  50208. */
  50209. doNotLoadControllerMeshes?: boolean;
  50210. /**
  50211. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50212. * If not found, the xr input profile data will be used.
  50213. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50214. */
  50215. forceInputProfile?: string;
  50216. /**
  50217. * Do not send a request to the controller repository to load the profile.
  50218. *
  50219. * Instead, use the controllers available in babylon itself.
  50220. */
  50221. disableOnlineControllerRepository?: boolean;
  50222. /**
  50223. * A custom URL for the controllers repository
  50224. */
  50225. customControllersRepositoryURL?: string;
  50226. /**
  50227. * Should the controller model's components not move according to the user input
  50228. */
  50229. disableControllerAnimation?: boolean;
  50230. /**
  50231. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50232. */
  50233. controllerOptions?: IWebXRControllerOptions;
  50234. }
  50235. /**
  50236. * XR input used to track XR inputs such as controllers/rays
  50237. */
  50238. export class WebXRInput implements IDisposable {
  50239. /**
  50240. * the xr session manager for this session
  50241. */
  50242. xrSessionManager: WebXRSessionManager;
  50243. /**
  50244. * the WebXR camera for this session. Mainly used for teleportation
  50245. */
  50246. xrCamera: WebXRCamera;
  50247. private readonly options;
  50248. /**
  50249. * XR controllers being tracked
  50250. */
  50251. controllers: Array<WebXRInputSource>;
  50252. private _frameObserver;
  50253. private _sessionEndedObserver;
  50254. private _sessionInitObserver;
  50255. /**
  50256. * Event when a controller has been connected/added
  50257. */
  50258. onControllerAddedObservable: Observable<WebXRInputSource>;
  50259. /**
  50260. * Event when a controller has been removed/disconnected
  50261. */
  50262. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50263. /**
  50264. * Initializes the WebXRInput
  50265. * @param xrSessionManager the xr session manager for this session
  50266. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50267. * @param options = initialization options for this xr input
  50268. */
  50269. constructor(
  50270. /**
  50271. * the xr session manager for this session
  50272. */
  50273. xrSessionManager: WebXRSessionManager,
  50274. /**
  50275. * the WebXR camera for this session. Mainly used for teleportation
  50276. */
  50277. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50278. private _onInputSourcesChange;
  50279. private _addAndRemoveControllers;
  50280. /**
  50281. * Disposes of the object
  50282. */
  50283. dispose(): void;
  50284. }
  50285. }
  50286. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50287. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50288. import { Observable, EventState } from "babylonjs/Misc/observable";
  50289. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50290. /**
  50291. * This is the base class for all WebXR features.
  50292. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50293. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50294. */
  50295. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50296. protected _xrSessionManager: WebXRSessionManager;
  50297. private _attached;
  50298. private _removeOnDetach;
  50299. /**
  50300. * Should auto-attach be disabled?
  50301. */
  50302. disableAutoAttach: boolean;
  50303. /**
  50304. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50305. */
  50306. xrNativeFeatureName: string;
  50307. /**
  50308. * Construct a new (abstract) WebXR feature
  50309. * @param _xrSessionManager the xr session manager for this feature
  50310. */
  50311. constructor(_xrSessionManager: WebXRSessionManager);
  50312. /**
  50313. * Is this feature attached
  50314. */
  50315. get attached(): boolean;
  50316. /**
  50317. * attach this feature
  50318. *
  50319. * @param force should attachment be forced (even when already attached)
  50320. * @returns true if successful, false is failed or already attached
  50321. */
  50322. attach(force?: boolean): boolean;
  50323. /**
  50324. * detach this feature.
  50325. *
  50326. * @returns true if successful, false if failed or already detached
  50327. */
  50328. detach(): boolean;
  50329. /**
  50330. * Dispose this feature and all of the resources attached
  50331. */
  50332. dispose(): void;
  50333. /**
  50334. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50335. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50336. *
  50337. * @returns whether or not the feature is compatible in this environment
  50338. */
  50339. isCompatible(): boolean;
  50340. /**
  50341. * This is used to register callbacks that will automatically be removed when detach is called.
  50342. * @param observable the observable to which the observer will be attached
  50343. * @param callback the callback to register
  50344. */
  50345. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50346. /**
  50347. * Code in this function will be executed on each xrFrame received from the browser.
  50348. * This function will not execute after the feature is detached.
  50349. * @param _xrFrame the current frame
  50350. */
  50351. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50352. }
  50353. }
  50354. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50355. import { IDisposable, Scene } from "babylonjs/scene";
  50356. import { Nullable } from "babylonjs/types";
  50357. import { Observable } from "babylonjs/Misc/observable";
  50358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50359. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50360. import { Camera } from "babylonjs/Cameras/camera";
  50361. /**
  50362. * Renders a layer on top of an existing scene
  50363. */
  50364. export class UtilityLayerRenderer implements IDisposable {
  50365. /** the original scene that will be rendered on top of */
  50366. originalScene: Scene;
  50367. private _pointerCaptures;
  50368. private _lastPointerEvents;
  50369. private static _DefaultUtilityLayer;
  50370. private static _DefaultKeepDepthUtilityLayer;
  50371. private _sharedGizmoLight;
  50372. private _renderCamera;
  50373. /**
  50374. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50375. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50376. * @returns the camera that is used when rendering the utility layer
  50377. */
  50378. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50379. /**
  50380. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50381. * @param cam the camera that should be used when rendering the utility layer
  50382. */
  50383. setRenderCamera(cam: Nullable<Camera>): void;
  50384. /**
  50385. * @hidden
  50386. * Light which used by gizmos to get light shading
  50387. */
  50388. _getSharedGizmoLight(): HemisphericLight;
  50389. /**
  50390. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50391. */
  50392. pickUtilitySceneFirst: boolean;
  50393. /**
  50394. * 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)
  50395. */
  50396. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50397. /**
  50398. * 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)
  50399. */
  50400. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50401. /**
  50402. * The scene that is rendered on top of the original scene
  50403. */
  50404. utilityLayerScene: Scene;
  50405. /**
  50406. * If the utility layer should automatically be rendered on top of existing scene
  50407. */
  50408. shouldRender: boolean;
  50409. /**
  50410. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50411. */
  50412. onlyCheckPointerDownEvents: boolean;
  50413. /**
  50414. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50415. */
  50416. processAllEvents: boolean;
  50417. /**
  50418. * Observable raised when the pointer move from the utility layer scene to the main scene
  50419. */
  50420. onPointerOutObservable: Observable<number>;
  50421. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50422. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50423. private _afterRenderObserver;
  50424. private _sceneDisposeObserver;
  50425. private _originalPointerObserver;
  50426. /**
  50427. * Instantiates a UtilityLayerRenderer
  50428. * @param originalScene the original scene that will be rendered on top of
  50429. * @param handleEvents boolean indicating if the utility layer should handle events
  50430. */
  50431. constructor(
  50432. /** the original scene that will be rendered on top of */
  50433. originalScene: Scene, handleEvents?: boolean);
  50434. private _notifyObservers;
  50435. /**
  50436. * Renders the utility layers scene on top of the original scene
  50437. */
  50438. render(): void;
  50439. /**
  50440. * Disposes of the renderer
  50441. */
  50442. dispose(): void;
  50443. private _updateCamera;
  50444. }
  50445. }
  50446. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50447. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50449. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50450. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50451. import { Scene } from "babylonjs/scene";
  50452. import { Nullable } from "babylonjs/types";
  50453. import { Color3 } from "babylonjs/Maths/math.color";
  50454. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50455. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50456. /**
  50457. * Options interface for the pointer selection module
  50458. */
  50459. export interface IWebXRControllerPointerSelectionOptions {
  50460. /**
  50461. * if provided, this scene will be used to render meshes.
  50462. */
  50463. customUtilityLayerScene?: Scene;
  50464. /**
  50465. * 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)
  50466. * If not disabled, the last picked point will be used to execute a pointer up event
  50467. * If disabled, pointer up event will be triggered right after the pointer down event.
  50468. * Used in screen and gaze target ray mode only
  50469. */
  50470. disablePointerUpOnTouchOut: boolean;
  50471. /**
  50472. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50473. */
  50474. forceGazeMode: boolean;
  50475. /**
  50476. * 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
  50477. * to start a new countdown to the pointer down event.
  50478. * Defaults to 1.
  50479. */
  50480. gazeModePointerMovedFactor?: number;
  50481. /**
  50482. * Different button type to use instead of the main component
  50483. */
  50484. overrideButtonId?: string;
  50485. /**
  50486. * use this rendering group id for the meshes (optional)
  50487. */
  50488. renderingGroupId?: number;
  50489. /**
  50490. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50491. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50492. * 3000 means 3 seconds between pointing at something and selecting it
  50493. */
  50494. timeToSelect?: number;
  50495. /**
  50496. * Should meshes created here be added to a utility layer or the main scene
  50497. */
  50498. useUtilityLayer?: boolean;
  50499. /**
  50500. * Optional WebXR camera to be used for gaze selection
  50501. */
  50502. gazeCamera?: WebXRCamera;
  50503. /**
  50504. * the xr input to use with this pointer selection
  50505. */
  50506. xrInput: WebXRInput;
  50507. }
  50508. /**
  50509. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50510. */
  50511. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50512. private readonly _options;
  50513. private static _idCounter;
  50514. private _attachController;
  50515. private _controllers;
  50516. private _scene;
  50517. private _tmpVectorForPickCompare;
  50518. /**
  50519. * The module's name
  50520. */
  50521. static readonly Name: string;
  50522. /**
  50523. * The (Babylon) version of this module.
  50524. * This is an integer representing the implementation version.
  50525. * This number does not correspond to the WebXR specs version
  50526. */
  50527. static readonly Version: number;
  50528. /**
  50529. * Disable lighting on the laser pointer (so it will always be visible)
  50530. */
  50531. disablePointerLighting: boolean;
  50532. /**
  50533. * Disable lighting on the selection mesh (so it will always be visible)
  50534. */
  50535. disableSelectionMeshLighting: boolean;
  50536. /**
  50537. * Should the laser pointer be displayed
  50538. */
  50539. displayLaserPointer: boolean;
  50540. /**
  50541. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50542. */
  50543. displaySelectionMesh: boolean;
  50544. /**
  50545. * This color will be set to the laser pointer when selection is triggered
  50546. */
  50547. laserPointerPickedColor: Color3;
  50548. /**
  50549. * Default color of the laser pointer
  50550. */
  50551. laserPointerDefaultColor: Color3;
  50552. /**
  50553. * default color of the selection ring
  50554. */
  50555. selectionMeshDefaultColor: Color3;
  50556. /**
  50557. * This color will be applied to the selection ring when selection is triggered
  50558. */
  50559. selectionMeshPickedColor: Color3;
  50560. /**
  50561. * Optional filter to be used for ray selection. This predicate shares behavior with
  50562. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50563. */
  50564. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50565. /**
  50566. * constructs a new background remover module
  50567. * @param _xrSessionManager the session manager for this module
  50568. * @param _options read-only options to be used in this module
  50569. */
  50570. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50571. /**
  50572. * attach this feature
  50573. * Will usually be called by the features manager
  50574. *
  50575. * @returns true if successful.
  50576. */
  50577. attach(): boolean;
  50578. /**
  50579. * detach this feature.
  50580. * Will usually be called by the features manager
  50581. *
  50582. * @returns true if successful.
  50583. */
  50584. detach(): boolean;
  50585. /**
  50586. * Will get the mesh under a specific pointer.
  50587. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50588. * @param controllerId the controllerId to check
  50589. * @returns The mesh under pointer or null if no mesh is under the pointer
  50590. */
  50591. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50592. /**
  50593. * Get the xr controller that correlates to the pointer id in the pointer event
  50594. *
  50595. * @param id the pointer id to search for
  50596. * @returns the controller that correlates to this id or null if not found
  50597. */
  50598. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50599. protected _onXRFrame(_xrFrame: XRFrame): void;
  50600. private _attachGazeMode;
  50601. private _attachScreenRayMode;
  50602. private _attachTrackedPointerRayMode;
  50603. private _convertNormalToDirectionOfRay;
  50604. private _detachController;
  50605. private _generateNewMeshPair;
  50606. private _pickingMoved;
  50607. private _updatePointerDistance;
  50608. /** @hidden */
  50609. get lasterPointerDefaultColor(): Color3;
  50610. }
  50611. }
  50612. declare module "babylonjs/XR/webXREnterExitUI" {
  50613. import { Nullable } from "babylonjs/types";
  50614. import { Observable } from "babylonjs/Misc/observable";
  50615. import { IDisposable, Scene } from "babylonjs/scene";
  50616. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50617. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50618. /**
  50619. * Button which can be used to enter a different mode of XR
  50620. */
  50621. export class WebXREnterExitUIButton {
  50622. /** button element */
  50623. element: HTMLElement;
  50624. /** XR initialization options for the button */
  50625. sessionMode: XRSessionMode;
  50626. /** Reference space type */
  50627. referenceSpaceType: XRReferenceSpaceType;
  50628. /**
  50629. * Creates a WebXREnterExitUIButton
  50630. * @param element button element
  50631. * @param sessionMode XR initialization session mode
  50632. * @param referenceSpaceType the type of reference space to be used
  50633. */
  50634. constructor(
  50635. /** button element */
  50636. element: HTMLElement,
  50637. /** XR initialization options for the button */
  50638. sessionMode: XRSessionMode,
  50639. /** Reference space type */
  50640. referenceSpaceType: XRReferenceSpaceType);
  50641. /**
  50642. * Extendable function which can be used to update the button's visuals when the state changes
  50643. * @param activeButton the current active button in the UI
  50644. */
  50645. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50646. }
  50647. /**
  50648. * Options to create the webXR UI
  50649. */
  50650. export class WebXREnterExitUIOptions {
  50651. /**
  50652. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50653. */
  50654. customButtons?: Array<WebXREnterExitUIButton>;
  50655. /**
  50656. * A reference space type to use when creating the default button.
  50657. * Default is local-floor
  50658. */
  50659. referenceSpaceType?: XRReferenceSpaceType;
  50660. /**
  50661. * Context to enter xr with
  50662. */
  50663. renderTarget?: Nullable<WebXRRenderTarget>;
  50664. /**
  50665. * A session mode to use when creating the default button.
  50666. * Default is immersive-vr
  50667. */
  50668. sessionMode?: XRSessionMode;
  50669. /**
  50670. * A list of optional features to init the session with
  50671. */
  50672. optionalFeatures?: string[];
  50673. /**
  50674. * A list of optional features to init the session with
  50675. */
  50676. requiredFeatures?: string[];
  50677. }
  50678. /**
  50679. * UI to allow the user to enter/exit XR mode
  50680. */
  50681. export class WebXREnterExitUI implements IDisposable {
  50682. private scene;
  50683. /** version of the options passed to this UI */
  50684. options: WebXREnterExitUIOptions;
  50685. private _activeButton;
  50686. private _buttons;
  50687. private _overlay;
  50688. /**
  50689. * Fired every time the active button is changed.
  50690. *
  50691. * When xr is entered via a button that launches xr that button will be the callback parameter
  50692. *
  50693. * When exiting xr the callback parameter will be null)
  50694. */
  50695. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50696. /**
  50697. *
  50698. * @param scene babylon scene object to use
  50699. * @param options (read-only) version of the options passed to this UI
  50700. */
  50701. private constructor();
  50702. /**
  50703. * Creates UI to allow the user to enter/exit XR mode
  50704. * @param scene the scene to add the ui to
  50705. * @param helper the xr experience helper to enter/exit xr with
  50706. * @param options options to configure the UI
  50707. * @returns the created ui
  50708. */
  50709. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50710. /**
  50711. * Disposes of the XR UI component
  50712. */
  50713. dispose(): void;
  50714. private _updateButtons;
  50715. }
  50716. }
  50717. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50718. import { Vector3 } from "babylonjs/Maths/math.vector";
  50719. import { Color4 } from "babylonjs/Maths/math.color";
  50720. import { Nullable } from "babylonjs/types";
  50721. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50722. import { Scene } from "babylonjs/scene";
  50723. /**
  50724. * Class containing static functions to help procedurally build meshes
  50725. */
  50726. export class LinesBuilder {
  50727. /**
  50728. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50729. * * 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
  50730. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50731. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50732. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50733. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50734. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50735. * * 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
  50736. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50739. * @param name defines the name of the new line system
  50740. * @param options defines the options used to create the line system
  50741. * @param scene defines the hosting scene
  50742. * @returns a new line system mesh
  50743. */
  50744. static CreateLineSystem(name: string, options: {
  50745. lines: Vector3[][];
  50746. updatable?: boolean;
  50747. instance?: Nullable<LinesMesh>;
  50748. colors?: Nullable<Color4[][]>;
  50749. useVertexAlpha?: boolean;
  50750. }, scene: Nullable<Scene>): LinesMesh;
  50751. /**
  50752. * Creates a line mesh
  50753. * 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
  50754. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50755. * * The parameter `points` is an array successive Vector3
  50756. * * 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
  50757. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50758. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50759. * * When updating an instance, remember that only point positions can change, not the number of points
  50760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50762. * @param name defines the name of the new line system
  50763. * @param options defines the options used to create the line system
  50764. * @param scene defines the hosting scene
  50765. * @returns a new line mesh
  50766. */
  50767. static CreateLines(name: string, options: {
  50768. points: Vector3[];
  50769. updatable?: boolean;
  50770. instance?: Nullable<LinesMesh>;
  50771. colors?: Color4[];
  50772. useVertexAlpha?: boolean;
  50773. }, scene?: Nullable<Scene>): LinesMesh;
  50774. /**
  50775. * Creates a dashed line mesh
  50776. * * 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
  50777. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50778. * * The parameter `points` is an array successive Vector3
  50779. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50780. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50781. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50782. * * 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
  50783. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50784. * * When updating an instance, remember that only point positions can change, not the number of points
  50785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50786. * @param name defines the name of the mesh
  50787. * @param options defines the options used to create the mesh
  50788. * @param scene defines the hosting scene
  50789. * @returns the dashed line mesh
  50790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50791. */
  50792. static CreateDashedLines(name: string, options: {
  50793. points: Vector3[];
  50794. dashSize?: number;
  50795. gapSize?: number;
  50796. dashNb?: number;
  50797. updatable?: boolean;
  50798. instance?: LinesMesh;
  50799. useVertexAlpha?: boolean;
  50800. }, scene?: Nullable<Scene>): LinesMesh;
  50801. }
  50802. }
  50803. declare module "babylonjs/Misc/timer" {
  50804. import { Observable, Observer } from "babylonjs/Misc/observable";
  50805. import { Nullable } from "babylonjs/types";
  50806. import { IDisposable } from "babylonjs/scene";
  50807. /**
  50808. * Construction options for a timer
  50809. */
  50810. export interface ITimerOptions<T> {
  50811. /**
  50812. * Time-to-end
  50813. */
  50814. timeout: number;
  50815. /**
  50816. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50817. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50818. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50819. */
  50820. contextObservable: Observable<T>;
  50821. /**
  50822. * Optional parameters when adding an observer to the observable
  50823. */
  50824. observableParameters?: {
  50825. mask?: number;
  50826. insertFirst?: boolean;
  50827. scope?: any;
  50828. };
  50829. /**
  50830. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50831. */
  50832. breakCondition?: (data?: ITimerData<T>) => boolean;
  50833. /**
  50834. * Will be triggered when the time condition has met
  50835. */
  50836. onEnded?: (data: ITimerData<any>) => void;
  50837. /**
  50838. * Will be triggered when the break condition has met (prematurely ended)
  50839. */
  50840. onAborted?: (data: ITimerData<any>) => void;
  50841. /**
  50842. * Optional function to execute on each tick (or count)
  50843. */
  50844. onTick?: (data: ITimerData<any>) => void;
  50845. }
  50846. /**
  50847. * An interface defining the data sent by the timer
  50848. */
  50849. export interface ITimerData<T> {
  50850. /**
  50851. * When did it start
  50852. */
  50853. startTime: number;
  50854. /**
  50855. * Time now
  50856. */
  50857. currentTime: number;
  50858. /**
  50859. * Time passed since started
  50860. */
  50861. deltaTime: number;
  50862. /**
  50863. * How much is completed, in [0.0...1.0].
  50864. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50865. */
  50866. completeRate: number;
  50867. /**
  50868. * What the registered observable sent in the last count
  50869. */
  50870. payload: T;
  50871. }
  50872. /**
  50873. * The current state of the timer
  50874. */
  50875. export enum TimerState {
  50876. /**
  50877. * Timer initialized, not yet started
  50878. */
  50879. INIT = 0,
  50880. /**
  50881. * Timer started and counting
  50882. */
  50883. STARTED = 1,
  50884. /**
  50885. * Timer ended (whether aborted or time reached)
  50886. */
  50887. ENDED = 2
  50888. }
  50889. /**
  50890. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50891. *
  50892. * @param options options with which to initialize this timer
  50893. */
  50894. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50895. /**
  50896. * An advanced implementation of a timer class
  50897. */
  50898. export class AdvancedTimer<T = any> implements IDisposable {
  50899. /**
  50900. * Will notify each time the timer calculates the remaining time
  50901. */
  50902. onEachCountObservable: Observable<ITimerData<T>>;
  50903. /**
  50904. * Will trigger when the timer was aborted due to the break condition
  50905. */
  50906. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50907. /**
  50908. * Will trigger when the timer ended successfully
  50909. */
  50910. onTimerEndedObservable: Observable<ITimerData<T>>;
  50911. /**
  50912. * Will trigger when the timer state has changed
  50913. */
  50914. onStateChangedObservable: Observable<TimerState>;
  50915. private _observer;
  50916. private _contextObservable;
  50917. private _observableParameters;
  50918. private _startTime;
  50919. private _timer;
  50920. private _state;
  50921. private _breakCondition;
  50922. private _timeToEnd;
  50923. private _breakOnNextTick;
  50924. /**
  50925. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50926. * @param options construction options for this advanced timer
  50927. */
  50928. constructor(options: ITimerOptions<T>);
  50929. /**
  50930. * set a breaking condition for this timer. Default is to never break during count
  50931. * @param predicate the new break condition. Returns true to break, false otherwise
  50932. */
  50933. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50934. /**
  50935. * Reset ALL associated observables in this advanced timer
  50936. */
  50937. clearObservables(): void;
  50938. /**
  50939. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50940. *
  50941. * @param timeToEnd how much time to measure until timer ended
  50942. */
  50943. start(timeToEnd?: number): void;
  50944. /**
  50945. * Will force a stop on the next tick.
  50946. */
  50947. stop(): void;
  50948. /**
  50949. * Dispose this timer, clearing all resources
  50950. */
  50951. dispose(): void;
  50952. private _setState;
  50953. private _tick;
  50954. private _stop;
  50955. }
  50956. }
  50957. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50958. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50959. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50960. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50962. import { Vector3 } from "babylonjs/Maths/math.vector";
  50963. import { Material } from "babylonjs/Materials/material";
  50964. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50965. import { Scene } from "babylonjs/scene";
  50966. /**
  50967. * The options container for the teleportation module
  50968. */
  50969. export interface IWebXRTeleportationOptions {
  50970. /**
  50971. * if provided, this scene will be used to render meshes.
  50972. */
  50973. customUtilityLayerScene?: Scene;
  50974. /**
  50975. * Values to configure the default target mesh
  50976. */
  50977. defaultTargetMeshOptions?: {
  50978. /**
  50979. * Fill color of the teleportation area
  50980. */
  50981. teleportationFillColor?: string;
  50982. /**
  50983. * Border color for the teleportation area
  50984. */
  50985. teleportationBorderColor?: string;
  50986. /**
  50987. * Disable the mesh's animation sequence
  50988. */
  50989. disableAnimation?: boolean;
  50990. /**
  50991. * Disable lighting on the material or the ring and arrow
  50992. */
  50993. disableLighting?: boolean;
  50994. /**
  50995. * Override the default material of the torus and arrow
  50996. */
  50997. torusArrowMaterial?: Material;
  50998. };
  50999. /**
  51000. * A list of meshes to use as floor meshes.
  51001. * Meshes can be added and removed after initializing the feature using the
  51002. * addFloorMesh and removeFloorMesh functions
  51003. * If empty, rotation will still work
  51004. */
  51005. floorMeshes?: AbstractMesh[];
  51006. /**
  51007. * use this rendering group id for the meshes (optional)
  51008. */
  51009. renderingGroupId?: number;
  51010. /**
  51011. * Should teleportation move only to snap points
  51012. */
  51013. snapPointsOnly?: boolean;
  51014. /**
  51015. * An array of points to which the teleportation will snap to.
  51016. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51017. */
  51018. snapPositions?: Vector3[];
  51019. /**
  51020. * How close should the teleportation ray be in order to snap to position.
  51021. * Default to 0.8 units (meters)
  51022. */
  51023. snapToPositionRadius?: number;
  51024. /**
  51025. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51026. * If you want to support rotation, make sure your mesh has a direction indicator.
  51027. *
  51028. * When left untouched, the default mesh will be initialized.
  51029. */
  51030. teleportationTargetMesh?: AbstractMesh;
  51031. /**
  51032. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51033. */
  51034. timeToTeleport?: number;
  51035. /**
  51036. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51037. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51038. */
  51039. useMainComponentOnly?: boolean;
  51040. /**
  51041. * Should meshes created here be added to a utility layer or the main scene
  51042. */
  51043. useUtilityLayer?: boolean;
  51044. /**
  51045. * Babylon XR Input class for controller
  51046. */
  51047. xrInput: WebXRInput;
  51048. }
  51049. /**
  51050. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51051. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51052. * the input of the attached controllers.
  51053. */
  51054. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51055. private _options;
  51056. private _controllers;
  51057. private _currentTeleportationControllerId;
  51058. private _floorMeshes;
  51059. private _quadraticBezierCurve;
  51060. private _selectionFeature;
  51061. private _snapToPositions;
  51062. private _snappedToPoint;
  51063. private _teleportationRingMaterial?;
  51064. private _tmpRay;
  51065. private _tmpVector;
  51066. /**
  51067. * The module's name
  51068. */
  51069. static readonly Name: string;
  51070. /**
  51071. * The (Babylon) version of this module.
  51072. * This is an integer representing the implementation version.
  51073. * This number does not correspond to the webxr specs version
  51074. */
  51075. static readonly Version: number;
  51076. /**
  51077. * Is movement backwards enabled
  51078. */
  51079. backwardsMovementEnabled: boolean;
  51080. /**
  51081. * Distance to travel when moving backwards
  51082. */
  51083. backwardsTeleportationDistance: number;
  51084. /**
  51085. * The distance from the user to the inspection point in the direction of the controller
  51086. * A higher number will allow the user to move further
  51087. * defaults to 5 (meters, in xr units)
  51088. */
  51089. parabolicCheckRadius: number;
  51090. /**
  51091. * Should the module support parabolic ray on top of direct ray
  51092. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51093. * Very helpful when moving between floors / different heights
  51094. */
  51095. parabolicRayEnabled: boolean;
  51096. /**
  51097. * How much rotation should be applied when rotating right and left
  51098. */
  51099. rotationAngle: number;
  51100. /**
  51101. * Is rotation enabled when moving forward?
  51102. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51103. */
  51104. rotationEnabled: boolean;
  51105. /**
  51106. * constructs a new anchor system
  51107. * @param _xrSessionManager an instance of WebXRSessionManager
  51108. * @param _options configuration object for this feature
  51109. */
  51110. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51111. /**
  51112. * Get the snapPointsOnly flag
  51113. */
  51114. get snapPointsOnly(): boolean;
  51115. /**
  51116. * Sets the snapPointsOnly flag
  51117. * @param snapToPoints should teleportation be exclusively to snap points
  51118. */
  51119. set snapPointsOnly(snapToPoints: boolean);
  51120. /**
  51121. * Add a new mesh to the floor meshes array
  51122. * @param mesh the mesh to use as floor mesh
  51123. */
  51124. addFloorMesh(mesh: AbstractMesh): void;
  51125. /**
  51126. * Add a new snap-to point to fix teleportation to this position
  51127. * @param newSnapPoint The new Snap-To point
  51128. */
  51129. addSnapPoint(newSnapPoint: Vector3): void;
  51130. attach(): boolean;
  51131. detach(): boolean;
  51132. dispose(): void;
  51133. /**
  51134. * Remove a mesh from the floor meshes array
  51135. * @param mesh the mesh to remove
  51136. */
  51137. removeFloorMesh(mesh: AbstractMesh): void;
  51138. /**
  51139. * Remove a mesh from the floor meshes array using its name
  51140. * @param name the mesh name to remove
  51141. */
  51142. removeFloorMeshByName(name: string): void;
  51143. /**
  51144. * 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
  51145. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51146. * @returns was the point found and removed or not
  51147. */
  51148. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51149. /**
  51150. * This function sets a selection feature that will be disabled when
  51151. * the forward ray is shown and will be reattached when hidden.
  51152. * This is used to remove the selection rays when moving.
  51153. * @param selectionFeature the feature to disable when forward movement is enabled
  51154. */
  51155. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  51156. protected _onXRFrame(_xrFrame: XRFrame): void;
  51157. private _attachController;
  51158. private _createDefaultTargetMesh;
  51159. private _detachController;
  51160. private _findClosestSnapPointWithRadius;
  51161. private _setTargetMeshPosition;
  51162. private _setTargetMeshVisibility;
  51163. private _showParabolicPath;
  51164. private _teleportForward;
  51165. }
  51166. }
  51167. declare module "babylonjs/XR/webXRDefaultExperience" {
  51168. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51169. import { Scene } from "babylonjs/scene";
  51170. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51171. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51172. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51173. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51175. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51176. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51177. /**
  51178. * Options for the default xr helper
  51179. */
  51180. export class WebXRDefaultExperienceOptions {
  51181. /**
  51182. * Enable or disable default UI to enter XR
  51183. */
  51184. disableDefaultUI?: boolean;
  51185. /**
  51186. * Should teleportation not initialize. defaults to false.
  51187. */
  51188. disableTeleportation?: boolean;
  51189. /**
  51190. * Floor meshes that will be used for teleport
  51191. */
  51192. floorMeshes?: Array<AbstractMesh>;
  51193. /**
  51194. * If set to true, the first frame will not be used to reset position
  51195. * The first frame is mainly used when copying transformation from the old camera
  51196. * Mainly used in AR
  51197. */
  51198. ignoreNativeCameraTransformation?: boolean;
  51199. /**
  51200. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51201. */
  51202. inputOptions?: IWebXRInputOptions;
  51203. /**
  51204. * optional configuration for the output canvas
  51205. */
  51206. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51207. /**
  51208. * optional UI options. This can be used among other to change session mode and reference space type
  51209. */
  51210. uiOptions?: WebXREnterExitUIOptions;
  51211. /**
  51212. * When loading teleportation and pointer select, use stable versions instead of latest.
  51213. */
  51214. useStablePlugins?: boolean;
  51215. /**
  51216. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51217. */
  51218. renderingGroupId?: number;
  51219. /**
  51220. * A list of optional features to init the session with
  51221. * If set to true, all features we support will be added
  51222. */
  51223. optionalFeatures?: boolean | string[];
  51224. }
  51225. /**
  51226. * Default experience which provides a similar setup to the previous webVRExperience
  51227. */
  51228. export class WebXRDefaultExperience {
  51229. /**
  51230. * Base experience
  51231. */
  51232. baseExperience: WebXRExperienceHelper;
  51233. /**
  51234. * Enables ui for entering/exiting xr
  51235. */
  51236. enterExitUI: WebXREnterExitUI;
  51237. /**
  51238. * Input experience extension
  51239. */
  51240. input: WebXRInput;
  51241. /**
  51242. * Enables laser pointer and selection
  51243. */
  51244. pointerSelection: WebXRControllerPointerSelection;
  51245. /**
  51246. * Default target xr should render to
  51247. */
  51248. renderTarget: WebXRRenderTarget;
  51249. /**
  51250. * Enables teleportation
  51251. */
  51252. teleportation: WebXRMotionControllerTeleportation;
  51253. private constructor();
  51254. /**
  51255. * Creates the default xr experience
  51256. * @param scene scene
  51257. * @param options options for basic configuration
  51258. * @returns resulting WebXRDefaultExperience
  51259. */
  51260. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51261. /**
  51262. * DIsposes of the experience helper
  51263. */
  51264. dispose(): void;
  51265. }
  51266. }
  51267. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51268. import { Observable } from "babylonjs/Misc/observable";
  51269. import { Nullable } from "babylonjs/types";
  51270. import { Camera } from "babylonjs/Cameras/camera";
  51271. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51272. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51273. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51274. import { Scene } from "babylonjs/scene";
  51275. import { Vector3 } from "babylonjs/Maths/math.vector";
  51276. import { Color3 } from "babylonjs/Maths/math.color";
  51277. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51279. import { Mesh } from "babylonjs/Meshes/mesh";
  51280. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51281. import { EasingFunction } from "babylonjs/Animations/easing";
  51282. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51283. import "babylonjs/Meshes/Builders/groundBuilder";
  51284. import "babylonjs/Meshes/Builders/torusBuilder";
  51285. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51286. import "babylonjs/Gamepads/gamepadSceneComponent";
  51287. import "babylonjs/Animations/animatable";
  51288. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51289. /**
  51290. * Options to modify the vr teleportation behavior.
  51291. */
  51292. export interface VRTeleportationOptions {
  51293. /**
  51294. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51295. */
  51296. floorMeshName?: string;
  51297. /**
  51298. * A list of meshes to be used as the teleportation floor. (default: empty)
  51299. */
  51300. floorMeshes?: Mesh[];
  51301. /**
  51302. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51303. */
  51304. teleportationMode?: number;
  51305. /**
  51306. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51307. */
  51308. teleportationTime?: number;
  51309. /**
  51310. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51311. */
  51312. teleportationSpeed?: number;
  51313. /**
  51314. * The easing function used in the animation or null for Linear. (default CircleEase)
  51315. */
  51316. easingFunction?: EasingFunction;
  51317. }
  51318. /**
  51319. * Options to modify the vr experience helper's behavior.
  51320. */
  51321. export interface VRExperienceHelperOptions extends WebVROptions {
  51322. /**
  51323. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51324. */
  51325. createDeviceOrientationCamera?: boolean;
  51326. /**
  51327. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51328. */
  51329. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51330. /**
  51331. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51332. */
  51333. laserToggle?: boolean;
  51334. /**
  51335. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51336. */
  51337. floorMeshes?: Mesh[];
  51338. /**
  51339. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51340. */
  51341. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51342. /**
  51343. * Defines if WebXR should be used instead of WebVR (if available)
  51344. */
  51345. useXR?: boolean;
  51346. }
  51347. /**
  51348. * Event containing information after VR has been entered
  51349. */
  51350. export class OnAfterEnteringVRObservableEvent {
  51351. /**
  51352. * If entering vr was successful
  51353. */
  51354. success: boolean;
  51355. }
  51356. /**
  51357. * Helps to quickly add VR support to an existing scene.
  51358. * See https://doc.babylonjs.com/how_to/webvr_helper
  51359. */
  51360. export class VRExperienceHelper {
  51361. /** Options to modify the vr experience helper's behavior. */
  51362. webVROptions: VRExperienceHelperOptions;
  51363. private _scene;
  51364. private _position;
  51365. private _btnVR;
  51366. private _btnVRDisplayed;
  51367. private _webVRsupported;
  51368. private _webVRready;
  51369. private _webVRrequesting;
  51370. private _webVRpresenting;
  51371. private _hasEnteredVR;
  51372. private _fullscreenVRpresenting;
  51373. private _inputElement;
  51374. private _webVRCamera;
  51375. private _vrDeviceOrientationCamera;
  51376. private _deviceOrientationCamera;
  51377. private _existingCamera;
  51378. private _onKeyDown;
  51379. private _onVrDisplayPresentChange;
  51380. private _onVRDisplayChanged;
  51381. private _onVRRequestPresentStart;
  51382. private _onVRRequestPresentComplete;
  51383. /**
  51384. * 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)
  51385. */
  51386. enableGazeEvenWhenNoPointerLock: boolean;
  51387. /**
  51388. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51389. */
  51390. exitVROnDoubleTap: boolean;
  51391. /**
  51392. * Observable raised right before entering VR.
  51393. */
  51394. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51395. /**
  51396. * Observable raised when entering VR has completed.
  51397. */
  51398. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51399. /**
  51400. * Observable raised when exiting VR.
  51401. */
  51402. onExitingVRObservable: Observable<VRExperienceHelper>;
  51403. /**
  51404. * Observable raised when controller mesh is loaded.
  51405. */
  51406. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51407. /** Return this.onEnteringVRObservable
  51408. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51409. */
  51410. get onEnteringVR(): Observable<VRExperienceHelper>;
  51411. /** Return this.onExitingVRObservable
  51412. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51413. */
  51414. get onExitingVR(): Observable<VRExperienceHelper>;
  51415. /** Return this.onControllerMeshLoadedObservable
  51416. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51417. */
  51418. get onControllerMeshLoaded(): Observable<WebVRController>;
  51419. private _rayLength;
  51420. private _useCustomVRButton;
  51421. private _teleportationRequested;
  51422. private _teleportActive;
  51423. private _floorMeshName;
  51424. private _floorMeshesCollection;
  51425. private _teleportationMode;
  51426. private _teleportationTime;
  51427. private _teleportationSpeed;
  51428. private _teleportationEasing;
  51429. private _rotationAllowed;
  51430. private _teleportBackwardsVector;
  51431. private _teleportationTarget;
  51432. private _isDefaultTeleportationTarget;
  51433. private _postProcessMove;
  51434. private _teleportationFillColor;
  51435. private _teleportationBorderColor;
  51436. private _rotationAngle;
  51437. private _haloCenter;
  51438. private _cameraGazer;
  51439. private _padSensibilityUp;
  51440. private _padSensibilityDown;
  51441. private _leftController;
  51442. private _rightController;
  51443. private _gazeColor;
  51444. private _laserColor;
  51445. private _pickedLaserColor;
  51446. private _pickedGazeColor;
  51447. /**
  51448. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51449. */
  51450. onNewMeshSelected: Observable<AbstractMesh>;
  51451. /**
  51452. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51453. * This observable will provide the mesh and the controller used to select the mesh
  51454. */
  51455. onMeshSelectedWithController: Observable<{
  51456. mesh: AbstractMesh;
  51457. controller: WebVRController;
  51458. }>;
  51459. /**
  51460. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51461. */
  51462. onNewMeshPicked: Observable<PickingInfo>;
  51463. private _circleEase;
  51464. /**
  51465. * Observable raised before camera teleportation
  51466. */
  51467. onBeforeCameraTeleport: Observable<Vector3>;
  51468. /**
  51469. * Observable raised after camera teleportation
  51470. */
  51471. onAfterCameraTeleport: Observable<Vector3>;
  51472. /**
  51473. * Observable raised when current selected mesh gets unselected
  51474. */
  51475. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51476. private _raySelectionPredicate;
  51477. /**
  51478. * To be optionaly changed by user to define custom ray selection
  51479. */
  51480. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51481. /**
  51482. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51483. */
  51484. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51485. /**
  51486. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51487. */
  51488. teleportationEnabled: boolean;
  51489. private _defaultHeight;
  51490. private _teleportationInitialized;
  51491. private _interactionsEnabled;
  51492. private _interactionsRequested;
  51493. private _displayGaze;
  51494. private _displayLaserPointer;
  51495. /**
  51496. * The mesh used to display where the user is going to teleport.
  51497. */
  51498. get teleportationTarget(): Mesh;
  51499. /**
  51500. * Sets the mesh to be used to display where the user is going to teleport.
  51501. */
  51502. set teleportationTarget(value: Mesh);
  51503. /**
  51504. * 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
  51505. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51506. * See https://doc.babylonjs.com/resources/baking_transformations
  51507. */
  51508. get gazeTrackerMesh(): Mesh;
  51509. set gazeTrackerMesh(value: Mesh);
  51510. /**
  51511. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51512. */
  51513. updateGazeTrackerScale: boolean;
  51514. /**
  51515. * If the gaze trackers color should be updated when selecting meshes
  51516. */
  51517. updateGazeTrackerColor: boolean;
  51518. /**
  51519. * If the controller laser color should be updated when selecting meshes
  51520. */
  51521. updateControllerLaserColor: boolean;
  51522. /**
  51523. * The gaze tracking mesh corresponding to the left controller
  51524. */
  51525. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51526. /**
  51527. * The gaze tracking mesh corresponding to the right controller
  51528. */
  51529. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51530. /**
  51531. * If the ray of the gaze should be displayed.
  51532. */
  51533. get displayGaze(): boolean;
  51534. /**
  51535. * Sets if the ray of the gaze should be displayed.
  51536. */
  51537. set displayGaze(value: boolean);
  51538. /**
  51539. * If the ray of the LaserPointer should be displayed.
  51540. */
  51541. get displayLaserPointer(): boolean;
  51542. /**
  51543. * Sets if the ray of the LaserPointer should be displayed.
  51544. */
  51545. set displayLaserPointer(value: boolean);
  51546. /**
  51547. * The deviceOrientationCamera used as the camera when not in VR.
  51548. */
  51549. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51550. /**
  51551. * Based on the current WebVR support, returns the current VR camera used.
  51552. */
  51553. get currentVRCamera(): Nullable<Camera>;
  51554. /**
  51555. * The webVRCamera which is used when in VR.
  51556. */
  51557. get webVRCamera(): WebVRFreeCamera;
  51558. /**
  51559. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51560. */
  51561. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51562. /**
  51563. * The html button that is used to trigger entering into VR.
  51564. */
  51565. get vrButton(): Nullable<HTMLButtonElement>;
  51566. private get _teleportationRequestInitiated();
  51567. /**
  51568. * Defines whether or not Pointer lock should be requested when switching to
  51569. * full screen.
  51570. */
  51571. requestPointerLockOnFullScreen: boolean;
  51572. /**
  51573. * If asking to force XR, this will be populated with the default xr experience
  51574. */
  51575. xr: WebXRDefaultExperience;
  51576. /**
  51577. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51578. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51579. */
  51580. xrTestDone: boolean;
  51581. /**
  51582. * Instantiates a VRExperienceHelper.
  51583. * Helps to quickly add VR support to an existing scene.
  51584. * @param scene The scene the VRExperienceHelper belongs to.
  51585. * @param webVROptions Options to modify the vr experience helper's behavior.
  51586. */
  51587. constructor(scene: Scene,
  51588. /** Options to modify the vr experience helper's behavior. */
  51589. webVROptions?: VRExperienceHelperOptions);
  51590. private completeVRInit;
  51591. private _onDefaultMeshLoaded;
  51592. private _onResize;
  51593. private _onFullscreenChange;
  51594. /**
  51595. * Gets a value indicating if we are currently in VR mode.
  51596. */
  51597. get isInVRMode(): boolean;
  51598. private onVrDisplayPresentChange;
  51599. private onVRDisplayChanged;
  51600. private moveButtonToBottomRight;
  51601. private displayVRButton;
  51602. private updateButtonVisibility;
  51603. private _cachedAngularSensibility;
  51604. /**
  51605. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51606. * Otherwise, will use the fullscreen API.
  51607. */
  51608. enterVR(): void;
  51609. /**
  51610. * Attempt to exit VR, or fullscreen.
  51611. */
  51612. exitVR(): void;
  51613. /**
  51614. * The position of the vr experience helper.
  51615. */
  51616. get position(): Vector3;
  51617. /**
  51618. * Sets the position of the vr experience helper.
  51619. */
  51620. set position(value: Vector3);
  51621. /**
  51622. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51623. */
  51624. enableInteractions(): void;
  51625. private get _noControllerIsActive();
  51626. private beforeRender;
  51627. private _isTeleportationFloor;
  51628. /**
  51629. * Adds a floor mesh to be used for teleportation.
  51630. * @param floorMesh the mesh to be used for teleportation.
  51631. */
  51632. addFloorMesh(floorMesh: Mesh): void;
  51633. /**
  51634. * Removes a floor mesh from being used for teleportation.
  51635. * @param floorMesh the mesh to be removed.
  51636. */
  51637. removeFloorMesh(floorMesh: Mesh): void;
  51638. /**
  51639. * Enables interactions and teleportation using the VR controllers and gaze.
  51640. * @param vrTeleportationOptions options to modify teleportation behavior.
  51641. */
  51642. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51643. private _onNewGamepadConnected;
  51644. private _tryEnableInteractionOnController;
  51645. private _onNewGamepadDisconnected;
  51646. private _enableInteractionOnController;
  51647. private _checkTeleportWithRay;
  51648. private _checkRotate;
  51649. private _checkTeleportBackwards;
  51650. private _enableTeleportationOnController;
  51651. private _createTeleportationCircles;
  51652. private _displayTeleportationTarget;
  51653. private _hideTeleportationTarget;
  51654. private _rotateCamera;
  51655. private _moveTeleportationSelectorTo;
  51656. private _workingVector;
  51657. private _workingQuaternion;
  51658. private _workingMatrix;
  51659. /**
  51660. * Time Constant Teleportation Mode
  51661. */
  51662. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51663. /**
  51664. * Speed Constant Teleportation Mode
  51665. */
  51666. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51667. /**
  51668. * Teleports the users feet to the desired location
  51669. * @param location The location where the user's feet should be placed
  51670. */
  51671. teleportCamera(location: Vector3): void;
  51672. private _convertNormalToDirectionOfRay;
  51673. private _castRayAndSelectObject;
  51674. private _notifySelectedMeshUnselected;
  51675. /**
  51676. * Permanently set new colors for the laser pointer
  51677. * @param color the new laser color
  51678. * @param pickedColor the new laser color when picked mesh detected
  51679. */
  51680. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51681. /**
  51682. * Set lighting enabled / disabled on the laser pointer of both controllers
  51683. * @param enabled should the lighting be enabled on the laser pointer
  51684. */
  51685. setLaserLightingState(enabled?: boolean): void;
  51686. /**
  51687. * Permanently set new colors for the gaze pointer
  51688. * @param color the new gaze color
  51689. * @param pickedColor the new gaze color when picked mesh detected
  51690. */
  51691. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51692. /**
  51693. * Sets the color of the laser ray from the vr controllers.
  51694. * @param color new color for the ray.
  51695. */
  51696. changeLaserColor(color: Color3): void;
  51697. /**
  51698. * Sets the color of the ray from the vr headsets gaze.
  51699. * @param color new color for the ray.
  51700. */
  51701. changeGazeColor(color: Color3): void;
  51702. /**
  51703. * Exits VR and disposes of the vr experience helper
  51704. */
  51705. dispose(): void;
  51706. /**
  51707. * Gets the name of the VRExperienceHelper class
  51708. * @returns "VRExperienceHelper"
  51709. */
  51710. getClassName(): string;
  51711. }
  51712. }
  51713. declare module "babylonjs/Cameras/VR/index" {
  51714. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51715. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51716. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51717. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51718. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51719. export * from "babylonjs/Cameras/VR/webVRCamera";
  51720. }
  51721. declare module "babylonjs/Cameras/RigModes/index" {
  51722. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51723. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51724. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51725. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51726. }
  51727. declare module "babylonjs/Cameras/index" {
  51728. export * from "babylonjs/Cameras/Inputs/index";
  51729. export * from "babylonjs/Cameras/cameraInputsManager";
  51730. export * from "babylonjs/Cameras/camera";
  51731. export * from "babylonjs/Cameras/targetCamera";
  51732. export * from "babylonjs/Cameras/freeCamera";
  51733. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51734. export * from "babylonjs/Cameras/touchCamera";
  51735. export * from "babylonjs/Cameras/arcRotateCamera";
  51736. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51737. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51738. export * from "babylonjs/Cameras/flyCamera";
  51739. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51740. export * from "babylonjs/Cameras/followCamera";
  51741. export * from "babylonjs/Cameras/followCameraInputsManager";
  51742. export * from "babylonjs/Cameras/gamepadCamera";
  51743. export * from "babylonjs/Cameras/Stereoscopic/index";
  51744. export * from "babylonjs/Cameras/universalCamera";
  51745. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51746. export * from "babylonjs/Cameras/VR/index";
  51747. export * from "babylonjs/Cameras/RigModes/index";
  51748. }
  51749. declare module "babylonjs/Collisions/index" {
  51750. export * from "babylonjs/Collisions/collider";
  51751. export * from "babylonjs/Collisions/collisionCoordinator";
  51752. export * from "babylonjs/Collisions/pickingInfo";
  51753. export * from "babylonjs/Collisions/intersectionInfo";
  51754. export * from "babylonjs/Collisions/meshCollisionData";
  51755. }
  51756. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51757. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51758. import { Vector3 } from "babylonjs/Maths/math.vector";
  51759. import { Ray } from "babylonjs/Culling/ray";
  51760. import { Plane } from "babylonjs/Maths/math.plane";
  51761. /**
  51762. * Contains an array of blocks representing the octree
  51763. */
  51764. export interface IOctreeContainer<T> {
  51765. /**
  51766. * Blocks within the octree
  51767. */
  51768. blocks: Array<OctreeBlock<T>>;
  51769. }
  51770. /**
  51771. * Class used to store a cell in an octree
  51772. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51773. */
  51774. export class OctreeBlock<T> {
  51775. /**
  51776. * Gets the content of the current block
  51777. */
  51778. entries: T[];
  51779. /**
  51780. * Gets the list of block children
  51781. */
  51782. blocks: Array<OctreeBlock<T>>;
  51783. private _depth;
  51784. private _maxDepth;
  51785. private _capacity;
  51786. private _minPoint;
  51787. private _maxPoint;
  51788. private _boundingVectors;
  51789. private _creationFunc;
  51790. /**
  51791. * Creates a new block
  51792. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51793. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51794. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51795. * @param depth defines the current depth of this block in the octree
  51796. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51797. * @param creationFunc defines a callback to call when an element is added to the block
  51798. */
  51799. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51800. /**
  51801. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51802. */
  51803. get capacity(): number;
  51804. /**
  51805. * Gets the minimum vector (in world space) of the block's bounding box
  51806. */
  51807. get minPoint(): Vector3;
  51808. /**
  51809. * Gets the maximum vector (in world space) of the block's bounding box
  51810. */
  51811. get maxPoint(): Vector3;
  51812. /**
  51813. * Add a new element to this block
  51814. * @param entry defines the element to add
  51815. */
  51816. addEntry(entry: T): void;
  51817. /**
  51818. * Remove an element from this block
  51819. * @param entry defines the element to remove
  51820. */
  51821. removeEntry(entry: T): void;
  51822. /**
  51823. * Add an array of elements to this block
  51824. * @param entries defines the array of elements to add
  51825. */
  51826. addEntries(entries: T[]): void;
  51827. /**
  51828. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51829. * @param frustumPlanes defines the frustum planes to test
  51830. * @param selection defines the array to store current content if selection is positive
  51831. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51832. */
  51833. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51834. /**
  51835. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51836. * @param sphereCenter defines the bounding sphere center
  51837. * @param sphereRadius defines the bounding sphere radius
  51838. * @param selection defines the array to store current content if selection is positive
  51839. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51840. */
  51841. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51842. /**
  51843. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51844. * @param ray defines the ray to test with
  51845. * @param selection defines the array to store current content if selection is positive
  51846. */
  51847. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51848. /**
  51849. * Subdivide the content into child blocks (this block will then be empty)
  51850. */
  51851. createInnerBlocks(): void;
  51852. /**
  51853. * @hidden
  51854. */
  51855. 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;
  51856. }
  51857. }
  51858. declare module "babylonjs/Culling/Octrees/octree" {
  51859. import { SmartArray } from "babylonjs/Misc/smartArray";
  51860. import { Vector3 } from "babylonjs/Maths/math.vector";
  51861. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51863. import { Ray } from "babylonjs/Culling/ray";
  51864. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51865. import { Plane } from "babylonjs/Maths/math.plane";
  51866. /**
  51867. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51869. */
  51870. export class Octree<T> {
  51871. /** 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.) */
  51872. maxDepth: number;
  51873. /**
  51874. * Blocks within the octree containing objects
  51875. */
  51876. blocks: Array<OctreeBlock<T>>;
  51877. /**
  51878. * Content stored in the octree
  51879. */
  51880. dynamicContent: T[];
  51881. private _maxBlockCapacity;
  51882. private _selectionContent;
  51883. private _creationFunc;
  51884. /**
  51885. * Creates a octree
  51886. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51887. * @param creationFunc function to be used to instatiate the octree
  51888. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51889. * @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.)
  51890. */
  51891. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51892. /** 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.) */
  51893. maxDepth?: number);
  51894. /**
  51895. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51896. * @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);
  51897. * @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);
  51898. * @param entries meshes to be added to the octree blocks
  51899. */
  51900. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51901. /**
  51902. * Adds a mesh to the octree
  51903. * @param entry Mesh to add to the octree
  51904. */
  51905. addMesh(entry: T): void;
  51906. /**
  51907. * Remove an element from the octree
  51908. * @param entry defines the element to remove
  51909. */
  51910. removeMesh(entry: T): void;
  51911. /**
  51912. * Selects an array of meshes within the frustum
  51913. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51914. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51915. * @returns array of meshes within the frustum
  51916. */
  51917. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51918. /**
  51919. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51920. * @param sphereCenter defines the bounding sphere center
  51921. * @param sphereRadius defines the bounding sphere radius
  51922. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51923. * @returns an array of objects that intersect the sphere
  51924. */
  51925. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51926. /**
  51927. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51928. * @param ray defines the ray to test with
  51929. * @returns array of intersected objects
  51930. */
  51931. intersectsRay(ray: Ray): SmartArray<T>;
  51932. /**
  51933. * Adds a mesh into the octree block if it intersects the block
  51934. */
  51935. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51936. /**
  51937. * Adds a submesh into the octree block if it intersects the block
  51938. */
  51939. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51940. }
  51941. }
  51942. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51943. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51944. import { Scene } from "babylonjs/scene";
  51945. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51947. import { Ray } from "babylonjs/Culling/ray";
  51948. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51949. import { Collider } from "babylonjs/Collisions/collider";
  51950. module "babylonjs/scene" {
  51951. interface Scene {
  51952. /**
  51953. * @hidden
  51954. * Backing Filed
  51955. */
  51956. _selectionOctree: Octree<AbstractMesh>;
  51957. /**
  51958. * Gets the octree used to boost mesh selection (picking)
  51959. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51960. */
  51961. selectionOctree: Octree<AbstractMesh>;
  51962. /**
  51963. * Creates or updates the octree used to boost selection (picking)
  51964. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51965. * @param maxCapacity defines the maximum capacity per leaf
  51966. * @param maxDepth defines the maximum depth of the octree
  51967. * @returns an octree of AbstractMesh
  51968. */
  51969. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51970. }
  51971. }
  51972. module "babylonjs/Meshes/abstractMesh" {
  51973. interface AbstractMesh {
  51974. /**
  51975. * @hidden
  51976. * Backing Field
  51977. */
  51978. _submeshesOctree: Octree<SubMesh>;
  51979. /**
  51980. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51981. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51982. * @param maxCapacity defines the maximum size of each block (64 by default)
  51983. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51984. * @returns the new octree
  51985. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51986. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51987. */
  51988. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51989. }
  51990. }
  51991. /**
  51992. * Defines the octree scene component responsible to manage any octrees
  51993. * in a given scene.
  51994. */
  51995. export class OctreeSceneComponent {
  51996. /**
  51997. * The component name help to identify the component in the list of scene components.
  51998. */
  51999. readonly name: string;
  52000. /**
  52001. * The scene the component belongs to.
  52002. */
  52003. scene: Scene;
  52004. /**
  52005. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52006. */
  52007. readonly checksIsEnabled: boolean;
  52008. /**
  52009. * Creates a new instance of the component for the given scene
  52010. * @param scene Defines the scene to register the component in
  52011. */
  52012. constructor(scene: Scene);
  52013. /**
  52014. * Registers the component in a given scene
  52015. */
  52016. register(): void;
  52017. /**
  52018. * Return the list of active meshes
  52019. * @returns the list of active meshes
  52020. */
  52021. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52022. /**
  52023. * Return the list of active sub meshes
  52024. * @param mesh The mesh to get the candidates sub meshes from
  52025. * @returns the list of active sub meshes
  52026. */
  52027. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52028. private _tempRay;
  52029. /**
  52030. * Return the list of sub meshes intersecting with a given local ray
  52031. * @param mesh defines the mesh to find the submesh for
  52032. * @param localRay defines the ray in local space
  52033. * @returns the list of intersecting sub meshes
  52034. */
  52035. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52036. /**
  52037. * Return the list of sub meshes colliding with a collider
  52038. * @param mesh defines the mesh to find the submesh for
  52039. * @param collider defines the collider to evaluate the collision against
  52040. * @returns the list of colliding sub meshes
  52041. */
  52042. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52043. /**
  52044. * Rebuilds the elements related to this component in case of
  52045. * context lost for instance.
  52046. */
  52047. rebuild(): void;
  52048. /**
  52049. * Disposes the component and the associated ressources.
  52050. */
  52051. dispose(): void;
  52052. }
  52053. }
  52054. declare module "babylonjs/Culling/Octrees/index" {
  52055. export * from "babylonjs/Culling/Octrees/octree";
  52056. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52057. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52058. }
  52059. declare module "babylonjs/Culling/index" {
  52060. export * from "babylonjs/Culling/boundingBox";
  52061. export * from "babylonjs/Culling/boundingInfo";
  52062. export * from "babylonjs/Culling/boundingSphere";
  52063. export * from "babylonjs/Culling/Octrees/index";
  52064. export * from "babylonjs/Culling/ray";
  52065. }
  52066. declare module "babylonjs/Gizmos/gizmo" {
  52067. import { Nullable } from "babylonjs/types";
  52068. import { IDisposable } from "babylonjs/scene";
  52069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52070. import { Mesh } from "babylonjs/Meshes/mesh";
  52071. import { Node } from "babylonjs/node";
  52072. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52073. /**
  52074. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52075. */
  52076. export class Gizmo implements IDisposable {
  52077. /** The utility layer the gizmo will be added to */
  52078. gizmoLayer: UtilityLayerRenderer;
  52079. /**
  52080. * The root mesh of the gizmo
  52081. */
  52082. _rootMesh: Mesh;
  52083. private _attachedMesh;
  52084. private _attachedNode;
  52085. /**
  52086. * Ratio for the scale of the gizmo (Default: 1)
  52087. */
  52088. scaleRatio: number;
  52089. /**
  52090. * If a custom mesh has been set (Default: false)
  52091. */
  52092. protected _customMeshSet: boolean;
  52093. /**
  52094. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52095. * * When set, interactions will be enabled
  52096. */
  52097. get attachedMesh(): Nullable<AbstractMesh>;
  52098. set attachedMesh(value: Nullable<AbstractMesh>);
  52099. /**
  52100. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52101. * * When set, interactions will be enabled
  52102. */
  52103. get attachedNode(): Nullable<Node>;
  52104. set attachedNode(value: Nullable<Node>);
  52105. /**
  52106. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52107. * @param mesh The mesh to replace the default mesh of the gizmo
  52108. */
  52109. setCustomMesh(mesh: Mesh): void;
  52110. /**
  52111. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52112. */
  52113. updateGizmoRotationToMatchAttachedMesh: boolean;
  52114. /**
  52115. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52116. */
  52117. updateGizmoPositionToMatchAttachedMesh: boolean;
  52118. /**
  52119. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52120. */
  52121. updateScale: boolean;
  52122. protected _interactionsEnabled: boolean;
  52123. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52124. private _beforeRenderObserver;
  52125. private _tempQuaternion;
  52126. private _tempVector;
  52127. private _tempVector2;
  52128. /**
  52129. * Creates a gizmo
  52130. * @param gizmoLayer The utility layer the gizmo will be added to
  52131. */
  52132. constructor(
  52133. /** The utility layer the gizmo will be added to */
  52134. gizmoLayer?: UtilityLayerRenderer);
  52135. /**
  52136. * Updates the gizmo to match the attached mesh's position/rotation
  52137. */
  52138. protected _update(): void;
  52139. /**
  52140. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52141. * @param value Node, TransformNode or mesh
  52142. */
  52143. protected _matrixChanged(): void;
  52144. /**
  52145. * Disposes of the gizmo
  52146. */
  52147. dispose(): void;
  52148. }
  52149. }
  52150. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52151. import { Observable } from "babylonjs/Misc/observable";
  52152. import { Nullable } from "babylonjs/types";
  52153. import { Vector3 } from "babylonjs/Maths/math.vector";
  52154. import { Color3 } from "babylonjs/Maths/math.color";
  52155. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52156. import { Node } from "babylonjs/node";
  52157. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52158. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52159. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52160. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52161. import { Scene } from "babylonjs/scene";
  52162. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52163. /**
  52164. * Single plane drag gizmo
  52165. */
  52166. export class PlaneDragGizmo extends Gizmo {
  52167. /**
  52168. * Drag behavior responsible for the gizmos dragging interactions
  52169. */
  52170. dragBehavior: PointerDragBehavior;
  52171. private _pointerObserver;
  52172. /**
  52173. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52174. */
  52175. snapDistance: number;
  52176. /**
  52177. * Event that fires each time the gizmo snaps to a new location.
  52178. * * snapDistance is the the change in distance
  52179. */
  52180. onSnapObservable: Observable<{
  52181. snapDistance: number;
  52182. }>;
  52183. private _plane;
  52184. private _coloredMaterial;
  52185. private _hoverMaterial;
  52186. private _isEnabled;
  52187. private _parent;
  52188. /** @hidden */
  52189. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52190. /** @hidden */
  52191. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52192. /**
  52193. * Creates a PlaneDragGizmo
  52194. * @param gizmoLayer The utility layer the gizmo will be added to
  52195. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52196. * @param color The color of the gizmo
  52197. */
  52198. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52199. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52200. /**
  52201. * If the gizmo is enabled
  52202. */
  52203. set isEnabled(value: boolean);
  52204. get isEnabled(): boolean;
  52205. /**
  52206. * Disposes of the gizmo
  52207. */
  52208. dispose(): void;
  52209. }
  52210. }
  52211. declare module "babylonjs/Gizmos/positionGizmo" {
  52212. import { Observable } from "babylonjs/Misc/observable";
  52213. import { Nullable } from "babylonjs/types";
  52214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52215. import { Node } from "babylonjs/node";
  52216. import { Mesh } from "babylonjs/Meshes/mesh";
  52217. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52218. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52219. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52220. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52221. /**
  52222. * Gizmo that enables dragging a mesh along 3 axis
  52223. */
  52224. export class PositionGizmo extends Gizmo {
  52225. /**
  52226. * Internal gizmo used for interactions on the x axis
  52227. */
  52228. xGizmo: AxisDragGizmo;
  52229. /**
  52230. * Internal gizmo used for interactions on the y axis
  52231. */
  52232. yGizmo: AxisDragGizmo;
  52233. /**
  52234. * Internal gizmo used for interactions on the z axis
  52235. */
  52236. zGizmo: AxisDragGizmo;
  52237. /**
  52238. * Internal gizmo used for interactions on the yz plane
  52239. */
  52240. xPlaneGizmo: PlaneDragGizmo;
  52241. /**
  52242. * Internal gizmo used for interactions on the xz plane
  52243. */
  52244. yPlaneGizmo: PlaneDragGizmo;
  52245. /**
  52246. * Internal gizmo used for interactions on the xy plane
  52247. */
  52248. zPlaneGizmo: PlaneDragGizmo;
  52249. /**
  52250. * private variables
  52251. */
  52252. private _meshAttached;
  52253. private _nodeAttached;
  52254. private _updateGizmoRotationToMatchAttachedMesh;
  52255. private _snapDistance;
  52256. private _scaleRatio;
  52257. /** Fires an event when any of it's sub gizmos are dragged */
  52258. onDragStartObservable: Observable<unknown>;
  52259. /** Fires an event when any of it's sub gizmos are released from dragging */
  52260. onDragEndObservable: Observable<unknown>;
  52261. /**
  52262. * If set to true, planar drag is enabled
  52263. */
  52264. private _planarGizmoEnabled;
  52265. get attachedMesh(): Nullable<AbstractMesh>;
  52266. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52267. get attachedNode(): Nullable<Node>;
  52268. set attachedNode(node: Nullable<Node>);
  52269. /**
  52270. * Creates a PositionGizmo
  52271. * @param gizmoLayer The utility layer the gizmo will be added to
  52272. @param thickness display gizmo axis thickness
  52273. */
  52274. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52275. /**
  52276. * If the planar drag gizmo is enabled
  52277. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52278. */
  52279. set planarGizmoEnabled(value: boolean);
  52280. get planarGizmoEnabled(): boolean;
  52281. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52282. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52283. /**
  52284. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52285. */
  52286. set snapDistance(value: number);
  52287. get snapDistance(): number;
  52288. /**
  52289. * Ratio for the scale of the gizmo (Default: 1)
  52290. */
  52291. set scaleRatio(value: number);
  52292. get scaleRatio(): number;
  52293. /**
  52294. * Disposes of the gizmo
  52295. */
  52296. dispose(): void;
  52297. /**
  52298. * CustomMeshes are not supported by this gizmo
  52299. * @param mesh The mesh to replace the default mesh of the gizmo
  52300. */
  52301. setCustomMesh(mesh: Mesh): void;
  52302. }
  52303. }
  52304. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52305. import { Observable } from "babylonjs/Misc/observable";
  52306. import { Nullable } from "babylonjs/types";
  52307. import { Vector3 } from "babylonjs/Maths/math.vector";
  52308. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52309. import { Node } from "babylonjs/node";
  52310. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52311. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52312. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52313. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52314. import { Scene } from "babylonjs/scene";
  52315. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52316. import { Color3 } from "babylonjs/Maths/math.color";
  52317. /**
  52318. * Single axis drag gizmo
  52319. */
  52320. export class AxisDragGizmo extends Gizmo {
  52321. /**
  52322. * Drag behavior responsible for the gizmos dragging interactions
  52323. */
  52324. dragBehavior: PointerDragBehavior;
  52325. private _pointerObserver;
  52326. /**
  52327. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52328. */
  52329. snapDistance: number;
  52330. /**
  52331. * Event that fires each time the gizmo snaps to a new location.
  52332. * * snapDistance is the the change in distance
  52333. */
  52334. onSnapObservable: Observable<{
  52335. snapDistance: number;
  52336. }>;
  52337. private _isEnabled;
  52338. private _parent;
  52339. private _arrow;
  52340. private _coloredMaterial;
  52341. private _hoverMaterial;
  52342. /** @hidden */
  52343. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52344. /** @hidden */
  52345. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52346. /**
  52347. * Creates an AxisDragGizmo
  52348. * @param gizmoLayer The utility layer the gizmo will be added to
  52349. * @param dragAxis The axis which the gizmo will be able to drag on
  52350. * @param color The color of the gizmo
  52351. * @param thickness display gizmo axis thickness
  52352. */
  52353. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52354. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52355. /**
  52356. * If the gizmo is enabled
  52357. */
  52358. set isEnabled(value: boolean);
  52359. get isEnabled(): boolean;
  52360. /**
  52361. * Disposes of the gizmo
  52362. */
  52363. dispose(): void;
  52364. }
  52365. }
  52366. declare module "babylonjs/Debug/axesViewer" {
  52367. import { Vector3 } from "babylonjs/Maths/math.vector";
  52368. import { Nullable } from "babylonjs/types";
  52369. import { Scene } from "babylonjs/scene";
  52370. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52371. /**
  52372. * The Axes viewer will show 3 axes in a specific point in space
  52373. */
  52374. export class AxesViewer {
  52375. private _xAxis;
  52376. private _yAxis;
  52377. private _zAxis;
  52378. private _scaleLinesFactor;
  52379. private _instanced;
  52380. /**
  52381. * Gets the hosting scene
  52382. */
  52383. scene: Scene;
  52384. /**
  52385. * Gets or sets a number used to scale line length
  52386. */
  52387. scaleLines: number;
  52388. /** Gets the node hierarchy used to render x-axis */
  52389. get xAxis(): TransformNode;
  52390. /** Gets the node hierarchy used to render y-axis */
  52391. get yAxis(): TransformNode;
  52392. /** Gets the node hierarchy used to render z-axis */
  52393. get zAxis(): TransformNode;
  52394. /**
  52395. * Creates a new AxesViewer
  52396. * @param scene defines the hosting scene
  52397. * @param scaleLines defines a number used to scale line length (1 by default)
  52398. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52399. * @param xAxis defines the node hierarchy used to render the x-axis
  52400. * @param yAxis defines the node hierarchy used to render the y-axis
  52401. * @param zAxis defines the node hierarchy used to render the z-axis
  52402. */
  52403. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52404. /**
  52405. * Force the viewer to update
  52406. * @param position defines the position of the viewer
  52407. * @param xaxis defines the x axis of the viewer
  52408. * @param yaxis defines the y axis of the viewer
  52409. * @param zaxis defines the z axis of the viewer
  52410. */
  52411. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52412. /**
  52413. * Creates an instance of this axes viewer.
  52414. * @returns a new axes viewer with instanced meshes
  52415. */
  52416. createInstance(): AxesViewer;
  52417. /** Releases resources */
  52418. dispose(): void;
  52419. private static _SetRenderingGroupId;
  52420. }
  52421. }
  52422. declare module "babylonjs/Debug/boneAxesViewer" {
  52423. import { Nullable } from "babylonjs/types";
  52424. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52425. import { Vector3 } from "babylonjs/Maths/math.vector";
  52426. import { Mesh } from "babylonjs/Meshes/mesh";
  52427. import { Bone } from "babylonjs/Bones/bone";
  52428. import { Scene } from "babylonjs/scene";
  52429. /**
  52430. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52431. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52432. */
  52433. export class BoneAxesViewer extends AxesViewer {
  52434. /**
  52435. * Gets or sets the target mesh where to display the axes viewer
  52436. */
  52437. mesh: Nullable<Mesh>;
  52438. /**
  52439. * Gets or sets the target bone where to display the axes viewer
  52440. */
  52441. bone: Nullable<Bone>;
  52442. /** Gets current position */
  52443. pos: Vector3;
  52444. /** Gets direction of X axis */
  52445. xaxis: Vector3;
  52446. /** Gets direction of Y axis */
  52447. yaxis: Vector3;
  52448. /** Gets direction of Z axis */
  52449. zaxis: Vector3;
  52450. /**
  52451. * Creates a new BoneAxesViewer
  52452. * @param scene defines the hosting scene
  52453. * @param bone defines the target bone
  52454. * @param mesh defines the target mesh
  52455. * @param scaleLines defines a scaling factor for line length (1 by default)
  52456. */
  52457. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52458. /**
  52459. * Force the viewer to update
  52460. */
  52461. update(): void;
  52462. /** Releases resources */
  52463. dispose(): void;
  52464. }
  52465. }
  52466. declare module "babylonjs/Debug/debugLayer" {
  52467. import { Scene } from "babylonjs/scene";
  52468. /**
  52469. * Interface used to define scene explorer extensibility option
  52470. */
  52471. export interface IExplorerExtensibilityOption {
  52472. /**
  52473. * Define the option label
  52474. */
  52475. label: string;
  52476. /**
  52477. * Defines the action to execute on click
  52478. */
  52479. action: (entity: any) => void;
  52480. }
  52481. /**
  52482. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52483. */
  52484. export interface IExplorerExtensibilityGroup {
  52485. /**
  52486. * Defines a predicate to test if a given type mut be extended
  52487. */
  52488. predicate: (entity: any) => boolean;
  52489. /**
  52490. * Gets the list of options added to a type
  52491. */
  52492. entries: IExplorerExtensibilityOption[];
  52493. }
  52494. /**
  52495. * Interface used to define the options to use to create the Inspector
  52496. */
  52497. export interface IInspectorOptions {
  52498. /**
  52499. * Display in overlay mode (default: false)
  52500. */
  52501. overlay?: boolean;
  52502. /**
  52503. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52504. */
  52505. globalRoot?: HTMLElement;
  52506. /**
  52507. * Display the Scene explorer
  52508. */
  52509. showExplorer?: boolean;
  52510. /**
  52511. * Display the property inspector
  52512. */
  52513. showInspector?: boolean;
  52514. /**
  52515. * Display in embed mode (both panes on the right)
  52516. */
  52517. embedMode?: boolean;
  52518. /**
  52519. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52520. */
  52521. handleResize?: boolean;
  52522. /**
  52523. * Allow the panes to popup (default: true)
  52524. */
  52525. enablePopup?: boolean;
  52526. /**
  52527. * Allow the panes to be closed by users (default: true)
  52528. */
  52529. enableClose?: boolean;
  52530. /**
  52531. * Optional list of extensibility entries
  52532. */
  52533. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52534. /**
  52535. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52536. */
  52537. inspectorURL?: string;
  52538. /**
  52539. * Optional initial tab (default to DebugLayerTab.Properties)
  52540. */
  52541. initialTab?: DebugLayerTab;
  52542. }
  52543. module "babylonjs/scene" {
  52544. interface Scene {
  52545. /**
  52546. * @hidden
  52547. * Backing field
  52548. */
  52549. _debugLayer: DebugLayer;
  52550. /**
  52551. * Gets the debug layer (aka Inspector) associated with the scene
  52552. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52553. */
  52554. debugLayer: DebugLayer;
  52555. }
  52556. }
  52557. /**
  52558. * Enum of inspector action tab
  52559. */
  52560. export enum DebugLayerTab {
  52561. /**
  52562. * Properties tag (default)
  52563. */
  52564. Properties = 0,
  52565. /**
  52566. * Debug tab
  52567. */
  52568. Debug = 1,
  52569. /**
  52570. * Statistics tab
  52571. */
  52572. Statistics = 2,
  52573. /**
  52574. * Tools tab
  52575. */
  52576. Tools = 3,
  52577. /**
  52578. * Settings tab
  52579. */
  52580. Settings = 4
  52581. }
  52582. /**
  52583. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52584. * what is happening in your scene
  52585. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52586. */
  52587. export class DebugLayer {
  52588. /**
  52589. * Define the url to get the inspector script from.
  52590. * By default it uses the babylonjs CDN.
  52591. * @ignoreNaming
  52592. */
  52593. static InspectorURL: string;
  52594. private _scene;
  52595. private BJSINSPECTOR;
  52596. private _onPropertyChangedObservable?;
  52597. /**
  52598. * Observable triggered when a property is changed through the inspector.
  52599. */
  52600. get onPropertyChangedObservable(): any;
  52601. /**
  52602. * Instantiates a new debug layer.
  52603. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52604. * what is happening in your scene
  52605. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52606. * @param scene Defines the scene to inspect
  52607. */
  52608. constructor(scene: Scene);
  52609. /** Creates the inspector window. */
  52610. private _createInspector;
  52611. /**
  52612. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52613. * @param entity defines the entity to select
  52614. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52615. */
  52616. select(entity: any, lineContainerTitles?: string | string[]): void;
  52617. /** Get the inspector from bundle or global */
  52618. private _getGlobalInspector;
  52619. /**
  52620. * Get if the inspector is visible or not.
  52621. * @returns true if visible otherwise, false
  52622. */
  52623. isVisible(): boolean;
  52624. /**
  52625. * Hide the inspector and close its window.
  52626. */
  52627. hide(): void;
  52628. /**
  52629. * Update the scene in the inspector
  52630. */
  52631. setAsActiveScene(): void;
  52632. /**
  52633. * Launch the debugLayer.
  52634. * @param config Define the configuration of the inspector
  52635. * @return a promise fulfilled when the debug layer is visible
  52636. */
  52637. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52638. }
  52639. }
  52640. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52641. import { Nullable } from "babylonjs/types";
  52642. import { Scene } from "babylonjs/scene";
  52643. import { Vector4 } from "babylonjs/Maths/math.vector";
  52644. import { Color4 } from "babylonjs/Maths/math.color";
  52645. import { Mesh } from "babylonjs/Meshes/mesh";
  52646. /**
  52647. * Class containing static functions to help procedurally build meshes
  52648. */
  52649. export class BoxBuilder {
  52650. /**
  52651. * Creates a box mesh
  52652. * * The parameter `size` sets the size (float) of each box side (default 1)
  52653. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52654. * * 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)
  52655. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52659. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52660. * @param name defines the name of the mesh
  52661. * @param options defines the options used to create the mesh
  52662. * @param scene defines the hosting scene
  52663. * @returns the box mesh
  52664. */
  52665. static CreateBox(name: string, options: {
  52666. size?: number;
  52667. width?: number;
  52668. height?: number;
  52669. depth?: number;
  52670. faceUV?: Vector4[];
  52671. faceColors?: Color4[];
  52672. sideOrientation?: number;
  52673. frontUVs?: Vector4;
  52674. backUVs?: Vector4;
  52675. wrap?: boolean;
  52676. topBaseAt?: number;
  52677. bottomBaseAt?: number;
  52678. updatable?: boolean;
  52679. }, scene?: Nullable<Scene>): Mesh;
  52680. }
  52681. }
  52682. declare module "babylonjs/Debug/physicsViewer" {
  52683. import { Nullable } from "babylonjs/types";
  52684. import { Scene } from "babylonjs/scene";
  52685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52686. import { Mesh } from "babylonjs/Meshes/mesh";
  52687. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52688. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52689. /**
  52690. * Used to show the physics impostor around the specific mesh
  52691. */
  52692. export class PhysicsViewer {
  52693. /** @hidden */
  52694. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52695. /** @hidden */
  52696. protected _meshes: Array<Nullable<AbstractMesh>>;
  52697. /** @hidden */
  52698. protected _scene: Nullable<Scene>;
  52699. /** @hidden */
  52700. protected _numMeshes: number;
  52701. /** @hidden */
  52702. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52703. private _renderFunction;
  52704. private _utilityLayer;
  52705. private _debugBoxMesh;
  52706. private _debugSphereMesh;
  52707. private _debugCylinderMesh;
  52708. private _debugMaterial;
  52709. private _debugMeshMeshes;
  52710. /**
  52711. * Creates a new PhysicsViewer
  52712. * @param scene defines the hosting scene
  52713. */
  52714. constructor(scene: Scene);
  52715. /** @hidden */
  52716. protected _updateDebugMeshes(): void;
  52717. /**
  52718. * Renders a specified physic impostor
  52719. * @param impostor defines the impostor to render
  52720. * @param targetMesh defines the mesh represented by the impostor
  52721. * @returns the new debug mesh used to render the impostor
  52722. */
  52723. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52724. /**
  52725. * Hides a specified physic impostor
  52726. * @param impostor defines the impostor to hide
  52727. */
  52728. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52729. private _getDebugMaterial;
  52730. private _getDebugBoxMesh;
  52731. private _getDebugSphereMesh;
  52732. private _getDebugCylinderMesh;
  52733. private _getDebugMeshMesh;
  52734. private _getDebugMesh;
  52735. /** Releases all resources */
  52736. dispose(): void;
  52737. }
  52738. }
  52739. declare module "babylonjs/Debug/rayHelper" {
  52740. import { Nullable } from "babylonjs/types";
  52741. import { Ray } from "babylonjs/Culling/ray";
  52742. import { Vector3 } from "babylonjs/Maths/math.vector";
  52743. import { Color3 } from "babylonjs/Maths/math.color";
  52744. import { Scene } from "babylonjs/scene";
  52745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52746. import "babylonjs/Meshes/Builders/linesBuilder";
  52747. /**
  52748. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52749. * in order to better appreciate the issue one might have.
  52750. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52751. */
  52752. export class RayHelper {
  52753. /**
  52754. * Defines the ray we are currently tryin to visualize.
  52755. */
  52756. ray: Nullable<Ray>;
  52757. private _renderPoints;
  52758. private _renderLine;
  52759. private _renderFunction;
  52760. private _scene;
  52761. private _updateToMeshFunction;
  52762. private _attachedToMesh;
  52763. private _meshSpaceDirection;
  52764. private _meshSpaceOrigin;
  52765. /**
  52766. * Helper function to create a colored helper in a scene in one line.
  52767. * @param ray Defines the ray we are currently tryin to visualize
  52768. * @param scene Defines the scene the ray is used in
  52769. * @param color Defines the color we want to see the ray in
  52770. * @returns The newly created ray helper.
  52771. */
  52772. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52773. /**
  52774. * Instantiate a new ray helper.
  52775. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52776. * in order to better appreciate the issue one might have.
  52777. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52778. * @param ray Defines the ray we are currently tryin to visualize
  52779. */
  52780. constructor(ray: Ray);
  52781. /**
  52782. * Shows the ray we are willing to debug.
  52783. * @param scene Defines the scene the ray needs to be rendered in
  52784. * @param color Defines the color the ray needs to be rendered in
  52785. */
  52786. show(scene: Scene, color?: Color3): void;
  52787. /**
  52788. * Hides the ray we are debugging.
  52789. */
  52790. hide(): void;
  52791. private _render;
  52792. /**
  52793. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52794. * @param mesh Defines the mesh we want the helper attached to
  52795. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52796. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52797. * @param length Defines the length of the ray
  52798. */
  52799. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52800. /**
  52801. * Detach the ray helper from the mesh it has previously been attached to.
  52802. */
  52803. detachFromMesh(): void;
  52804. private _updateToMesh;
  52805. /**
  52806. * Dispose the helper and release its associated resources.
  52807. */
  52808. dispose(): void;
  52809. }
  52810. }
  52811. declare module "babylonjs/Debug/ISkeletonViewer" {
  52812. /**
  52813. * Defines the options associated with the creation of a SkeletonViewer.
  52814. */
  52815. export interface ISkeletonViewerOptions {
  52816. /** Should the system pause animations before building the Viewer? */
  52817. pauseAnimations: boolean;
  52818. /** Should the system return the skeleton to rest before building? */
  52819. returnToRest: boolean;
  52820. /** public Display Mode of the Viewer */
  52821. displayMode: number;
  52822. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52823. displayOptions: ISkeletonViewerDisplayOptions;
  52824. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  52825. computeBonesUsingShaders: boolean;
  52826. }
  52827. /**
  52828. * Defines how to display the various bone meshes for the viewer.
  52829. */
  52830. export interface ISkeletonViewerDisplayOptions {
  52831. /** How far down to start tapering the bone spurs */
  52832. midStep?: number;
  52833. /** How big is the midStep? */
  52834. midStepFactor?: number;
  52835. /** Base for the Sphere Size */
  52836. sphereBaseSize?: number;
  52837. /** The ratio of the sphere to the longest bone in units */
  52838. sphereScaleUnit?: number;
  52839. /** Ratio for the Sphere Size */
  52840. sphereFactor?: number;
  52841. }
  52842. }
  52843. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52844. import { Nullable } from "babylonjs/types";
  52845. import { Scene } from "babylonjs/scene";
  52846. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52847. import { Color4 } from "babylonjs/Maths/math.color";
  52848. import { Mesh } from "babylonjs/Meshes/mesh";
  52849. /**
  52850. * Class containing static functions to help procedurally build meshes
  52851. */
  52852. export class RibbonBuilder {
  52853. /**
  52854. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52855. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52856. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52857. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52858. * * 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
  52859. * * 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
  52860. * * 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
  52861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52863. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52864. * * 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
  52865. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52866. * * 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
  52867. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52869. * @param name defines the name of the mesh
  52870. * @param options defines the options used to create the mesh
  52871. * @param scene defines the hosting scene
  52872. * @returns the ribbon mesh
  52873. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52874. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52875. */
  52876. static CreateRibbon(name: string, options: {
  52877. pathArray: Vector3[][];
  52878. closeArray?: boolean;
  52879. closePath?: boolean;
  52880. offset?: number;
  52881. updatable?: boolean;
  52882. sideOrientation?: number;
  52883. frontUVs?: Vector4;
  52884. backUVs?: Vector4;
  52885. instance?: Mesh;
  52886. invertUV?: boolean;
  52887. uvs?: Vector2[];
  52888. colors?: Color4[];
  52889. }, scene?: Nullable<Scene>): Mesh;
  52890. }
  52891. }
  52892. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52893. import { Nullable } from "babylonjs/types";
  52894. import { Scene } from "babylonjs/scene";
  52895. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52896. import { Mesh } from "babylonjs/Meshes/mesh";
  52897. /**
  52898. * Class containing static functions to help procedurally build meshes
  52899. */
  52900. export class ShapeBuilder {
  52901. /**
  52902. * 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.
  52903. * * 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.
  52904. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52905. * * 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.
  52906. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52907. * * 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
  52908. * * 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
  52909. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52912. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52914. * @param name defines the name of the mesh
  52915. * @param options defines the options used to create the mesh
  52916. * @param scene defines the hosting scene
  52917. * @returns the extruded shape mesh
  52918. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52920. */
  52921. static ExtrudeShape(name: string, options: {
  52922. shape: Vector3[];
  52923. path: Vector3[];
  52924. scale?: number;
  52925. rotation?: number;
  52926. cap?: number;
  52927. updatable?: boolean;
  52928. sideOrientation?: number;
  52929. frontUVs?: Vector4;
  52930. backUVs?: Vector4;
  52931. instance?: Mesh;
  52932. invertUV?: boolean;
  52933. }, scene?: Nullable<Scene>): Mesh;
  52934. /**
  52935. * Creates an custom extruded shape mesh.
  52936. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52937. * * 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.
  52938. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52939. * * 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
  52940. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52941. * * 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
  52942. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52943. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52944. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52945. * * 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
  52946. * * 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
  52947. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52950. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52952. * @param name defines the name of the mesh
  52953. * @param options defines the options used to create the mesh
  52954. * @param scene defines the hosting scene
  52955. * @returns the custom extruded shape mesh
  52956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52957. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52959. */
  52960. static ExtrudeShapeCustom(name: string, options: {
  52961. shape: Vector3[];
  52962. path: Vector3[];
  52963. scaleFunction?: any;
  52964. rotationFunction?: any;
  52965. ribbonCloseArray?: boolean;
  52966. ribbonClosePath?: boolean;
  52967. cap?: number;
  52968. updatable?: boolean;
  52969. sideOrientation?: number;
  52970. frontUVs?: Vector4;
  52971. backUVs?: Vector4;
  52972. instance?: Mesh;
  52973. invertUV?: boolean;
  52974. }, scene?: Nullable<Scene>): Mesh;
  52975. private static _ExtrudeShapeGeneric;
  52976. }
  52977. }
  52978. declare module "babylonjs/Debug/skeletonViewer" {
  52979. import { Color3 } from "babylonjs/Maths/math.color";
  52980. import { Scene } from "babylonjs/scene";
  52981. import { Nullable } from "babylonjs/types";
  52982. import { Skeleton } from "babylonjs/Bones/skeleton";
  52983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52984. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52985. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52986. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52987. import { ISkeletonViewerOptions } from "babylonjs/Debug/ISkeletonViewer";
  52988. /**
  52989. * Class used to render a debug view of a given skeleton
  52990. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52991. */
  52992. export class SkeletonViewer {
  52993. /** defines the skeleton to render */
  52994. skeleton: Skeleton;
  52995. /** defines the mesh attached to the skeleton */
  52996. mesh: AbstractMesh;
  52997. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52998. autoUpdateBonesMatrices: boolean;
  52999. /** defines the rendering group id to use with the viewer */
  53000. renderingGroupId: number;
  53001. /** is the options for the viewer */
  53002. options: Partial<ISkeletonViewerOptions>;
  53003. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53004. static readonly DISPLAY_LINES: number;
  53005. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53006. static readonly DISPLAY_SPHERES: number;
  53007. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53008. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53009. /** If SkeletonViewer scene scope. */
  53010. private _scene;
  53011. /** Gets or sets the color used to render the skeleton */
  53012. color: Color3;
  53013. /** Array of the points of the skeleton fo the line view. */
  53014. private _debugLines;
  53015. /** The SkeletonViewers Mesh. */
  53016. private _debugMesh;
  53017. /** If SkeletonViewer is enabled. */
  53018. private _isEnabled;
  53019. /** If SkeletonViewer is ready. */
  53020. private _ready;
  53021. /** SkeletonViewer render observable. */
  53022. private _obs;
  53023. /** The Utility Layer to render the gizmos in. */
  53024. private _utilityLayer;
  53025. private _boneIndices;
  53026. /** Gets the Scene. */
  53027. get scene(): Scene;
  53028. /** Gets the utilityLayer. */
  53029. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53030. /** Checks Ready Status. */
  53031. get isReady(): Boolean;
  53032. /** Sets Ready Status. */
  53033. set ready(value: boolean);
  53034. /** Gets the debugMesh */
  53035. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53036. /** Sets the debugMesh */
  53037. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53038. /** Gets the material */
  53039. get material(): StandardMaterial;
  53040. /** Sets the material */
  53041. set material(value: StandardMaterial);
  53042. /** Gets the material */
  53043. get displayMode(): number;
  53044. /** Sets the material */
  53045. set displayMode(value: number);
  53046. /**
  53047. * Creates a new SkeletonViewer
  53048. * @param skeleton defines the skeleton to render
  53049. * @param mesh defines the mesh attached to the skeleton
  53050. * @param scene defines the hosting scene
  53051. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53052. * @param renderingGroupId defines the rendering group id to use with the viewer
  53053. * @param options All of the extra constructor options for the SkeletonViewer
  53054. */
  53055. constructor(
  53056. /** defines the skeleton to render */
  53057. skeleton: Skeleton,
  53058. /** defines the mesh attached to the skeleton */
  53059. mesh: AbstractMesh,
  53060. /** The Scene scope*/
  53061. scene: Scene,
  53062. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53063. autoUpdateBonesMatrices?: boolean,
  53064. /** defines the rendering group id to use with the viewer */
  53065. renderingGroupId?: number,
  53066. /** is the options for the viewer */
  53067. options?: Partial<ISkeletonViewerOptions>);
  53068. /** The Dynamic bindings for the update functions */
  53069. private _bindObs;
  53070. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53071. update(): void;
  53072. /** Gets or sets a boolean indicating if the viewer is enabled */
  53073. set isEnabled(value: boolean);
  53074. get isEnabled(): boolean;
  53075. private _getBonePosition;
  53076. private _getLinesForBonesWithLength;
  53077. private _getLinesForBonesNoLength;
  53078. /** function to revert the mesh and scene back to the initial state. */
  53079. private _revert;
  53080. /** function to build and bind sphere joint points and spur bone representations. */
  53081. private _buildSpheresAndSpurs;
  53082. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53083. private _displayLinesUpdate;
  53084. /** Changes the displayMode of the skeleton viewer
  53085. * @param mode The displayMode numerical value
  53086. */
  53087. changeDisplayMode(mode: number): void;
  53088. /** Release associated resources */
  53089. dispose(): void;
  53090. }
  53091. }
  53092. declare module "babylonjs/Debug/index" {
  53093. export * from "babylonjs/Debug/axesViewer";
  53094. export * from "babylonjs/Debug/boneAxesViewer";
  53095. export * from "babylonjs/Debug/debugLayer";
  53096. export * from "babylonjs/Debug/physicsViewer";
  53097. export * from "babylonjs/Debug/rayHelper";
  53098. export * from "babylonjs/Debug/skeletonViewer";
  53099. export * from "babylonjs/Debug/ISkeletonViewer";
  53100. }
  53101. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53102. /**
  53103. * Enum for Device Types
  53104. */
  53105. export enum DeviceType {
  53106. /** Generic */
  53107. Generic = 0,
  53108. /** Keyboard */
  53109. Keyboard = 1,
  53110. /** Mouse */
  53111. Mouse = 2,
  53112. /** Touch Pointers */
  53113. Touch = 3,
  53114. /** PS4 Dual Shock */
  53115. DualShock = 4,
  53116. /** Xbox */
  53117. Xbox = 5,
  53118. /** Switch Controller */
  53119. Switch = 6
  53120. }
  53121. /**
  53122. * Enum for All Pointers (Touch/Mouse)
  53123. */
  53124. export enum PointerInput {
  53125. /** Horizontal Axis */
  53126. Horizontal = 0,
  53127. /** Vertical Axis */
  53128. Vertical = 1,
  53129. /** Left Click or Touch */
  53130. LeftClick = 2,
  53131. /** Middle Click */
  53132. MiddleClick = 3,
  53133. /** Right Click */
  53134. RightClick = 4,
  53135. /** Browser Back */
  53136. BrowserBack = 5,
  53137. /** Browser Forward */
  53138. BrowserForward = 6
  53139. }
  53140. /**
  53141. * Enum for Dual Shock Gamepad
  53142. */
  53143. export enum DualShockInput {
  53144. /** Cross */
  53145. Cross = 0,
  53146. /** Circle */
  53147. Circle = 1,
  53148. /** Square */
  53149. Square = 2,
  53150. /** Triangle */
  53151. Triangle = 3,
  53152. /** L1 */
  53153. L1 = 4,
  53154. /** R1 */
  53155. R1 = 5,
  53156. /** L2 */
  53157. L2 = 6,
  53158. /** R2 */
  53159. R2 = 7,
  53160. /** Share */
  53161. Share = 8,
  53162. /** Options */
  53163. Options = 9,
  53164. /** L3 */
  53165. L3 = 10,
  53166. /** R3 */
  53167. R3 = 11,
  53168. /** DPadUp */
  53169. DPadUp = 12,
  53170. /** DPadDown */
  53171. DPadDown = 13,
  53172. /** DPadLeft */
  53173. DPadLeft = 14,
  53174. /** DRight */
  53175. DPadRight = 15,
  53176. /** Home */
  53177. Home = 16,
  53178. /** TouchPad */
  53179. TouchPad = 17,
  53180. /** LStickXAxis */
  53181. LStickXAxis = 18,
  53182. /** LStickYAxis */
  53183. LStickYAxis = 19,
  53184. /** RStickXAxis */
  53185. RStickXAxis = 20,
  53186. /** RStickYAxis */
  53187. RStickYAxis = 21
  53188. }
  53189. /**
  53190. * Enum for Xbox Gamepad
  53191. */
  53192. export enum XboxInput {
  53193. /** A */
  53194. A = 0,
  53195. /** B */
  53196. B = 1,
  53197. /** X */
  53198. X = 2,
  53199. /** Y */
  53200. Y = 3,
  53201. /** LB */
  53202. LB = 4,
  53203. /** RB */
  53204. RB = 5,
  53205. /** LT */
  53206. LT = 6,
  53207. /** RT */
  53208. RT = 7,
  53209. /** Back */
  53210. Back = 8,
  53211. /** Start */
  53212. Start = 9,
  53213. /** LS */
  53214. LS = 10,
  53215. /** RS */
  53216. RS = 11,
  53217. /** DPadUp */
  53218. DPadUp = 12,
  53219. /** DPadDown */
  53220. DPadDown = 13,
  53221. /** DPadLeft */
  53222. DPadLeft = 14,
  53223. /** DRight */
  53224. DPadRight = 15,
  53225. /** Home */
  53226. Home = 16,
  53227. /** LStickXAxis */
  53228. LStickXAxis = 17,
  53229. /** LStickYAxis */
  53230. LStickYAxis = 18,
  53231. /** RStickXAxis */
  53232. RStickXAxis = 19,
  53233. /** RStickYAxis */
  53234. RStickYAxis = 20
  53235. }
  53236. /**
  53237. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53238. */
  53239. export enum SwitchInput {
  53240. /** B */
  53241. B = 0,
  53242. /** A */
  53243. A = 1,
  53244. /** Y */
  53245. Y = 2,
  53246. /** X */
  53247. X = 3,
  53248. /** L */
  53249. L = 4,
  53250. /** R */
  53251. R = 5,
  53252. /** ZL */
  53253. ZL = 6,
  53254. /** ZR */
  53255. ZR = 7,
  53256. /** Minus */
  53257. Minus = 8,
  53258. /** Plus */
  53259. Plus = 9,
  53260. /** LS */
  53261. LS = 10,
  53262. /** RS */
  53263. RS = 11,
  53264. /** DPadUp */
  53265. DPadUp = 12,
  53266. /** DPadDown */
  53267. DPadDown = 13,
  53268. /** DPadLeft */
  53269. DPadLeft = 14,
  53270. /** DRight */
  53271. DPadRight = 15,
  53272. /** Home */
  53273. Home = 16,
  53274. /** Capture */
  53275. Capture = 17,
  53276. /** LStickXAxis */
  53277. LStickXAxis = 18,
  53278. /** LStickYAxis */
  53279. LStickYAxis = 19,
  53280. /** RStickXAxis */
  53281. RStickXAxis = 20,
  53282. /** RStickYAxis */
  53283. RStickYAxis = 21
  53284. }
  53285. }
  53286. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53287. import { Engine } from "babylonjs/Engines/engine";
  53288. import { IDisposable } from "babylonjs/scene";
  53289. import { Nullable } from "babylonjs/types";
  53290. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53291. /**
  53292. * This class will take all inputs from Keyboard, Pointer, and
  53293. * any Gamepads and provide a polling system that all devices
  53294. * will use. This class assumes that there will only be one
  53295. * pointer device and one keyboard.
  53296. */
  53297. export class DeviceInputSystem implements IDisposable {
  53298. /**
  53299. * Callback to be triggered when a device is connected
  53300. */
  53301. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53302. /**
  53303. * Callback to be triggered when a device is disconnected
  53304. */
  53305. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53306. /**
  53307. * Callback to be triggered when event driven input is updated
  53308. */
  53309. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53310. private _inputs;
  53311. private _gamepads;
  53312. private _keyboardActive;
  53313. private _pointerActive;
  53314. private _elementToAttachTo;
  53315. private _keyboardDownEvent;
  53316. private _keyboardUpEvent;
  53317. private _pointerMoveEvent;
  53318. private _pointerDownEvent;
  53319. private _pointerUpEvent;
  53320. private _gamepadConnectedEvent;
  53321. private _gamepadDisconnectedEvent;
  53322. private static _MAX_KEYCODES;
  53323. private static _MAX_POINTER_INPUTS;
  53324. private constructor();
  53325. /**
  53326. * Creates a new DeviceInputSystem instance
  53327. * @param engine Engine to pull input element from
  53328. * @returns The new instance
  53329. */
  53330. static Create(engine: Engine): DeviceInputSystem;
  53331. /**
  53332. * Checks for current device input value, given an id and input index
  53333. * @param deviceName Id of connected device
  53334. * @param inputIndex Index of device input
  53335. * @returns Current value of input
  53336. */
  53337. /**
  53338. * Checks for current device input value, given an id and input index
  53339. * @param deviceType Enum specifiying device type
  53340. * @param deviceSlot "Slot" or index that device is referenced in
  53341. * @param inputIndex Id of input to be checked
  53342. * @returns Current value of input
  53343. */
  53344. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  53345. /**
  53346. * Dispose of all the eventlisteners
  53347. */
  53348. dispose(): void;
  53349. /**
  53350. * Add device and inputs to device array
  53351. * @param deviceType Enum specifiying device type
  53352. * @param deviceSlot "Slot" or index that device is referenced in
  53353. * @param numberOfInputs Number of input entries to create for given device
  53354. */
  53355. private _registerDevice;
  53356. /**
  53357. * Given a specific device name, remove that device from the device map
  53358. * @param deviceType Enum specifiying device type
  53359. * @param deviceSlot "Slot" or index that device is referenced in
  53360. */
  53361. private _unregisterDevice;
  53362. /**
  53363. * Handle all actions that come from keyboard interaction
  53364. */
  53365. private _handleKeyActions;
  53366. /**
  53367. * Handle all actions that come from pointer interaction
  53368. */
  53369. private _handlePointerActions;
  53370. /**
  53371. * Handle all actions that come from gamepad interaction
  53372. */
  53373. private _handleGamepadActions;
  53374. /**
  53375. * Update all non-event based devices with each frame
  53376. * @param deviceType Enum specifiying device type
  53377. * @param deviceSlot "Slot" or index that device is referenced in
  53378. * @param inputIndex Id of input to be checked
  53379. */
  53380. private _updateDevice;
  53381. /**
  53382. * Gets DeviceType from the device name
  53383. * @param deviceName Name of Device from DeviceInputSystem
  53384. * @returns DeviceType enum value
  53385. */
  53386. private _getGamepadDeviceType;
  53387. }
  53388. }
  53389. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53390. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53391. /**
  53392. * Type to handle enforcement of inputs
  53393. */
  53394. 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;
  53395. }
  53396. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53397. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53398. import { Engine } from "babylonjs/Engines/engine";
  53399. import { IDisposable } from "babylonjs/scene";
  53400. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53401. import { Nullable } from "babylonjs/types";
  53402. import { Observable } from "babylonjs/Misc/observable";
  53403. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53404. /**
  53405. * Class that handles all input for a specific device
  53406. */
  53407. export class DeviceSource<T extends DeviceType> {
  53408. /** Type of device */
  53409. readonly deviceType: DeviceType;
  53410. /** "Slot" or index that device is referenced in */
  53411. readonly deviceSlot: number;
  53412. /**
  53413. * Observable to handle device input changes per device
  53414. */
  53415. readonly onInputChangedObservable: Observable<{
  53416. inputIndex: DeviceInput<T>;
  53417. previousState: Nullable<number>;
  53418. currentState: Nullable<number>;
  53419. }>;
  53420. private readonly _deviceInputSystem;
  53421. /**
  53422. * Default Constructor
  53423. * @param deviceInputSystem Reference to DeviceInputSystem
  53424. * @param deviceType Type of device
  53425. * @param deviceSlot "Slot" or index that device is referenced in
  53426. */
  53427. constructor(deviceInputSystem: DeviceInputSystem,
  53428. /** Type of device */
  53429. deviceType: DeviceType,
  53430. /** "Slot" or index that device is referenced in */
  53431. deviceSlot?: number);
  53432. /**
  53433. * Get input for specific input
  53434. * @param inputIndex index of specific input on device
  53435. * @returns Input value from DeviceInputSystem
  53436. */
  53437. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  53438. }
  53439. /**
  53440. * Class to keep track of devices
  53441. */
  53442. export class DeviceSourceManager implements IDisposable {
  53443. /**
  53444. * Observable to be triggered when before a device is connected
  53445. */
  53446. readonly onBeforeDeviceConnectedObservable: Observable<{
  53447. deviceType: DeviceType;
  53448. deviceSlot: number;
  53449. }>;
  53450. /**
  53451. * Observable to be triggered when before a device is disconnected
  53452. */
  53453. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53454. deviceType: DeviceType;
  53455. deviceSlot: number;
  53456. }>;
  53457. /**
  53458. * Observable to be triggered when after a device is connected
  53459. */
  53460. readonly onAfterDeviceConnectedObservable: Observable<{
  53461. deviceType: DeviceType;
  53462. deviceSlot: number;
  53463. }>;
  53464. /**
  53465. * Observable to be triggered when after a device is disconnected
  53466. */
  53467. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53468. deviceType: DeviceType;
  53469. deviceSlot: number;
  53470. }>;
  53471. private readonly _devices;
  53472. private readonly _firstDevice;
  53473. private readonly _deviceInputSystem;
  53474. /**
  53475. * Default Constructor
  53476. * @param engine engine to pull input element from
  53477. */
  53478. constructor(engine: Engine);
  53479. /**
  53480. * Gets a DeviceSource, given a type and slot
  53481. * @param deviceType Enum specifying device type
  53482. * @param deviceSlot "Slot" or index that device is referenced in
  53483. * @returns DeviceSource object
  53484. */
  53485. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53486. /**
  53487. * Gets an array of DeviceSource objects for a given device type
  53488. * @param deviceType Enum specifying device type
  53489. * @returns Array of DeviceSource objects
  53490. */
  53491. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53492. /**
  53493. * Dispose of DeviceInputSystem and other parts
  53494. */
  53495. dispose(): void;
  53496. /**
  53497. * Function to add device name to device list
  53498. * @param deviceType Enum specifying device type
  53499. * @param deviceSlot "Slot" or index that device is referenced in
  53500. */
  53501. private _addDevice;
  53502. /**
  53503. * Function to remove device name to device list
  53504. * @param deviceType Enum specifying device type
  53505. * @param deviceSlot "Slot" or index that device is referenced in
  53506. */
  53507. private _removeDevice;
  53508. /**
  53509. * Updates array storing first connected device of each type
  53510. * @param type Type of Device
  53511. */
  53512. private _updateFirstDevices;
  53513. }
  53514. }
  53515. declare module "babylonjs/DeviceInput/index" {
  53516. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53517. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53518. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53519. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53520. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53521. }
  53522. declare module "babylonjs/Engines/nullEngine" {
  53523. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53524. import { Engine } from "babylonjs/Engines/engine";
  53525. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53526. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53527. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53528. import { Effect } from "babylonjs/Materials/effect";
  53529. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53530. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53531. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53532. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53533. /**
  53534. * Options to create the null engine
  53535. */
  53536. export class NullEngineOptions {
  53537. /**
  53538. * Render width (Default: 512)
  53539. */
  53540. renderWidth: number;
  53541. /**
  53542. * Render height (Default: 256)
  53543. */
  53544. renderHeight: number;
  53545. /**
  53546. * Texture size (Default: 512)
  53547. */
  53548. textureSize: number;
  53549. /**
  53550. * If delta time between frames should be constant
  53551. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53552. */
  53553. deterministicLockstep: boolean;
  53554. /**
  53555. * Maximum about of steps between frames (Default: 4)
  53556. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53557. */
  53558. lockstepMaxSteps: number;
  53559. /**
  53560. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53561. */
  53562. useHighPrecisionMatrix?: boolean;
  53563. }
  53564. /**
  53565. * The null engine class provides support for headless version of babylon.js.
  53566. * This can be used in server side scenario or for testing purposes
  53567. */
  53568. export class NullEngine extends Engine {
  53569. private _options;
  53570. /**
  53571. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53572. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53573. * @returns true if engine is in deterministic lock step mode
  53574. */
  53575. isDeterministicLockStep(): boolean;
  53576. /**
  53577. * Gets the max steps when engine is running in deterministic lock step
  53578. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53579. * @returns the max steps
  53580. */
  53581. getLockstepMaxSteps(): number;
  53582. /**
  53583. * Gets the current hardware scaling level.
  53584. * By default the hardware scaling level is computed from the window device ratio.
  53585. * 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.
  53586. * @returns a number indicating the current hardware scaling level
  53587. */
  53588. getHardwareScalingLevel(): number;
  53589. constructor(options?: NullEngineOptions);
  53590. /**
  53591. * Creates a vertex buffer
  53592. * @param vertices the data for the vertex buffer
  53593. * @returns the new WebGL static buffer
  53594. */
  53595. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53596. /**
  53597. * Creates a new index buffer
  53598. * @param indices defines the content of the index buffer
  53599. * @param updatable defines if the index buffer must be updatable
  53600. * @returns a new webGL buffer
  53601. */
  53602. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53603. /**
  53604. * Clear the current render buffer or the current render target (if any is set up)
  53605. * @param color defines the color to use
  53606. * @param backBuffer defines if the back buffer must be cleared
  53607. * @param depth defines if the depth buffer must be cleared
  53608. * @param stencil defines if the stencil buffer must be cleared
  53609. */
  53610. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53611. /**
  53612. * Gets the current render width
  53613. * @param useScreen defines if screen size must be used (or the current render target if any)
  53614. * @returns a number defining the current render width
  53615. */
  53616. getRenderWidth(useScreen?: boolean): number;
  53617. /**
  53618. * Gets the current render height
  53619. * @param useScreen defines if screen size must be used (or the current render target if any)
  53620. * @returns a number defining the current render height
  53621. */
  53622. getRenderHeight(useScreen?: boolean): number;
  53623. /**
  53624. * Set the WebGL's viewport
  53625. * @param viewport defines the viewport element to be used
  53626. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53627. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53628. */
  53629. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53630. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53631. /**
  53632. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53633. * @param pipelineContext defines the pipeline context to use
  53634. * @param uniformsNames defines the list of uniform names
  53635. * @returns an array of webGL uniform locations
  53636. */
  53637. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53638. /**
  53639. * Gets the lsit of active attributes for a given webGL program
  53640. * @param pipelineContext defines the pipeline context to use
  53641. * @param attributesNames defines the list of attribute names to get
  53642. * @returns an array of indices indicating the offset of each attribute
  53643. */
  53644. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53645. /**
  53646. * Binds an effect to the webGL context
  53647. * @param effect defines the effect to bind
  53648. */
  53649. bindSamplers(effect: Effect): void;
  53650. /**
  53651. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53652. * @param effect defines the effect to activate
  53653. */
  53654. enableEffect(effect: Effect): void;
  53655. /**
  53656. * Set various states to the webGL context
  53657. * @param culling defines backface culling state
  53658. * @param zOffset defines the value to apply to zOffset (0 by default)
  53659. * @param force defines if states must be applied even if cache is up to date
  53660. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53661. */
  53662. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53663. /**
  53664. * Set the value of an uniform to an array of int32
  53665. * @param uniform defines the webGL uniform location where to store the value
  53666. * @param array defines the array of int32 to store
  53667. */
  53668. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53669. /**
  53670. * Set the value of an uniform to an array of int32 (stored as vec2)
  53671. * @param uniform defines the webGL uniform location where to store the value
  53672. * @param array defines the array of int32 to store
  53673. */
  53674. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53675. /**
  53676. * Set the value of an uniform to an array of int32 (stored as vec3)
  53677. * @param uniform defines the webGL uniform location where to store the value
  53678. * @param array defines the array of int32 to store
  53679. */
  53680. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53681. /**
  53682. * Set the value of an uniform to an array of int32 (stored as vec4)
  53683. * @param uniform defines the webGL uniform location where to store the value
  53684. * @param array defines the array of int32 to store
  53685. */
  53686. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53687. /**
  53688. * Set the value of an uniform to an array of float32
  53689. * @param uniform defines the webGL uniform location where to store the value
  53690. * @param array defines the array of float32 to store
  53691. */
  53692. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53693. /**
  53694. * Set the value of an uniform to an array of float32 (stored as vec2)
  53695. * @param uniform defines the webGL uniform location where to store the value
  53696. * @param array defines the array of float32 to store
  53697. */
  53698. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53699. /**
  53700. * Set the value of an uniform to an array of float32 (stored as vec3)
  53701. * @param uniform defines the webGL uniform location where to store the value
  53702. * @param array defines the array of float32 to store
  53703. */
  53704. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53705. /**
  53706. * Set the value of an uniform to an array of float32 (stored as vec4)
  53707. * @param uniform defines the webGL uniform location where to store the value
  53708. * @param array defines the array of float32 to store
  53709. */
  53710. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53711. /**
  53712. * Set the value of an uniform to an array of number
  53713. * @param uniform defines the webGL uniform location where to store the value
  53714. * @param array defines the array of number to store
  53715. */
  53716. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53717. /**
  53718. * Set the value of an uniform to an array of number (stored as vec2)
  53719. * @param uniform defines the webGL uniform location where to store the value
  53720. * @param array defines the array of number to store
  53721. */
  53722. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53723. /**
  53724. * Set the value of an uniform to an array of number (stored as vec3)
  53725. * @param uniform defines the webGL uniform location where to store the value
  53726. * @param array defines the array of number to store
  53727. */
  53728. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53729. /**
  53730. * Set the value of an uniform to an array of number (stored as vec4)
  53731. * @param uniform defines the webGL uniform location where to store the value
  53732. * @param array defines the array of number to store
  53733. */
  53734. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53735. /**
  53736. * Set the value of an uniform to an array of float32 (stored as matrices)
  53737. * @param uniform defines the webGL uniform location where to store the value
  53738. * @param matrices defines the array of float32 to store
  53739. */
  53740. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53741. /**
  53742. * Set the value of an uniform to a matrix (3x3)
  53743. * @param uniform defines the webGL uniform location where to store the value
  53744. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  53745. */
  53746. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53747. /**
  53748. * Set the value of an uniform to a matrix (2x2)
  53749. * @param uniform defines the webGL uniform location where to store the value
  53750. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  53751. */
  53752. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53753. /**
  53754. * Set the value of an uniform to a number (float)
  53755. * @param uniform defines the webGL uniform location where to store the value
  53756. * @param value defines the float number to store
  53757. */
  53758. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53759. /**
  53760. * Set the value of an uniform to a vec2
  53761. * @param uniform defines the webGL uniform location where to store the value
  53762. * @param x defines the 1st component of the value
  53763. * @param y defines the 2nd component of the value
  53764. */
  53765. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53766. /**
  53767. * Set the value of an uniform to a vec3
  53768. * @param uniform defines the webGL uniform location where to store the value
  53769. * @param x defines the 1st component of the value
  53770. * @param y defines the 2nd component of the value
  53771. * @param z defines the 3rd component of the value
  53772. */
  53773. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53774. /**
  53775. * Set the value of an uniform to a boolean
  53776. * @param uniform defines the webGL uniform location where to store the value
  53777. * @param bool defines the boolean to store
  53778. */
  53779. setBool(uniform: WebGLUniformLocation, bool: number): void;
  53780. /**
  53781. * Set the value of an uniform to a vec4
  53782. * @param uniform defines the webGL uniform location where to store the value
  53783. * @param x defines the 1st component of the value
  53784. * @param y defines the 2nd component of the value
  53785. * @param z defines the 3rd component of the value
  53786. * @param w defines the 4th component of the value
  53787. */
  53788. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53789. /**
  53790. * Sets the current alpha mode
  53791. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  53792. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53793. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53794. */
  53795. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53796. /**
  53797. * Bind webGl buffers directly to the webGL context
  53798. * @param vertexBuffers defines the vertex buffer to bind
  53799. * @param indexBuffer defines the index buffer to bind
  53800. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  53801. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  53802. * @param effect defines the effect associated with the vertex buffer
  53803. */
  53804. bindBuffers(vertexBuffers: {
  53805. [key: string]: VertexBuffer;
  53806. }, indexBuffer: DataBuffer, effect: Effect): void;
  53807. /**
  53808. * Force the entire cache to be cleared
  53809. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  53810. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  53811. */
  53812. wipeCaches(bruteForce?: boolean): void;
  53813. /**
  53814. * Send a draw order
  53815. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  53816. * @param indexStart defines the starting index
  53817. * @param indexCount defines the number of index to draw
  53818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53819. */
  53820. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  53821. /**
  53822. * Draw a list of indexed primitives
  53823. * @param fillMode defines the primitive to use
  53824. * @param indexStart defines the starting index
  53825. * @param indexCount defines the number of index to draw
  53826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53827. */
  53828. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53829. /**
  53830. * Draw a list of unindexed primitives
  53831. * @param fillMode defines the primitive to use
  53832. * @param verticesStart defines the index of first vertex to draw
  53833. * @param verticesCount defines the count of vertices to draw
  53834. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53835. */
  53836. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53837. /** @hidden */
  53838. _createTexture(): WebGLTexture;
  53839. /** @hidden */
  53840. _releaseTexture(texture: InternalTexture): void;
  53841. /**
  53842. * Usually called from Texture.ts.
  53843. * Passed information to create a WebGLTexture
  53844. * @param urlArg defines a value which contains one of the following:
  53845. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53846. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53847. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53848. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53849. * @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)
  53850. * @param scene needed for loading to the correct scene
  53851. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53852. * @param onLoad optional callback to be called upon successful completion
  53853. * @param onError optional callback to be called upon failure
  53854. * @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
  53855. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53856. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53857. * @param forcedExtension defines the extension to use to pick the right loader
  53858. * @param mimeType defines an optional mime type
  53859. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53860. */
  53861. 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;
  53862. /**
  53863. * Creates a new render target texture
  53864. * @param size defines the size of the texture
  53865. * @param options defines the options used to create the texture
  53866. * @returns a new render target texture stored in an InternalTexture
  53867. */
  53868. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  53869. /**
  53870. * Update the sampling mode of a given texture
  53871. * @param samplingMode defines the required sampling mode
  53872. * @param texture defines the texture to update
  53873. */
  53874. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53875. /**
  53876. * Binds the frame buffer to the specified texture.
  53877. * @param texture The texture to render to or null for the default canvas
  53878. * @param faceIndex The face of the texture to render to in case of cube texture
  53879. * @param requiredWidth The width of the target to render to
  53880. * @param requiredHeight The height of the target to render to
  53881. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  53882. * @param lodLevel defines le lod level to bind to the frame buffer
  53883. */
  53884. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53885. /**
  53886. * Unbind the current render target texture from the webGL context
  53887. * @param texture defines the render target texture to unbind
  53888. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53889. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53890. */
  53891. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53892. /**
  53893. * Creates a dynamic vertex buffer
  53894. * @param vertices the data for the dynamic vertex buffer
  53895. * @returns the new WebGL dynamic buffer
  53896. */
  53897. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  53898. /**
  53899. * Update the content of a dynamic texture
  53900. * @param texture defines the texture to update
  53901. * @param canvas defines the canvas containing the source
  53902. * @param invertY defines if data must be stored with Y axis inverted
  53903. * @param premulAlpha defines if alpha is stored as premultiplied
  53904. * @param format defines the format of the data
  53905. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53906. */
  53907. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53908. /**
  53909. * Gets a boolean indicating if all created effects are ready
  53910. * @returns true if all effects are ready
  53911. */
  53912. areAllEffectsReady(): boolean;
  53913. /**
  53914. * @hidden
  53915. * Get the current error code of the webGL context
  53916. * @returns the error code
  53917. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53918. */
  53919. getError(): number;
  53920. /** @hidden */
  53921. _getUnpackAlignement(): number;
  53922. /** @hidden */
  53923. _unpackFlipY(value: boolean): void;
  53924. /**
  53925. * Update a dynamic index buffer
  53926. * @param indexBuffer defines the target index buffer
  53927. * @param indices defines the data to update
  53928. * @param offset defines the offset in the target index buffer where update should start
  53929. */
  53930. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53931. /**
  53932. * Updates a dynamic vertex buffer.
  53933. * @param vertexBuffer the vertex buffer to update
  53934. * @param vertices the data used to update the vertex buffer
  53935. * @param byteOffset the byte offset of the data (optional)
  53936. * @param byteLength the byte length of the data (optional)
  53937. */
  53938. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  53939. /** @hidden */
  53940. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  53941. /** @hidden */
  53942. _bindTexture(channel: number, texture: InternalTexture): void;
  53943. protected _deleteBuffer(buffer: WebGLBuffer): void;
  53944. /**
  53945. * 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
  53946. */
  53947. releaseEffects(): void;
  53948. displayLoadingUI(): void;
  53949. hideLoadingUI(): void;
  53950. /** @hidden */
  53951. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53952. /** @hidden */
  53953. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53954. /** @hidden */
  53955. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53956. /** @hidden */
  53957. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53958. }
  53959. }
  53960. declare module "babylonjs/Instrumentation/timeToken" {
  53961. import { Nullable } from "babylonjs/types";
  53962. /**
  53963. * @hidden
  53964. **/
  53965. export class _TimeToken {
  53966. _startTimeQuery: Nullable<WebGLQuery>;
  53967. _endTimeQuery: Nullable<WebGLQuery>;
  53968. _timeElapsedQuery: Nullable<WebGLQuery>;
  53969. _timeElapsedQueryEnded: boolean;
  53970. }
  53971. }
  53972. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  53973. import { Nullable, int } from "babylonjs/types";
  53974. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  53975. /** @hidden */
  53976. export class _OcclusionDataStorage {
  53977. /** @hidden */
  53978. occlusionInternalRetryCounter: number;
  53979. /** @hidden */
  53980. isOcclusionQueryInProgress: boolean;
  53981. /** @hidden */
  53982. isOccluded: boolean;
  53983. /** @hidden */
  53984. occlusionRetryCount: number;
  53985. /** @hidden */
  53986. occlusionType: number;
  53987. /** @hidden */
  53988. occlusionQueryAlgorithmType: number;
  53989. }
  53990. module "babylonjs/Engines/engine" {
  53991. interface Engine {
  53992. /**
  53993. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53994. * @return the new query
  53995. */
  53996. createQuery(): WebGLQuery;
  53997. /**
  53998. * Delete and release a webGL query
  53999. * @param query defines the query to delete
  54000. * @return the current engine
  54001. */
  54002. deleteQuery(query: WebGLQuery): Engine;
  54003. /**
  54004. * Check if a given query has resolved and got its value
  54005. * @param query defines the query to check
  54006. * @returns true if the query got its value
  54007. */
  54008. isQueryResultAvailable(query: WebGLQuery): boolean;
  54009. /**
  54010. * Gets the value of a given query
  54011. * @param query defines the query to check
  54012. * @returns the value of the query
  54013. */
  54014. getQueryResult(query: WebGLQuery): number;
  54015. /**
  54016. * Initiates an occlusion query
  54017. * @param algorithmType defines the algorithm to use
  54018. * @param query defines the query to use
  54019. * @returns the current engine
  54020. * @see https://doc.babylonjs.com/features/occlusionquery
  54021. */
  54022. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54023. /**
  54024. * Ends an occlusion query
  54025. * @see https://doc.babylonjs.com/features/occlusionquery
  54026. * @param algorithmType defines the algorithm to use
  54027. * @returns the current engine
  54028. */
  54029. endOcclusionQuery(algorithmType: number): Engine;
  54030. /**
  54031. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54032. * Please note that only one query can be issued at a time
  54033. * @returns a time token used to track the time span
  54034. */
  54035. startTimeQuery(): Nullable<_TimeToken>;
  54036. /**
  54037. * Ends a time query
  54038. * @param token defines the token used to measure the time span
  54039. * @returns the time spent (in ns)
  54040. */
  54041. endTimeQuery(token: _TimeToken): int;
  54042. /** @hidden */
  54043. _currentNonTimestampToken: Nullable<_TimeToken>;
  54044. /** @hidden */
  54045. _createTimeQuery(): WebGLQuery;
  54046. /** @hidden */
  54047. _deleteTimeQuery(query: WebGLQuery): void;
  54048. /** @hidden */
  54049. _getGlAlgorithmType(algorithmType: number): number;
  54050. /** @hidden */
  54051. _getTimeQueryResult(query: WebGLQuery): any;
  54052. /** @hidden */
  54053. _getTimeQueryAvailability(query: WebGLQuery): any;
  54054. }
  54055. }
  54056. module "babylonjs/Meshes/abstractMesh" {
  54057. interface AbstractMesh {
  54058. /**
  54059. * Backing filed
  54060. * @hidden
  54061. */
  54062. __occlusionDataStorage: _OcclusionDataStorage;
  54063. /**
  54064. * Access property
  54065. * @hidden
  54066. */
  54067. _occlusionDataStorage: _OcclusionDataStorage;
  54068. /**
  54069. * 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.
  54070. * The default value is -1 which means don't break the query and wait till the result
  54071. * @see https://doc.babylonjs.com/features/occlusionquery
  54072. */
  54073. occlusionRetryCount: number;
  54074. /**
  54075. * 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:
  54076. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54077. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54078. * * 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.
  54079. * @see https://doc.babylonjs.com/features/occlusionquery
  54080. */
  54081. occlusionType: number;
  54082. /**
  54083. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54084. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54085. * * 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.
  54086. * @see https://doc.babylonjs.com/features/occlusionquery
  54087. */
  54088. occlusionQueryAlgorithmType: number;
  54089. /**
  54090. * 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
  54091. * @see https://doc.babylonjs.com/features/occlusionquery
  54092. */
  54093. isOccluded: boolean;
  54094. /**
  54095. * Flag to check the progress status of the query
  54096. * @see https://doc.babylonjs.com/features/occlusionquery
  54097. */
  54098. isOcclusionQueryInProgress: boolean;
  54099. }
  54100. }
  54101. }
  54102. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54103. import { Nullable } from "babylonjs/types";
  54104. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54105. /** @hidden */
  54106. export var _forceTransformFeedbackToBundle: boolean;
  54107. module "babylonjs/Engines/engine" {
  54108. interface Engine {
  54109. /**
  54110. * Creates a webGL transform feedback object
  54111. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54112. * @returns the webGL transform feedback object
  54113. */
  54114. createTransformFeedback(): WebGLTransformFeedback;
  54115. /**
  54116. * Delete a webGL transform feedback object
  54117. * @param value defines the webGL transform feedback object to delete
  54118. */
  54119. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54120. /**
  54121. * Bind a webGL transform feedback object to the webgl context
  54122. * @param value defines the webGL transform feedback object to bind
  54123. */
  54124. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54125. /**
  54126. * Begins a transform feedback operation
  54127. * @param usePoints defines if points or triangles must be used
  54128. */
  54129. beginTransformFeedback(usePoints: boolean): void;
  54130. /**
  54131. * Ends a transform feedback operation
  54132. */
  54133. endTransformFeedback(): void;
  54134. /**
  54135. * Specify the varyings to use with transform feedback
  54136. * @param program defines the associated webGL program
  54137. * @param value defines the list of strings representing the varying names
  54138. */
  54139. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54140. /**
  54141. * Bind a webGL buffer for a transform feedback operation
  54142. * @param value defines the webGL buffer to bind
  54143. */
  54144. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54145. }
  54146. }
  54147. }
  54148. declare module "babylonjs/Engines/Extensions/engine.views" {
  54149. import { Camera } from "babylonjs/Cameras/camera";
  54150. import { Nullable } from "babylonjs/types";
  54151. /**
  54152. * Class used to define an additional view for the engine
  54153. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54154. */
  54155. export class EngineView {
  54156. /** Defines the canvas where to render the view */
  54157. target: HTMLCanvasElement;
  54158. /** Defines an optional camera used to render the view (will use active camera else) */
  54159. camera?: Camera;
  54160. }
  54161. module "babylonjs/Engines/engine" {
  54162. interface Engine {
  54163. /**
  54164. * Gets or sets the HTML element to use for attaching events
  54165. */
  54166. inputElement: Nullable<HTMLElement>;
  54167. /**
  54168. * Gets the current engine view
  54169. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54170. */
  54171. activeView: Nullable<EngineView>;
  54172. /** Gets or sets the list of views */
  54173. views: EngineView[];
  54174. /**
  54175. * Register a new child canvas
  54176. * @param canvas defines the canvas to register
  54177. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54178. * @returns the associated view
  54179. */
  54180. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54181. /**
  54182. * Remove a registered child canvas
  54183. * @param canvas defines the canvas to remove
  54184. * @returns the current engine
  54185. */
  54186. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54187. }
  54188. }
  54189. }
  54190. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54191. import { Nullable } from "babylonjs/types";
  54192. module "babylonjs/Engines/engine" {
  54193. interface Engine {
  54194. /** @hidden */
  54195. _excludedCompressedTextures: string[];
  54196. /** @hidden */
  54197. _textureFormatInUse: string;
  54198. /**
  54199. * Gets the list of texture formats supported
  54200. */
  54201. readonly texturesSupported: Array<string>;
  54202. /**
  54203. * Gets the texture format in use
  54204. */
  54205. readonly textureFormatInUse: Nullable<string>;
  54206. /**
  54207. * Set the compressed texture extensions or file names to skip.
  54208. *
  54209. * @param skippedFiles defines the list of those texture files you want to skip
  54210. * Example: [".dds", ".env", "myfile.png"]
  54211. */
  54212. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54213. /**
  54214. * Set the compressed texture format to use, based on the formats you have, and the formats
  54215. * supported by the hardware / browser.
  54216. *
  54217. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54218. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54219. * to API arguments needed to compressed textures. This puts the burden on the container
  54220. * generator to house the arcane code for determining these for current & future formats.
  54221. *
  54222. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54223. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54224. *
  54225. * Note: The result of this call is not taken into account when a texture is base64.
  54226. *
  54227. * @param formatsAvailable defines the list of those format families you have created
  54228. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54229. *
  54230. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54231. * @returns The extension selected.
  54232. */
  54233. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54234. }
  54235. }
  54236. }
  54237. declare module "babylonjs/Engines/Extensions/index" {
  54238. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54239. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54240. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54241. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54242. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54243. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54244. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54245. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54246. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54247. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54248. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54249. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54250. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54251. export * from "babylonjs/Engines/Extensions/engine.views";
  54252. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54253. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54254. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54255. }
  54256. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54257. import { Nullable } from "babylonjs/types";
  54258. /**
  54259. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54260. */
  54261. export interface CubeMapInfo {
  54262. /**
  54263. * The pixel array for the front face.
  54264. * This is stored in format, left to right, up to down format.
  54265. */
  54266. front: Nullable<ArrayBufferView>;
  54267. /**
  54268. * The pixel array for the back face.
  54269. * This is stored in format, left to right, up to down format.
  54270. */
  54271. back: Nullable<ArrayBufferView>;
  54272. /**
  54273. * The pixel array for the left face.
  54274. * This is stored in format, left to right, up to down format.
  54275. */
  54276. left: Nullable<ArrayBufferView>;
  54277. /**
  54278. * The pixel array for the right face.
  54279. * This is stored in format, left to right, up to down format.
  54280. */
  54281. right: Nullable<ArrayBufferView>;
  54282. /**
  54283. * The pixel array for the up face.
  54284. * This is stored in format, left to right, up to down format.
  54285. */
  54286. up: Nullable<ArrayBufferView>;
  54287. /**
  54288. * The pixel array for the down face.
  54289. * This is stored in format, left to right, up to down format.
  54290. */
  54291. down: Nullable<ArrayBufferView>;
  54292. /**
  54293. * The size of the cubemap stored.
  54294. *
  54295. * Each faces will be size * size pixels.
  54296. */
  54297. size: number;
  54298. /**
  54299. * The format of the texture.
  54300. *
  54301. * RGBA, RGB.
  54302. */
  54303. format: number;
  54304. /**
  54305. * The type of the texture data.
  54306. *
  54307. * UNSIGNED_INT, FLOAT.
  54308. */
  54309. type: number;
  54310. /**
  54311. * Specifies whether the texture is in gamma space.
  54312. */
  54313. gammaSpace: boolean;
  54314. }
  54315. /**
  54316. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54317. */
  54318. export class PanoramaToCubeMapTools {
  54319. private static FACE_LEFT;
  54320. private static FACE_RIGHT;
  54321. private static FACE_FRONT;
  54322. private static FACE_BACK;
  54323. private static FACE_DOWN;
  54324. private static FACE_UP;
  54325. /**
  54326. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54327. *
  54328. * @param float32Array The source data.
  54329. * @param inputWidth The width of the input panorama.
  54330. * @param inputHeight The height of the input panorama.
  54331. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54332. * @return The cubemap data
  54333. */
  54334. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54335. private static CreateCubemapTexture;
  54336. private static CalcProjectionSpherical;
  54337. }
  54338. }
  54339. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54340. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54341. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54342. import { Nullable } from "babylonjs/types";
  54343. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54344. /**
  54345. * Helper class dealing with the extraction of spherical polynomial dataArray
  54346. * from a cube map.
  54347. */
  54348. export class CubeMapToSphericalPolynomialTools {
  54349. private static FileFaces;
  54350. /**
  54351. * Converts a texture to the according Spherical Polynomial data.
  54352. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54353. *
  54354. * @param texture The texture to extract the information from.
  54355. * @return The Spherical Polynomial data.
  54356. */
  54357. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54358. /**
  54359. * Converts a cubemap to the according Spherical Polynomial data.
  54360. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54361. *
  54362. * @param cubeInfo The Cube map to extract the information from.
  54363. * @return The Spherical Polynomial data.
  54364. */
  54365. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54366. }
  54367. }
  54368. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54369. import { Nullable } from "babylonjs/types";
  54370. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54371. module "babylonjs/Materials/Textures/baseTexture" {
  54372. interface BaseTexture {
  54373. /**
  54374. * Get the polynomial representation of the texture data.
  54375. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54376. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54377. */
  54378. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54379. }
  54380. }
  54381. }
  54382. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54383. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54384. /** @hidden */
  54385. export var rgbdEncodePixelShader: {
  54386. name: string;
  54387. shader: string;
  54388. };
  54389. }
  54390. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54391. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54392. /** @hidden */
  54393. export var rgbdDecodePixelShader: {
  54394. name: string;
  54395. shader: string;
  54396. };
  54397. }
  54398. declare module "babylonjs/Misc/environmentTextureTools" {
  54399. import { Nullable } from "babylonjs/types";
  54400. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54401. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54403. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54404. import "babylonjs/Engines/Extensions/engine.readTexture";
  54405. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54406. import "babylonjs/Shaders/rgbdEncode.fragment";
  54407. import "babylonjs/Shaders/rgbdDecode.fragment";
  54408. /**
  54409. * Raw texture data and descriptor sufficient for WebGL texture upload
  54410. */
  54411. export interface EnvironmentTextureInfo {
  54412. /**
  54413. * Version of the environment map
  54414. */
  54415. version: number;
  54416. /**
  54417. * Width of image
  54418. */
  54419. width: number;
  54420. /**
  54421. * Irradiance information stored in the file.
  54422. */
  54423. irradiance: any;
  54424. /**
  54425. * Specular information stored in the file.
  54426. */
  54427. specular: any;
  54428. }
  54429. /**
  54430. * Defines One Image in the file. It requires only the position in the file
  54431. * as well as the length.
  54432. */
  54433. interface BufferImageData {
  54434. /**
  54435. * Length of the image data.
  54436. */
  54437. length: number;
  54438. /**
  54439. * Position of the data from the null terminator delimiting the end of the JSON.
  54440. */
  54441. position: number;
  54442. }
  54443. /**
  54444. * Defines the specular data enclosed in the file.
  54445. * This corresponds to the version 1 of the data.
  54446. */
  54447. export interface EnvironmentTextureSpecularInfoV1 {
  54448. /**
  54449. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54450. */
  54451. specularDataPosition?: number;
  54452. /**
  54453. * This contains all the images data needed to reconstruct the cubemap.
  54454. */
  54455. mipmaps: Array<BufferImageData>;
  54456. /**
  54457. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54458. */
  54459. lodGenerationScale: number;
  54460. }
  54461. /**
  54462. * Sets of helpers addressing the serialization and deserialization of environment texture
  54463. * stored in a BabylonJS env file.
  54464. * Those files are usually stored as .env files.
  54465. */
  54466. export class EnvironmentTextureTools {
  54467. /**
  54468. * Magic number identifying the env file.
  54469. */
  54470. private static _MagicBytes;
  54471. /**
  54472. * Gets the environment info from an env file.
  54473. * @param data The array buffer containing the .env bytes.
  54474. * @returns the environment file info (the json header) if successfully parsed.
  54475. */
  54476. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54477. /**
  54478. * Creates an environment texture from a loaded cube texture.
  54479. * @param texture defines the cube texture to convert in env file
  54480. * @return a promise containing the environment data if succesfull.
  54481. */
  54482. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54483. /**
  54484. * Creates a JSON representation of the spherical data.
  54485. * @param texture defines the texture containing the polynomials
  54486. * @return the JSON representation of the spherical info
  54487. */
  54488. private static _CreateEnvTextureIrradiance;
  54489. /**
  54490. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54491. * @param data the image data
  54492. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54493. * @return the views described by info providing access to the underlying buffer
  54494. */
  54495. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54496. /**
  54497. * Uploads the texture info contained in the env file to the GPU.
  54498. * @param texture defines the internal texture to upload to
  54499. * @param data defines the data to load
  54500. * @param info defines the texture info retrieved through the GetEnvInfo method
  54501. * @returns a promise
  54502. */
  54503. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54504. private static _OnImageReadyAsync;
  54505. /**
  54506. * Uploads the levels of image data to the GPU.
  54507. * @param texture defines the internal texture to upload to
  54508. * @param imageData defines the array buffer views of image data [mipmap][face]
  54509. * @returns a promise
  54510. */
  54511. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54512. /**
  54513. * Uploads spherical polynomials information to the texture.
  54514. * @param texture defines the texture we are trying to upload the information to
  54515. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54516. */
  54517. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54518. /** @hidden */
  54519. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54520. }
  54521. }
  54522. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54523. /**
  54524. * Class used to inline functions in shader code
  54525. */
  54526. export class ShaderCodeInliner {
  54527. private static readonly _RegexpFindFunctionNameAndType;
  54528. private _sourceCode;
  54529. private _functionDescr;
  54530. private _numMaxIterations;
  54531. /** Gets or sets the token used to mark the functions to inline */
  54532. inlineToken: string;
  54533. /** Gets or sets the debug mode */
  54534. debug: boolean;
  54535. /** Gets the code after the inlining process */
  54536. get code(): string;
  54537. /**
  54538. * Initializes the inliner
  54539. * @param sourceCode shader code source to inline
  54540. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54541. */
  54542. constructor(sourceCode: string, numMaxIterations?: number);
  54543. /**
  54544. * Start the processing of the shader code
  54545. */
  54546. processCode(): void;
  54547. private _collectFunctions;
  54548. private _processInlining;
  54549. private _extractBetweenMarkers;
  54550. private _skipWhitespaces;
  54551. private _removeComments;
  54552. private _replaceFunctionCallsByCode;
  54553. private _findBackward;
  54554. private _escapeRegExp;
  54555. private _replaceNames;
  54556. }
  54557. }
  54558. declare module "babylonjs/Engines/nativeEngine" {
  54559. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54560. import { Engine } from "babylonjs/Engines/engine";
  54561. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54562. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54563. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54564. import { Effect } from "babylonjs/Materials/effect";
  54565. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54566. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54567. import { IColor4Like } from "babylonjs/Maths/math.like";
  54568. import { Scene } from "babylonjs/scene";
  54569. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54570. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54571. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54572. /**
  54573. * Container for accessors for natively-stored mesh data buffers.
  54574. */
  54575. class NativeDataBuffer extends DataBuffer {
  54576. /**
  54577. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54578. */
  54579. nativeIndexBuffer?: any;
  54580. /**
  54581. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54582. */
  54583. nativeVertexBuffer?: any;
  54584. }
  54585. /** @hidden */
  54586. class NativeTexture extends InternalTexture {
  54587. getInternalTexture(): InternalTexture;
  54588. getViewCount(): number;
  54589. }
  54590. /** @hidden */
  54591. export class NativeEngine extends Engine {
  54592. private readonly _native;
  54593. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54594. private readonly INVALID_HANDLE;
  54595. private _boundBuffersVertexArray;
  54596. getHardwareScalingLevel(): number;
  54597. constructor();
  54598. dispose(): void;
  54599. /**
  54600. * Can be used to override the current requestAnimationFrame requester.
  54601. * @hidden
  54602. */
  54603. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54604. /**
  54605. * Override default engine behavior.
  54606. * @param color
  54607. * @param backBuffer
  54608. * @param depth
  54609. * @param stencil
  54610. */
  54611. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54612. /**
  54613. * Gets host document
  54614. * @returns the host document object
  54615. */
  54616. getHostDocument(): Nullable<Document>;
  54617. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54618. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54619. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54620. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54621. [key: string]: VertexBuffer;
  54622. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54623. bindBuffers(vertexBuffers: {
  54624. [key: string]: VertexBuffer;
  54625. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54626. recordVertexArrayObject(vertexBuffers: {
  54627. [key: string]: VertexBuffer;
  54628. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54629. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54630. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54631. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54632. /**
  54633. * Draw a list of indexed primitives
  54634. * @param fillMode defines the primitive to use
  54635. * @param indexStart defines the starting index
  54636. * @param indexCount defines the number of index to draw
  54637. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54638. */
  54639. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54640. /**
  54641. * Draw a list of unindexed primitives
  54642. * @param fillMode defines the primitive to use
  54643. * @param verticesStart defines the index of first vertex to draw
  54644. * @param verticesCount defines the count of vertices to draw
  54645. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54646. */
  54647. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54648. createPipelineContext(): IPipelineContext;
  54649. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54650. /** @hidden */
  54651. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54652. /** @hidden */
  54653. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54654. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54655. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54656. protected _setProgram(program: WebGLProgram): void;
  54657. _releaseEffect(effect: Effect): void;
  54658. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54659. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54660. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54661. bindSamplers(effect: Effect): void;
  54662. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54663. getRenderWidth(useScreen?: boolean): number;
  54664. getRenderHeight(useScreen?: boolean): number;
  54665. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54666. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54667. /**
  54668. * Set the z offset to apply to current rendering
  54669. * @param value defines the offset to apply
  54670. */
  54671. setZOffset(value: number): void;
  54672. /**
  54673. * Gets the current value of the zOffset
  54674. * @returns the current zOffset state
  54675. */
  54676. getZOffset(): number;
  54677. /**
  54678. * Enable or disable depth buffering
  54679. * @param enable defines the state to set
  54680. */
  54681. setDepthBuffer(enable: boolean): void;
  54682. /**
  54683. * Gets a boolean indicating if depth writing is enabled
  54684. * @returns the current depth writing state
  54685. */
  54686. getDepthWrite(): boolean;
  54687. /**
  54688. * Enable or disable depth writing
  54689. * @param enable defines the state to set
  54690. */
  54691. setDepthWrite(enable: boolean): void;
  54692. /**
  54693. * Enable or disable color writing
  54694. * @param enable defines the state to set
  54695. */
  54696. setColorWrite(enable: boolean): void;
  54697. /**
  54698. * Gets a boolean indicating if color writing is enabled
  54699. * @returns the current color writing state
  54700. */
  54701. getColorWrite(): boolean;
  54702. /**
  54703. * Sets alpha constants used by some alpha blending modes
  54704. * @param r defines the red component
  54705. * @param g defines the green component
  54706. * @param b defines the blue component
  54707. * @param a defines the alpha component
  54708. */
  54709. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  54710. /**
  54711. * Sets the current alpha mode
  54712. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  54713. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54714. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54715. */
  54716. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54717. /**
  54718. * Gets the current alpha mode
  54719. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54720. * @returns the current alpha mode
  54721. */
  54722. getAlphaMode(): number;
  54723. setInt(uniform: WebGLUniformLocation, int: number): void;
  54724. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  54725. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  54726. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  54727. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  54728. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  54729. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54730. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54731. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54732. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54733. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54734. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54735. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54736. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54737. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54738. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54739. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54740. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54741. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54742. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54743. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  54744. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54745. wipeCaches(bruteForce?: boolean): void;
  54746. _createTexture(): WebGLTexture;
  54747. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54748. /**
  54749. * Usually called from Texture.ts.
  54750. * Passed information to create a WebGLTexture
  54751. * @param url defines a value which contains one of the following:
  54752. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54753. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54754. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54755. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54756. * @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)
  54757. * @param scene needed for loading to the correct scene
  54758. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54759. * @param onLoad optional callback to be called upon successful completion
  54760. * @param onError optional callback to be called upon failure
  54761. * @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
  54762. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54763. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54764. * @param forcedExtension defines the extension to use to pick the right loader
  54765. * @param mimeType defines an optional mime type
  54766. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54767. */
  54768. 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;
  54769. /**
  54770. * Creates a cube texture
  54771. * @param rootUrl defines the url where the files to load is located
  54772. * @param scene defines the current scene
  54773. * @param files defines the list of files to load (1 per face)
  54774. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54775. * @param onLoad defines an optional callback raised when the texture is loaded
  54776. * @param onError defines an optional callback raised if there is an issue to load the texture
  54777. * @param format defines the format of the data
  54778. * @param forcedExtension defines the extension to use to pick the right loader
  54779. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54780. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54781. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54782. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54783. * @returns the cube texture as an InternalTexture
  54784. */
  54785. 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;
  54786. private _getSamplingFilter;
  54787. private static _GetNativeTextureFormat;
  54788. createRenderTargetTexture(size: number | {
  54789. width: number;
  54790. height: number;
  54791. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54792. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54793. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54794. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54795. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54796. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54797. /**
  54798. * Updates a dynamic vertex buffer.
  54799. * @param vertexBuffer the vertex buffer to update
  54800. * @param data the data used to update the vertex buffer
  54801. * @param byteOffset the byte offset of the data (optional)
  54802. * @param byteLength the byte length of the data (optional)
  54803. */
  54804. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54805. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54806. private _updateAnisotropicLevel;
  54807. private _getAddressMode;
  54808. /** @hidden */
  54809. _bindTexture(channel: number, texture: InternalTexture): void;
  54810. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54811. releaseEffects(): void;
  54812. /** @hidden */
  54813. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54814. /** @hidden */
  54815. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54816. /** @hidden */
  54817. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54818. /** @hidden */
  54819. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54820. }
  54821. }
  54822. declare module "babylonjs/Engines/index" {
  54823. export * from "babylonjs/Engines/constants";
  54824. export * from "babylonjs/Engines/engineCapabilities";
  54825. export * from "babylonjs/Engines/instancingAttributeInfo";
  54826. export * from "babylonjs/Engines/thinEngine";
  54827. export * from "babylonjs/Engines/engine";
  54828. export * from "babylonjs/Engines/engineStore";
  54829. export * from "babylonjs/Engines/nullEngine";
  54830. export * from "babylonjs/Engines/Extensions/index";
  54831. export * from "babylonjs/Engines/IPipelineContext";
  54832. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54833. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54834. export * from "babylonjs/Engines/nativeEngine";
  54835. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54836. export * from "babylonjs/Engines/performanceConfigurator";
  54837. }
  54838. declare module "babylonjs/Events/clipboardEvents" {
  54839. /**
  54840. * Gather the list of clipboard event types as constants.
  54841. */
  54842. export class ClipboardEventTypes {
  54843. /**
  54844. * The clipboard event is fired when a copy command is active (pressed).
  54845. */
  54846. static readonly COPY: number;
  54847. /**
  54848. * The clipboard event is fired when a cut command is active (pressed).
  54849. */
  54850. static readonly CUT: number;
  54851. /**
  54852. * The clipboard event is fired when a paste command is active (pressed).
  54853. */
  54854. static readonly PASTE: number;
  54855. }
  54856. /**
  54857. * This class is used to store clipboard related info for the onClipboardObservable event.
  54858. */
  54859. export class ClipboardInfo {
  54860. /**
  54861. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54862. */
  54863. type: number;
  54864. /**
  54865. * Defines the related dom event
  54866. */
  54867. event: ClipboardEvent;
  54868. /**
  54869. *Creates an instance of ClipboardInfo.
  54870. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54871. * @param event Defines the related dom event
  54872. */
  54873. constructor(
  54874. /**
  54875. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54876. */
  54877. type: number,
  54878. /**
  54879. * Defines the related dom event
  54880. */
  54881. event: ClipboardEvent);
  54882. /**
  54883. * Get the clipboard event's type from the keycode.
  54884. * @param keyCode Defines the keyCode for the current keyboard event.
  54885. * @return {number}
  54886. */
  54887. static GetTypeFromCharacter(keyCode: number): number;
  54888. }
  54889. }
  54890. declare module "babylonjs/Events/index" {
  54891. export * from "babylonjs/Events/keyboardEvents";
  54892. export * from "babylonjs/Events/pointerEvents";
  54893. export * from "babylonjs/Events/clipboardEvents";
  54894. }
  54895. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54896. import { Scene } from "babylonjs/scene";
  54897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54898. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54899. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54900. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54901. /**
  54902. * Google Daydream controller
  54903. */
  54904. export class DaydreamController extends WebVRController {
  54905. /**
  54906. * Base Url for the controller model.
  54907. */
  54908. static MODEL_BASE_URL: string;
  54909. /**
  54910. * File name for the controller model.
  54911. */
  54912. static MODEL_FILENAME: string;
  54913. /**
  54914. * Gamepad Id prefix used to identify Daydream Controller.
  54915. */
  54916. static readonly GAMEPAD_ID_PREFIX: string;
  54917. /**
  54918. * Creates a new DaydreamController from a gamepad
  54919. * @param vrGamepad the gamepad that the controller should be created from
  54920. */
  54921. constructor(vrGamepad: any);
  54922. /**
  54923. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54924. * @param scene scene in which to add meshes
  54925. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54926. */
  54927. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54928. /**
  54929. * Called once for each button that changed state since the last frame
  54930. * @param buttonIdx Which button index changed
  54931. * @param state New state of the button
  54932. * @param changes Which properties on the state changed since last frame
  54933. */
  54934. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54935. }
  54936. }
  54937. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54938. import { Scene } from "babylonjs/scene";
  54939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54940. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54941. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54942. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54943. /**
  54944. * Gear VR Controller
  54945. */
  54946. export class GearVRController extends WebVRController {
  54947. /**
  54948. * Base Url for the controller model.
  54949. */
  54950. static MODEL_BASE_URL: string;
  54951. /**
  54952. * File name for the controller model.
  54953. */
  54954. static MODEL_FILENAME: string;
  54955. /**
  54956. * Gamepad Id prefix used to identify this controller.
  54957. */
  54958. static readonly GAMEPAD_ID_PREFIX: string;
  54959. private readonly _buttonIndexToObservableNameMap;
  54960. /**
  54961. * Creates a new GearVRController from a gamepad
  54962. * @param vrGamepad the gamepad that the controller should be created from
  54963. */
  54964. constructor(vrGamepad: any);
  54965. /**
  54966. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54967. * @param scene scene in which to add meshes
  54968. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54969. */
  54970. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54971. /**
  54972. * Called once for each button that changed state since the last frame
  54973. * @param buttonIdx Which button index changed
  54974. * @param state New state of the button
  54975. * @param changes Which properties on the state changed since last frame
  54976. */
  54977. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54978. }
  54979. }
  54980. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54981. import { Scene } from "babylonjs/scene";
  54982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54983. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54984. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54985. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54986. /**
  54987. * Generic Controller
  54988. */
  54989. export class GenericController extends WebVRController {
  54990. /**
  54991. * Base Url for the controller model.
  54992. */
  54993. static readonly MODEL_BASE_URL: string;
  54994. /**
  54995. * File name for the controller model.
  54996. */
  54997. static readonly MODEL_FILENAME: string;
  54998. /**
  54999. * Creates a new GenericController from a gamepad
  55000. * @param vrGamepad the gamepad that the controller should be created from
  55001. */
  55002. constructor(vrGamepad: any);
  55003. /**
  55004. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55005. * @param scene scene in which to add meshes
  55006. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55007. */
  55008. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55009. /**
  55010. * Called once for each button that changed state since the last frame
  55011. * @param buttonIdx Which button index changed
  55012. * @param state New state of the button
  55013. * @param changes Which properties on the state changed since last frame
  55014. */
  55015. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55016. }
  55017. }
  55018. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55019. import { Observable } from "babylonjs/Misc/observable";
  55020. import { Scene } from "babylonjs/scene";
  55021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55022. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55023. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55024. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55025. /**
  55026. * Oculus Touch Controller
  55027. */
  55028. export class OculusTouchController extends WebVRController {
  55029. /**
  55030. * Base Url for the controller model.
  55031. */
  55032. static MODEL_BASE_URL: string;
  55033. /**
  55034. * File name for the left controller model.
  55035. */
  55036. static MODEL_LEFT_FILENAME: string;
  55037. /**
  55038. * File name for the right controller model.
  55039. */
  55040. static MODEL_RIGHT_FILENAME: string;
  55041. /**
  55042. * Base Url for the Quest controller model.
  55043. */
  55044. static QUEST_MODEL_BASE_URL: string;
  55045. /**
  55046. * @hidden
  55047. * If the controllers are running on a device that needs the updated Quest controller models
  55048. */
  55049. static _IsQuest: boolean;
  55050. /**
  55051. * Fired when the secondary trigger on this controller is modified
  55052. */
  55053. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55054. /**
  55055. * Fired when the thumb rest on this controller is modified
  55056. */
  55057. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55058. /**
  55059. * Creates a new OculusTouchController from a gamepad
  55060. * @param vrGamepad the gamepad that the controller should be created from
  55061. */
  55062. constructor(vrGamepad: any);
  55063. /**
  55064. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55065. * @param scene scene in which to add meshes
  55066. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55067. */
  55068. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55069. /**
  55070. * Fired when the A button on this controller is modified
  55071. */
  55072. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55073. /**
  55074. * Fired when the B button on this controller is modified
  55075. */
  55076. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55077. /**
  55078. * Fired when the X button on this controller is modified
  55079. */
  55080. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55081. /**
  55082. * Fired when the Y button on this controller is modified
  55083. */
  55084. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55085. /**
  55086. * Called once for each button that changed state since the last frame
  55087. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55088. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55089. * 2) secondary trigger (same)
  55090. * 3) A (right) X (left), touch, pressed = value
  55091. * 4) B / Y
  55092. * 5) thumb rest
  55093. * @param buttonIdx Which button index changed
  55094. * @param state New state of the button
  55095. * @param changes Which properties on the state changed since last frame
  55096. */
  55097. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55098. }
  55099. }
  55100. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55101. import { Scene } from "babylonjs/scene";
  55102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55103. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55104. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55105. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55106. import { Observable } from "babylonjs/Misc/observable";
  55107. /**
  55108. * Vive Controller
  55109. */
  55110. export class ViveController extends WebVRController {
  55111. /**
  55112. * Base Url for the controller model.
  55113. */
  55114. static MODEL_BASE_URL: string;
  55115. /**
  55116. * File name for the controller model.
  55117. */
  55118. static MODEL_FILENAME: string;
  55119. /**
  55120. * Creates a new ViveController from a gamepad
  55121. * @param vrGamepad the gamepad that the controller should be created from
  55122. */
  55123. constructor(vrGamepad: any);
  55124. /**
  55125. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55126. * @param scene scene in which to add meshes
  55127. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55128. */
  55129. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55130. /**
  55131. * Fired when the left button on this controller is modified
  55132. */
  55133. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55134. /**
  55135. * Fired when the right button on this controller is modified
  55136. */
  55137. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55138. /**
  55139. * Fired when the menu button on this controller is modified
  55140. */
  55141. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55142. /**
  55143. * Called once for each button that changed state since the last frame
  55144. * Vive mapping:
  55145. * 0: touchpad
  55146. * 1: trigger
  55147. * 2: left AND right buttons
  55148. * 3: menu button
  55149. * @param buttonIdx Which button index changed
  55150. * @param state New state of the button
  55151. * @param changes Which properties on the state changed since last frame
  55152. */
  55153. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55154. }
  55155. }
  55156. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55157. import { Observable } from "babylonjs/Misc/observable";
  55158. import { Scene } from "babylonjs/scene";
  55159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55160. import { Ray } from "babylonjs/Culling/ray";
  55161. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55162. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55163. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55164. /**
  55165. * Defines the WindowsMotionController object that the state of the windows motion controller
  55166. */
  55167. export class WindowsMotionController extends WebVRController {
  55168. /**
  55169. * The base url used to load the left and right controller models
  55170. */
  55171. static MODEL_BASE_URL: string;
  55172. /**
  55173. * The name of the left controller model file
  55174. */
  55175. static MODEL_LEFT_FILENAME: string;
  55176. /**
  55177. * The name of the right controller model file
  55178. */
  55179. static MODEL_RIGHT_FILENAME: string;
  55180. /**
  55181. * The controller name prefix for this controller type
  55182. */
  55183. static readonly GAMEPAD_ID_PREFIX: string;
  55184. /**
  55185. * The controller id pattern for this controller type
  55186. */
  55187. private static readonly GAMEPAD_ID_PATTERN;
  55188. private _loadedMeshInfo;
  55189. protected readonly _mapping: {
  55190. buttons: string[];
  55191. buttonMeshNames: {
  55192. trigger: string;
  55193. menu: string;
  55194. grip: string;
  55195. thumbstick: string;
  55196. trackpad: string;
  55197. };
  55198. buttonObservableNames: {
  55199. trigger: string;
  55200. menu: string;
  55201. grip: string;
  55202. thumbstick: string;
  55203. trackpad: string;
  55204. };
  55205. axisMeshNames: string[];
  55206. pointingPoseMeshName: string;
  55207. };
  55208. /**
  55209. * Fired when the trackpad on this controller is clicked
  55210. */
  55211. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55212. /**
  55213. * Fired when the trackpad on this controller is modified
  55214. */
  55215. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55216. /**
  55217. * The current x and y values of this controller's trackpad
  55218. */
  55219. trackpad: StickValues;
  55220. /**
  55221. * Creates a new WindowsMotionController from a gamepad
  55222. * @param vrGamepad the gamepad that the controller should be created from
  55223. */
  55224. constructor(vrGamepad: any);
  55225. /**
  55226. * Fired when the trigger on this controller is modified
  55227. */
  55228. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55229. /**
  55230. * Fired when the menu button on this controller is modified
  55231. */
  55232. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55233. /**
  55234. * Fired when the grip button on this controller is modified
  55235. */
  55236. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55237. /**
  55238. * Fired when the thumbstick button on this controller is modified
  55239. */
  55240. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55241. /**
  55242. * Fired when the touchpad button on this controller is modified
  55243. */
  55244. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55245. /**
  55246. * Fired when the touchpad values on this controller are modified
  55247. */
  55248. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55249. protected _updateTrackpad(): void;
  55250. /**
  55251. * Called once per frame by the engine.
  55252. */
  55253. update(): void;
  55254. /**
  55255. * Called once for each button that changed state since the last frame
  55256. * @param buttonIdx Which button index changed
  55257. * @param state New state of the button
  55258. * @param changes Which properties on the state changed since last frame
  55259. */
  55260. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55261. /**
  55262. * Moves the buttons on the controller mesh based on their current state
  55263. * @param buttonName the name of the button to move
  55264. * @param buttonValue the value of the button which determines the buttons new position
  55265. */
  55266. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55267. /**
  55268. * Moves the axis on the controller mesh based on its current state
  55269. * @param axis the index of the axis
  55270. * @param axisValue the value of the axis which determines the meshes new position
  55271. * @hidden
  55272. */
  55273. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55274. /**
  55275. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55276. * @param scene scene in which to add meshes
  55277. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55278. */
  55279. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55280. /**
  55281. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55282. * can be transformed by button presses and axes values, based on this._mapping.
  55283. *
  55284. * @param scene scene in which the meshes exist
  55285. * @param meshes list of meshes that make up the controller model to process
  55286. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55287. */
  55288. private processModel;
  55289. private createMeshInfo;
  55290. /**
  55291. * Gets the ray of the controller in the direction the controller is pointing
  55292. * @param length the length the resulting ray should be
  55293. * @returns a ray in the direction the controller is pointing
  55294. */
  55295. getForwardRay(length?: number): Ray;
  55296. /**
  55297. * Disposes of the controller
  55298. */
  55299. dispose(): void;
  55300. }
  55301. /**
  55302. * This class represents a new windows motion controller in XR.
  55303. */
  55304. export class XRWindowsMotionController extends WindowsMotionController {
  55305. /**
  55306. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55307. */
  55308. protected readonly _mapping: {
  55309. buttons: string[];
  55310. buttonMeshNames: {
  55311. trigger: string;
  55312. menu: string;
  55313. grip: string;
  55314. thumbstick: string;
  55315. trackpad: string;
  55316. };
  55317. buttonObservableNames: {
  55318. trigger: string;
  55319. menu: string;
  55320. grip: string;
  55321. thumbstick: string;
  55322. trackpad: string;
  55323. };
  55324. axisMeshNames: string[];
  55325. pointingPoseMeshName: string;
  55326. };
  55327. /**
  55328. * Construct a new XR-Based windows motion controller
  55329. *
  55330. * @param gamepadInfo the gamepad object from the browser
  55331. */
  55332. constructor(gamepadInfo: any);
  55333. /**
  55334. * holds the thumbstick values (X,Y)
  55335. */
  55336. thumbstickValues: StickValues;
  55337. /**
  55338. * Fired when the thumbstick on this controller is clicked
  55339. */
  55340. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55341. /**
  55342. * Fired when the thumbstick on this controller is modified
  55343. */
  55344. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55345. /**
  55346. * Fired when the touchpad button on this controller is modified
  55347. */
  55348. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55349. /**
  55350. * Fired when the touchpad values on this controller are modified
  55351. */
  55352. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55353. /**
  55354. * Fired when the thumbstick button on this controller is modified
  55355. * here to prevent breaking changes
  55356. */
  55357. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55358. /**
  55359. * updating the thumbstick(!) and not the trackpad.
  55360. * This is named this way due to the difference between WebVR and XR and to avoid
  55361. * changing the parent class.
  55362. */
  55363. protected _updateTrackpad(): void;
  55364. /**
  55365. * Disposes the class with joy
  55366. */
  55367. dispose(): void;
  55368. }
  55369. }
  55370. declare module "babylonjs/Gamepads/Controllers/index" {
  55371. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55372. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55373. export * from "babylonjs/Gamepads/Controllers/genericController";
  55374. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55375. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55376. export * from "babylonjs/Gamepads/Controllers/viveController";
  55377. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55378. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55379. }
  55380. declare module "babylonjs/Gamepads/index" {
  55381. export * from "babylonjs/Gamepads/Controllers/index";
  55382. export * from "babylonjs/Gamepads/gamepad";
  55383. export * from "babylonjs/Gamepads/gamepadManager";
  55384. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55385. export * from "babylonjs/Gamepads/xboxGamepad";
  55386. export * from "babylonjs/Gamepads/dualShockGamepad";
  55387. }
  55388. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55389. import { Scene } from "babylonjs/scene";
  55390. import { Vector4 } from "babylonjs/Maths/math.vector";
  55391. import { Color4 } from "babylonjs/Maths/math.color";
  55392. import { Mesh } from "babylonjs/Meshes/mesh";
  55393. import { Nullable } from "babylonjs/types";
  55394. /**
  55395. * Class containing static functions to help procedurally build meshes
  55396. */
  55397. export class PolyhedronBuilder {
  55398. /**
  55399. * Creates a polyhedron mesh
  55400. * * 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
  55401. * * The parameter `size` (positive float, default 1) sets the polygon size
  55402. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55403. * * 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`
  55404. * * 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
  55405. * * 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)`)
  55406. * * 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
  55407. * * 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
  55408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55411. * @param name defines the name of the mesh
  55412. * @param options defines the options used to create the mesh
  55413. * @param scene defines the hosting scene
  55414. * @returns the polyhedron mesh
  55415. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55416. */
  55417. static CreatePolyhedron(name: string, options: {
  55418. type?: number;
  55419. size?: number;
  55420. sizeX?: number;
  55421. sizeY?: number;
  55422. sizeZ?: number;
  55423. custom?: any;
  55424. faceUV?: Vector4[];
  55425. faceColors?: Color4[];
  55426. flat?: boolean;
  55427. updatable?: boolean;
  55428. sideOrientation?: number;
  55429. frontUVs?: Vector4;
  55430. backUVs?: Vector4;
  55431. }, scene?: Nullable<Scene>): Mesh;
  55432. }
  55433. }
  55434. declare module "babylonjs/Gizmos/scaleGizmo" {
  55435. import { Observable } from "babylonjs/Misc/observable";
  55436. import { Nullable } from "babylonjs/types";
  55437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55438. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55439. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55440. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55441. import { Node } from "babylonjs/node";
  55442. /**
  55443. * Gizmo that enables scaling a mesh along 3 axis
  55444. */
  55445. export class ScaleGizmo extends Gizmo {
  55446. /**
  55447. * Internal gizmo used for interactions on the x axis
  55448. */
  55449. xGizmo: AxisScaleGizmo;
  55450. /**
  55451. * Internal gizmo used for interactions on the y axis
  55452. */
  55453. yGizmo: AxisScaleGizmo;
  55454. /**
  55455. * Internal gizmo used for interactions on the z axis
  55456. */
  55457. zGizmo: AxisScaleGizmo;
  55458. /**
  55459. * Internal gizmo used to scale all axis equally
  55460. */
  55461. uniformScaleGizmo: AxisScaleGizmo;
  55462. private _meshAttached;
  55463. private _nodeAttached;
  55464. private _updateGizmoRotationToMatchAttachedMesh;
  55465. private _snapDistance;
  55466. private _scaleRatio;
  55467. private _uniformScalingMesh;
  55468. private _octahedron;
  55469. private _sensitivity;
  55470. /** Fires an event when any of it's sub gizmos are dragged */
  55471. onDragStartObservable: Observable<unknown>;
  55472. /** Fires an event when any of it's sub gizmos are released from dragging */
  55473. onDragEndObservable: Observable<unknown>;
  55474. get attachedMesh(): Nullable<AbstractMesh>;
  55475. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55476. get attachedNode(): Nullable<Node>;
  55477. set attachedNode(node: Nullable<Node>);
  55478. /**
  55479. * Creates a ScaleGizmo
  55480. * @param gizmoLayer The utility layer the gizmo will be added to
  55481. * @param thickness display gizmo axis thickness
  55482. */
  55483. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55484. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55485. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55486. /**
  55487. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55488. */
  55489. set snapDistance(value: number);
  55490. get snapDistance(): number;
  55491. /**
  55492. * Ratio for the scale of the gizmo (Default: 1)
  55493. */
  55494. set scaleRatio(value: number);
  55495. get scaleRatio(): number;
  55496. /**
  55497. * Sensitivity factor for dragging (Default: 1)
  55498. */
  55499. set sensitivity(value: number);
  55500. get sensitivity(): number;
  55501. /**
  55502. * Disposes of the gizmo
  55503. */
  55504. dispose(): void;
  55505. }
  55506. }
  55507. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55508. import { Observable } from "babylonjs/Misc/observable";
  55509. import { Nullable } from "babylonjs/types";
  55510. import { Vector3 } from "babylonjs/Maths/math.vector";
  55511. import { Node } from "babylonjs/node";
  55512. import { Mesh } from "babylonjs/Meshes/mesh";
  55513. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55514. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55515. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55516. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55517. import { Color3 } from "babylonjs/Maths/math.color";
  55518. /**
  55519. * Single axis scale gizmo
  55520. */
  55521. export class AxisScaleGizmo extends Gizmo {
  55522. /**
  55523. * Drag behavior responsible for the gizmos dragging interactions
  55524. */
  55525. dragBehavior: PointerDragBehavior;
  55526. private _pointerObserver;
  55527. /**
  55528. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55529. */
  55530. snapDistance: number;
  55531. /**
  55532. * Event that fires each time the gizmo snaps to a new location.
  55533. * * snapDistance is the the change in distance
  55534. */
  55535. onSnapObservable: Observable<{
  55536. snapDistance: number;
  55537. }>;
  55538. /**
  55539. * If the scaling operation should be done on all axis (default: false)
  55540. */
  55541. uniformScaling: boolean;
  55542. /**
  55543. * Custom sensitivity value for the drag strength
  55544. */
  55545. sensitivity: number;
  55546. private _isEnabled;
  55547. private _parent;
  55548. private _arrow;
  55549. private _coloredMaterial;
  55550. private _hoverMaterial;
  55551. /**
  55552. * Creates an AxisScaleGizmo
  55553. * @param gizmoLayer The utility layer the gizmo will be added to
  55554. * @param dragAxis The axis which the gizmo will be able to scale on
  55555. * @param color The color of the gizmo
  55556. * @param thickness display gizmo axis thickness
  55557. */
  55558. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55559. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55560. /**
  55561. * If the gizmo is enabled
  55562. */
  55563. set isEnabled(value: boolean);
  55564. get isEnabled(): boolean;
  55565. /**
  55566. * Disposes of the gizmo
  55567. */
  55568. dispose(): void;
  55569. /**
  55570. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55571. * @param mesh The mesh to replace the default mesh of the gizmo
  55572. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55573. */
  55574. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55575. }
  55576. }
  55577. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55578. import { Observable } from "babylonjs/Misc/observable";
  55579. import { Nullable } from "babylonjs/types";
  55580. import { Vector3 } from "babylonjs/Maths/math.vector";
  55581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55582. import { Mesh } from "babylonjs/Meshes/mesh";
  55583. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55584. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55585. import { Color3 } from "babylonjs/Maths/math.color";
  55586. import "babylonjs/Meshes/Builders/boxBuilder";
  55587. /**
  55588. * Bounding box gizmo
  55589. */
  55590. export class BoundingBoxGizmo extends Gizmo {
  55591. private _lineBoundingBox;
  55592. private _rotateSpheresParent;
  55593. private _scaleBoxesParent;
  55594. private _boundingDimensions;
  55595. private _renderObserver;
  55596. private _pointerObserver;
  55597. private _scaleDragSpeed;
  55598. private _tmpQuaternion;
  55599. private _tmpVector;
  55600. private _tmpRotationMatrix;
  55601. /**
  55602. * 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)
  55603. */
  55604. ignoreChildren: boolean;
  55605. /**
  55606. * 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)
  55607. */
  55608. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55609. /**
  55610. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55611. */
  55612. rotationSphereSize: number;
  55613. /**
  55614. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55615. */
  55616. scaleBoxSize: number;
  55617. /**
  55618. * 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)
  55619. */
  55620. fixedDragMeshScreenSize: boolean;
  55621. /**
  55622. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55623. */
  55624. fixedDragMeshScreenSizeDistanceFactor: number;
  55625. /**
  55626. * Fired when a rotation sphere or scale box is dragged
  55627. */
  55628. onDragStartObservable: Observable<{}>;
  55629. /**
  55630. * Fired when a scale box is dragged
  55631. */
  55632. onScaleBoxDragObservable: Observable<{}>;
  55633. /**
  55634. * Fired when a scale box drag is ended
  55635. */
  55636. onScaleBoxDragEndObservable: Observable<{}>;
  55637. /**
  55638. * Fired when a rotation sphere is dragged
  55639. */
  55640. onRotationSphereDragObservable: Observable<{}>;
  55641. /**
  55642. * Fired when a rotation sphere drag is ended
  55643. */
  55644. onRotationSphereDragEndObservable: Observable<{}>;
  55645. /**
  55646. * 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)
  55647. */
  55648. scalePivot: Nullable<Vector3>;
  55649. /**
  55650. * Mesh used as a pivot to rotate the attached node
  55651. */
  55652. private _anchorMesh;
  55653. private _existingMeshScale;
  55654. private _dragMesh;
  55655. private pointerDragBehavior;
  55656. private coloredMaterial;
  55657. private hoverColoredMaterial;
  55658. /**
  55659. * Sets the color of the bounding box gizmo
  55660. * @param color the color to set
  55661. */
  55662. setColor(color: Color3): void;
  55663. /**
  55664. * Creates an BoundingBoxGizmo
  55665. * @param gizmoLayer The utility layer the gizmo will be added to
  55666. * @param color The color of the gizmo
  55667. */
  55668. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55669. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55670. private _selectNode;
  55671. /**
  55672. * Updates the bounding box information for the Gizmo
  55673. */
  55674. updateBoundingBox(): void;
  55675. private _updateRotationSpheres;
  55676. private _updateScaleBoxes;
  55677. /**
  55678. * Enables rotation on the specified axis and disables rotation on the others
  55679. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55680. */
  55681. setEnabledRotationAxis(axis: string): void;
  55682. /**
  55683. * Enables/disables scaling
  55684. * @param enable if scaling should be enabled
  55685. * @param homogeneousScaling defines if scaling should only be homogeneous
  55686. */
  55687. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55688. private _updateDummy;
  55689. /**
  55690. * Enables a pointer drag behavior on the bounding box of the gizmo
  55691. */
  55692. enableDragBehavior(): void;
  55693. /**
  55694. * Disposes of the gizmo
  55695. */
  55696. dispose(): void;
  55697. /**
  55698. * 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)
  55699. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  55700. * @returns the bounding box mesh with the passed in mesh as a child
  55701. */
  55702. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  55703. /**
  55704. * CustomMeshes are not supported by this gizmo
  55705. * @param mesh The mesh to replace the default mesh of the gizmo
  55706. */
  55707. setCustomMesh(mesh: Mesh): void;
  55708. }
  55709. }
  55710. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  55711. import { Observable } from "babylonjs/Misc/observable";
  55712. import { Nullable } from "babylonjs/types";
  55713. import { Vector3 } from "babylonjs/Maths/math.vector";
  55714. import { Color3 } from "babylonjs/Maths/math.color";
  55715. import { Node } from "babylonjs/node";
  55716. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55717. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55718. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55719. import "babylonjs/Meshes/Builders/linesBuilder";
  55720. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55721. /**
  55722. * Single plane rotation gizmo
  55723. */
  55724. export class PlaneRotationGizmo extends Gizmo {
  55725. /**
  55726. * Drag behavior responsible for the gizmos dragging interactions
  55727. */
  55728. dragBehavior: PointerDragBehavior;
  55729. private _pointerObserver;
  55730. /**
  55731. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  55732. */
  55733. snapDistance: number;
  55734. /**
  55735. * Event that fires each time the gizmo snaps to a new location.
  55736. * * snapDistance is the the change in distance
  55737. */
  55738. onSnapObservable: Observable<{
  55739. snapDistance: number;
  55740. }>;
  55741. private _isEnabled;
  55742. private _parent;
  55743. /**
  55744. * Creates a PlaneRotationGizmo
  55745. * @param gizmoLayer The utility layer the gizmo will be added to
  55746. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  55747. * @param color The color of the gizmo
  55748. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55749. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55750. * @param thickness display gizmo axis thickness
  55751. */
  55752. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  55753. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55754. /**
  55755. * If the gizmo is enabled
  55756. */
  55757. set isEnabled(value: boolean);
  55758. get isEnabled(): boolean;
  55759. /**
  55760. * Disposes of the gizmo
  55761. */
  55762. dispose(): void;
  55763. }
  55764. }
  55765. declare module "babylonjs/Gizmos/rotationGizmo" {
  55766. import { Observable } from "babylonjs/Misc/observable";
  55767. import { Nullable } from "babylonjs/types";
  55768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55769. import { Mesh } from "babylonjs/Meshes/mesh";
  55770. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55771. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55772. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55773. import { Node } from "babylonjs/node";
  55774. /**
  55775. * Gizmo that enables rotating a mesh along 3 axis
  55776. */
  55777. export class RotationGizmo extends Gizmo {
  55778. /**
  55779. * Internal gizmo used for interactions on the x axis
  55780. */
  55781. xGizmo: PlaneRotationGizmo;
  55782. /**
  55783. * Internal gizmo used for interactions on the y axis
  55784. */
  55785. yGizmo: PlaneRotationGizmo;
  55786. /**
  55787. * Internal gizmo used for interactions on the z axis
  55788. */
  55789. zGizmo: PlaneRotationGizmo;
  55790. /** Fires an event when any of it's sub gizmos are dragged */
  55791. onDragStartObservable: Observable<unknown>;
  55792. /** Fires an event when any of it's sub gizmos are released from dragging */
  55793. onDragEndObservable: Observable<unknown>;
  55794. private _meshAttached;
  55795. private _nodeAttached;
  55796. get attachedMesh(): Nullable<AbstractMesh>;
  55797. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55798. get attachedNode(): Nullable<Node>;
  55799. set attachedNode(node: Nullable<Node>);
  55800. /**
  55801. * Creates a RotationGizmo
  55802. * @param gizmoLayer The utility layer the gizmo will be added to
  55803. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55804. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55805. * @param thickness display gizmo axis thickness
  55806. */
  55807. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  55808. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55809. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55810. /**
  55811. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55812. */
  55813. set snapDistance(value: number);
  55814. get snapDistance(): number;
  55815. /**
  55816. * Ratio for the scale of the gizmo (Default: 1)
  55817. */
  55818. set scaleRatio(value: number);
  55819. get scaleRatio(): number;
  55820. /**
  55821. * Disposes of the gizmo
  55822. */
  55823. dispose(): void;
  55824. /**
  55825. * CustomMeshes are not supported by this gizmo
  55826. * @param mesh The mesh to replace the default mesh of the gizmo
  55827. */
  55828. setCustomMesh(mesh: Mesh): void;
  55829. }
  55830. }
  55831. declare module "babylonjs/Gizmos/gizmoManager" {
  55832. import { Observable } from "babylonjs/Misc/observable";
  55833. import { Nullable } from "babylonjs/types";
  55834. import { Scene, IDisposable } from "babylonjs/scene";
  55835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55836. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55837. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55838. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55839. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55840. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55841. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55842. /**
  55843. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55844. */
  55845. export class GizmoManager implements IDisposable {
  55846. private scene;
  55847. /**
  55848. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55849. */
  55850. gizmos: {
  55851. positionGizmo: Nullable<PositionGizmo>;
  55852. rotationGizmo: Nullable<RotationGizmo>;
  55853. scaleGizmo: Nullable<ScaleGizmo>;
  55854. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55855. };
  55856. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55857. clearGizmoOnEmptyPointerEvent: boolean;
  55858. /** Fires an event when the manager is attached to a mesh */
  55859. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55860. private _gizmosEnabled;
  55861. private _pointerObserver;
  55862. private _attachedMesh;
  55863. private _boundingBoxColor;
  55864. private _defaultUtilityLayer;
  55865. private _defaultKeepDepthUtilityLayer;
  55866. private _thickness;
  55867. /**
  55868. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55869. */
  55870. boundingBoxDragBehavior: SixDofDragBehavior;
  55871. /**
  55872. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55873. */
  55874. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55875. /**
  55876. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55877. */
  55878. usePointerToAttachGizmos: boolean;
  55879. /**
  55880. * Utility layer that the bounding box gizmo belongs to
  55881. */
  55882. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55883. /**
  55884. * Utility layer that all gizmos besides bounding box belong to
  55885. */
  55886. get utilityLayer(): UtilityLayerRenderer;
  55887. /**
  55888. * Instatiates a gizmo manager
  55889. * @param scene the scene to overlay the gizmos on top of
  55890. * @param thickness display gizmo axis thickness
  55891. */
  55892. constructor(scene: Scene, thickness?: number);
  55893. /**
  55894. * Attaches a set of gizmos to the specified mesh
  55895. * @param mesh The mesh the gizmo's should be attached to
  55896. */
  55897. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55898. /**
  55899. * If the position gizmo is enabled
  55900. */
  55901. set positionGizmoEnabled(value: boolean);
  55902. get positionGizmoEnabled(): boolean;
  55903. /**
  55904. * If the rotation gizmo is enabled
  55905. */
  55906. set rotationGizmoEnabled(value: boolean);
  55907. get rotationGizmoEnabled(): boolean;
  55908. /**
  55909. * If the scale gizmo is enabled
  55910. */
  55911. set scaleGizmoEnabled(value: boolean);
  55912. get scaleGizmoEnabled(): boolean;
  55913. /**
  55914. * If the boundingBox gizmo is enabled
  55915. */
  55916. set boundingBoxGizmoEnabled(value: boolean);
  55917. get boundingBoxGizmoEnabled(): boolean;
  55918. /**
  55919. * Disposes of the gizmo manager
  55920. */
  55921. dispose(): void;
  55922. }
  55923. }
  55924. declare module "babylonjs/Lights/directionalLight" {
  55925. import { Camera } from "babylonjs/Cameras/camera";
  55926. import { Scene } from "babylonjs/scene";
  55927. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55929. import { Light } from "babylonjs/Lights/light";
  55930. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55931. import { Effect } from "babylonjs/Materials/effect";
  55932. /**
  55933. * A directional light is defined by a direction (what a surprise!).
  55934. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55935. * 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.
  55936. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55937. */
  55938. export class DirectionalLight extends ShadowLight {
  55939. private _shadowFrustumSize;
  55940. /**
  55941. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55942. */
  55943. get shadowFrustumSize(): number;
  55944. /**
  55945. * Specifies a fix frustum size for the shadow generation.
  55946. */
  55947. set shadowFrustumSize(value: number);
  55948. private _shadowOrthoScale;
  55949. /**
  55950. * Gets the shadow projection scale against the optimal computed one.
  55951. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55952. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55953. */
  55954. get shadowOrthoScale(): number;
  55955. /**
  55956. * Sets the shadow projection scale against the optimal computed one.
  55957. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55958. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55959. */
  55960. set shadowOrthoScale(value: number);
  55961. /**
  55962. * Automatically compute the projection matrix to best fit (including all the casters)
  55963. * on each frame.
  55964. */
  55965. autoUpdateExtends: boolean;
  55966. /**
  55967. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55968. * on each frame. autoUpdateExtends must be set to true for this to work
  55969. */
  55970. autoCalcShadowZBounds: boolean;
  55971. private _orthoLeft;
  55972. private _orthoRight;
  55973. private _orthoTop;
  55974. private _orthoBottom;
  55975. /**
  55976. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55977. * The directional light is emitted from everywhere in the given direction.
  55978. * It can cast shadows.
  55979. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55980. * @param name The friendly name of the light
  55981. * @param direction The direction of the light
  55982. * @param scene The scene the light belongs to
  55983. */
  55984. constructor(name: string, direction: Vector3, scene: Scene);
  55985. /**
  55986. * Returns the string "DirectionalLight".
  55987. * @return The class name
  55988. */
  55989. getClassName(): string;
  55990. /**
  55991. * Returns the integer 1.
  55992. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55993. */
  55994. getTypeID(): number;
  55995. /**
  55996. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55997. * Returns the DirectionalLight Shadow projection matrix.
  55998. */
  55999. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56000. /**
  56001. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56002. * Returns the DirectionalLight Shadow projection matrix.
  56003. */
  56004. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56005. /**
  56006. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56007. * Returns the DirectionalLight Shadow projection matrix.
  56008. */
  56009. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56010. protected _buildUniformLayout(): void;
  56011. /**
  56012. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56013. * @param effect The effect to update
  56014. * @param lightIndex The index of the light in the effect to update
  56015. * @returns The directional light
  56016. */
  56017. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56018. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56019. /**
  56020. * Gets the minZ used for shadow according to both the scene and the light.
  56021. *
  56022. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56023. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56024. * @param activeCamera The camera we are returning the min for
  56025. * @returns the depth min z
  56026. */
  56027. getDepthMinZ(activeCamera: Camera): number;
  56028. /**
  56029. * Gets the maxZ used for shadow according to both the scene and the light.
  56030. *
  56031. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56032. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56033. * @param activeCamera The camera we are returning the max for
  56034. * @returns the depth max z
  56035. */
  56036. getDepthMaxZ(activeCamera: Camera): number;
  56037. /**
  56038. * Prepares the list of defines specific to the light type.
  56039. * @param defines the list of defines
  56040. * @param lightIndex defines the index of the light for the effect
  56041. */
  56042. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56043. }
  56044. }
  56045. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56046. import { Mesh } from "babylonjs/Meshes/mesh";
  56047. /**
  56048. * Class containing static functions to help procedurally build meshes
  56049. */
  56050. export class HemisphereBuilder {
  56051. /**
  56052. * Creates a hemisphere mesh
  56053. * @param name defines the name of the mesh
  56054. * @param options defines the options used to create the mesh
  56055. * @param scene defines the hosting scene
  56056. * @returns the hemisphere mesh
  56057. */
  56058. static CreateHemisphere(name: string, options: {
  56059. segments?: number;
  56060. diameter?: number;
  56061. sideOrientation?: number;
  56062. }, scene: any): Mesh;
  56063. }
  56064. }
  56065. declare module "babylonjs/Lights/spotLight" {
  56066. import { Nullable } from "babylonjs/types";
  56067. import { Scene } from "babylonjs/scene";
  56068. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56070. import { Effect } from "babylonjs/Materials/effect";
  56071. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56072. import { Light } from "babylonjs/Lights/light";
  56073. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56074. /**
  56075. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56076. * These values define a cone of light starting from the position, emitting toward the direction.
  56077. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56078. * and the exponent defines the speed of the decay of the light with distance (reach).
  56079. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56080. */
  56081. export class SpotLight extends ShadowLight {
  56082. private _angle;
  56083. private _innerAngle;
  56084. private _cosHalfAngle;
  56085. private _lightAngleScale;
  56086. private _lightAngleOffset;
  56087. /**
  56088. * Gets the cone angle of the spot light in Radians.
  56089. */
  56090. get angle(): number;
  56091. /**
  56092. * Sets the cone angle of the spot light in Radians.
  56093. */
  56094. set angle(value: number);
  56095. /**
  56096. * Only used in gltf falloff mode, this defines the angle where
  56097. * the directional falloff will start before cutting at angle which could be seen
  56098. * as outer angle.
  56099. */
  56100. get innerAngle(): number;
  56101. /**
  56102. * Only used in gltf falloff mode, this defines the angle where
  56103. * the directional falloff will start before cutting at angle which could be seen
  56104. * as outer angle.
  56105. */
  56106. set innerAngle(value: number);
  56107. private _shadowAngleScale;
  56108. /**
  56109. * Allows scaling the angle of the light for shadow generation only.
  56110. */
  56111. get shadowAngleScale(): number;
  56112. /**
  56113. * Allows scaling the angle of the light for shadow generation only.
  56114. */
  56115. set shadowAngleScale(value: number);
  56116. /**
  56117. * The light decay speed with the distance from the emission spot.
  56118. */
  56119. exponent: number;
  56120. private _projectionTextureMatrix;
  56121. /**
  56122. * Allows reading the projecton texture
  56123. */
  56124. get projectionTextureMatrix(): Matrix;
  56125. protected _projectionTextureLightNear: number;
  56126. /**
  56127. * Gets the near clip of the Spotlight for texture projection.
  56128. */
  56129. get projectionTextureLightNear(): number;
  56130. /**
  56131. * Sets the near clip of the Spotlight for texture projection.
  56132. */
  56133. set projectionTextureLightNear(value: number);
  56134. protected _projectionTextureLightFar: number;
  56135. /**
  56136. * Gets the far clip of the Spotlight for texture projection.
  56137. */
  56138. get projectionTextureLightFar(): number;
  56139. /**
  56140. * Sets the far clip of the Spotlight for texture projection.
  56141. */
  56142. set projectionTextureLightFar(value: number);
  56143. protected _projectionTextureUpDirection: Vector3;
  56144. /**
  56145. * Gets the Up vector of the Spotlight for texture projection.
  56146. */
  56147. get projectionTextureUpDirection(): Vector3;
  56148. /**
  56149. * Sets the Up vector of the Spotlight for texture projection.
  56150. */
  56151. set projectionTextureUpDirection(value: Vector3);
  56152. private _projectionTexture;
  56153. /**
  56154. * Gets the projection texture of the light.
  56155. */
  56156. get projectionTexture(): Nullable<BaseTexture>;
  56157. /**
  56158. * Sets the projection texture of the light.
  56159. */
  56160. set projectionTexture(value: Nullable<BaseTexture>);
  56161. private _projectionTextureViewLightDirty;
  56162. private _projectionTextureProjectionLightDirty;
  56163. private _projectionTextureDirty;
  56164. private _projectionTextureViewTargetVector;
  56165. private _projectionTextureViewLightMatrix;
  56166. private _projectionTextureProjectionLightMatrix;
  56167. private _projectionTextureScalingMatrix;
  56168. /**
  56169. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56170. * It can cast shadows.
  56171. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56172. * @param name The light friendly name
  56173. * @param position The position of the spot light in the scene
  56174. * @param direction The direction of the light in the scene
  56175. * @param angle The cone angle of the light in Radians
  56176. * @param exponent The light decay speed with the distance from the emission spot
  56177. * @param scene The scene the lights belongs to
  56178. */
  56179. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56180. /**
  56181. * Returns the string "SpotLight".
  56182. * @returns the class name
  56183. */
  56184. getClassName(): string;
  56185. /**
  56186. * Returns the integer 2.
  56187. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56188. */
  56189. getTypeID(): number;
  56190. /**
  56191. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56192. */
  56193. protected _setDirection(value: Vector3): void;
  56194. /**
  56195. * Overrides the position setter to recompute the projection texture view light Matrix.
  56196. */
  56197. protected _setPosition(value: Vector3): void;
  56198. /**
  56199. * 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.
  56200. * Returns the SpotLight.
  56201. */
  56202. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56203. protected _computeProjectionTextureViewLightMatrix(): void;
  56204. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56205. /**
  56206. * Main function for light texture projection matrix computing.
  56207. */
  56208. protected _computeProjectionTextureMatrix(): void;
  56209. protected _buildUniformLayout(): void;
  56210. private _computeAngleValues;
  56211. /**
  56212. * Sets the passed Effect "effect" with the Light textures.
  56213. * @param effect The effect to update
  56214. * @param lightIndex The index of the light in the effect to update
  56215. * @returns The light
  56216. */
  56217. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56218. /**
  56219. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56220. * @param effect The effect to update
  56221. * @param lightIndex The index of the light in the effect to update
  56222. * @returns The spot light
  56223. */
  56224. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56225. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56226. /**
  56227. * Disposes the light and the associated resources.
  56228. */
  56229. dispose(): void;
  56230. /**
  56231. * Prepares the list of defines specific to the light type.
  56232. * @param defines the list of defines
  56233. * @param lightIndex defines the index of the light for the effect
  56234. */
  56235. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56236. }
  56237. }
  56238. declare module "babylonjs/Gizmos/lightGizmo" {
  56239. import { Nullable } from "babylonjs/types";
  56240. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56241. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56242. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56243. import { Light } from "babylonjs/Lights/light";
  56244. /**
  56245. * Gizmo that enables viewing a light
  56246. */
  56247. export class LightGizmo extends Gizmo {
  56248. private _lightMesh;
  56249. private _material;
  56250. private _cachedPosition;
  56251. private _cachedForward;
  56252. private _attachedMeshParent;
  56253. /**
  56254. * Creates a LightGizmo
  56255. * @param gizmoLayer The utility layer the gizmo will be added to
  56256. */
  56257. constructor(gizmoLayer?: UtilityLayerRenderer);
  56258. private _light;
  56259. /**
  56260. * The light that the gizmo is attached to
  56261. */
  56262. set light(light: Nullable<Light>);
  56263. get light(): Nullable<Light>;
  56264. /**
  56265. * Gets the material used to render the light gizmo
  56266. */
  56267. get material(): StandardMaterial;
  56268. /**
  56269. * @hidden
  56270. * Updates the gizmo to match the attached mesh's position/rotation
  56271. */
  56272. protected _update(): void;
  56273. private static _Scale;
  56274. /**
  56275. * Creates the lines for a light mesh
  56276. */
  56277. private static _CreateLightLines;
  56278. /**
  56279. * Disposes of the light gizmo
  56280. */
  56281. dispose(): void;
  56282. private static _CreateHemisphericLightMesh;
  56283. private static _CreatePointLightMesh;
  56284. private static _CreateSpotLightMesh;
  56285. private static _CreateDirectionalLightMesh;
  56286. }
  56287. }
  56288. declare module "babylonjs/Gizmos/index" {
  56289. export * from "babylonjs/Gizmos/axisDragGizmo";
  56290. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56291. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56292. export * from "babylonjs/Gizmos/gizmo";
  56293. export * from "babylonjs/Gizmos/gizmoManager";
  56294. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56295. export * from "babylonjs/Gizmos/positionGizmo";
  56296. export * from "babylonjs/Gizmos/rotationGizmo";
  56297. export * from "babylonjs/Gizmos/scaleGizmo";
  56298. export * from "babylonjs/Gizmos/lightGizmo";
  56299. export * from "babylonjs/Gizmos/planeDragGizmo";
  56300. }
  56301. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56302. /** @hidden */
  56303. export var backgroundFragmentDeclaration: {
  56304. name: string;
  56305. shader: string;
  56306. };
  56307. }
  56308. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56309. /** @hidden */
  56310. export var backgroundUboDeclaration: {
  56311. name: string;
  56312. shader: string;
  56313. };
  56314. }
  56315. declare module "babylonjs/Shaders/background.fragment" {
  56316. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56317. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56318. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56319. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56320. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56321. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56322. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56323. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56324. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56325. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56326. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56327. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56328. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56329. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56330. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56331. /** @hidden */
  56332. export var backgroundPixelShader: {
  56333. name: string;
  56334. shader: string;
  56335. };
  56336. }
  56337. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56338. /** @hidden */
  56339. export var backgroundVertexDeclaration: {
  56340. name: string;
  56341. shader: string;
  56342. };
  56343. }
  56344. declare module "babylonjs/Shaders/background.vertex" {
  56345. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56346. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56347. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56348. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56349. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56350. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56351. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56352. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56353. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56354. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56355. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56356. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56357. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56358. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56359. /** @hidden */
  56360. export var backgroundVertexShader: {
  56361. name: string;
  56362. shader: string;
  56363. };
  56364. }
  56365. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56366. import { Nullable, int, float } from "babylonjs/types";
  56367. import { Scene } from "babylonjs/scene";
  56368. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56369. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56371. import { Mesh } from "babylonjs/Meshes/mesh";
  56372. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56373. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56374. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56375. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56376. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56377. import { Color3 } from "babylonjs/Maths/math.color";
  56378. import "babylonjs/Shaders/background.fragment";
  56379. import "babylonjs/Shaders/background.vertex";
  56380. /**
  56381. * Background material used to create an efficient environement around your scene.
  56382. */
  56383. export class BackgroundMaterial extends PushMaterial {
  56384. /**
  56385. * Standard reflectance value at parallel view angle.
  56386. */
  56387. static StandardReflectance0: number;
  56388. /**
  56389. * Standard reflectance value at grazing angle.
  56390. */
  56391. static StandardReflectance90: number;
  56392. protected _primaryColor: Color3;
  56393. /**
  56394. * Key light Color (multiply against the environement texture)
  56395. */
  56396. primaryColor: Color3;
  56397. protected __perceptualColor: Nullable<Color3>;
  56398. /**
  56399. * Experimental Internal Use Only.
  56400. *
  56401. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56402. * This acts as a helper to set the primary color to a more "human friendly" value.
  56403. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56404. * output color as close as possible from the chosen value.
  56405. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56406. * part of lighting setup.)
  56407. */
  56408. get _perceptualColor(): Nullable<Color3>;
  56409. set _perceptualColor(value: Nullable<Color3>);
  56410. protected _primaryColorShadowLevel: float;
  56411. /**
  56412. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56413. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56414. */
  56415. get primaryColorShadowLevel(): float;
  56416. set primaryColorShadowLevel(value: float);
  56417. protected _primaryColorHighlightLevel: float;
  56418. /**
  56419. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56420. * The primary color is used at the level chosen to define what the white area would look.
  56421. */
  56422. get primaryColorHighlightLevel(): float;
  56423. set primaryColorHighlightLevel(value: float);
  56424. protected _reflectionTexture: Nullable<BaseTexture>;
  56425. /**
  56426. * Reflection Texture used in the material.
  56427. * Should be author in a specific way for the best result (refer to the documentation).
  56428. */
  56429. reflectionTexture: Nullable<BaseTexture>;
  56430. protected _reflectionBlur: float;
  56431. /**
  56432. * Reflection Texture level of blur.
  56433. *
  56434. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56435. * texture twice.
  56436. */
  56437. reflectionBlur: float;
  56438. protected _diffuseTexture: Nullable<BaseTexture>;
  56439. /**
  56440. * Diffuse Texture used in the material.
  56441. * Should be author in a specific way for the best result (refer to the documentation).
  56442. */
  56443. diffuseTexture: Nullable<BaseTexture>;
  56444. protected _shadowLights: Nullable<IShadowLight[]>;
  56445. /**
  56446. * Specify the list of lights casting shadow on the material.
  56447. * All scene shadow lights will be included if null.
  56448. */
  56449. shadowLights: Nullable<IShadowLight[]>;
  56450. protected _shadowLevel: float;
  56451. /**
  56452. * Helps adjusting the shadow to a softer level if required.
  56453. * 0 means black shadows and 1 means no shadows.
  56454. */
  56455. shadowLevel: float;
  56456. protected _sceneCenter: Vector3;
  56457. /**
  56458. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56459. * It is usually zero but might be interesting to modify according to your setup.
  56460. */
  56461. sceneCenter: Vector3;
  56462. protected _opacityFresnel: boolean;
  56463. /**
  56464. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56465. * This helps ensuring a nice transition when the camera goes under the ground.
  56466. */
  56467. opacityFresnel: boolean;
  56468. protected _reflectionFresnel: boolean;
  56469. /**
  56470. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56471. * This helps adding a mirror texture on the ground.
  56472. */
  56473. reflectionFresnel: boolean;
  56474. protected _reflectionFalloffDistance: number;
  56475. /**
  56476. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56477. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56478. */
  56479. reflectionFalloffDistance: number;
  56480. protected _reflectionAmount: number;
  56481. /**
  56482. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56483. */
  56484. reflectionAmount: number;
  56485. protected _reflectionReflectance0: number;
  56486. /**
  56487. * This specifies the weight of the reflection at grazing angle.
  56488. */
  56489. reflectionReflectance0: number;
  56490. protected _reflectionReflectance90: number;
  56491. /**
  56492. * This specifies the weight of the reflection at a perpendicular point of view.
  56493. */
  56494. reflectionReflectance90: number;
  56495. /**
  56496. * Sets the reflection reflectance fresnel values according to the default standard
  56497. * empirically know to work well :-)
  56498. */
  56499. set reflectionStandardFresnelWeight(value: number);
  56500. protected _useRGBColor: boolean;
  56501. /**
  56502. * Helps to directly use the maps channels instead of their level.
  56503. */
  56504. useRGBColor: boolean;
  56505. protected _enableNoise: boolean;
  56506. /**
  56507. * This helps reducing the banding effect that could occur on the background.
  56508. */
  56509. enableNoise: boolean;
  56510. /**
  56511. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56512. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56513. * Recommended to be keep at 1.0 except for special cases.
  56514. */
  56515. get fovMultiplier(): number;
  56516. set fovMultiplier(value: number);
  56517. private _fovMultiplier;
  56518. /**
  56519. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56520. */
  56521. useEquirectangularFOV: boolean;
  56522. private _maxSimultaneousLights;
  56523. /**
  56524. * Number of Simultaneous lights allowed on the material.
  56525. */
  56526. maxSimultaneousLights: int;
  56527. private _shadowOnly;
  56528. /**
  56529. * Make the material only render shadows
  56530. */
  56531. shadowOnly: boolean;
  56532. /**
  56533. * Default configuration related to image processing available in the Background Material.
  56534. */
  56535. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56536. /**
  56537. * Keep track of the image processing observer to allow dispose and replace.
  56538. */
  56539. private _imageProcessingObserver;
  56540. /**
  56541. * Attaches a new image processing configuration to the PBR Material.
  56542. * @param configuration (if null the scene configuration will be use)
  56543. */
  56544. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56545. /**
  56546. * Gets the image processing configuration used either in this material.
  56547. */
  56548. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56549. /**
  56550. * Sets the Default image processing configuration used either in the this material.
  56551. *
  56552. * If sets to null, the scene one is in use.
  56553. */
  56554. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56555. /**
  56556. * Gets wether the color curves effect is enabled.
  56557. */
  56558. get cameraColorCurvesEnabled(): boolean;
  56559. /**
  56560. * Sets wether the color curves effect is enabled.
  56561. */
  56562. set cameraColorCurvesEnabled(value: boolean);
  56563. /**
  56564. * Gets wether the color grading effect is enabled.
  56565. */
  56566. get cameraColorGradingEnabled(): boolean;
  56567. /**
  56568. * Gets wether the color grading effect is enabled.
  56569. */
  56570. set cameraColorGradingEnabled(value: boolean);
  56571. /**
  56572. * Gets wether tonemapping is enabled or not.
  56573. */
  56574. get cameraToneMappingEnabled(): boolean;
  56575. /**
  56576. * Sets wether tonemapping is enabled or not
  56577. */
  56578. set cameraToneMappingEnabled(value: boolean);
  56579. /**
  56580. * The camera exposure used on this material.
  56581. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56582. * This corresponds to a photographic exposure.
  56583. */
  56584. get cameraExposure(): float;
  56585. /**
  56586. * The camera exposure used on this material.
  56587. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56588. * This corresponds to a photographic exposure.
  56589. */
  56590. set cameraExposure(value: float);
  56591. /**
  56592. * Gets The camera contrast used on this material.
  56593. */
  56594. get cameraContrast(): float;
  56595. /**
  56596. * Sets The camera contrast used on this material.
  56597. */
  56598. set cameraContrast(value: float);
  56599. /**
  56600. * Gets the Color Grading 2D Lookup Texture.
  56601. */
  56602. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56603. /**
  56604. * Sets the Color Grading 2D Lookup Texture.
  56605. */
  56606. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56607. /**
  56608. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56609. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56610. * 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;
  56611. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56612. */
  56613. get cameraColorCurves(): Nullable<ColorCurves>;
  56614. /**
  56615. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56616. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56617. * 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;
  56618. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56619. */
  56620. set cameraColorCurves(value: Nullable<ColorCurves>);
  56621. /**
  56622. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  56623. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  56624. */
  56625. switchToBGR: boolean;
  56626. private _renderTargets;
  56627. private _reflectionControls;
  56628. private _white;
  56629. private _primaryShadowColor;
  56630. private _primaryHighlightColor;
  56631. /**
  56632. * Instantiates a Background Material in the given scene
  56633. * @param name The friendly name of the material
  56634. * @param scene The scene to add the material to
  56635. */
  56636. constructor(name: string, scene: Scene);
  56637. /**
  56638. * Gets a boolean indicating that current material needs to register RTT
  56639. */
  56640. get hasRenderTargetTextures(): boolean;
  56641. /**
  56642. * The entire material has been created in order to prevent overdraw.
  56643. * @returns false
  56644. */
  56645. needAlphaTesting(): boolean;
  56646. /**
  56647. * The entire material has been created in order to prevent overdraw.
  56648. * @returns true if blending is enable
  56649. */
  56650. needAlphaBlending(): boolean;
  56651. /**
  56652. * Checks wether the material is ready to be rendered for a given mesh.
  56653. * @param mesh The mesh to render
  56654. * @param subMesh The submesh to check against
  56655. * @param useInstances Specify wether or not the material is used with instances
  56656. * @returns true if all the dependencies are ready (Textures, Effects...)
  56657. */
  56658. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56659. /**
  56660. * Compute the primary color according to the chosen perceptual color.
  56661. */
  56662. private _computePrimaryColorFromPerceptualColor;
  56663. /**
  56664. * Compute the highlights and shadow colors according to their chosen levels.
  56665. */
  56666. private _computePrimaryColors;
  56667. /**
  56668. * Build the uniform buffer used in the material.
  56669. */
  56670. buildUniformLayout(): void;
  56671. /**
  56672. * Unbind the material.
  56673. */
  56674. unbind(): void;
  56675. /**
  56676. * Bind only the world matrix to the material.
  56677. * @param world The world matrix to bind.
  56678. */
  56679. bindOnlyWorldMatrix(world: Matrix): void;
  56680. /**
  56681. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  56682. * @param world The world matrix to bind.
  56683. * @param subMesh The submesh to bind for.
  56684. */
  56685. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56686. /**
  56687. * Checks to see if a texture is used in the material.
  56688. * @param texture - Base texture to use.
  56689. * @returns - Boolean specifying if a texture is used in the material.
  56690. */
  56691. hasTexture(texture: BaseTexture): boolean;
  56692. /**
  56693. * Dispose the material.
  56694. * @param forceDisposeEffect Force disposal of the associated effect.
  56695. * @param forceDisposeTextures Force disposal of the associated textures.
  56696. */
  56697. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56698. /**
  56699. * Clones the material.
  56700. * @param name The cloned name.
  56701. * @returns The cloned material.
  56702. */
  56703. clone(name: string): BackgroundMaterial;
  56704. /**
  56705. * Serializes the current material to its JSON representation.
  56706. * @returns The JSON representation.
  56707. */
  56708. serialize(): any;
  56709. /**
  56710. * Gets the class name of the material
  56711. * @returns "BackgroundMaterial"
  56712. */
  56713. getClassName(): string;
  56714. /**
  56715. * Parse a JSON input to create back a background material.
  56716. * @param source The JSON data to parse
  56717. * @param scene The scene to create the parsed material in
  56718. * @param rootUrl The root url of the assets the material depends upon
  56719. * @returns the instantiated BackgroundMaterial.
  56720. */
  56721. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  56722. }
  56723. }
  56724. declare module "babylonjs/Helpers/environmentHelper" {
  56725. import { Observable } from "babylonjs/Misc/observable";
  56726. import { Nullable } from "babylonjs/types";
  56727. import { Scene } from "babylonjs/scene";
  56728. import { Vector3 } from "babylonjs/Maths/math.vector";
  56729. import { Color3 } from "babylonjs/Maths/math.color";
  56730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56731. import { Mesh } from "babylonjs/Meshes/mesh";
  56732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56733. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  56734. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56735. import "babylonjs/Meshes/Builders/planeBuilder";
  56736. import "babylonjs/Meshes/Builders/boxBuilder";
  56737. /**
  56738. * Represents the different options available during the creation of
  56739. * a Environment helper.
  56740. *
  56741. * This can control the default ground, skybox and image processing setup of your scene.
  56742. */
  56743. export interface IEnvironmentHelperOptions {
  56744. /**
  56745. * Specifies whether or not to create a ground.
  56746. * True by default.
  56747. */
  56748. createGround: boolean;
  56749. /**
  56750. * Specifies the ground size.
  56751. * 15 by default.
  56752. */
  56753. groundSize: number;
  56754. /**
  56755. * The texture used on the ground for the main color.
  56756. * Comes from the BabylonJS CDN by default.
  56757. *
  56758. * Remarks: Can be either a texture or a url.
  56759. */
  56760. groundTexture: string | BaseTexture;
  56761. /**
  56762. * The color mixed in the ground texture by default.
  56763. * BabylonJS clearColor by default.
  56764. */
  56765. groundColor: Color3;
  56766. /**
  56767. * Specifies the ground opacity.
  56768. * 1 by default.
  56769. */
  56770. groundOpacity: number;
  56771. /**
  56772. * Enables the ground to receive shadows.
  56773. * True by default.
  56774. */
  56775. enableGroundShadow: boolean;
  56776. /**
  56777. * Helps preventing the shadow to be fully black on the ground.
  56778. * 0.5 by default.
  56779. */
  56780. groundShadowLevel: number;
  56781. /**
  56782. * Creates a mirror texture attach to the ground.
  56783. * false by default.
  56784. */
  56785. enableGroundMirror: boolean;
  56786. /**
  56787. * Specifies the ground mirror size ratio.
  56788. * 0.3 by default as the default kernel is 64.
  56789. */
  56790. groundMirrorSizeRatio: number;
  56791. /**
  56792. * Specifies the ground mirror blur kernel size.
  56793. * 64 by default.
  56794. */
  56795. groundMirrorBlurKernel: number;
  56796. /**
  56797. * Specifies the ground mirror visibility amount.
  56798. * 1 by default
  56799. */
  56800. groundMirrorAmount: number;
  56801. /**
  56802. * Specifies the ground mirror reflectance weight.
  56803. * This uses the standard weight of the background material to setup the fresnel effect
  56804. * of the mirror.
  56805. * 1 by default.
  56806. */
  56807. groundMirrorFresnelWeight: number;
  56808. /**
  56809. * Specifies the ground mirror Falloff distance.
  56810. * This can helps reducing the size of the reflection.
  56811. * 0 by Default.
  56812. */
  56813. groundMirrorFallOffDistance: number;
  56814. /**
  56815. * Specifies the ground mirror texture type.
  56816. * Unsigned Int by Default.
  56817. */
  56818. groundMirrorTextureType: number;
  56819. /**
  56820. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56821. * the shown objects.
  56822. */
  56823. groundYBias: number;
  56824. /**
  56825. * Specifies whether or not to create a skybox.
  56826. * True by default.
  56827. */
  56828. createSkybox: boolean;
  56829. /**
  56830. * Specifies the skybox size.
  56831. * 20 by default.
  56832. */
  56833. skyboxSize: number;
  56834. /**
  56835. * The texture used on the skybox for the main color.
  56836. * Comes from the BabylonJS CDN by default.
  56837. *
  56838. * Remarks: Can be either a texture or a url.
  56839. */
  56840. skyboxTexture: string | BaseTexture;
  56841. /**
  56842. * The color mixed in the skybox texture by default.
  56843. * BabylonJS clearColor by default.
  56844. */
  56845. skyboxColor: Color3;
  56846. /**
  56847. * The background rotation around the Y axis of the scene.
  56848. * This helps aligning the key lights of your scene with the background.
  56849. * 0 by default.
  56850. */
  56851. backgroundYRotation: number;
  56852. /**
  56853. * Compute automatically the size of the elements to best fit with the scene.
  56854. */
  56855. sizeAuto: boolean;
  56856. /**
  56857. * Default position of the rootMesh if autoSize is not true.
  56858. */
  56859. rootPosition: Vector3;
  56860. /**
  56861. * Sets up the image processing in the scene.
  56862. * true by default.
  56863. */
  56864. setupImageProcessing: boolean;
  56865. /**
  56866. * The texture used as your environment texture in the scene.
  56867. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56868. *
  56869. * Remarks: Can be either a texture or a url.
  56870. */
  56871. environmentTexture: string | BaseTexture;
  56872. /**
  56873. * The value of the exposure to apply to the scene.
  56874. * 0.6 by default if setupImageProcessing is true.
  56875. */
  56876. cameraExposure: number;
  56877. /**
  56878. * The value of the contrast to apply to the scene.
  56879. * 1.6 by default if setupImageProcessing is true.
  56880. */
  56881. cameraContrast: number;
  56882. /**
  56883. * Specifies whether or not tonemapping should be enabled in the scene.
  56884. * true by default if setupImageProcessing is true.
  56885. */
  56886. toneMappingEnabled: boolean;
  56887. }
  56888. /**
  56889. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56890. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56891. * It also helps with the default setup of your imageProcessing configuration.
  56892. */
  56893. export class EnvironmentHelper {
  56894. /**
  56895. * Default ground texture URL.
  56896. */
  56897. private static _groundTextureCDNUrl;
  56898. /**
  56899. * Default skybox texture URL.
  56900. */
  56901. private static _skyboxTextureCDNUrl;
  56902. /**
  56903. * Default environment texture URL.
  56904. */
  56905. private static _environmentTextureCDNUrl;
  56906. /**
  56907. * Creates the default options for the helper.
  56908. */
  56909. private static _getDefaultOptions;
  56910. private _rootMesh;
  56911. /**
  56912. * Gets the root mesh created by the helper.
  56913. */
  56914. get rootMesh(): Mesh;
  56915. private _skybox;
  56916. /**
  56917. * Gets the skybox created by the helper.
  56918. */
  56919. get skybox(): Nullable<Mesh>;
  56920. private _skyboxTexture;
  56921. /**
  56922. * Gets the skybox texture created by the helper.
  56923. */
  56924. get skyboxTexture(): Nullable<BaseTexture>;
  56925. private _skyboxMaterial;
  56926. /**
  56927. * Gets the skybox material created by the helper.
  56928. */
  56929. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56930. private _ground;
  56931. /**
  56932. * Gets the ground mesh created by the helper.
  56933. */
  56934. get ground(): Nullable<Mesh>;
  56935. private _groundTexture;
  56936. /**
  56937. * Gets the ground texture created by the helper.
  56938. */
  56939. get groundTexture(): Nullable<BaseTexture>;
  56940. private _groundMirror;
  56941. /**
  56942. * Gets the ground mirror created by the helper.
  56943. */
  56944. get groundMirror(): Nullable<MirrorTexture>;
  56945. /**
  56946. * Gets the ground mirror render list to helps pushing the meshes
  56947. * you wish in the ground reflection.
  56948. */
  56949. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56950. private _groundMaterial;
  56951. /**
  56952. * Gets the ground material created by the helper.
  56953. */
  56954. get groundMaterial(): Nullable<BackgroundMaterial>;
  56955. /**
  56956. * Stores the creation options.
  56957. */
  56958. private readonly _scene;
  56959. private _options;
  56960. /**
  56961. * This observable will be notified with any error during the creation of the environment,
  56962. * mainly texture creation errors.
  56963. */
  56964. onErrorObservable: Observable<{
  56965. message?: string;
  56966. exception?: any;
  56967. }>;
  56968. /**
  56969. * constructor
  56970. * @param options Defines the options we want to customize the helper
  56971. * @param scene The scene to add the material to
  56972. */
  56973. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56974. /**
  56975. * Updates the background according to the new options
  56976. * @param options
  56977. */
  56978. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56979. /**
  56980. * Sets the primary color of all the available elements.
  56981. * @param color the main color to affect to the ground and the background
  56982. */
  56983. setMainColor(color: Color3): void;
  56984. /**
  56985. * Setup the image processing according to the specified options.
  56986. */
  56987. private _setupImageProcessing;
  56988. /**
  56989. * Setup the environment texture according to the specified options.
  56990. */
  56991. private _setupEnvironmentTexture;
  56992. /**
  56993. * Setup the background according to the specified options.
  56994. */
  56995. private _setupBackground;
  56996. /**
  56997. * Get the scene sizes according to the setup.
  56998. */
  56999. private _getSceneSize;
  57000. /**
  57001. * Setup the ground according to the specified options.
  57002. */
  57003. private _setupGround;
  57004. /**
  57005. * Setup the ground material according to the specified options.
  57006. */
  57007. private _setupGroundMaterial;
  57008. /**
  57009. * Setup the ground diffuse texture according to the specified options.
  57010. */
  57011. private _setupGroundDiffuseTexture;
  57012. /**
  57013. * Setup the ground mirror texture according to the specified options.
  57014. */
  57015. private _setupGroundMirrorTexture;
  57016. /**
  57017. * Setup the ground to receive the mirror texture.
  57018. */
  57019. private _setupMirrorInGroundMaterial;
  57020. /**
  57021. * Setup the skybox according to the specified options.
  57022. */
  57023. private _setupSkybox;
  57024. /**
  57025. * Setup the skybox material according to the specified options.
  57026. */
  57027. private _setupSkyboxMaterial;
  57028. /**
  57029. * Setup the skybox reflection texture according to the specified options.
  57030. */
  57031. private _setupSkyboxReflectionTexture;
  57032. private _errorHandler;
  57033. /**
  57034. * Dispose all the elements created by the Helper.
  57035. */
  57036. dispose(): void;
  57037. }
  57038. }
  57039. declare module "babylonjs/Helpers/photoDome" {
  57040. import { Observable } from "babylonjs/Misc/observable";
  57041. import { Nullable } from "babylonjs/types";
  57042. import { Scene } from "babylonjs/scene";
  57043. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57044. import { Mesh } from "babylonjs/Meshes/mesh";
  57045. import { Texture } from "babylonjs/Materials/Textures/texture";
  57046. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57047. import "babylonjs/Meshes/Builders/sphereBuilder";
  57048. /**
  57049. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57050. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57051. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57052. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57053. */
  57054. export class PhotoDome extends TransformNode {
  57055. /**
  57056. * Define the image as a Monoscopic panoramic 360 image.
  57057. */
  57058. static readonly MODE_MONOSCOPIC: number;
  57059. /**
  57060. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57061. */
  57062. static readonly MODE_TOPBOTTOM: number;
  57063. /**
  57064. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57065. */
  57066. static readonly MODE_SIDEBYSIDE: number;
  57067. private _useDirectMapping;
  57068. /**
  57069. * The texture being displayed on the sphere
  57070. */
  57071. protected _photoTexture: Texture;
  57072. /**
  57073. * Gets or sets the texture being displayed on the sphere
  57074. */
  57075. get photoTexture(): Texture;
  57076. set photoTexture(value: Texture);
  57077. /**
  57078. * Observable raised when an error occured while loading the 360 image
  57079. */
  57080. onLoadErrorObservable: Observable<string>;
  57081. /**
  57082. * The skybox material
  57083. */
  57084. protected _material: BackgroundMaterial;
  57085. /**
  57086. * The surface used for the skybox
  57087. */
  57088. protected _mesh: Mesh;
  57089. /**
  57090. * Gets the mesh used for the skybox.
  57091. */
  57092. get mesh(): Mesh;
  57093. /**
  57094. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57095. * Also see the options.resolution property.
  57096. */
  57097. get fovMultiplier(): number;
  57098. set fovMultiplier(value: number);
  57099. private _imageMode;
  57100. /**
  57101. * Gets or set the current video mode for the video. It can be:
  57102. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  57103. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57104. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57105. */
  57106. get imageMode(): number;
  57107. set imageMode(value: number);
  57108. /**
  57109. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  57110. * @param name Element's name, child elements will append suffixes for their own names.
  57111. * @param urlsOfPhoto defines the url of the photo to display
  57112. * @param options defines an object containing optional or exposed sub element properties
  57113. * @param onError defines a callback called when an error occured while loading the texture
  57114. */
  57115. constructor(name: string, urlOfPhoto: string, options: {
  57116. resolution?: number;
  57117. size?: number;
  57118. useDirectMapping?: boolean;
  57119. faceForward?: boolean;
  57120. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57121. private _onBeforeCameraRenderObserver;
  57122. private _changeImageMode;
  57123. /**
  57124. * Releases resources associated with this node.
  57125. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57126. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57127. */
  57128. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57129. }
  57130. }
  57131. declare module "babylonjs/Misc/rgbdTextureTools" {
  57132. import "babylonjs/Shaders/rgbdDecode.fragment";
  57133. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57134. import { Texture } from "babylonjs/Materials/Textures/texture";
  57135. /**
  57136. * Class used to host RGBD texture specific utilities
  57137. */
  57138. export class RGBDTextureTools {
  57139. /**
  57140. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57141. * @param texture the texture to expand.
  57142. */
  57143. static ExpandRGBDTexture(texture: Texture): void;
  57144. }
  57145. }
  57146. declare module "babylonjs/Misc/brdfTextureTools" {
  57147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57148. import { Scene } from "babylonjs/scene";
  57149. /**
  57150. * Class used to host texture specific utilities
  57151. */
  57152. export class BRDFTextureTools {
  57153. /**
  57154. * Prevents texture cache collision
  57155. */
  57156. private static _instanceNumber;
  57157. /**
  57158. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57159. * @param scene defines the hosting scene
  57160. * @returns the environment BRDF texture
  57161. */
  57162. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57163. private static _environmentBRDFBase64Texture;
  57164. }
  57165. }
  57166. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57167. import { Nullable } from "babylonjs/types";
  57168. import { Color3 } from "babylonjs/Maths/math.color";
  57169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57170. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57171. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57172. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57173. import { Engine } from "babylonjs/Engines/engine";
  57174. import { Scene } from "babylonjs/scene";
  57175. /**
  57176. * @hidden
  57177. */
  57178. export interface IMaterialClearCoatDefines {
  57179. CLEARCOAT: boolean;
  57180. CLEARCOAT_DEFAULTIOR: boolean;
  57181. CLEARCOAT_TEXTURE: boolean;
  57182. CLEARCOAT_TEXTUREDIRECTUV: number;
  57183. CLEARCOAT_BUMP: boolean;
  57184. CLEARCOAT_BUMPDIRECTUV: number;
  57185. CLEARCOAT_TINT: boolean;
  57186. CLEARCOAT_TINT_TEXTURE: boolean;
  57187. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57188. /** @hidden */
  57189. _areTexturesDirty: boolean;
  57190. }
  57191. /**
  57192. * Define the code related to the clear coat parameters of the pbr material.
  57193. */
  57194. export class PBRClearCoatConfiguration {
  57195. /**
  57196. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57197. * The default fits with a polyurethane material.
  57198. */
  57199. private static readonly _DefaultIndexOfRefraction;
  57200. private _isEnabled;
  57201. /**
  57202. * Defines if the clear coat is enabled in the material.
  57203. */
  57204. isEnabled: boolean;
  57205. /**
  57206. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57207. */
  57208. intensity: number;
  57209. /**
  57210. * Defines the clear coat layer roughness.
  57211. */
  57212. roughness: number;
  57213. private _indexOfRefraction;
  57214. /**
  57215. * Defines the index of refraction of the clear coat.
  57216. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57217. * The default fits with a polyurethane material.
  57218. * Changing the default value is more performance intensive.
  57219. */
  57220. indexOfRefraction: number;
  57221. private _texture;
  57222. /**
  57223. * Stores the clear coat values in a texture.
  57224. */
  57225. texture: Nullable<BaseTexture>;
  57226. private _bumpTexture;
  57227. /**
  57228. * Define the clear coat specific bump texture.
  57229. */
  57230. bumpTexture: Nullable<BaseTexture>;
  57231. private _isTintEnabled;
  57232. /**
  57233. * Defines if the clear coat tint is enabled in the material.
  57234. */
  57235. isTintEnabled: boolean;
  57236. /**
  57237. * Defines the clear coat tint of the material.
  57238. * This is only use if tint is enabled
  57239. */
  57240. tintColor: Color3;
  57241. /**
  57242. * Defines the distance at which the tint color should be found in the
  57243. * clear coat media.
  57244. * This is only use if tint is enabled
  57245. */
  57246. tintColorAtDistance: number;
  57247. /**
  57248. * Defines the clear coat layer thickness.
  57249. * This is only use if tint is enabled
  57250. */
  57251. tintThickness: number;
  57252. private _tintTexture;
  57253. /**
  57254. * Stores the clear tint values in a texture.
  57255. * rgb is tint
  57256. * a is a thickness factor
  57257. */
  57258. tintTexture: Nullable<BaseTexture>;
  57259. /** @hidden */
  57260. private _internalMarkAllSubMeshesAsTexturesDirty;
  57261. /** @hidden */
  57262. _markAllSubMeshesAsTexturesDirty(): void;
  57263. /**
  57264. * Instantiate a new istance of clear coat configuration.
  57265. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57266. */
  57267. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57268. /**
  57269. * Gets wehter the submesh is ready to be used or not.
  57270. * @param defines the list of "defines" to update.
  57271. * @param scene defines the scene the material belongs to.
  57272. * @param engine defines the engine the material belongs to.
  57273. * @param disableBumpMap defines wether the material disables bump or not.
  57274. * @returns - boolean indicating that the submesh is ready or not.
  57275. */
  57276. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57277. /**
  57278. * Checks to see if a texture is used in the material.
  57279. * @param defines the list of "defines" to update.
  57280. * @param scene defines the scene to the material belongs to.
  57281. */
  57282. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57283. /**
  57284. * Binds the material data.
  57285. * @param uniformBuffer defines the Uniform buffer to fill in.
  57286. * @param scene defines the scene the material belongs to.
  57287. * @param engine defines the engine the material belongs to.
  57288. * @param disableBumpMap defines wether the material disables bump or not.
  57289. * @param isFrozen defines wether the material is frozen or not.
  57290. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57291. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57292. */
  57293. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57294. /**
  57295. * Checks to see if a texture is used in the material.
  57296. * @param texture - Base texture to use.
  57297. * @returns - Boolean specifying if a texture is used in the material.
  57298. */
  57299. hasTexture(texture: BaseTexture): boolean;
  57300. /**
  57301. * Returns an array of the actively used textures.
  57302. * @param activeTextures Array of BaseTextures
  57303. */
  57304. getActiveTextures(activeTextures: BaseTexture[]): void;
  57305. /**
  57306. * Returns the animatable textures.
  57307. * @param animatables Array of animatable textures.
  57308. */
  57309. getAnimatables(animatables: IAnimatable[]): void;
  57310. /**
  57311. * Disposes the resources of the material.
  57312. * @param forceDisposeTextures - Forces the disposal of all textures.
  57313. */
  57314. dispose(forceDisposeTextures?: boolean): void;
  57315. /**
  57316. * Get the current class name of the texture useful for serialization or dynamic coding.
  57317. * @returns "PBRClearCoatConfiguration"
  57318. */
  57319. getClassName(): string;
  57320. /**
  57321. * Add fallbacks to the effect fallbacks list.
  57322. * @param defines defines the Base texture to use.
  57323. * @param fallbacks defines the current fallback list.
  57324. * @param currentRank defines the current fallback rank.
  57325. * @returns the new fallback rank.
  57326. */
  57327. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57328. /**
  57329. * Add the required uniforms to the current list.
  57330. * @param uniforms defines the current uniform list.
  57331. */
  57332. static AddUniforms(uniforms: string[]): void;
  57333. /**
  57334. * Add the required samplers to the current list.
  57335. * @param samplers defines the current sampler list.
  57336. */
  57337. static AddSamplers(samplers: string[]): void;
  57338. /**
  57339. * Add the required uniforms to the current buffer.
  57340. * @param uniformBuffer defines the current uniform buffer.
  57341. */
  57342. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57343. /**
  57344. * Makes a duplicate of the current configuration into another one.
  57345. * @param clearCoatConfiguration define the config where to copy the info
  57346. */
  57347. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57348. /**
  57349. * Serializes this clear coat configuration.
  57350. * @returns - An object with the serialized config.
  57351. */
  57352. serialize(): any;
  57353. /**
  57354. * Parses a anisotropy Configuration from a serialized object.
  57355. * @param source - Serialized object.
  57356. * @param scene Defines the scene we are parsing for
  57357. * @param rootUrl Defines the rootUrl to load from
  57358. */
  57359. parse(source: any, scene: Scene, rootUrl: string): void;
  57360. }
  57361. }
  57362. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57363. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57365. import { Vector2 } from "babylonjs/Maths/math.vector";
  57366. import { Scene } from "babylonjs/scene";
  57367. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57368. import { Nullable } from "babylonjs/types";
  57369. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57370. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57371. /**
  57372. * @hidden
  57373. */
  57374. export interface IMaterialAnisotropicDefines {
  57375. ANISOTROPIC: boolean;
  57376. ANISOTROPIC_TEXTURE: boolean;
  57377. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57378. MAINUV1: boolean;
  57379. _areTexturesDirty: boolean;
  57380. _needUVs: boolean;
  57381. }
  57382. /**
  57383. * Define the code related to the anisotropic parameters of the pbr material.
  57384. */
  57385. export class PBRAnisotropicConfiguration {
  57386. private _isEnabled;
  57387. /**
  57388. * Defines if the anisotropy is enabled in the material.
  57389. */
  57390. isEnabled: boolean;
  57391. /**
  57392. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57393. */
  57394. intensity: number;
  57395. /**
  57396. * Defines if the effect is along the tangents, bitangents or in between.
  57397. * By default, the effect is "strectching" the highlights along the tangents.
  57398. */
  57399. direction: Vector2;
  57400. private _texture;
  57401. /**
  57402. * Stores the anisotropy values in a texture.
  57403. * rg is direction (like normal from -1 to 1)
  57404. * b is a intensity
  57405. */
  57406. texture: Nullable<BaseTexture>;
  57407. /** @hidden */
  57408. private _internalMarkAllSubMeshesAsTexturesDirty;
  57409. /** @hidden */
  57410. _markAllSubMeshesAsTexturesDirty(): void;
  57411. /**
  57412. * Instantiate a new istance of anisotropy configuration.
  57413. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57414. */
  57415. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57416. /**
  57417. * Specifies that the submesh is ready to be used.
  57418. * @param defines the list of "defines" to update.
  57419. * @param scene defines the scene the material belongs to.
  57420. * @returns - boolean indicating that the submesh is ready or not.
  57421. */
  57422. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57423. /**
  57424. * Checks to see if a texture is used in the material.
  57425. * @param defines the list of "defines" to update.
  57426. * @param mesh the mesh we are preparing the defines for.
  57427. * @param scene defines the scene the material belongs to.
  57428. */
  57429. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57430. /**
  57431. * Binds the material data.
  57432. * @param uniformBuffer defines the Uniform buffer to fill in.
  57433. * @param scene defines the scene the material belongs to.
  57434. * @param isFrozen defines wether the material is frozen or not.
  57435. */
  57436. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57437. /**
  57438. * Checks to see if a texture is used in the material.
  57439. * @param texture - Base texture to use.
  57440. * @returns - Boolean specifying if a texture is used in the material.
  57441. */
  57442. hasTexture(texture: BaseTexture): boolean;
  57443. /**
  57444. * Returns an array of the actively used textures.
  57445. * @param activeTextures Array of BaseTextures
  57446. */
  57447. getActiveTextures(activeTextures: BaseTexture[]): void;
  57448. /**
  57449. * Returns the animatable textures.
  57450. * @param animatables Array of animatable textures.
  57451. */
  57452. getAnimatables(animatables: IAnimatable[]): void;
  57453. /**
  57454. * Disposes the resources of the material.
  57455. * @param forceDisposeTextures - Forces the disposal of all textures.
  57456. */
  57457. dispose(forceDisposeTextures?: boolean): void;
  57458. /**
  57459. * Get the current class name of the texture useful for serialization or dynamic coding.
  57460. * @returns "PBRAnisotropicConfiguration"
  57461. */
  57462. getClassName(): string;
  57463. /**
  57464. * Add fallbacks to the effect fallbacks list.
  57465. * @param defines defines the Base texture to use.
  57466. * @param fallbacks defines the current fallback list.
  57467. * @param currentRank defines the current fallback rank.
  57468. * @returns the new fallback rank.
  57469. */
  57470. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57471. /**
  57472. * Add the required uniforms to the current list.
  57473. * @param uniforms defines the current uniform list.
  57474. */
  57475. static AddUniforms(uniforms: string[]): void;
  57476. /**
  57477. * Add the required uniforms to the current buffer.
  57478. * @param uniformBuffer defines the current uniform buffer.
  57479. */
  57480. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57481. /**
  57482. * Add the required samplers to the current list.
  57483. * @param samplers defines the current sampler list.
  57484. */
  57485. static AddSamplers(samplers: string[]): void;
  57486. /**
  57487. * Makes a duplicate of the current configuration into another one.
  57488. * @param anisotropicConfiguration define the config where to copy the info
  57489. */
  57490. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57491. /**
  57492. * Serializes this anisotropy configuration.
  57493. * @returns - An object with the serialized config.
  57494. */
  57495. serialize(): any;
  57496. /**
  57497. * Parses a anisotropy Configuration from a serialized object.
  57498. * @param source - Serialized object.
  57499. * @param scene Defines the scene we are parsing for
  57500. * @param rootUrl Defines the rootUrl to load from
  57501. */
  57502. parse(source: any, scene: Scene, rootUrl: string): void;
  57503. }
  57504. }
  57505. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57506. import { Scene } from "babylonjs/scene";
  57507. /**
  57508. * @hidden
  57509. */
  57510. export interface IMaterialBRDFDefines {
  57511. BRDF_V_HEIGHT_CORRELATED: boolean;
  57512. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57513. SPHERICAL_HARMONICS: boolean;
  57514. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57515. /** @hidden */
  57516. _areMiscDirty: boolean;
  57517. }
  57518. /**
  57519. * Define the code related to the BRDF parameters of the pbr material.
  57520. */
  57521. export class PBRBRDFConfiguration {
  57522. /**
  57523. * Default value used for the energy conservation.
  57524. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57525. */
  57526. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57527. /**
  57528. * Default value used for the Smith Visibility Height Correlated mode.
  57529. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57530. */
  57531. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57532. /**
  57533. * Default value used for the IBL diffuse part.
  57534. * This can help switching back to the polynomials mode globally which is a tiny bit
  57535. * less GPU intensive at the drawback of a lower quality.
  57536. */
  57537. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57538. /**
  57539. * Default value used for activating energy conservation for the specular workflow.
  57540. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57541. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57542. */
  57543. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  57544. private _useEnergyConservation;
  57545. /**
  57546. * Defines if the material uses energy conservation.
  57547. */
  57548. useEnergyConservation: boolean;
  57549. private _useSmithVisibilityHeightCorrelated;
  57550. /**
  57551. * LEGACY Mode set to false
  57552. * Defines if the material uses height smith correlated visibility term.
  57553. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  57554. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  57555. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  57556. * Not relying on height correlated will also disable energy conservation.
  57557. */
  57558. useSmithVisibilityHeightCorrelated: boolean;
  57559. private _useSphericalHarmonics;
  57560. /**
  57561. * LEGACY Mode set to false
  57562. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  57563. * diffuse part of the IBL.
  57564. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  57565. * to the ground truth.
  57566. */
  57567. useSphericalHarmonics: boolean;
  57568. private _useSpecularGlossinessInputEnergyConservation;
  57569. /**
  57570. * Defines if the material uses energy conservation, when the specular workflow is active.
  57571. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57572. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57573. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  57574. */
  57575. useSpecularGlossinessInputEnergyConservation: boolean;
  57576. /** @hidden */
  57577. private _internalMarkAllSubMeshesAsMiscDirty;
  57578. /** @hidden */
  57579. _markAllSubMeshesAsMiscDirty(): void;
  57580. /**
  57581. * Instantiate a new istance of clear coat configuration.
  57582. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  57583. */
  57584. constructor(markAllSubMeshesAsMiscDirty: () => void);
  57585. /**
  57586. * Checks to see if a texture is used in the material.
  57587. * @param defines the list of "defines" to update.
  57588. */
  57589. prepareDefines(defines: IMaterialBRDFDefines): void;
  57590. /**
  57591. * Get the current class name of the texture useful for serialization or dynamic coding.
  57592. * @returns "PBRClearCoatConfiguration"
  57593. */
  57594. getClassName(): string;
  57595. /**
  57596. * Makes a duplicate of the current configuration into another one.
  57597. * @param brdfConfiguration define the config where to copy the info
  57598. */
  57599. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  57600. /**
  57601. * Serializes this BRDF configuration.
  57602. * @returns - An object with the serialized config.
  57603. */
  57604. serialize(): any;
  57605. /**
  57606. * Parses a anisotropy Configuration from a serialized object.
  57607. * @param source - Serialized object.
  57608. * @param scene Defines the scene we are parsing for
  57609. * @param rootUrl Defines the rootUrl to load from
  57610. */
  57611. parse(source: any, scene: Scene, rootUrl: string): void;
  57612. }
  57613. }
  57614. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  57615. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57616. import { Color3 } from "babylonjs/Maths/math.color";
  57617. import { Scene } from "babylonjs/scene";
  57618. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57619. import { Nullable } from "babylonjs/types";
  57620. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57621. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57622. /**
  57623. * @hidden
  57624. */
  57625. export interface IMaterialSheenDefines {
  57626. SHEEN: boolean;
  57627. SHEEN_TEXTURE: boolean;
  57628. SHEEN_TEXTUREDIRECTUV: number;
  57629. SHEEN_LINKWITHALBEDO: boolean;
  57630. SHEEN_ROUGHNESS: boolean;
  57631. SHEEN_ALBEDOSCALING: boolean;
  57632. /** @hidden */
  57633. _areTexturesDirty: boolean;
  57634. }
  57635. /**
  57636. * Define the code related to the Sheen parameters of the pbr material.
  57637. */
  57638. export class PBRSheenConfiguration {
  57639. private _isEnabled;
  57640. /**
  57641. * Defines if the material uses sheen.
  57642. */
  57643. isEnabled: boolean;
  57644. private _linkSheenWithAlbedo;
  57645. /**
  57646. * Defines if the sheen is linked to the sheen color.
  57647. */
  57648. linkSheenWithAlbedo: boolean;
  57649. /**
  57650. * Defines the sheen intensity.
  57651. */
  57652. intensity: number;
  57653. /**
  57654. * Defines the sheen color.
  57655. */
  57656. color: Color3;
  57657. private _texture;
  57658. /**
  57659. * Stores the sheen tint values in a texture.
  57660. * rgb is tint
  57661. * a is a intensity or roughness if roughness has been defined
  57662. */
  57663. texture: Nullable<BaseTexture>;
  57664. private _roughness;
  57665. /**
  57666. * Defines the sheen roughness.
  57667. * It is not taken into account if linkSheenWithAlbedo is true.
  57668. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  57669. */
  57670. roughness: Nullable<number>;
  57671. private _albedoScaling;
  57672. /**
  57673. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  57674. * It allows the strength of the sheen effect to not depend on the base color of the material,
  57675. * making it easier to setup and tweak the effect
  57676. */
  57677. albedoScaling: boolean;
  57678. /** @hidden */
  57679. private _internalMarkAllSubMeshesAsTexturesDirty;
  57680. /** @hidden */
  57681. _markAllSubMeshesAsTexturesDirty(): void;
  57682. /**
  57683. * Instantiate a new istance of clear coat configuration.
  57684. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57685. */
  57686. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57687. /**
  57688. * Specifies that the submesh is ready to be used.
  57689. * @param defines the list of "defines" to update.
  57690. * @param scene defines the scene the material belongs to.
  57691. * @returns - boolean indicating that the submesh is ready or not.
  57692. */
  57693. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  57694. /**
  57695. * Checks to see if a texture is used in the material.
  57696. * @param defines the list of "defines" to update.
  57697. * @param scene defines the scene the material belongs to.
  57698. */
  57699. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  57700. /**
  57701. * Binds the material data.
  57702. * @param uniformBuffer defines the Uniform buffer to fill in.
  57703. * @param scene defines the scene the material belongs to.
  57704. * @param isFrozen defines wether the material is frozen or not.
  57705. */
  57706. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57707. /**
  57708. * Checks to see if a texture is used in the material.
  57709. * @param texture - Base texture to use.
  57710. * @returns - Boolean specifying if a texture is used in the material.
  57711. */
  57712. hasTexture(texture: BaseTexture): boolean;
  57713. /**
  57714. * Returns an array of the actively used textures.
  57715. * @param activeTextures Array of BaseTextures
  57716. */
  57717. getActiveTextures(activeTextures: BaseTexture[]): void;
  57718. /**
  57719. * Returns the animatable textures.
  57720. * @param animatables Array of animatable textures.
  57721. */
  57722. getAnimatables(animatables: IAnimatable[]): void;
  57723. /**
  57724. * Disposes the resources of the material.
  57725. * @param forceDisposeTextures - Forces the disposal of all textures.
  57726. */
  57727. dispose(forceDisposeTextures?: boolean): void;
  57728. /**
  57729. * Get the current class name of the texture useful for serialization or dynamic coding.
  57730. * @returns "PBRSheenConfiguration"
  57731. */
  57732. getClassName(): string;
  57733. /**
  57734. * Add fallbacks to the effect fallbacks list.
  57735. * @param defines defines the Base texture to use.
  57736. * @param fallbacks defines the current fallback list.
  57737. * @param currentRank defines the current fallback rank.
  57738. * @returns the new fallback rank.
  57739. */
  57740. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57741. /**
  57742. * Add the required uniforms to the current list.
  57743. * @param uniforms defines the current uniform list.
  57744. */
  57745. static AddUniforms(uniforms: string[]): void;
  57746. /**
  57747. * Add the required uniforms to the current buffer.
  57748. * @param uniformBuffer defines the current uniform buffer.
  57749. */
  57750. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57751. /**
  57752. * Add the required samplers to the current list.
  57753. * @param samplers defines the current sampler list.
  57754. */
  57755. static AddSamplers(samplers: string[]): void;
  57756. /**
  57757. * Makes a duplicate of the current configuration into another one.
  57758. * @param sheenConfiguration define the config where to copy the info
  57759. */
  57760. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57761. /**
  57762. * Serializes this BRDF configuration.
  57763. * @returns - An object with the serialized config.
  57764. */
  57765. serialize(): any;
  57766. /**
  57767. * Parses a anisotropy Configuration from a serialized object.
  57768. * @param source - Serialized object.
  57769. * @param scene Defines the scene we are parsing for
  57770. * @param rootUrl Defines the rootUrl to load from
  57771. */
  57772. parse(source: any, scene: Scene, rootUrl: string): void;
  57773. }
  57774. }
  57775. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57776. import { Nullable } from "babylonjs/types";
  57777. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57778. import { Color3 } from "babylonjs/Maths/math.color";
  57779. import { SmartArray } from "babylonjs/Misc/smartArray";
  57780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57782. import { Effect } from "babylonjs/Materials/effect";
  57783. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57784. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57785. import { Engine } from "babylonjs/Engines/engine";
  57786. import { Scene } from "babylonjs/scene";
  57787. /**
  57788. * @hidden
  57789. */
  57790. export interface IMaterialSubSurfaceDefines {
  57791. SUBSURFACE: boolean;
  57792. SS_REFRACTION: boolean;
  57793. SS_TRANSLUCENCY: boolean;
  57794. SS_SCATTERING: boolean;
  57795. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57796. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57797. SS_REFRACTIONMAP_3D: boolean;
  57798. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57799. SS_LODINREFRACTIONALPHA: boolean;
  57800. SS_GAMMAREFRACTION: boolean;
  57801. SS_RGBDREFRACTION: boolean;
  57802. SS_LINEARSPECULARREFRACTION: boolean;
  57803. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57804. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57805. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57806. /** @hidden */
  57807. _areTexturesDirty: boolean;
  57808. }
  57809. /**
  57810. * Define the code related to the sub surface parameters of the pbr material.
  57811. */
  57812. export class PBRSubSurfaceConfiguration {
  57813. private _isRefractionEnabled;
  57814. /**
  57815. * Defines if the refraction is enabled in the material.
  57816. */
  57817. isRefractionEnabled: boolean;
  57818. private _isTranslucencyEnabled;
  57819. /**
  57820. * Defines if the translucency is enabled in the material.
  57821. */
  57822. isTranslucencyEnabled: boolean;
  57823. private _isScatteringEnabled;
  57824. /**
  57825. * Defines if the sub surface scattering is enabled in the material.
  57826. */
  57827. isScatteringEnabled: boolean;
  57828. private _scatteringDiffusionProfileIndex;
  57829. /**
  57830. * Diffusion profile for subsurface scattering.
  57831. * Useful for better scattering in the skins or foliages.
  57832. */
  57833. get scatteringDiffusionProfile(): Nullable<Color3>;
  57834. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57835. /**
  57836. * Defines the refraction intensity of the material.
  57837. * The refraction when enabled replaces the Diffuse part of the material.
  57838. * The intensity helps transitionning between diffuse and refraction.
  57839. */
  57840. refractionIntensity: number;
  57841. /**
  57842. * Defines the translucency intensity of the material.
  57843. * When translucency has been enabled, this defines how much of the "translucency"
  57844. * is addded to the diffuse part of the material.
  57845. */
  57846. translucencyIntensity: number;
  57847. /**
  57848. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57849. */
  57850. useAlbedoToTintRefraction: boolean;
  57851. private _thicknessTexture;
  57852. /**
  57853. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57854. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57855. * 0 would mean minimumThickness
  57856. * 1 would mean maximumThickness
  57857. * The other channels might be use as a mask to vary the different effects intensity.
  57858. */
  57859. thicknessTexture: Nullable<BaseTexture>;
  57860. private _refractionTexture;
  57861. /**
  57862. * Defines the texture to use for refraction.
  57863. */
  57864. refractionTexture: Nullable<BaseTexture>;
  57865. private _indexOfRefraction;
  57866. /**
  57867. * Index of refraction of the material base layer.
  57868. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57869. *
  57870. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57871. *
  57872. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57873. */
  57874. indexOfRefraction: number;
  57875. private _volumeIndexOfRefraction;
  57876. /**
  57877. * Index of refraction of the material's volume.
  57878. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57879. *
  57880. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57881. * the volume will use the same IOR as the surface.
  57882. */
  57883. get volumeIndexOfRefraction(): number;
  57884. set volumeIndexOfRefraction(value: number);
  57885. private _invertRefractionY;
  57886. /**
  57887. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57888. */
  57889. invertRefractionY: boolean;
  57890. private _linkRefractionWithTransparency;
  57891. /**
  57892. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57893. * Materials half opaque for instance using refraction could benefit from this control.
  57894. */
  57895. linkRefractionWithTransparency: boolean;
  57896. /**
  57897. * Defines the minimum thickness stored in the thickness map.
  57898. * If no thickness map is defined, this value will be used to simulate thickness.
  57899. */
  57900. minimumThickness: number;
  57901. /**
  57902. * Defines the maximum thickness stored in the thickness map.
  57903. */
  57904. maximumThickness: number;
  57905. /**
  57906. * Defines the volume tint of the material.
  57907. * This is used for both translucency and scattering.
  57908. */
  57909. tintColor: Color3;
  57910. /**
  57911. * Defines the distance at which the tint color should be found in the media.
  57912. * This is used for refraction only.
  57913. */
  57914. tintColorAtDistance: number;
  57915. /**
  57916. * Defines how far each channel transmit through the media.
  57917. * It is defined as a color to simplify it selection.
  57918. */
  57919. diffusionDistance: Color3;
  57920. private _useMaskFromThicknessTexture;
  57921. /**
  57922. * Stores the intensity of the different subsurface effects in the thickness texture.
  57923. * * the green channel is the translucency intensity.
  57924. * * the blue channel is the scattering intensity.
  57925. * * the alpha channel is the refraction intensity.
  57926. */
  57927. useMaskFromThicknessTexture: boolean;
  57928. private _scene;
  57929. /** @hidden */
  57930. private _internalMarkAllSubMeshesAsTexturesDirty;
  57931. private _internalMarkScenePrePassDirty;
  57932. /** @hidden */
  57933. _markAllSubMeshesAsTexturesDirty(): void;
  57934. /** @hidden */
  57935. _markScenePrePassDirty(): void;
  57936. /**
  57937. * Instantiate a new istance of sub surface configuration.
  57938. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57939. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57940. * @param scene The scene
  57941. */
  57942. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57943. /**
  57944. * Gets wehter the submesh is ready to be used or not.
  57945. * @param defines the list of "defines" to update.
  57946. * @param scene defines the scene the material belongs to.
  57947. * @returns - boolean indicating that the submesh is ready or not.
  57948. */
  57949. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57950. /**
  57951. * Checks to see if a texture is used in the material.
  57952. * @param defines the list of "defines" to update.
  57953. * @param scene defines the scene to the material belongs to.
  57954. */
  57955. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57956. /**
  57957. * Binds the material data.
  57958. * @param uniformBuffer defines the Uniform buffer to fill in.
  57959. * @param scene defines the scene the material belongs to.
  57960. * @param engine defines the engine the material belongs to.
  57961. * @param isFrozen defines whether the material is frozen or not.
  57962. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57963. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57964. */
  57965. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57966. /**
  57967. * Unbinds the material from the mesh.
  57968. * @param activeEffect defines the effect that should be unbound from.
  57969. * @returns true if unbound, otherwise false
  57970. */
  57971. unbind(activeEffect: Effect): boolean;
  57972. /**
  57973. * Returns the texture used for refraction or null if none is used.
  57974. * @param scene defines the scene the material belongs to.
  57975. * @returns - Refraction texture if present. If no refraction texture and refraction
  57976. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57977. */
  57978. private _getRefractionTexture;
  57979. /**
  57980. * Returns true if alpha blending should be disabled.
  57981. */
  57982. get disableAlphaBlending(): boolean;
  57983. /**
  57984. * Fills the list of render target textures.
  57985. * @param renderTargets the list of render targets to update
  57986. */
  57987. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57988. /**
  57989. * Checks to see if a texture is used in the material.
  57990. * @param texture - Base texture to use.
  57991. * @returns - Boolean specifying if a texture is used in the material.
  57992. */
  57993. hasTexture(texture: BaseTexture): boolean;
  57994. /**
  57995. * Gets a boolean indicating that current material needs to register RTT
  57996. * @returns true if this uses a render target otherwise false.
  57997. */
  57998. hasRenderTargetTextures(): boolean;
  57999. /**
  58000. * Returns an array of the actively used textures.
  58001. * @param activeTextures Array of BaseTextures
  58002. */
  58003. getActiveTextures(activeTextures: BaseTexture[]): void;
  58004. /**
  58005. * Returns the animatable textures.
  58006. * @param animatables Array of animatable textures.
  58007. */
  58008. getAnimatables(animatables: IAnimatable[]): void;
  58009. /**
  58010. * Disposes the resources of the material.
  58011. * @param forceDisposeTextures - Forces the disposal of all textures.
  58012. */
  58013. dispose(forceDisposeTextures?: boolean): void;
  58014. /**
  58015. * Get the current class name of the texture useful for serialization or dynamic coding.
  58016. * @returns "PBRSubSurfaceConfiguration"
  58017. */
  58018. getClassName(): string;
  58019. /**
  58020. * Add fallbacks to the effect fallbacks list.
  58021. * @param defines defines the Base texture to use.
  58022. * @param fallbacks defines the current fallback list.
  58023. * @param currentRank defines the current fallback rank.
  58024. * @returns the new fallback rank.
  58025. */
  58026. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58027. /**
  58028. * Add the required uniforms to the current list.
  58029. * @param uniforms defines the current uniform list.
  58030. */
  58031. static AddUniforms(uniforms: string[]): void;
  58032. /**
  58033. * Add the required samplers to the current list.
  58034. * @param samplers defines the current sampler list.
  58035. */
  58036. static AddSamplers(samplers: string[]): void;
  58037. /**
  58038. * Add the required uniforms to the current buffer.
  58039. * @param uniformBuffer defines the current uniform buffer.
  58040. */
  58041. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58042. /**
  58043. * Makes a duplicate of the current configuration into another one.
  58044. * @param configuration define the config where to copy the info
  58045. */
  58046. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58047. /**
  58048. * Serializes this Sub Surface configuration.
  58049. * @returns - An object with the serialized config.
  58050. */
  58051. serialize(): any;
  58052. /**
  58053. * Parses a anisotropy Configuration from a serialized object.
  58054. * @param source - Serialized object.
  58055. * @param scene Defines the scene we are parsing for
  58056. * @param rootUrl Defines the rootUrl to load from
  58057. */
  58058. parse(source: any, scene: Scene, rootUrl: string): void;
  58059. }
  58060. }
  58061. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58062. /** @hidden */
  58063. export var pbrFragmentDeclaration: {
  58064. name: string;
  58065. shader: string;
  58066. };
  58067. }
  58068. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58069. /** @hidden */
  58070. export var pbrUboDeclaration: {
  58071. name: string;
  58072. shader: string;
  58073. };
  58074. }
  58075. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58076. /** @hidden */
  58077. export var pbrFragmentExtraDeclaration: {
  58078. name: string;
  58079. shader: string;
  58080. };
  58081. }
  58082. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58083. /** @hidden */
  58084. export var pbrFragmentSamplersDeclaration: {
  58085. name: string;
  58086. shader: string;
  58087. };
  58088. }
  58089. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58090. /** @hidden */
  58091. export var importanceSampling: {
  58092. name: string;
  58093. shader: string;
  58094. };
  58095. }
  58096. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58097. /** @hidden */
  58098. export var pbrHelperFunctions: {
  58099. name: string;
  58100. shader: string;
  58101. };
  58102. }
  58103. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58104. /** @hidden */
  58105. export var harmonicsFunctions: {
  58106. name: string;
  58107. shader: string;
  58108. };
  58109. }
  58110. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58111. /** @hidden */
  58112. export var pbrDirectLightingSetupFunctions: {
  58113. name: string;
  58114. shader: string;
  58115. };
  58116. }
  58117. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58118. /** @hidden */
  58119. export var pbrDirectLightingFalloffFunctions: {
  58120. name: string;
  58121. shader: string;
  58122. };
  58123. }
  58124. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58125. /** @hidden */
  58126. export var pbrBRDFFunctions: {
  58127. name: string;
  58128. shader: string;
  58129. };
  58130. }
  58131. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58132. /** @hidden */
  58133. export var hdrFilteringFunctions: {
  58134. name: string;
  58135. shader: string;
  58136. };
  58137. }
  58138. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58139. /** @hidden */
  58140. export var pbrDirectLightingFunctions: {
  58141. name: string;
  58142. shader: string;
  58143. };
  58144. }
  58145. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58146. /** @hidden */
  58147. export var pbrIBLFunctions: {
  58148. name: string;
  58149. shader: string;
  58150. };
  58151. }
  58152. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58153. /** @hidden */
  58154. export var pbrBlockAlbedoOpacity: {
  58155. name: string;
  58156. shader: string;
  58157. };
  58158. }
  58159. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58160. /** @hidden */
  58161. export var pbrBlockReflectivity: {
  58162. name: string;
  58163. shader: string;
  58164. };
  58165. }
  58166. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58167. /** @hidden */
  58168. export var pbrBlockAmbientOcclusion: {
  58169. name: string;
  58170. shader: string;
  58171. };
  58172. }
  58173. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58174. /** @hidden */
  58175. export var pbrBlockAlphaFresnel: {
  58176. name: string;
  58177. shader: string;
  58178. };
  58179. }
  58180. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58181. /** @hidden */
  58182. export var pbrBlockAnisotropic: {
  58183. name: string;
  58184. shader: string;
  58185. };
  58186. }
  58187. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58188. /** @hidden */
  58189. export var pbrBlockReflection: {
  58190. name: string;
  58191. shader: string;
  58192. };
  58193. }
  58194. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58195. /** @hidden */
  58196. export var pbrBlockSheen: {
  58197. name: string;
  58198. shader: string;
  58199. };
  58200. }
  58201. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58202. /** @hidden */
  58203. export var pbrBlockClearcoat: {
  58204. name: string;
  58205. shader: string;
  58206. };
  58207. }
  58208. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58209. /** @hidden */
  58210. export var pbrBlockSubSurface: {
  58211. name: string;
  58212. shader: string;
  58213. };
  58214. }
  58215. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58216. /** @hidden */
  58217. export var pbrBlockNormalGeometric: {
  58218. name: string;
  58219. shader: string;
  58220. };
  58221. }
  58222. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58223. /** @hidden */
  58224. export var pbrBlockNormalFinal: {
  58225. name: string;
  58226. shader: string;
  58227. };
  58228. }
  58229. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58230. /** @hidden */
  58231. export var pbrBlockLightmapInit: {
  58232. name: string;
  58233. shader: string;
  58234. };
  58235. }
  58236. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58237. /** @hidden */
  58238. export var pbrBlockGeometryInfo: {
  58239. name: string;
  58240. shader: string;
  58241. };
  58242. }
  58243. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58244. /** @hidden */
  58245. export var pbrBlockReflectance0: {
  58246. name: string;
  58247. shader: string;
  58248. };
  58249. }
  58250. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58251. /** @hidden */
  58252. export var pbrBlockReflectance: {
  58253. name: string;
  58254. shader: string;
  58255. };
  58256. }
  58257. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58258. /** @hidden */
  58259. export var pbrBlockDirectLighting: {
  58260. name: string;
  58261. shader: string;
  58262. };
  58263. }
  58264. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58265. /** @hidden */
  58266. export var pbrBlockFinalLitComponents: {
  58267. name: string;
  58268. shader: string;
  58269. };
  58270. }
  58271. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58272. /** @hidden */
  58273. export var pbrBlockFinalUnlitComponents: {
  58274. name: string;
  58275. shader: string;
  58276. };
  58277. }
  58278. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58279. /** @hidden */
  58280. export var pbrBlockFinalColorComposition: {
  58281. name: string;
  58282. shader: string;
  58283. };
  58284. }
  58285. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58286. /** @hidden */
  58287. export var pbrBlockImageProcessing: {
  58288. name: string;
  58289. shader: string;
  58290. };
  58291. }
  58292. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58293. /** @hidden */
  58294. export var pbrDebug: {
  58295. name: string;
  58296. shader: string;
  58297. };
  58298. }
  58299. declare module "babylonjs/Shaders/pbr.fragment" {
  58300. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58301. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58302. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58303. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58304. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58305. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58306. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58307. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58308. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58309. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58310. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58311. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58312. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58313. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58314. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58315. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58316. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58317. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58318. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58319. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58320. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58321. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58322. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58323. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58324. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58325. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58326. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58327. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58328. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58329. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58330. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58331. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58332. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58333. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58334. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58335. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58336. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58337. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58338. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58339. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58340. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58341. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58342. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58343. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58344. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58345. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58346. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58347. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58348. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58349. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58350. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58351. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58352. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58353. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58354. /** @hidden */
  58355. export var pbrPixelShader: {
  58356. name: string;
  58357. shader: string;
  58358. };
  58359. }
  58360. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58361. /** @hidden */
  58362. export var pbrVertexDeclaration: {
  58363. name: string;
  58364. shader: string;
  58365. };
  58366. }
  58367. declare module "babylonjs/Shaders/pbr.vertex" {
  58368. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58369. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58370. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58371. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58372. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58373. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58374. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58375. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58376. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58377. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58378. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58379. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58380. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58381. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58382. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58383. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58384. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58385. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58387. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58388. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58389. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58390. /** @hidden */
  58391. export var pbrVertexShader: {
  58392. name: string;
  58393. shader: string;
  58394. };
  58395. }
  58396. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58397. import { Nullable } from "babylonjs/types";
  58398. import { Scene } from "babylonjs/scene";
  58399. import { Matrix } from "babylonjs/Maths/math.vector";
  58400. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58402. import { Mesh } from "babylonjs/Meshes/mesh";
  58403. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58404. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58405. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58406. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58407. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58408. import { Color3 } from "babylonjs/Maths/math.color";
  58409. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58410. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58411. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58412. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58414. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58415. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58416. import "babylonjs/Shaders/pbr.fragment";
  58417. import "babylonjs/Shaders/pbr.vertex";
  58418. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58419. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58420. /**
  58421. * Manages the defines for the PBR Material.
  58422. * @hidden
  58423. */
  58424. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58425. PBR: boolean;
  58426. NUM_SAMPLES: string;
  58427. REALTIME_FILTERING: boolean;
  58428. MAINUV1: boolean;
  58429. MAINUV2: boolean;
  58430. UV1: boolean;
  58431. UV2: boolean;
  58432. ALBEDO: boolean;
  58433. GAMMAALBEDO: boolean;
  58434. ALBEDODIRECTUV: number;
  58435. VERTEXCOLOR: boolean;
  58436. DETAIL: boolean;
  58437. DETAILDIRECTUV: number;
  58438. DETAIL_NORMALBLENDMETHOD: number;
  58439. AMBIENT: boolean;
  58440. AMBIENTDIRECTUV: number;
  58441. AMBIENTINGRAYSCALE: boolean;
  58442. OPACITY: boolean;
  58443. VERTEXALPHA: boolean;
  58444. OPACITYDIRECTUV: number;
  58445. OPACITYRGB: boolean;
  58446. ALPHATEST: boolean;
  58447. DEPTHPREPASS: boolean;
  58448. ALPHABLEND: boolean;
  58449. ALPHAFROMALBEDO: boolean;
  58450. ALPHATESTVALUE: string;
  58451. SPECULAROVERALPHA: boolean;
  58452. RADIANCEOVERALPHA: boolean;
  58453. ALPHAFRESNEL: boolean;
  58454. LINEARALPHAFRESNEL: boolean;
  58455. PREMULTIPLYALPHA: boolean;
  58456. EMISSIVE: boolean;
  58457. EMISSIVEDIRECTUV: number;
  58458. REFLECTIVITY: boolean;
  58459. REFLECTIVITYDIRECTUV: number;
  58460. SPECULARTERM: boolean;
  58461. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58462. MICROSURFACEAUTOMATIC: boolean;
  58463. LODBASEDMICROSFURACE: boolean;
  58464. MICROSURFACEMAP: boolean;
  58465. MICROSURFACEMAPDIRECTUV: number;
  58466. METALLICWORKFLOW: boolean;
  58467. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58468. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58469. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58470. AOSTOREINMETALMAPRED: boolean;
  58471. METALLIC_REFLECTANCE: boolean;
  58472. METALLIC_REFLECTANCEDIRECTUV: number;
  58473. ENVIRONMENTBRDF: boolean;
  58474. ENVIRONMENTBRDF_RGBD: boolean;
  58475. NORMAL: boolean;
  58476. TANGENT: boolean;
  58477. BUMP: boolean;
  58478. BUMPDIRECTUV: number;
  58479. OBJECTSPACE_NORMALMAP: boolean;
  58480. PARALLAX: boolean;
  58481. PARALLAXOCCLUSION: boolean;
  58482. NORMALXYSCALE: boolean;
  58483. LIGHTMAP: boolean;
  58484. LIGHTMAPDIRECTUV: number;
  58485. USELIGHTMAPASSHADOWMAP: boolean;
  58486. GAMMALIGHTMAP: boolean;
  58487. RGBDLIGHTMAP: boolean;
  58488. REFLECTION: boolean;
  58489. REFLECTIONMAP_3D: boolean;
  58490. REFLECTIONMAP_SPHERICAL: boolean;
  58491. REFLECTIONMAP_PLANAR: boolean;
  58492. REFLECTIONMAP_CUBIC: boolean;
  58493. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58494. REFLECTIONMAP_PROJECTION: boolean;
  58495. REFLECTIONMAP_SKYBOX: boolean;
  58496. REFLECTIONMAP_EXPLICIT: boolean;
  58497. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58498. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58499. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58500. INVERTCUBICMAP: boolean;
  58501. USESPHERICALFROMREFLECTIONMAP: boolean;
  58502. USEIRRADIANCEMAP: boolean;
  58503. SPHERICAL_HARMONICS: boolean;
  58504. USESPHERICALINVERTEX: boolean;
  58505. REFLECTIONMAP_OPPOSITEZ: boolean;
  58506. LODINREFLECTIONALPHA: boolean;
  58507. GAMMAREFLECTION: boolean;
  58508. RGBDREFLECTION: boolean;
  58509. LINEARSPECULARREFLECTION: boolean;
  58510. RADIANCEOCCLUSION: boolean;
  58511. HORIZONOCCLUSION: boolean;
  58512. INSTANCES: boolean;
  58513. THIN_INSTANCES: boolean;
  58514. PREPASS: boolean;
  58515. SCENE_MRT_COUNT: number;
  58516. NUM_BONE_INFLUENCERS: number;
  58517. BonesPerMesh: number;
  58518. BONETEXTURE: boolean;
  58519. NONUNIFORMSCALING: boolean;
  58520. MORPHTARGETS: boolean;
  58521. MORPHTARGETS_NORMAL: boolean;
  58522. MORPHTARGETS_TANGENT: boolean;
  58523. MORPHTARGETS_UV: boolean;
  58524. NUM_MORPH_INFLUENCERS: number;
  58525. IMAGEPROCESSING: boolean;
  58526. VIGNETTE: boolean;
  58527. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58528. VIGNETTEBLENDMODEOPAQUE: boolean;
  58529. TONEMAPPING: boolean;
  58530. TONEMAPPING_ACES: boolean;
  58531. CONTRAST: boolean;
  58532. COLORCURVES: boolean;
  58533. COLORGRADING: boolean;
  58534. COLORGRADING3D: boolean;
  58535. SAMPLER3DGREENDEPTH: boolean;
  58536. SAMPLER3DBGRMAP: boolean;
  58537. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58538. EXPOSURE: boolean;
  58539. MULTIVIEW: boolean;
  58540. USEPHYSICALLIGHTFALLOFF: boolean;
  58541. USEGLTFLIGHTFALLOFF: boolean;
  58542. TWOSIDEDLIGHTING: boolean;
  58543. SHADOWFLOAT: boolean;
  58544. CLIPPLANE: boolean;
  58545. CLIPPLANE2: boolean;
  58546. CLIPPLANE3: boolean;
  58547. CLIPPLANE4: boolean;
  58548. CLIPPLANE5: boolean;
  58549. CLIPPLANE6: boolean;
  58550. POINTSIZE: boolean;
  58551. FOG: boolean;
  58552. LOGARITHMICDEPTH: boolean;
  58553. FORCENORMALFORWARD: boolean;
  58554. SPECULARAA: boolean;
  58555. CLEARCOAT: boolean;
  58556. CLEARCOAT_DEFAULTIOR: boolean;
  58557. CLEARCOAT_TEXTURE: boolean;
  58558. CLEARCOAT_TEXTUREDIRECTUV: number;
  58559. CLEARCOAT_BUMP: boolean;
  58560. CLEARCOAT_BUMPDIRECTUV: number;
  58561. CLEARCOAT_TINT: boolean;
  58562. CLEARCOAT_TINT_TEXTURE: boolean;
  58563. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  58564. ANISOTROPIC: boolean;
  58565. ANISOTROPIC_TEXTURE: boolean;
  58566. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58567. BRDF_V_HEIGHT_CORRELATED: boolean;
  58568. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58569. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58570. SHEEN: boolean;
  58571. SHEEN_TEXTURE: boolean;
  58572. SHEEN_TEXTUREDIRECTUV: number;
  58573. SHEEN_LINKWITHALBEDO: boolean;
  58574. SHEEN_ROUGHNESS: boolean;
  58575. SHEEN_ALBEDOSCALING: boolean;
  58576. SUBSURFACE: boolean;
  58577. SS_REFRACTION: boolean;
  58578. SS_TRANSLUCENCY: boolean;
  58579. SS_SCATTERING: boolean;
  58580. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58581. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58582. SS_REFRACTIONMAP_3D: boolean;
  58583. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58584. SS_LODINREFRACTIONALPHA: boolean;
  58585. SS_GAMMAREFRACTION: boolean;
  58586. SS_RGBDREFRACTION: boolean;
  58587. SS_LINEARSPECULARREFRACTION: boolean;
  58588. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58589. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58590. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58591. UNLIT: boolean;
  58592. DEBUGMODE: number;
  58593. /**
  58594. * Initializes the PBR Material defines.
  58595. */
  58596. constructor();
  58597. /**
  58598. * Resets the PBR Material defines.
  58599. */
  58600. reset(): void;
  58601. }
  58602. /**
  58603. * The Physically based material base class of BJS.
  58604. *
  58605. * This offers the main features of a standard PBR material.
  58606. * For more information, please refer to the documentation :
  58607. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58608. */
  58609. export abstract class PBRBaseMaterial extends PushMaterial {
  58610. /**
  58611. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58612. */
  58613. static readonly PBRMATERIAL_OPAQUE: number;
  58614. /**
  58615. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58616. */
  58617. static readonly PBRMATERIAL_ALPHATEST: number;
  58618. /**
  58619. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58620. */
  58621. static readonly PBRMATERIAL_ALPHABLEND: number;
  58622. /**
  58623. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58624. * They are also discarded below the alpha cutoff threshold to improve performances.
  58625. */
  58626. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58627. /**
  58628. * Defines the default value of how much AO map is occluding the analytical lights
  58629. * (point spot...).
  58630. */
  58631. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58632. /**
  58633. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  58634. */
  58635. static readonly LIGHTFALLOFF_PHYSICAL: number;
  58636. /**
  58637. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  58638. * to enhance interoperability with other engines.
  58639. */
  58640. static readonly LIGHTFALLOFF_GLTF: number;
  58641. /**
  58642. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  58643. * to enhance interoperability with other materials.
  58644. */
  58645. static readonly LIGHTFALLOFF_STANDARD: number;
  58646. /**
  58647. * Intensity of the direct lights e.g. the four lights available in your scene.
  58648. * This impacts both the direct diffuse and specular highlights.
  58649. */
  58650. protected _directIntensity: number;
  58651. /**
  58652. * Intensity of the emissive part of the material.
  58653. * This helps controlling the emissive effect without modifying the emissive color.
  58654. */
  58655. protected _emissiveIntensity: number;
  58656. /**
  58657. * Intensity of the environment e.g. how much the environment will light the object
  58658. * either through harmonics for rough material or through the refelction for shiny ones.
  58659. */
  58660. protected _environmentIntensity: number;
  58661. /**
  58662. * This is a special control allowing the reduction of the specular highlights coming from the
  58663. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58664. */
  58665. protected _specularIntensity: number;
  58666. /**
  58667. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  58668. */
  58669. private _lightingInfos;
  58670. /**
  58671. * Debug Control allowing disabling the bump map on this material.
  58672. */
  58673. protected _disableBumpMap: boolean;
  58674. /**
  58675. * AKA Diffuse Texture in standard nomenclature.
  58676. */
  58677. protected _albedoTexture: Nullable<BaseTexture>;
  58678. /**
  58679. * AKA Occlusion Texture in other nomenclature.
  58680. */
  58681. protected _ambientTexture: Nullable<BaseTexture>;
  58682. /**
  58683. * AKA Occlusion Texture Intensity in other nomenclature.
  58684. */
  58685. protected _ambientTextureStrength: number;
  58686. /**
  58687. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58688. * 1 means it completely occludes it
  58689. * 0 mean it has no impact
  58690. */
  58691. protected _ambientTextureImpactOnAnalyticalLights: number;
  58692. /**
  58693. * Stores the alpha values in a texture.
  58694. */
  58695. protected _opacityTexture: Nullable<BaseTexture>;
  58696. /**
  58697. * Stores the reflection values in a texture.
  58698. */
  58699. protected _reflectionTexture: Nullable<BaseTexture>;
  58700. /**
  58701. * Stores the emissive values in a texture.
  58702. */
  58703. protected _emissiveTexture: Nullable<BaseTexture>;
  58704. /**
  58705. * AKA Specular texture in other nomenclature.
  58706. */
  58707. protected _reflectivityTexture: Nullable<BaseTexture>;
  58708. /**
  58709. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58710. */
  58711. protected _metallicTexture: Nullable<BaseTexture>;
  58712. /**
  58713. * Specifies the metallic scalar of the metallic/roughness workflow.
  58714. * Can also be used to scale the metalness values of the metallic texture.
  58715. */
  58716. protected _metallic: Nullable<number>;
  58717. /**
  58718. * Specifies the roughness scalar of the metallic/roughness workflow.
  58719. * Can also be used to scale the roughness values of the metallic texture.
  58720. */
  58721. protected _roughness: Nullable<number>;
  58722. /**
  58723. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58724. * By default the indexOfrefraction is used to compute F0;
  58725. *
  58726. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58727. *
  58728. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58729. * F90 = metallicReflectanceColor;
  58730. */
  58731. protected _metallicF0Factor: number;
  58732. /**
  58733. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58734. * By default the F90 is always 1;
  58735. *
  58736. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58737. *
  58738. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58739. * F90 = metallicReflectanceColor;
  58740. */
  58741. protected _metallicReflectanceColor: Color3;
  58742. /**
  58743. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58744. * This is multiply against the scalar values defined in the material.
  58745. */
  58746. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  58747. /**
  58748. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58749. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58750. */
  58751. protected _microSurfaceTexture: Nullable<BaseTexture>;
  58752. /**
  58753. * Stores surface normal data used to displace a mesh in a texture.
  58754. */
  58755. protected _bumpTexture: Nullable<BaseTexture>;
  58756. /**
  58757. * Stores the pre-calculated light information of a mesh in a texture.
  58758. */
  58759. protected _lightmapTexture: Nullable<BaseTexture>;
  58760. /**
  58761. * The color of a material in ambient lighting.
  58762. */
  58763. protected _ambientColor: Color3;
  58764. /**
  58765. * AKA Diffuse Color in other nomenclature.
  58766. */
  58767. protected _albedoColor: Color3;
  58768. /**
  58769. * AKA Specular Color in other nomenclature.
  58770. */
  58771. protected _reflectivityColor: Color3;
  58772. /**
  58773. * The color applied when light is reflected from a material.
  58774. */
  58775. protected _reflectionColor: Color3;
  58776. /**
  58777. * The color applied when light is emitted from a material.
  58778. */
  58779. protected _emissiveColor: Color3;
  58780. /**
  58781. * AKA Glossiness in other nomenclature.
  58782. */
  58783. protected _microSurface: number;
  58784. /**
  58785. * Specifies that the material will use the light map as a show map.
  58786. */
  58787. protected _useLightmapAsShadowmap: boolean;
  58788. /**
  58789. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58790. * makes the reflect vector face the model (under horizon).
  58791. */
  58792. protected _useHorizonOcclusion: boolean;
  58793. /**
  58794. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58795. * too much the area relying on ambient texture to define their ambient occlusion.
  58796. */
  58797. protected _useRadianceOcclusion: boolean;
  58798. /**
  58799. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58800. */
  58801. protected _useAlphaFromAlbedoTexture: boolean;
  58802. /**
  58803. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58804. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58805. */
  58806. protected _useSpecularOverAlpha: boolean;
  58807. /**
  58808. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58809. */
  58810. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58811. /**
  58812. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58813. */
  58814. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58815. /**
  58816. * Specifies if the metallic texture contains the roughness information in its green channel.
  58817. */
  58818. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58819. /**
  58820. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58821. */
  58822. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58823. /**
  58824. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58825. */
  58826. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58827. /**
  58828. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58829. */
  58830. protected _useAmbientInGrayScale: boolean;
  58831. /**
  58832. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58833. * The material will try to infer what glossiness each pixel should be.
  58834. */
  58835. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58836. /**
  58837. * Defines the falloff type used in this material.
  58838. * It by default is Physical.
  58839. */
  58840. protected _lightFalloff: number;
  58841. /**
  58842. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58843. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58844. */
  58845. protected _useRadianceOverAlpha: boolean;
  58846. /**
  58847. * Allows using an object space normal map (instead of tangent space).
  58848. */
  58849. protected _useObjectSpaceNormalMap: boolean;
  58850. /**
  58851. * Allows using the bump map in parallax mode.
  58852. */
  58853. protected _useParallax: boolean;
  58854. /**
  58855. * Allows using the bump map in parallax occlusion mode.
  58856. */
  58857. protected _useParallaxOcclusion: boolean;
  58858. /**
  58859. * Controls the scale bias of the parallax mode.
  58860. */
  58861. protected _parallaxScaleBias: number;
  58862. /**
  58863. * If sets to true, disables all the lights affecting the material.
  58864. */
  58865. protected _disableLighting: boolean;
  58866. /**
  58867. * Number of Simultaneous lights allowed on the material.
  58868. */
  58869. protected _maxSimultaneousLights: number;
  58870. /**
  58871. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58872. */
  58873. protected _invertNormalMapX: boolean;
  58874. /**
  58875. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58876. */
  58877. protected _invertNormalMapY: boolean;
  58878. /**
  58879. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58880. */
  58881. protected _twoSidedLighting: boolean;
  58882. /**
  58883. * Defines the alpha limits in alpha test mode.
  58884. */
  58885. protected _alphaCutOff: number;
  58886. /**
  58887. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58888. */
  58889. protected _forceAlphaTest: boolean;
  58890. /**
  58891. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58892. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58893. */
  58894. protected _useAlphaFresnel: boolean;
  58895. /**
  58896. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58897. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58898. */
  58899. protected _useLinearAlphaFresnel: boolean;
  58900. /**
  58901. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58902. * from cos thetav and roughness:
  58903. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58904. */
  58905. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58906. /**
  58907. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58908. */
  58909. protected _forceIrradianceInFragment: boolean;
  58910. private _realTimeFiltering;
  58911. /**
  58912. * Enables realtime filtering on the texture.
  58913. */
  58914. get realTimeFiltering(): boolean;
  58915. set realTimeFiltering(b: boolean);
  58916. private _realTimeFilteringQuality;
  58917. /**
  58918. * Quality switch for realtime filtering
  58919. */
  58920. get realTimeFilteringQuality(): number;
  58921. set realTimeFilteringQuality(n: number);
  58922. /**
  58923. * Can this material render to several textures at once
  58924. */
  58925. get canRenderToMRT(): boolean;
  58926. /**
  58927. * Force normal to face away from face.
  58928. */
  58929. protected _forceNormalForward: boolean;
  58930. /**
  58931. * Enables specular anti aliasing in the PBR shader.
  58932. * It will both interacts on the Geometry for analytical and IBL lighting.
  58933. * It also prefilter the roughness map based on the bump values.
  58934. */
  58935. protected _enableSpecularAntiAliasing: boolean;
  58936. /**
  58937. * Default configuration related to image processing available in the PBR Material.
  58938. */
  58939. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58940. /**
  58941. * Keep track of the image processing observer to allow dispose and replace.
  58942. */
  58943. private _imageProcessingObserver;
  58944. /**
  58945. * Attaches a new image processing configuration to the PBR Material.
  58946. * @param configuration
  58947. */
  58948. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58949. /**
  58950. * Stores the available render targets.
  58951. */
  58952. private _renderTargets;
  58953. /**
  58954. * Sets the global ambient color for the material used in lighting calculations.
  58955. */
  58956. private _globalAmbientColor;
  58957. /**
  58958. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58959. */
  58960. private _useLogarithmicDepth;
  58961. /**
  58962. * If set to true, no lighting calculations will be applied.
  58963. */
  58964. private _unlit;
  58965. private _debugMode;
  58966. /**
  58967. * @hidden
  58968. * This is reserved for the inspector.
  58969. * Defines the material debug mode.
  58970. * It helps seeing only some components of the material while troubleshooting.
  58971. */
  58972. debugMode: number;
  58973. /**
  58974. * @hidden
  58975. * This is reserved for the inspector.
  58976. * Specify from where on screen the debug mode should start.
  58977. * The value goes from -1 (full screen) to 1 (not visible)
  58978. * It helps with side by side comparison against the final render
  58979. * This defaults to -1
  58980. */
  58981. private debugLimit;
  58982. /**
  58983. * @hidden
  58984. * This is reserved for the inspector.
  58985. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58986. * You can use the factor to better multiply the final value.
  58987. */
  58988. private debugFactor;
  58989. /**
  58990. * Defines the clear coat layer parameters for the material.
  58991. */
  58992. readonly clearCoat: PBRClearCoatConfiguration;
  58993. /**
  58994. * Defines the anisotropic parameters for the material.
  58995. */
  58996. readonly anisotropy: PBRAnisotropicConfiguration;
  58997. /**
  58998. * Defines the BRDF parameters for the material.
  58999. */
  59000. readonly brdf: PBRBRDFConfiguration;
  59001. /**
  59002. * Defines the Sheen parameters for the material.
  59003. */
  59004. readonly sheen: PBRSheenConfiguration;
  59005. /**
  59006. * Defines the SubSurface parameters for the material.
  59007. */
  59008. readonly subSurface: PBRSubSurfaceConfiguration;
  59009. /**
  59010. * Defines the detail map parameters for the material.
  59011. */
  59012. readonly detailMap: DetailMapConfiguration;
  59013. protected _rebuildInParallel: boolean;
  59014. /**
  59015. * Instantiates a new PBRMaterial instance.
  59016. *
  59017. * @param name The material name
  59018. * @param scene The scene the material will be use in.
  59019. */
  59020. constructor(name: string, scene: Scene);
  59021. /**
  59022. * Gets a boolean indicating that current material needs to register RTT
  59023. */
  59024. get hasRenderTargetTextures(): boolean;
  59025. /**
  59026. * Gets the name of the material class.
  59027. */
  59028. getClassName(): string;
  59029. /**
  59030. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59031. */
  59032. get useLogarithmicDepth(): boolean;
  59033. /**
  59034. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59035. */
  59036. set useLogarithmicDepth(value: boolean);
  59037. /**
  59038. * Returns true if alpha blending should be disabled.
  59039. */
  59040. protected get _disableAlphaBlending(): boolean;
  59041. /**
  59042. * Specifies whether or not this material should be rendered in alpha blend mode.
  59043. */
  59044. needAlphaBlending(): boolean;
  59045. /**
  59046. * Specifies whether or not this material should be rendered in alpha test mode.
  59047. */
  59048. needAlphaTesting(): boolean;
  59049. /**
  59050. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59051. */
  59052. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59053. /**
  59054. * Gets the texture used for the alpha test.
  59055. */
  59056. getAlphaTestTexture(): Nullable<BaseTexture>;
  59057. /**
  59058. * Specifies that the submesh is ready to be used.
  59059. * @param mesh - BJS mesh.
  59060. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59061. * @param useInstances - Specifies that instances should be used.
  59062. * @returns - boolean indicating that the submesh is ready or not.
  59063. */
  59064. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59065. /**
  59066. * Specifies if the material uses metallic roughness workflow.
  59067. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59068. */
  59069. isMetallicWorkflow(): boolean;
  59070. private _prepareEffect;
  59071. private _prepareDefines;
  59072. /**
  59073. * Force shader compilation
  59074. */
  59075. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59076. /**
  59077. * Initializes the uniform buffer layout for the shader.
  59078. */
  59079. buildUniformLayout(): void;
  59080. /**
  59081. * Unbinds the material from the mesh
  59082. */
  59083. unbind(): void;
  59084. /**
  59085. * Binds the submesh data.
  59086. * @param world - The world matrix.
  59087. * @param mesh - The BJS mesh.
  59088. * @param subMesh - A submesh of the BJS mesh.
  59089. */
  59090. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59091. /**
  59092. * Returns the animatable textures.
  59093. * @returns - Array of animatable textures.
  59094. */
  59095. getAnimatables(): IAnimatable[];
  59096. /**
  59097. * Returns the texture used for reflections.
  59098. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59099. */
  59100. private _getReflectionTexture;
  59101. /**
  59102. * Returns an array of the actively used textures.
  59103. * @returns - Array of BaseTextures
  59104. */
  59105. getActiveTextures(): BaseTexture[];
  59106. /**
  59107. * Checks to see if a texture is used in the material.
  59108. * @param texture - Base texture to use.
  59109. * @returns - Boolean specifying if a texture is used in the material.
  59110. */
  59111. hasTexture(texture: BaseTexture): boolean;
  59112. /**
  59113. * Sets the required values to the prepass renderer.
  59114. * @param prePassRenderer defines the prepass renderer to setup
  59115. */
  59116. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59117. /**
  59118. * Disposes the resources of the material.
  59119. * @param forceDisposeEffect - Forces the disposal of effects.
  59120. * @param forceDisposeTextures - Forces the disposal of all textures.
  59121. */
  59122. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59123. }
  59124. }
  59125. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59126. import { Nullable } from "babylonjs/types";
  59127. import { Scene } from "babylonjs/scene";
  59128. import { Color3 } from "babylonjs/Maths/math.color";
  59129. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59130. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59132. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59133. /**
  59134. * The Physically based material of BJS.
  59135. *
  59136. * This offers the main features of a standard PBR material.
  59137. * For more information, please refer to the documentation :
  59138. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59139. */
  59140. export class PBRMaterial extends PBRBaseMaterial {
  59141. /**
  59142. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59143. */
  59144. static readonly PBRMATERIAL_OPAQUE: number;
  59145. /**
  59146. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59147. */
  59148. static readonly PBRMATERIAL_ALPHATEST: number;
  59149. /**
  59150. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59151. */
  59152. static readonly PBRMATERIAL_ALPHABLEND: number;
  59153. /**
  59154. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59155. * They are also discarded below the alpha cutoff threshold to improve performances.
  59156. */
  59157. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59158. /**
  59159. * Defines the default value of how much AO map is occluding the analytical lights
  59160. * (point spot...).
  59161. */
  59162. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59163. /**
  59164. * Intensity of the direct lights e.g. the four lights available in your scene.
  59165. * This impacts both the direct diffuse and specular highlights.
  59166. */
  59167. directIntensity: number;
  59168. /**
  59169. * Intensity of the emissive part of the material.
  59170. * This helps controlling the emissive effect without modifying the emissive color.
  59171. */
  59172. emissiveIntensity: number;
  59173. /**
  59174. * Intensity of the environment e.g. how much the environment will light the object
  59175. * either through harmonics for rough material or through the refelction for shiny ones.
  59176. */
  59177. environmentIntensity: number;
  59178. /**
  59179. * This is a special control allowing the reduction of the specular highlights coming from the
  59180. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59181. */
  59182. specularIntensity: number;
  59183. /**
  59184. * Debug Control allowing disabling the bump map on this material.
  59185. */
  59186. disableBumpMap: boolean;
  59187. /**
  59188. * AKA Diffuse Texture in standard nomenclature.
  59189. */
  59190. albedoTexture: BaseTexture;
  59191. /**
  59192. * AKA Occlusion Texture in other nomenclature.
  59193. */
  59194. ambientTexture: BaseTexture;
  59195. /**
  59196. * AKA Occlusion Texture Intensity in other nomenclature.
  59197. */
  59198. ambientTextureStrength: number;
  59199. /**
  59200. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59201. * 1 means it completely occludes it
  59202. * 0 mean it has no impact
  59203. */
  59204. ambientTextureImpactOnAnalyticalLights: number;
  59205. /**
  59206. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59207. */
  59208. opacityTexture: BaseTexture;
  59209. /**
  59210. * Stores the reflection values in a texture.
  59211. */
  59212. reflectionTexture: Nullable<BaseTexture>;
  59213. /**
  59214. * Stores the emissive values in a texture.
  59215. */
  59216. emissiveTexture: BaseTexture;
  59217. /**
  59218. * AKA Specular texture in other nomenclature.
  59219. */
  59220. reflectivityTexture: BaseTexture;
  59221. /**
  59222. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59223. */
  59224. metallicTexture: BaseTexture;
  59225. /**
  59226. * Specifies the metallic scalar of the metallic/roughness workflow.
  59227. * Can also be used to scale the metalness values of the metallic texture.
  59228. */
  59229. metallic: Nullable<number>;
  59230. /**
  59231. * Specifies the roughness scalar of the metallic/roughness workflow.
  59232. * Can also be used to scale the roughness values of the metallic texture.
  59233. */
  59234. roughness: Nullable<number>;
  59235. /**
  59236. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59237. * By default the indexOfrefraction is used to compute F0;
  59238. *
  59239. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59240. *
  59241. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59242. * F90 = metallicReflectanceColor;
  59243. */
  59244. metallicF0Factor: number;
  59245. /**
  59246. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59247. * By default the F90 is always 1;
  59248. *
  59249. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59250. *
  59251. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59252. * F90 = metallicReflectanceColor;
  59253. */
  59254. metallicReflectanceColor: Color3;
  59255. /**
  59256. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59257. * This is multiply against the scalar values defined in the material.
  59258. */
  59259. metallicReflectanceTexture: Nullable<BaseTexture>;
  59260. /**
  59261. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59262. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59263. */
  59264. microSurfaceTexture: BaseTexture;
  59265. /**
  59266. * Stores surface normal data used to displace a mesh in a texture.
  59267. */
  59268. bumpTexture: BaseTexture;
  59269. /**
  59270. * Stores the pre-calculated light information of a mesh in a texture.
  59271. */
  59272. lightmapTexture: BaseTexture;
  59273. /**
  59274. * Stores the refracted light information in a texture.
  59275. */
  59276. get refractionTexture(): Nullable<BaseTexture>;
  59277. set refractionTexture(value: Nullable<BaseTexture>);
  59278. /**
  59279. * The color of a material in ambient lighting.
  59280. */
  59281. ambientColor: Color3;
  59282. /**
  59283. * AKA Diffuse Color in other nomenclature.
  59284. */
  59285. albedoColor: Color3;
  59286. /**
  59287. * AKA Specular Color in other nomenclature.
  59288. */
  59289. reflectivityColor: Color3;
  59290. /**
  59291. * The color reflected from the material.
  59292. */
  59293. reflectionColor: Color3;
  59294. /**
  59295. * The color emitted from the material.
  59296. */
  59297. emissiveColor: Color3;
  59298. /**
  59299. * AKA Glossiness in other nomenclature.
  59300. */
  59301. microSurface: number;
  59302. /**
  59303. * Index of refraction of the material base layer.
  59304. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59305. *
  59306. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59307. *
  59308. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59309. */
  59310. get indexOfRefraction(): number;
  59311. set indexOfRefraction(value: number);
  59312. /**
  59313. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59314. */
  59315. get invertRefractionY(): boolean;
  59316. set invertRefractionY(value: boolean);
  59317. /**
  59318. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59319. * Materials half opaque for instance using refraction could benefit from this control.
  59320. */
  59321. get linkRefractionWithTransparency(): boolean;
  59322. set linkRefractionWithTransparency(value: boolean);
  59323. /**
  59324. * If true, the light map contains occlusion information instead of lighting info.
  59325. */
  59326. useLightmapAsShadowmap: boolean;
  59327. /**
  59328. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59329. */
  59330. useAlphaFromAlbedoTexture: boolean;
  59331. /**
  59332. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59333. */
  59334. forceAlphaTest: boolean;
  59335. /**
  59336. * Defines the alpha limits in alpha test mode.
  59337. */
  59338. alphaCutOff: number;
  59339. /**
  59340. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59341. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59342. */
  59343. useSpecularOverAlpha: boolean;
  59344. /**
  59345. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59346. */
  59347. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59348. /**
  59349. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59350. */
  59351. useRoughnessFromMetallicTextureAlpha: boolean;
  59352. /**
  59353. * Specifies if the metallic texture contains the roughness information in its green channel.
  59354. */
  59355. useRoughnessFromMetallicTextureGreen: boolean;
  59356. /**
  59357. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59358. */
  59359. useMetallnessFromMetallicTextureBlue: boolean;
  59360. /**
  59361. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59362. */
  59363. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59364. /**
  59365. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59366. */
  59367. useAmbientInGrayScale: boolean;
  59368. /**
  59369. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59370. * The material will try to infer what glossiness each pixel should be.
  59371. */
  59372. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59373. /**
  59374. * BJS is using an harcoded light falloff based on a manually sets up range.
  59375. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59376. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59377. */
  59378. get usePhysicalLightFalloff(): boolean;
  59379. /**
  59380. * BJS is using an harcoded light falloff based on a manually sets up range.
  59381. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59382. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59383. */
  59384. set usePhysicalLightFalloff(value: boolean);
  59385. /**
  59386. * In order to support the falloff compatibility with gltf, a special mode has been added
  59387. * to reproduce the gltf light falloff.
  59388. */
  59389. get useGLTFLightFalloff(): boolean;
  59390. /**
  59391. * In order to support the falloff compatibility with gltf, a special mode has been added
  59392. * to reproduce the gltf light falloff.
  59393. */
  59394. set useGLTFLightFalloff(value: boolean);
  59395. /**
  59396. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59397. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59398. */
  59399. useRadianceOverAlpha: boolean;
  59400. /**
  59401. * Allows using an object space normal map (instead of tangent space).
  59402. */
  59403. useObjectSpaceNormalMap: boolean;
  59404. /**
  59405. * Allows using the bump map in parallax mode.
  59406. */
  59407. useParallax: boolean;
  59408. /**
  59409. * Allows using the bump map in parallax occlusion mode.
  59410. */
  59411. useParallaxOcclusion: boolean;
  59412. /**
  59413. * Controls the scale bias of the parallax mode.
  59414. */
  59415. parallaxScaleBias: number;
  59416. /**
  59417. * If sets to true, disables all the lights affecting the material.
  59418. */
  59419. disableLighting: boolean;
  59420. /**
  59421. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59422. */
  59423. forceIrradianceInFragment: boolean;
  59424. /**
  59425. * Number of Simultaneous lights allowed on the material.
  59426. */
  59427. maxSimultaneousLights: number;
  59428. /**
  59429. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59430. */
  59431. invertNormalMapX: boolean;
  59432. /**
  59433. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59434. */
  59435. invertNormalMapY: boolean;
  59436. /**
  59437. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59438. */
  59439. twoSidedLighting: boolean;
  59440. /**
  59441. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59442. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59443. */
  59444. useAlphaFresnel: boolean;
  59445. /**
  59446. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59447. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59448. */
  59449. useLinearAlphaFresnel: boolean;
  59450. /**
  59451. * Let user defines the brdf lookup texture used for IBL.
  59452. * A default 8bit version is embedded but you could point at :
  59453. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59454. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59455. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59456. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59457. */
  59458. environmentBRDFTexture: Nullable<BaseTexture>;
  59459. /**
  59460. * Force normal to face away from face.
  59461. */
  59462. forceNormalForward: boolean;
  59463. /**
  59464. * Enables specular anti aliasing in the PBR shader.
  59465. * It will both interacts on the Geometry for analytical and IBL lighting.
  59466. * It also prefilter the roughness map based on the bump values.
  59467. */
  59468. enableSpecularAntiAliasing: boolean;
  59469. /**
  59470. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59471. * makes the reflect vector face the model (under horizon).
  59472. */
  59473. useHorizonOcclusion: boolean;
  59474. /**
  59475. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59476. * too much the area relying on ambient texture to define their ambient occlusion.
  59477. */
  59478. useRadianceOcclusion: boolean;
  59479. /**
  59480. * If set to true, no lighting calculations will be applied.
  59481. */
  59482. unlit: boolean;
  59483. /**
  59484. * Gets the image processing configuration used either in this material.
  59485. */
  59486. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59487. /**
  59488. * Sets the Default image processing configuration used either in the this material.
  59489. *
  59490. * If sets to null, the scene one is in use.
  59491. */
  59492. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59493. /**
  59494. * Gets wether the color curves effect is enabled.
  59495. */
  59496. get cameraColorCurvesEnabled(): boolean;
  59497. /**
  59498. * Sets wether the color curves effect is enabled.
  59499. */
  59500. set cameraColorCurvesEnabled(value: boolean);
  59501. /**
  59502. * Gets wether the color grading effect is enabled.
  59503. */
  59504. get cameraColorGradingEnabled(): boolean;
  59505. /**
  59506. * Gets wether the color grading effect is enabled.
  59507. */
  59508. set cameraColorGradingEnabled(value: boolean);
  59509. /**
  59510. * Gets wether tonemapping is enabled or not.
  59511. */
  59512. get cameraToneMappingEnabled(): boolean;
  59513. /**
  59514. * Sets wether tonemapping is enabled or not
  59515. */
  59516. set cameraToneMappingEnabled(value: boolean);
  59517. /**
  59518. * The camera exposure used on this material.
  59519. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59520. * This corresponds to a photographic exposure.
  59521. */
  59522. get cameraExposure(): number;
  59523. /**
  59524. * The camera exposure used on this material.
  59525. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59526. * This corresponds to a photographic exposure.
  59527. */
  59528. set cameraExposure(value: number);
  59529. /**
  59530. * Gets The camera contrast used on this material.
  59531. */
  59532. get cameraContrast(): number;
  59533. /**
  59534. * Sets The camera contrast used on this material.
  59535. */
  59536. set cameraContrast(value: number);
  59537. /**
  59538. * Gets the Color Grading 2D Lookup Texture.
  59539. */
  59540. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59541. /**
  59542. * Sets the Color Grading 2D Lookup Texture.
  59543. */
  59544. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  59545. /**
  59546. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59547. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59548. * 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;
  59549. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59550. */
  59551. get cameraColorCurves(): Nullable<ColorCurves>;
  59552. /**
  59553. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59554. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59555. * 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;
  59556. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59557. */
  59558. set cameraColorCurves(value: Nullable<ColorCurves>);
  59559. /**
  59560. * Instantiates a new PBRMaterial instance.
  59561. *
  59562. * @param name The material name
  59563. * @param scene The scene the material will be use in.
  59564. */
  59565. constructor(name: string, scene: Scene);
  59566. /**
  59567. * Returns the name of this material class.
  59568. */
  59569. getClassName(): string;
  59570. /**
  59571. * Makes a duplicate of the current material.
  59572. * @param name - name to use for the new material.
  59573. */
  59574. clone(name: string): PBRMaterial;
  59575. /**
  59576. * Serializes this PBR Material.
  59577. * @returns - An object with the serialized material.
  59578. */
  59579. serialize(): any;
  59580. /**
  59581. * Parses a PBR Material from a serialized object.
  59582. * @param source - Serialized object.
  59583. * @param scene - BJS scene instance.
  59584. * @param rootUrl - url for the scene object
  59585. * @returns - PBRMaterial
  59586. */
  59587. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  59588. }
  59589. }
  59590. declare module "babylonjs/Misc/dds" {
  59591. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59592. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59593. import { Nullable } from "babylonjs/types";
  59594. import { Scene } from "babylonjs/scene";
  59595. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  59596. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59597. /**
  59598. * Direct draw surface info
  59599. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59600. */
  59601. export interface DDSInfo {
  59602. /**
  59603. * Width of the texture
  59604. */
  59605. width: number;
  59606. /**
  59607. * Width of the texture
  59608. */
  59609. height: number;
  59610. /**
  59611. * Number of Mipmaps for the texture
  59612. * @see https://en.wikipedia.org/wiki/Mipmap
  59613. */
  59614. mipmapCount: number;
  59615. /**
  59616. * If the textures format is a known fourCC format
  59617. * @see https://www.fourcc.org/
  59618. */
  59619. isFourCC: boolean;
  59620. /**
  59621. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59622. */
  59623. isRGB: boolean;
  59624. /**
  59625. * If the texture is a lumincance format
  59626. */
  59627. isLuminance: boolean;
  59628. /**
  59629. * If this is a cube texture
  59630. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59631. */
  59632. isCube: boolean;
  59633. /**
  59634. * If the texture is a compressed format eg. FOURCC_DXT1
  59635. */
  59636. isCompressed: boolean;
  59637. /**
  59638. * The dxgiFormat of the texture
  59639. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59640. */
  59641. dxgiFormat: number;
  59642. /**
  59643. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59644. */
  59645. textureType: number;
  59646. /**
  59647. * Sphericle polynomial created for the dds texture
  59648. */
  59649. sphericalPolynomial?: SphericalPolynomial;
  59650. }
  59651. /**
  59652. * Class used to provide DDS decompression tools
  59653. */
  59654. export class DDSTools {
  59655. /**
  59656. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59657. */
  59658. static StoreLODInAlphaChannel: boolean;
  59659. /**
  59660. * Gets DDS information from an array buffer
  59661. * @param data defines the array buffer view to read data from
  59662. * @returns the DDS information
  59663. */
  59664. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59665. private static _FloatView;
  59666. private static _Int32View;
  59667. private static _ToHalfFloat;
  59668. private static _FromHalfFloat;
  59669. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59670. private static _GetHalfFloatRGBAArrayBuffer;
  59671. private static _GetFloatRGBAArrayBuffer;
  59672. private static _GetFloatAsUIntRGBAArrayBuffer;
  59673. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59674. private static _GetRGBAArrayBuffer;
  59675. private static _ExtractLongWordOrder;
  59676. private static _GetRGBArrayBuffer;
  59677. private static _GetLuminanceArrayBuffer;
  59678. /**
  59679. * Uploads DDS Levels to a Babylon Texture
  59680. * @hidden
  59681. */
  59682. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59683. }
  59684. module "babylonjs/Engines/thinEngine" {
  59685. interface ThinEngine {
  59686. /**
  59687. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59688. * @param rootUrl defines the url where the file to load is located
  59689. * @param scene defines the current scene
  59690. * @param lodScale defines scale to apply to the mip map selection
  59691. * @param lodOffset defines offset to apply to the mip map selection
  59692. * @param onLoad defines an optional callback raised when the texture is loaded
  59693. * @param onError defines an optional callback raised if there is an issue to load the texture
  59694. * @param format defines the format of the data
  59695. * @param forcedExtension defines the extension to use to pick the right loader
  59696. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59697. * @returns the cube texture as an InternalTexture
  59698. */
  59699. 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;
  59700. }
  59701. }
  59702. }
  59703. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  59704. import { Nullable } from "babylonjs/types";
  59705. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59706. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59707. /**
  59708. * Implementation of the DDS Texture Loader.
  59709. * @hidden
  59710. */
  59711. export class _DDSTextureLoader implements IInternalTextureLoader {
  59712. /**
  59713. * Defines wether the loader supports cascade loading the different faces.
  59714. */
  59715. readonly supportCascades: boolean;
  59716. /**
  59717. * This returns if the loader support the current file information.
  59718. * @param extension defines the file extension of the file being loaded
  59719. * @returns true if the loader can load the specified file
  59720. */
  59721. canLoad(extension: string): boolean;
  59722. /**
  59723. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59724. * @param data contains the texture data
  59725. * @param texture defines the BabylonJS internal texture
  59726. * @param createPolynomials will be true if polynomials have been requested
  59727. * @param onLoad defines the callback to trigger once the texture is ready
  59728. * @param onError defines the callback to trigger in case of error
  59729. */
  59730. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59731. /**
  59732. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59733. * @param data contains the texture data
  59734. * @param texture defines the BabylonJS internal texture
  59735. * @param callback defines the method to call once ready to upload
  59736. */
  59737. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59738. }
  59739. }
  59740. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  59741. import { Nullable } from "babylonjs/types";
  59742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59743. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59744. /**
  59745. * Implementation of the ENV Texture Loader.
  59746. * @hidden
  59747. */
  59748. export class _ENVTextureLoader implements IInternalTextureLoader {
  59749. /**
  59750. * Defines wether the loader supports cascade loading the different faces.
  59751. */
  59752. readonly supportCascades: boolean;
  59753. /**
  59754. * This returns if the loader support the current file information.
  59755. * @param extension defines the file extension of the file being loaded
  59756. * @returns true if the loader can load the specified file
  59757. */
  59758. canLoad(extension: string): boolean;
  59759. /**
  59760. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59761. * @param data contains the texture data
  59762. * @param texture defines the BabylonJS internal texture
  59763. * @param createPolynomials will be true if polynomials have been requested
  59764. * @param onLoad defines the callback to trigger once the texture is ready
  59765. * @param onError defines the callback to trigger in case of error
  59766. */
  59767. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59768. /**
  59769. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59770. * @param data contains the texture data
  59771. * @param texture defines the BabylonJS internal texture
  59772. * @param callback defines the method to call once ready to upload
  59773. */
  59774. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59775. }
  59776. }
  59777. declare module "babylonjs/Misc/khronosTextureContainer" {
  59778. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59779. /**
  59780. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59781. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59782. */
  59783. export class KhronosTextureContainer {
  59784. /** contents of the KTX container file */
  59785. data: ArrayBufferView;
  59786. private static HEADER_LEN;
  59787. private static COMPRESSED_2D;
  59788. private static COMPRESSED_3D;
  59789. private static TEX_2D;
  59790. private static TEX_3D;
  59791. /**
  59792. * Gets the openGL type
  59793. */
  59794. glType: number;
  59795. /**
  59796. * Gets the openGL type size
  59797. */
  59798. glTypeSize: number;
  59799. /**
  59800. * Gets the openGL format
  59801. */
  59802. glFormat: number;
  59803. /**
  59804. * Gets the openGL internal format
  59805. */
  59806. glInternalFormat: number;
  59807. /**
  59808. * Gets the base internal format
  59809. */
  59810. glBaseInternalFormat: number;
  59811. /**
  59812. * Gets image width in pixel
  59813. */
  59814. pixelWidth: number;
  59815. /**
  59816. * Gets image height in pixel
  59817. */
  59818. pixelHeight: number;
  59819. /**
  59820. * Gets image depth in pixels
  59821. */
  59822. pixelDepth: number;
  59823. /**
  59824. * Gets the number of array elements
  59825. */
  59826. numberOfArrayElements: number;
  59827. /**
  59828. * Gets the number of faces
  59829. */
  59830. numberOfFaces: number;
  59831. /**
  59832. * Gets the number of mipmap levels
  59833. */
  59834. numberOfMipmapLevels: number;
  59835. /**
  59836. * Gets the bytes of key value data
  59837. */
  59838. bytesOfKeyValueData: number;
  59839. /**
  59840. * Gets the load type
  59841. */
  59842. loadType: number;
  59843. /**
  59844. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59845. */
  59846. isInvalid: boolean;
  59847. /**
  59848. * Creates a new KhronosTextureContainer
  59849. * @param data contents of the KTX container file
  59850. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59851. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59852. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59853. */
  59854. constructor(
  59855. /** contents of the KTX container file */
  59856. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59857. /**
  59858. * Uploads KTX content to a Babylon Texture.
  59859. * It is assumed that the texture has already been created & is currently bound
  59860. * @hidden
  59861. */
  59862. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59863. private _upload2DCompressedLevels;
  59864. /**
  59865. * Checks if the given data starts with a KTX file identifier.
  59866. * @param data the data to check
  59867. * @returns true if the data is a KTX file or false otherwise
  59868. */
  59869. static IsValid(data: ArrayBufferView): boolean;
  59870. }
  59871. }
  59872. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59873. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59874. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59875. /**
  59876. * Class for loading KTX2 files
  59877. * !!! Experimental Extension Subject to Changes !!!
  59878. * @hidden
  59879. */
  59880. export class KhronosTextureContainer2 {
  59881. private static _ModulePromise;
  59882. private static _TranscodeFormat;
  59883. constructor(engine: ThinEngine);
  59884. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59885. private _determineTranscodeFormat;
  59886. /**
  59887. * Checks if the given data starts with a KTX2 file identifier.
  59888. * @param data the data to check
  59889. * @returns true if the data is a KTX2 file or false otherwise
  59890. */
  59891. static IsValid(data: ArrayBufferView): boolean;
  59892. }
  59893. }
  59894. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59895. import { Nullable } from "babylonjs/types";
  59896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59897. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59898. /**
  59899. * Implementation of the KTX Texture Loader.
  59900. * @hidden
  59901. */
  59902. export class _KTXTextureLoader implements IInternalTextureLoader {
  59903. /**
  59904. * Defines wether the loader supports cascade loading the different faces.
  59905. */
  59906. readonly supportCascades: boolean;
  59907. /**
  59908. * This returns if the loader support the current file information.
  59909. * @param extension defines the file extension of the file being loaded
  59910. * @param mimeType defines the optional mime type of the file being loaded
  59911. * @returns true if the loader can load the specified file
  59912. */
  59913. canLoad(extension: string, mimeType?: string): boolean;
  59914. /**
  59915. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59916. * @param data contains the texture data
  59917. * @param texture defines the BabylonJS internal texture
  59918. * @param createPolynomials will be true if polynomials have been requested
  59919. * @param onLoad defines the callback to trigger once the texture is ready
  59920. * @param onError defines the callback to trigger in case of error
  59921. */
  59922. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59923. /**
  59924. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59925. * @param data contains the texture data
  59926. * @param texture defines the BabylonJS internal texture
  59927. * @param callback defines the method to call once ready to upload
  59928. */
  59929. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59930. }
  59931. }
  59932. declare module "babylonjs/Helpers/sceneHelpers" {
  59933. import { Nullable } from "babylonjs/types";
  59934. import { Mesh } from "babylonjs/Meshes/mesh";
  59935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59936. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59937. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59938. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59939. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59940. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59941. import "babylonjs/Meshes/Builders/boxBuilder";
  59942. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59943. /** @hidden */
  59944. export var _forceSceneHelpersToBundle: boolean;
  59945. module "babylonjs/scene" {
  59946. interface Scene {
  59947. /**
  59948. * Creates a default light for the scene.
  59949. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59950. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59951. */
  59952. createDefaultLight(replace?: boolean): void;
  59953. /**
  59954. * Creates a default camera for the scene.
  59955. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59956. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59957. * @param replace has default false, when true replaces the active camera in the scene
  59958. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59959. */
  59960. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59961. /**
  59962. * Creates a default camera and a default light.
  59963. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59964. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59965. * @param replace has the default false, when true replaces the active camera/light in the scene
  59966. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59967. */
  59968. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59969. /**
  59970. * Creates a new sky box
  59971. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59972. * @param environmentTexture defines the texture to use as environment texture
  59973. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59974. * @param scale defines the overall scale of the skybox
  59975. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59976. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59977. * @returns a new mesh holding the sky box
  59978. */
  59979. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59980. /**
  59981. * Creates a new environment
  59982. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59983. * @param options defines the options you can use to configure the environment
  59984. * @returns the new EnvironmentHelper
  59985. */
  59986. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59987. /**
  59988. * Creates a new VREXperienceHelper
  59989. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59990. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59991. * @returns a new VREXperienceHelper
  59992. */
  59993. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59994. /**
  59995. * Creates a new WebXRDefaultExperience
  59996. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59997. * @param options experience options
  59998. * @returns a promise for a new WebXRDefaultExperience
  59999. */
  60000. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60001. }
  60002. }
  60003. }
  60004. declare module "babylonjs/Helpers/videoDome" {
  60005. import { Scene } from "babylonjs/scene";
  60006. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60007. import { Mesh } from "babylonjs/Meshes/mesh";
  60008. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60009. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60010. import "babylonjs/Meshes/Builders/sphereBuilder";
  60011. /**
  60012. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60013. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60014. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60015. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60016. */
  60017. export class VideoDome extends TransformNode {
  60018. /**
  60019. * Define the video source as a Monoscopic panoramic 360 video.
  60020. */
  60021. static readonly MODE_MONOSCOPIC: number;
  60022. /**
  60023. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60024. */
  60025. static readonly MODE_TOPBOTTOM: number;
  60026. /**
  60027. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60028. */
  60029. static readonly MODE_SIDEBYSIDE: number;
  60030. private _halfDome;
  60031. private _useDirectMapping;
  60032. /**
  60033. * The video texture being displayed on the sphere
  60034. */
  60035. protected _videoTexture: VideoTexture;
  60036. /**
  60037. * Gets the video texture being displayed on the sphere
  60038. */
  60039. get videoTexture(): VideoTexture;
  60040. /**
  60041. * The skybox material
  60042. */
  60043. protected _material: BackgroundMaterial;
  60044. /**
  60045. * The surface used for the video dome
  60046. */
  60047. protected _mesh: Mesh;
  60048. /**
  60049. * Gets the mesh used for the video dome.
  60050. */
  60051. get mesh(): Mesh;
  60052. /**
  60053. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  60054. */
  60055. private _halfDomeMask;
  60056. /**
  60057. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60058. * Also see the options.resolution property.
  60059. */
  60060. get fovMultiplier(): number;
  60061. set fovMultiplier(value: number);
  60062. private _videoMode;
  60063. /**
  60064. * Gets or set the current video mode for the video. It can be:
  60065. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  60066. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60067. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60068. */
  60069. get videoMode(): number;
  60070. set videoMode(value: number);
  60071. /**
  60072. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  60073. *
  60074. */
  60075. get halfDome(): boolean;
  60076. /**
  60077. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  60078. */
  60079. set halfDome(enabled: boolean);
  60080. /**
  60081. * Oberserver used in Stereoscopic VR Mode.
  60082. */
  60083. private _onBeforeCameraRenderObserver;
  60084. /**
  60085. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  60086. * @param name Element's name, child elements will append suffixes for their own names.
  60087. * @param urlsOrVideo defines the url(s) or the video element to use
  60088. * @param options An object containing optional or exposed sub element properties
  60089. */
  60090. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  60091. resolution?: number;
  60092. clickToPlay?: boolean;
  60093. autoPlay?: boolean;
  60094. loop?: boolean;
  60095. size?: number;
  60096. poster?: string;
  60097. faceForward?: boolean;
  60098. useDirectMapping?: boolean;
  60099. halfDomeMode?: boolean;
  60100. }, scene: Scene);
  60101. private _changeVideoMode;
  60102. /**
  60103. * Releases resources associated with this node.
  60104. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  60105. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  60106. */
  60107. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  60108. }
  60109. }
  60110. declare module "babylonjs/Helpers/index" {
  60111. export * from "babylonjs/Helpers/environmentHelper";
  60112. export * from "babylonjs/Helpers/photoDome";
  60113. export * from "babylonjs/Helpers/sceneHelpers";
  60114. export * from "babylonjs/Helpers/videoDome";
  60115. }
  60116. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60117. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60118. import { IDisposable } from "babylonjs/scene";
  60119. import { Engine } from "babylonjs/Engines/engine";
  60120. /**
  60121. * This class can be used to get instrumentation data from a Babylon engine
  60122. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60123. */
  60124. export class EngineInstrumentation implements IDisposable {
  60125. /**
  60126. * Define the instrumented engine.
  60127. */
  60128. engine: Engine;
  60129. private _captureGPUFrameTime;
  60130. private _gpuFrameTimeToken;
  60131. private _gpuFrameTime;
  60132. private _captureShaderCompilationTime;
  60133. private _shaderCompilationTime;
  60134. private _onBeginFrameObserver;
  60135. private _onEndFrameObserver;
  60136. private _onBeforeShaderCompilationObserver;
  60137. private _onAfterShaderCompilationObserver;
  60138. /**
  60139. * Gets the perf counter used for GPU frame time
  60140. */
  60141. get gpuFrameTimeCounter(): PerfCounter;
  60142. /**
  60143. * Gets the GPU frame time capture status
  60144. */
  60145. get captureGPUFrameTime(): boolean;
  60146. /**
  60147. * Enable or disable the GPU frame time capture
  60148. */
  60149. set captureGPUFrameTime(value: boolean);
  60150. /**
  60151. * Gets the perf counter used for shader compilation time
  60152. */
  60153. get shaderCompilationTimeCounter(): PerfCounter;
  60154. /**
  60155. * Gets the shader compilation time capture status
  60156. */
  60157. get captureShaderCompilationTime(): boolean;
  60158. /**
  60159. * Enable or disable the shader compilation time capture
  60160. */
  60161. set captureShaderCompilationTime(value: boolean);
  60162. /**
  60163. * Instantiates a new engine instrumentation.
  60164. * This class can be used to get instrumentation data from a Babylon engine
  60165. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60166. * @param engine Defines the engine to instrument
  60167. */
  60168. constructor(
  60169. /**
  60170. * Define the instrumented engine.
  60171. */
  60172. engine: Engine);
  60173. /**
  60174. * Dispose and release associated resources.
  60175. */
  60176. dispose(): void;
  60177. }
  60178. }
  60179. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60180. import { Scene, IDisposable } from "babylonjs/scene";
  60181. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60182. /**
  60183. * This class can be used to get instrumentation data from a Babylon engine
  60184. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60185. */
  60186. export class SceneInstrumentation implements IDisposable {
  60187. /**
  60188. * Defines the scene to instrument
  60189. */
  60190. scene: Scene;
  60191. private _captureActiveMeshesEvaluationTime;
  60192. private _activeMeshesEvaluationTime;
  60193. private _captureRenderTargetsRenderTime;
  60194. private _renderTargetsRenderTime;
  60195. private _captureFrameTime;
  60196. private _frameTime;
  60197. private _captureRenderTime;
  60198. private _renderTime;
  60199. private _captureInterFrameTime;
  60200. private _interFrameTime;
  60201. private _captureParticlesRenderTime;
  60202. private _particlesRenderTime;
  60203. private _captureSpritesRenderTime;
  60204. private _spritesRenderTime;
  60205. private _capturePhysicsTime;
  60206. private _physicsTime;
  60207. private _captureAnimationsTime;
  60208. private _animationsTime;
  60209. private _captureCameraRenderTime;
  60210. private _cameraRenderTime;
  60211. private _onBeforeActiveMeshesEvaluationObserver;
  60212. private _onAfterActiveMeshesEvaluationObserver;
  60213. private _onBeforeRenderTargetsRenderObserver;
  60214. private _onAfterRenderTargetsRenderObserver;
  60215. private _onAfterRenderObserver;
  60216. private _onBeforeDrawPhaseObserver;
  60217. private _onAfterDrawPhaseObserver;
  60218. private _onBeforeAnimationsObserver;
  60219. private _onBeforeParticlesRenderingObserver;
  60220. private _onAfterParticlesRenderingObserver;
  60221. private _onBeforeSpritesRenderingObserver;
  60222. private _onAfterSpritesRenderingObserver;
  60223. private _onBeforePhysicsObserver;
  60224. private _onAfterPhysicsObserver;
  60225. private _onAfterAnimationsObserver;
  60226. private _onBeforeCameraRenderObserver;
  60227. private _onAfterCameraRenderObserver;
  60228. /**
  60229. * Gets the perf counter used for active meshes evaluation time
  60230. */
  60231. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60232. /**
  60233. * Gets the active meshes evaluation time capture status
  60234. */
  60235. get captureActiveMeshesEvaluationTime(): boolean;
  60236. /**
  60237. * Enable or disable the active meshes evaluation time capture
  60238. */
  60239. set captureActiveMeshesEvaluationTime(value: boolean);
  60240. /**
  60241. * Gets the perf counter used for render targets render time
  60242. */
  60243. get renderTargetsRenderTimeCounter(): PerfCounter;
  60244. /**
  60245. * Gets the render targets render time capture status
  60246. */
  60247. get captureRenderTargetsRenderTime(): boolean;
  60248. /**
  60249. * Enable or disable the render targets render time capture
  60250. */
  60251. set captureRenderTargetsRenderTime(value: boolean);
  60252. /**
  60253. * Gets the perf counter used for particles render time
  60254. */
  60255. get particlesRenderTimeCounter(): PerfCounter;
  60256. /**
  60257. * Gets the particles render time capture status
  60258. */
  60259. get captureParticlesRenderTime(): boolean;
  60260. /**
  60261. * Enable or disable the particles render time capture
  60262. */
  60263. set captureParticlesRenderTime(value: boolean);
  60264. /**
  60265. * Gets the perf counter used for sprites render time
  60266. */
  60267. get spritesRenderTimeCounter(): PerfCounter;
  60268. /**
  60269. * Gets the sprites render time capture status
  60270. */
  60271. get captureSpritesRenderTime(): boolean;
  60272. /**
  60273. * Enable or disable the sprites render time capture
  60274. */
  60275. set captureSpritesRenderTime(value: boolean);
  60276. /**
  60277. * Gets the perf counter used for physics time
  60278. */
  60279. get physicsTimeCounter(): PerfCounter;
  60280. /**
  60281. * Gets the physics time capture status
  60282. */
  60283. get capturePhysicsTime(): boolean;
  60284. /**
  60285. * Enable or disable the physics time capture
  60286. */
  60287. set capturePhysicsTime(value: boolean);
  60288. /**
  60289. * Gets the perf counter used for animations time
  60290. */
  60291. get animationsTimeCounter(): PerfCounter;
  60292. /**
  60293. * Gets the animations time capture status
  60294. */
  60295. get captureAnimationsTime(): boolean;
  60296. /**
  60297. * Enable or disable the animations time capture
  60298. */
  60299. set captureAnimationsTime(value: boolean);
  60300. /**
  60301. * Gets the perf counter used for frame time capture
  60302. */
  60303. get frameTimeCounter(): PerfCounter;
  60304. /**
  60305. * Gets the frame time capture status
  60306. */
  60307. get captureFrameTime(): boolean;
  60308. /**
  60309. * Enable or disable the frame time capture
  60310. */
  60311. set captureFrameTime(value: boolean);
  60312. /**
  60313. * Gets the perf counter used for inter-frames time capture
  60314. */
  60315. get interFrameTimeCounter(): PerfCounter;
  60316. /**
  60317. * Gets the inter-frames time capture status
  60318. */
  60319. get captureInterFrameTime(): boolean;
  60320. /**
  60321. * Enable or disable the inter-frames time capture
  60322. */
  60323. set captureInterFrameTime(value: boolean);
  60324. /**
  60325. * Gets the perf counter used for render time capture
  60326. */
  60327. get renderTimeCounter(): PerfCounter;
  60328. /**
  60329. * Gets the render time capture status
  60330. */
  60331. get captureRenderTime(): boolean;
  60332. /**
  60333. * Enable or disable the render time capture
  60334. */
  60335. set captureRenderTime(value: boolean);
  60336. /**
  60337. * Gets the perf counter used for camera render time capture
  60338. */
  60339. get cameraRenderTimeCounter(): PerfCounter;
  60340. /**
  60341. * Gets the camera render time capture status
  60342. */
  60343. get captureCameraRenderTime(): boolean;
  60344. /**
  60345. * Enable or disable the camera render time capture
  60346. */
  60347. set captureCameraRenderTime(value: boolean);
  60348. /**
  60349. * Gets the perf counter used for draw calls
  60350. */
  60351. get drawCallsCounter(): PerfCounter;
  60352. /**
  60353. * Instantiates a new scene instrumentation.
  60354. * This class can be used to get instrumentation data from a Babylon engine
  60355. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60356. * @param scene Defines the scene to instrument
  60357. */
  60358. constructor(
  60359. /**
  60360. * Defines the scene to instrument
  60361. */
  60362. scene: Scene);
  60363. /**
  60364. * Dispose and release associated resources.
  60365. */
  60366. dispose(): void;
  60367. }
  60368. }
  60369. declare module "babylonjs/Instrumentation/index" {
  60370. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60371. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60372. export * from "babylonjs/Instrumentation/timeToken";
  60373. }
  60374. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60375. /** @hidden */
  60376. export var glowMapGenerationPixelShader: {
  60377. name: string;
  60378. shader: string;
  60379. };
  60380. }
  60381. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60382. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60383. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60384. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60385. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60386. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60387. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60388. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60389. /** @hidden */
  60390. export var glowMapGenerationVertexShader: {
  60391. name: string;
  60392. shader: string;
  60393. };
  60394. }
  60395. declare module "babylonjs/Layers/effectLayer" {
  60396. import { Observable } from "babylonjs/Misc/observable";
  60397. import { Nullable } from "babylonjs/types";
  60398. import { Camera } from "babylonjs/Cameras/camera";
  60399. import { Scene } from "babylonjs/scene";
  60400. import { ISize } from "babylonjs/Maths/math.size";
  60401. import { Color4 } from "babylonjs/Maths/math.color";
  60402. import { Engine } from "babylonjs/Engines/engine";
  60403. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60405. import { Mesh } from "babylonjs/Meshes/mesh";
  60406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60408. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60409. import { Effect } from "babylonjs/Materials/effect";
  60410. import { Material } from "babylonjs/Materials/material";
  60411. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60412. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60413. /**
  60414. * Effect layer options. This helps customizing the behaviour
  60415. * of the effect layer.
  60416. */
  60417. export interface IEffectLayerOptions {
  60418. /**
  60419. * Multiplication factor apply to the canvas size to compute the render target size
  60420. * used to generated the objects (the smaller the faster).
  60421. */
  60422. mainTextureRatio: number;
  60423. /**
  60424. * Enforces a fixed size texture to ensure effect stability across devices.
  60425. */
  60426. mainTextureFixedSize?: number;
  60427. /**
  60428. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60429. */
  60430. alphaBlendingMode: number;
  60431. /**
  60432. * The camera attached to the layer.
  60433. */
  60434. camera: Nullable<Camera>;
  60435. /**
  60436. * The rendering group to draw the layer in.
  60437. */
  60438. renderingGroupId: number;
  60439. }
  60440. /**
  60441. * The effect layer Helps adding post process effect blended with the main pass.
  60442. *
  60443. * This can be for instance use to generate glow or higlight effects on the scene.
  60444. *
  60445. * The effect layer class can not be used directly and is intented to inherited from to be
  60446. * customized per effects.
  60447. */
  60448. export abstract class EffectLayer {
  60449. private _vertexBuffers;
  60450. private _indexBuffer;
  60451. private _cachedDefines;
  60452. private _effectLayerMapGenerationEffect;
  60453. private _effectLayerOptions;
  60454. private _mergeEffect;
  60455. protected _scene: Scene;
  60456. protected _engine: Engine;
  60457. protected _maxSize: number;
  60458. protected _mainTextureDesiredSize: ISize;
  60459. protected _mainTexture: RenderTargetTexture;
  60460. protected _shouldRender: boolean;
  60461. protected _postProcesses: PostProcess[];
  60462. protected _textures: BaseTexture[];
  60463. protected _emissiveTextureAndColor: {
  60464. texture: Nullable<BaseTexture>;
  60465. color: Color4;
  60466. };
  60467. /**
  60468. * The name of the layer
  60469. */
  60470. name: string;
  60471. /**
  60472. * The clear color of the texture used to generate the glow map.
  60473. */
  60474. neutralColor: Color4;
  60475. /**
  60476. * Specifies whether the highlight layer is enabled or not.
  60477. */
  60478. isEnabled: boolean;
  60479. /**
  60480. * Gets the camera attached to the layer.
  60481. */
  60482. get camera(): Nullable<Camera>;
  60483. /**
  60484. * Gets the rendering group id the layer should render in.
  60485. */
  60486. get renderingGroupId(): number;
  60487. set renderingGroupId(renderingGroupId: number);
  60488. /**
  60489. * An event triggered when the effect layer has been disposed.
  60490. */
  60491. onDisposeObservable: Observable<EffectLayer>;
  60492. /**
  60493. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60494. */
  60495. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60496. /**
  60497. * An event triggered when the generated texture is being merged in the scene.
  60498. */
  60499. onBeforeComposeObservable: Observable<EffectLayer>;
  60500. /**
  60501. * An event triggered when the mesh is rendered into the effect render target.
  60502. */
  60503. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60504. /**
  60505. * An event triggered after the mesh has been rendered into the effect render target.
  60506. */
  60507. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60508. /**
  60509. * An event triggered when the generated texture has been merged in the scene.
  60510. */
  60511. onAfterComposeObservable: Observable<EffectLayer>;
  60512. /**
  60513. * An event triggered when the efffect layer changes its size.
  60514. */
  60515. onSizeChangedObservable: Observable<EffectLayer>;
  60516. /** @hidden */
  60517. static _SceneComponentInitialization: (scene: Scene) => void;
  60518. /**
  60519. * Instantiates a new effect Layer and references it in the scene.
  60520. * @param name The name of the layer
  60521. * @param scene The scene to use the layer in
  60522. */
  60523. constructor(
  60524. /** The Friendly of the effect in the scene */
  60525. name: string, scene: Scene);
  60526. /**
  60527. * Get the effect name of the layer.
  60528. * @return The effect name
  60529. */
  60530. abstract getEffectName(): string;
  60531. /**
  60532. * Checks for the readiness of the element composing the layer.
  60533. * @param subMesh the mesh to check for
  60534. * @param useInstances specify whether or not to use instances to render the mesh
  60535. * @return true if ready otherwise, false
  60536. */
  60537. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60538. /**
  60539. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60540. * @returns true if the effect requires stencil during the main canvas render pass.
  60541. */
  60542. abstract needStencil(): boolean;
  60543. /**
  60544. * Create the merge effect. This is the shader use to blit the information back
  60545. * to the main canvas at the end of the scene rendering.
  60546. * @returns The effect containing the shader used to merge the effect on the main canvas
  60547. */
  60548. protected abstract _createMergeEffect(): Effect;
  60549. /**
  60550. * Creates the render target textures and post processes used in the effect layer.
  60551. */
  60552. protected abstract _createTextureAndPostProcesses(): void;
  60553. /**
  60554. * Implementation specific of rendering the generating effect on the main canvas.
  60555. * @param effect The effect used to render through
  60556. */
  60557. protected abstract _internalRender(effect: Effect): void;
  60558. /**
  60559. * Sets the required values for both the emissive texture and and the main color.
  60560. */
  60561. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60562. /**
  60563. * Free any resources and references associated to a mesh.
  60564. * Internal use
  60565. * @param mesh The mesh to free.
  60566. */
  60567. abstract _disposeMesh(mesh: Mesh): void;
  60568. /**
  60569. * Serializes this layer (Glow or Highlight for example)
  60570. * @returns a serialized layer object
  60571. */
  60572. abstract serialize?(): any;
  60573. /**
  60574. * Initializes the effect layer with the required options.
  60575. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  60576. */
  60577. protected _init(options: Partial<IEffectLayerOptions>): void;
  60578. /**
  60579. * Generates the index buffer of the full screen quad blending to the main canvas.
  60580. */
  60581. private _generateIndexBuffer;
  60582. /**
  60583. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60584. */
  60585. private _generateVertexBuffer;
  60586. /**
  60587. * Sets the main texture desired size which is the closest power of two
  60588. * of the engine canvas size.
  60589. */
  60590. private _setMainTextureSize;
  60591. /**
  60592. * Creates the main texture for the effect layer.
  60593. */
  60594. protected _createMainTexture(): void;
  60595. /**
  60596. * Adds specific effects defines.
  60597. * @param defines The defines to add specifics to.
  60598. */
  60599. protected _addCustomEffectDefines(defines: string[]): void;
  60600. /**
  60601. * Checks for the readiness of the element composing the layer.
  60602. * @param subMesh the mesh to check for
  60603. * @param useInstances specify whether or not to use instances to render the mesh
  60604. * @param emissiveTexture the associated emissive texture used to generate the glow
  60605. * @return true if ready otherwise, false
  60606. */
  60607. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60608. /**
  60609. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60610. */
  60611. render(): void;
  60612. /**
  60613. * Determine if a given mesh will be used in the current effect.
  60614. * @param mesh mesh to test
  60615. * @returns true if the mesh will be used
  60616. */
  60617. hasMesh(mesh: AbstractMesh): boolean;
  60618. /**
  60619. * Returns true if the layer contains information to display, otherwise false.
  60620. * @returns true if the glow layer should be rendered
  60621. */
  60622. shouldRender(): boolean;
  60623. /**
  60624. * Returns true if the mesh should render, otherwise false.
  60625. * @param mesh The mesh to render
  60626. * @returns true if it should render otherwise false
  60627. */
  60628. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60629. /**
  60630. * Returns true if the mesh can be rendered, otherwise false.
  60631. * @param mesh The mesh to render
  60632. * @param material The material used on the mesh
  60633. * @returns true if it can be rendered otherwise false
  60634. */
  60635. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60636. /**
  60637. * Returns true if the mesh should render, otherwise false.
  60638. * @param mesh The mesh to render
  60639. * @returns true if it should render otherwise false
  60640. */
  60641. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60642. /**
  60643. * Renders the submesh passed in parameter to the generation map.
  60644. */
  60645. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60646. /**
  60647. * Defines whether the current material of the mesh should be use to render the effect.
  60648. * @param mesh defines the current mesh to render
  60649. */
  60650. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60651. /**
  60652. * Rebuild the required buffers.
  60653. * @hidden Internal use only.
  60654. */
  60655. _rebuild(): void;
  60656. /**
  60657. * Dispose only the render target textures and post process.
  60658. */
  60659. private _disposeTextureAndPostProcesses;
  60660. /**
  60661. * Dispose the highlight layer and free resources.
  60662. */
  60663. dispose(): void;
  60664. /**
  60665. * Gets the class name of the effect layer
  60666. * @returns the string with the class name of the effect layer
  60667. */
  60668. getClassName(): string;
  60669. /**
  60670. * Creates an effect layer from parsed effect layer data
  60671. * @param parsedEffectLayer defines effect layer data
  60672. * @param scene defines the current scene
  60673. * @param rootUrl defines the root URL containing the effect layer information
  60674. * @returns a parsed effect Layer
  60675. */
  60676. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60677. }
  60678. }
  60679. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  60680. import { Scene } from "babylonjs/scene";
  60681. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60682. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60683. import { AbstractScene } from "babylonjs/abstractScene";
  60684. module "babylonjs/abstractScene" {
  60685. interface AbstractScene {
  60686. /**
  60687. * The list of effect layers (highlights/glow) added to the scene
  60688. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60689. * @see https://doc.babylonjs.com/how_to/glow_layer
  60690. */
  60691. effectLayers: Array<EffectLayer>;
  60692. /**
  60693. * Removes the given effect layer from this scene.
  60694. * @param toRemove defines the effect layer to remove
  60695. * @returns the index of the removed effect layer
  60696. */
  60697. removeEffectLayer(toRemove: EffectLayer): number;
  60698. /**
  60699. * Adds the given effect layer to this scene
  60700. * @param newEffectLayer defines the effect layer to add
  60701. */
  60702. addEffectLayer(newEffectLayer: EffectLayer): void;
  60703. }
  60704. }
  60705. /**
  60706. * Defines the layer scene component responsible to manage any effect layers
  60707. * in a given scene.
  60708. */
  60709. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60710. /**
  60711. * The component name helpfull to identify the component in the list of scene components.
  60712. */
  60713. readonly name: string;
  60714. /**
  60715. * The scene the component belongs to.
  60716. */
  60717. scene: Scene;
  60718. private _engine;
  60719. private _renderEffects;
  60720. private _needStencil;
  60721. private _previousStencilState;
  60722. /**
  60723. * Creates a new instance of the component for the given scene
  60724. * @param scene Defines the scene to register the component in
  60725. */
  60726. constructor(scene: Scene);
  60727. /**
  60728. * Registers the component in a given scene
  60729. */
  60730. register(): void;
  60731. /**
  60732. * Rebuilds the elements related to this component in case of
  60733. * context lost for instance.
  60734. */
  60735. rebuild(): void;
  60736. /**
  60737. * Serializes the component data to the specified json object
  60738. * @param serializationObject The object to serialize to
  60739. */
  60740. serialize(serializationObject: any): void;
  60741. /**
  60742. * Adds all the elements from the container to the scene
  60743. * @param container the container holding the elements
  60744. */
  60745. addFromContainer(container: AbstractScene): void;
  60746. /**
  60747. * Removes all the elements in the container from the scene
  60748. * @param container contains the elements to remove
  60749. * @param dispose if the removed element should be disposed (default: false)
  60750. */
  60751. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60752. /**
  60753. * Disposes the component and the associated ressources.
  60754. */
  60755. dispose(): void;
  60756. private _isReadyForMesh;
  60757. private _renderMainTexture;
  60758. private _setStencil;
  60759. private _setStencilBack;
  60760. private _draw;
  60761. private _drawCamera;
  60762. private _drawRenderingGroup;
  60763. }
  60764. }
  60765. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  60766. /** @hidden */
  60767. export var glowMapMergePixelShader: {
  60768. name: string;
  60769. shader: string;
  60770. };
  60771. }
  60772. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60773. /** @hidden */
  60774. export var glowMapMergeVertexShader: {
  60775. name: string;
  60776. shader: string;
  60777. };
  60778. }
  60779. declare module "babylonjs/Layers/glowLayer" {
  60780. import { Nullable } from "babylonjs/types";
  60781. import { Camera } from "babylonjs/Cameras/camera";
  60782. import { Scene } from "babylonjs/scene";
  60783. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60785. import { Mesh } from "babylonjs/Meshes/mesh";
  60786. import { Texture } from "babylonjs/Materials/Textures/texture";
  60787. import { Effect } from "babylonjs/Materials/effect";
  60788. import { Material } from "babylonjs/Materials/material";
  60789. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60790. import { Color4 } from "babylonjs/Maths/math.color";
  60791. import "babylonjs/Shaders/glowMapMerge.fragment";
  60792. import "babylonjs/Shaders/glowMapMerge.vertex";
  60793. import "babylonjs/Layers/effectLayerSceneComponent";
  60794. module "babylonjs/abstractScene" {
  60795. interface AbstractScene {
  60796. /**
  60797. * Return a the first highlight layer of the scene with a given name.
  60798. * @param name The name of the highlight layer to look for.
  60799. * @return The highlight layer if found otherwise null.
  60800. */
  60801. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60802. }
  60803. }
  60804. /**
  60805. * Glow layer options. This helps customizing the behaviour
  60806. * of the glow layer.
  60807. */
  60808. export interface IGlowLayerOptions {
  60809. /**
  60810. * Multiplication factor apply to the canvas size to compute the render target size
  60811. * used to generated the glowing objects (the smaller the faster).
  60812. */
  60813. mainTextureRatio: number;
  60814. /**
  60815. * Enforces a fixed size texture to ensure resize independant blur.
  60816. */
  60817. mainTextureFixedSize?: number;
  60818. /**
  60819. * How big is the kernel of the blur texture.
  60820. */
  60821. blurKernelSize: number;
  60822. /**
  60823. * The camera attached to the layer.
  60824. */
  60825. camera: Nullable<Camera>;
  60826. /**
  60827. * Enable MSAA by chosing the number of samples.
  60828. */
  60829. mainTextureSamples?: number;
  60830. /**
  60831. * The rendering group to draw the layer in.
  60832. */
  60833. renderingGroupId: number;
  60834. }
  60835. /**
  60836. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60837. *
  60838. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60839. *
  60840. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60841. */
  60842. export class GlowLayer extends EffectLayer {
  60843. /**
  60844. * Effect Name of the layer.
  60845. */
  60846. static readonly EffectName: string;
  60847. /**
  60848. * The default blur kernel size used for the glow.
  60849. */
  60850. static DefaultBlurKernelSize: number;
  60851. /**
  60852. * The default texture size ratio used for the glow.
  60853. */
  60854. static DefaultTextureRatio: number;
  60855. /**
  60856. * Sets the kernel size of the blur.
  60857. */
  60858. set blurKernelSize(value: number);
  60859. /**
  60860. * Gets the kernel size of the blur.
  60861. */
  60862. get blurKernelSize(): number;
  60863. /**
  60864. * Sets the glow intensity.
  60865. */
  60866. set intensity(value: number);
  60867. /**
  60868. * Gets the glow intensity.
  60869. */
  60870. get intensity(): number;
  60871. private _options;
  60872. private _intensity;
  60873. private _horizontalBlurPostprocess1;
  60874. private _verticalBlurPostprocess1;
  60875. private _horizontalBlurPostprocess2;
  60876. private _verticalBlurPostprocess2;
  60877. private _blurTexture1;
  60878. private _blurTexture2;
  60879. private _postProcesses1;
  60880. private _postProcesses2;
  60881. private _includedOnlyMeshes;
  60882. private _excludedMeshes;
  60883. private _meshesUsingTheirOwnMaterials;
  60884. /**
  60885. * Callback used to let the user override the color selection on a per mesh basis
  60886. */
  60887. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60888. /**
  60889. * Callback used to let the user override the texture selection on a per mesh basis
  60890. */
  60891. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60892. /**
  60893. * Instantiates a new glow Layer and references it to the scene.
  60894. * @param name The name of the layer
  60895. * @param scene The scene to use the layer in
  60896. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60897. */
  60898. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60899. /**
  60900. * Get the effect name of the layer.
  60901. * @return The effect name
  60902. */
  60903. getEffectName(): string;
  60904. /**
  60905. * Create the merge effect. This is the shader use to blit the information back
  60906. * to the main canvas at the end of the scene rendering.
  60907. */
  60908. protected _createMergeEffect(): Effect;
  60909. /**
  60910. * Creates the render target textures and post processes used in the glow layer.
  60911. */
  60912. protected _createTextureAndPostProcesses(): void;
  60913. /**
  60914. * Checks for the readiness of the element composing the layer.
  60915. * @param subMesh the mesh to check for
  60916. * @param useInstances specify wether or not to use instances to render the mesh
  60917. * @param emissiveTexture the associated emissive texture used to generate the glow
  60918. * @return true if ready otherwise, false
  60919. */
  60920. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60921. /**
  60922. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60923. */
  60924. needStencil(): boolean;
  60925. /**
  60926. * Returns true if the mesh can be rendered, otherwise false.
  60927. * @param mesh The mesh to render
  60928. * @param material The material used on the mesh
  60929. * @returns true if it can be rendered otherwise false
  60930. */
  60931. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60932. /**
  60933. * Implementation specific of rendering the generating effect on the main canvas.
  60934. * @param effect The effect used to render through
  60935. */
  60936. protected _internalRender(effect: Effect): void;
  60937. /**
  60938. * Sets the required values for both the emissive texture and and the main color.
  60939. */
  60940. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60941. /**
  60942. * Returns true if the mesh should render, otherwise false.
  60943. * @param mesh The mesh to render
  60944. * @returns true if it should render otherwise false
  60945. */
  60946. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60947. /**
  60948. * Adds specific effects defines.
  60949. * @param defines The defines to add specifics to.
  60950. */
  60951. protected _addCustomEffectDefines(defines: string[]): void;
  60952. /**
  60953. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60954. * @param mesh The mesh to exclude from the glow layer
  60955. */
  60956. addExcludedMesh(mesh: Mesh): void;
  60957. /**
  60958. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60959. * @param mesh The mesh to remove
  60960. */
  60961. removeExcludedMesh(mesh: Mesh): void;
  60962. /**
  60963. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60964. * @param mesh The mesh to include in the glow layer
  60965. */
  60966. addIncludedOnlyMesh(mesh: Mesh): void;
  60967. /**
  60968. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60969. * @param mesh The mesh to remove
  60970. */
  60971. removeIncludedOnlyMesh(mesh: Mesh): void;
  60972. /**
  60973. * Determine if a given mesh will be used in the glow layer
  60974. * @param mesh The mesh to test
  60975. * @returns true if the mesh will be highlighted by the current glow layer
  60976. */
  60977. hasMesh(mesh: AbstractMesh): boolean;
  60978. /**
  60979. * Defines whether the current material of the mesh should be use to render the effect.
  60980. * @param mesh defines the current mesh to render
  60981. */
  60982. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60983. /**
  60984. * Add a mesh to be rendered through its own material and not with emissive only.
  60985. * @param mesh The mesh for which we need to use its material
  60986. */
  60987. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60988. /**
  60989. * Remove a mesh from being rendered through its own material and not with emissive only.
  60990. * @param mesh The mesh for which we need to not use its material
  60991. */
  60992. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60993. /**
  60994. * Free any resources and references associated to a mesh.
  60995. * Internal use
  60996. * @param mesh The mesh to free.
  60997. * @hidden
  60998. */
  60999. _disposeMesh(mesh: Mesh): void;
  61000. /**
  61001. * Gets the class name of the effect layer
  61002. * @returns the string with the class name of the effect layer
  61003. */
  61004. getClassName(): string;
  61005. /**
  61006. * Serializes this glow layer
  61007. * @returns a serialized glow layer object
  61008. */
  61009. serialize(): any;
  61010. /**
  61011. * Creates a Glow Layer from parsed glow layer data
  61012. * @param parsedGlowLayer defines glow layer data
  61013. * @param scene defines the current scene
  61014. * @param rootUrl defines the root URL containing the glow layer information
  61015. * @returns a parsed Glow Layer
  61016. */
  61017. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61018. }
  61019. }
  61020. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61021. /** @hidden */
  61022. export var glowBlurPostProcessPixelShader: {
  61023. name: string;
  61024. shader: string;
  61025. };
  61026. }
  61027. declare module "babylonjs/Layers/highlightLayer" {
  61028. import { Observable } from "babylonjs/Misc/observable";
  61029. import { Nullable } from "babylonjs/types";
  61030. import { Camera } from "babylonjs/Cameras/camera";
  61031. import { Scene } from "babylonjs/scene";
  61032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61034. import { Mesh } from "babylonjs/Meshes/mesh";
  61035. import { Effect } from "babylonjs/Materials/effect";
  61036. import { Material } from "babylonjs/Materials/material";
  61037. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61038. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61039. import "babylonjs/Shaders/glowMapMerge.fragment";
  61040. import "babylonjs/Shaders/glowMapMerge.vertex";
  61041. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61042. module "babylonjs/abstractScene" {
  61043. interface AbstractScene {
  61044. /**
  61045. * Return a the first highlight layer of the scene with a given name.
  61046. * @param name The name of the highlight layer to look for.
  61047. * @return The highlight layer if found otherwise null.
  61048. */
  61049. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61050. }
  61051. }
  61052. /**
  61053. * Highlight layer options. This helps customizing the behaviour
  61054. * of the highlight layer.
  61055. */
  61056. export interface IHighlightLayerOptions {
  61057. /**
  61058. * Multiplication factor apply to the canvas size to compute the render target size
  61059. * used to generated the glowing objects (the smaller the faster).
  61060. */
  61061. mainTextureRatio: number;
  61062. /**
  61063. * Enforces a fixed size texture to ensure resize independant blur.
  61064. */
  61065. mainTextureFixedSize?: number;
  61066. /**
  61067. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61068. * of the picture to blur (the smaller the faster).
  61069. */
  61070. blurTextureSizeRatio: number;
  61071. /**
  61072. * How big in texel of the blur texture is the vertical blur.
  61073. */
  61074. blurVerticalSize: number;
  61075. /**
  61076. * How big in texel of the blur texture is the horizontal blur.
  61077. */
  61078. blurHorizontalSize: number;
  61079. /**
  61080. * Alpha blending mode used to apply the blur. Default is combine.
  61081. */
  61082. alphaBlendingMode: number;
  61083. /**
  61084. * The camera attached to the layer.
  61085. */
  61086. camera: Nullable<Camera>;
  61087. /**
  61088. * Should we display highlight as a solid stroke?
  61089. */
  61090. isStroke?: boolean;
  61091. /**
  61092. * The rendering group to draw the layer in.
  61093. */
  61094. renderingGroupId: number;
  61095. }
  61096. /**
  61097. * The highlight layer Helps adding a glow effect around a mesh.
  61098. *
  61099. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61100. * glowy meshes to your scene.
  61101. *
  61102. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61103. */
  61104. export class HighlightLayer extends EffectLayer {
  61105. name: string;
  61106. /**
  61107. * Effect Name of the highlight layer.
  61108. */
  61109. static readonly EffectName: string;
  61110. /**
  61111. * The neutral color used during the preparation of the glow effect.
  61112. * This is black by default as the blend operation is a blend operation.
  61113. */
  61114. static NeutralColor: Color4;
  61115. /**
  61116. * Stencil value used for glowing meshes.
  61117. */
  61118. static GlowingMeshStencilReference: number;
  61119. /**
  61120. * Stencil value used for the other meshes in the scene.
  61121. */
  61122. static NormalMeshStencilReference: number;
  61123. /**
  61124. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61125. */
  61126. innerGlow: boolean;
  61127. /**
  61128. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61129. */
  61130. outerGlow: boolean;
  61131. /**
  61132. * Specifies the horizontal size of the blur.
  61133. */
  61134. set blurHorizontalSize(value: number);
  61135. /**
  61136. * Specifies the vertical size of the blur.
  61137. */
  61138. set blurVerticalSize(value: number);
  61139. /**
  61140. * Gets the horizontal size of the blur.
  61141. */
  61142. get blurHorizontalSize(): number;
  61143. /**
  61144. * Gets the vertical size of the blur.
  61145. */
  61146. get blurVerticalSize(): number;
  61147. /**
  61148. * An event triggered when the highlight layer is being blurred.
  61149. */
  61150. onBeforeBlurObservable: Observable<HighlightLayer>;
  61151. /**
  61152. * An event triggered when the highlight layer has been blurred.
  61153. */
  61154. onAfterBlurObservable: Observable<HighlightLayer>;
  61155. private _instanceGlowingMeshStencilReference;
  61156. private _options;
  61157. private _downSamplePostprocess;
  61158. private _horizontalBlurPostprocess;
  61159. private _verticalBlurPostprocess;
  61160. private _blurTexture;
  61161. private _meshes;
  61162. private _excludedMeshes;
  61163. /**
  61164. * Instantiates a new highlight Layer and references it to the scene..
  61165. * @param name The name of the layer
  61166. * @param scene The scene to use the layer in
  61167. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61168. */
  61169. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61170. /**
  61171. * Get the effect name of the layer.
  61172. * @return The effect name
  61173. */
  61174. getEffectName(): string;
  61175. /**
  61176. * Create the merge effect. This is the shader use to blit the information back
  61177. * to the main canvas at the end of the scene rendering.
  61178. */
  61179. protected _createMergeEffect(): Effect;
  61180. /**
  61181. * Creates the render target textures and post processes used in the highlight layer.
  61182. */
  61183. protected _createTextureAndPostProcesses(): void;
  61184. /**
  61185. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61186. */
  61187. needStencil(): boolean;
  61188. /**
  61189. * Checks for the readiness of the element composing the layer.
  61190. * @param subMesh the mesh to check for
  61191. * @param useInstances specify wether or not to use instances to render the mesh
  61192. * @param emissiveTexture the associated emissive texture used to generate the glow
  61193. * @return true if ready otherwise, false
  61194. */
  61195. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61196. /**
  61197. * Implementation specific of rendering the generating effect on the main canvas.
  61198. * @param effect The effect used to render through
  61199. */
  61200. protected _internalRender(effect: Effect): void;
  61201. /**
  61202. * Returns true if the layer contains information to display, otherwise false.
  61203. */
  61204. shouldRender(): boolean;
  61205. /**
  61206. * Returns true if the mesh should render, otherwise false.
  61207. * @param mesh The mesh to render
  61208. * @returns true if it should render otherwise false
  61209. */
  61210. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61211. /**
  61212. * Returns true if the mesh can be rendered, otherwise false.
  61213. * @param mesh The mesh to render
  61214. * @param material The material used on the mesh
  61215. * @returns true if it can be rendered otherwise false
  61216. */
  61217. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61218. /**
  61219. * Adds specific effects defines.
  61220. * @param defines The defines to add specifics to.
  61221. */
  61222. protected _addCustomEffectDefines(defines: string[]): void;
  61223. /**
  61224. * Sets the required values for both the emissive texture and and the main color.
  61225. */
  61226. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61227. /**
  61228. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61229. * @param mesh The mesh to exclude from the highlight layer
  61230. */
  61231. addExcludedMesh(mesh: Mesh): void;
  61232. /**
  61233. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61234. * @param mesh The mesh to highlight
  61235. */
  61236. removeExcludedMesh(mesh: Mesh): void;
  61237. /**
  61238. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61239. * @param mesh mesh to test
  61240. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61241. */
  61242. hasMesh(mesh: AbstractMesh): boolean;
  61243. /**
  61244. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61245. * @param mesh The mesh to highlight
  61246. * @param color The color of the highlight
  61247. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61248. */
  61249. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61250. /**
  61251. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61252. * @param mesh The mesh to highlight
  61253. */
  61254. removeMesh(mesh: Mesh): void;
  61255. /**
  61256. * Remove all the meshes currently referenced in the highlight layer
  61257. */
  61258. removeAllMeshes(): void;
  61259. /**
  61260. * Force the stencil to the normal expected value for none glowing parts
  61261. */
  61262. private _defaultStencilReference;
  61263. /**
  61264. * Free any resources and references associated to a mesh.
  61265. * Internal use
  61266. * @param mesh The mesh to free.
  61267. * @hidden
  61268. */
  61269. _disposeMesh(mesh: Mesh): void;
  61270. /**
  61271. * Dispose the highlight layer and free resources.
  61272. */
  61273. dispose(): void;
  61274. /**
  61275. * Gets the class name of the effect layer
  61276. * @returns the string with the class name of the effect layer
  61277. */
  61278. getClassName(): string;
  61279. /**
  61280. * Serializes this Highlight layer
  61281. * @returns a serialized Highlight layer object
  61282. */
  61283. serialize(): any;
  61284. /**
  61285. * Creates a Highlight layer from parsed Highlight layer data
  61286. * @param parsedHightlightLayer defines the Highlight layer data
  61287. * @param scene defines the current scene
  61288. * @param rootUrl defines the root URL containing the Highlight layer information
  61289. * @returns a parsed Highlight layer
  61290. */
  61291. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61292. }
  61293. }
  61294. declare module "babylonjs/Layers/layerSceneComponent" {
  61295. import { Scene } from "babylonjs/scene";
  61296. import { ISceneComponent } from "babylonjs/sceneComponent";
  61297. import { Layer } from "babylonjs/Layers/layer";
  61298. import { AbstractScene } from "babylonjs/abstractScene";
  61299. module "babylonjs/abstractScene" {
  61300. interface AbstractScene {
  61301. /**
  61302. * The list of layers (background and foreground) of the scene
  61303. */
  61304. layers: Array<Layer>;
  61305. }
  61306. }
  61307. /**
  61308. * Defines the layer scene component responsible to manage any layers
  61309. * in a given scene.
  61310. */
  61311. export class LayerSceneComponent implements ISceneComponent {
  61312. /**
  61313. * The component name helpfull to identify the component in the list of scene components.
  61314. */
  61315. readonly name: string;
  61316. /**
  61317. * The scene the component belongs to.
  61318. */
  61319. scene: Scene;
  61320. private _engine;
  61321. /**
  61322. * Creates a new instance of the component for the given scene
  61323. * @param scene Defines the scene to register the component in
  61324. */
  61325. constructor(scene: Scene);
  61326. /**
  61327. * Registers the component in a given scene
  61328. */
  61329. register(): void;
  61330. /**
  61331. * Rebuilds the elements related to this component in case of
  61332. * context lost for instance.
  61333. */
  61334. rebuild(): void;
  61335. /**
  61336. * Disposes the component and the associated ressources.
  61337. */
  61338. dispose(): void;
  61339. private _draw;
  61340. private _drawCameraPredicate;
  61341. private _drawCameraBackground;
  61342. private _drawCameraForeground;
  61343. private _drawRenderTargetPredicate;
  61344. private _drawRenderTargetBackground;
  61345. private _drawRenderTargetForeground;
  61346. /**
  61347. * Adds all the elements from the container to the scene
  61348. * @param container the container holding the elements
  61349. */
  61350. addFromContainer(container: AbstractScene): void;
  61351. /**
  61352. * Removes all the elements in the container from the scene
  61353. * @param container contains the elements to remove
  61354. * @param dispose if the removed element should be disposed (default: false)
  61355. */
  61356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61357. }
  61358. }
  61359. declare module "babylonjs/Shaders/layer.fragment" {
  61360. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61361. /** @hidden */
  61362. export var layerPixelShader: {
  61363. name: string;
  61364. shader: string;
  61365. };
  61366. }
  61367. declare module "babylonjs/Shaders/layer.vertex" {
  61368. /** @hidden */
  61369. export var layerVertexShader: {
  61370. name: string;
  61371. shader: string;
  61372. };
  61373. }
  61374. declare module "babylonjs/Layers/layer" {
  61375. import { Observable } from "babylonjs/Misc/observable";
  61376. import { Nullable } from "babylonjs/types";
  61377. import { Scene } from "babylonjs/scene";
  61378. import { Vector2 } from "babylonjs/Maths/math.vector";
  61379. import { Color4 } from "babylonjs/Maths/math.color";
  61380. import { Texture } from "babylonjs/Materials/Textures/texture";
  61381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61382. import "babylonjs/Shaders/layer.fragment";
  61383. import "babylonjs/Shaders/layer.vertex";
  61384. /**
  61385. * This represents a full screen 2d layer.
  61386. * This can be useful to display a picture in the background of your scene for instance.
  61387. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61388. */
  61389. export class Layer {
  61390. /**
  61391. * Define the name of the layer.
  61392. */
  61393. name: string;
  61394. /**
  61395. * Define the texture the layer should display.
  61396. */
  61397. texture: Nullable<Texture>;
  61398. /**
  61399. * Is the layer in background or foreground.
  61400. */
  61401. isBackground: boolean;
  61402. /**
  61403. * Define the color of the layer (instead of texture).
  61404. */
  61405. color: Color4;
  61406. /**
  61407. * Define the scale of the layer in order to zoom in out of the texture.
  61408. */
  61409. scale: Vector2;
  61410. /**
  61411. * Define an offset for the layer in order to shift the texture.
  61412. */
  61413. offset: Vector2;
  61414. /**
  61415. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61416. */
  61417. alphaBlendingMode: number;
  61418. /**
  61419. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61420. * Alpha test will not mix with the background color in case of transparency.
  61421. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61422. */
  61423. alphaTest: boolean;
  61424. /**
  61425. * Define a mask to restrict the layer to only some of the scene cameras.
  61426. */
  61427. layerMask: number;
  61428. /**
  61429. * Define the list of render target the layer is visible into.
  61430. */
  61431. renderTargetTextures: RenderTargetTexture[];
  61432. /**
  61433. * Define if the layer is only used in renderTarget or if it also
  61434. * renders in the main frame buffer of the canvas.
  61435. */
  61436. renderOnlyInRenderTargetTextures: boolean;
  61437. private _scene;
  61438. private _vertexBuffers;
  61439. private _indexBuffer;
  61440. private _effect;
  61441. private _previousDefines;
  61442. /**
  61443. * An event triggered when the layer is disposed.
  61444. */
  61445. onDisposeObservable: Observable<Layer>;
  61446. private _onDisposeObserver;
  61447. /**
  61448. * Back compatibility with callback before the onDisposeObservable existed.
  61449. * The set callback will be triggered when the layer has been disposed.
  61450. */
  61451. set onDispose(callback: () => void);
  61452. /**
  61453. * An event triggered before rendering the scene
  61454. */
  61455. onBeforeRenderObservable: Observable<Layer>;
  61456. private _onBeforeRenderObserver;
  61457. /**
  61458. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61459. * The set callback will be triggered just before rendering the layer.
  61460. */
  61461. set onBeforeRender(callback: () => void);
  61462. /**
  61463. * An event triggered after rendering the scene
  61464. */
  61465. onAfterRenderObservable: Observable<Layer>;
  61466. private _onAfterRenderObserver;
  61467. /**
  61468. * Back compatibility with callback before the onAfterRenderObservable existed.
  61469. * The set callback will be triggered just after rendering the layer.
  61470. */
  61471. set onAfterRender(callback: () => void);
  61472. /**
  61473. * Instantiates a new layer.
  61474. * This represents a full screen 2d layer.
  61475. * This can be useful to display a picture in the background of your scene for instance.
  61476. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61477. * @param name Define the name of the layer in the scene
  61478. * @param imgUrl Define the url of the texture to display in the layer
  61479. * @param scene Define the scene the layer belongs to
  61480. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61481. * @param color Defines a color for the layer
  61482. */
  61483. constructor(
  61484. /**
  61485. * Define the name of the layer.
  61486. */
  61487. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61488. private _createIndexBuffer;
  61489. /** @hidden */
  61490. _rebuild(): void;
  61491. /**
  61492. * Renders the layer in the scene.
  61493. */
  61494. render(): void;
  61495. /**
  61496. * Disposes and releases the associated ressources.
  61497. */
  61498. dispose(): void;
  61499. }
  61500. }
  61501. declare module "babylonjs/Layers/index" {
  61502. export * from "babylonjs/Layers/effectLayer";
  61503. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61504. export * from "babylonjs/Layers/glowLayer";
  61505. export * from "babylonjs/Layers/highlightLayer";
  61506. export * from "babylonjs/Layers/layer";
  61507. export * from "babylonjs/Layers/layerSceneComponent";
  61508. }
  61509. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61510. /** @hidden */
  61511. export var lensFlarePixelShader: {
  61512. name: string;
  61513. shader: string;
  61514. };
  61515. }
  61516. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61517. /** @hidden */
  61518. export var lensFlareVertexShader: {
  61519. name: string;
  61520. shader: string;
  61521. };
  61522. }
  61523. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61524. import { Scene } from "babylonjs/scene";
  61525. import { Vector3 } from "babylonjs/Maths/math.vector";
  61526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61527. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61528. import "babylonjs/Shaders/lensFlare.fragment";
  61529. import "babylonjs/Shaders/lensFlare.vertex";
  61530. import { Viewport } from "babylonjs/Maths/math.viewport";
  61531. /**
  61532. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61533. * It is usually composed of several `lensFlare`.
  61534. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61535. */
  61536. export class LensFlareSystem {
  61537. /**
  61538. * Define the name of the lens flare system
  61539. */
  61540. name: string;
  61541. /**
  61542. * List of lens flares used in this system.
  61543. */
  61544. lensFlares: LensFlare[];
  61545. /**
  61546. * Define a limit from the border the lens flare can be visible.
  61547. */
  61548. borderLimit: number;
  61549. /**
  61550. * Define a viewport border we do not want to see the lens flare in.
  61551. */
  61552. viewportBorder: number;
  61553. /**
  61554. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61555. */
  61556. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61557. /**
  61558. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61559. */
  61560. layerMask: number;
  61561. /**
  61562. * Define the id of the lens flare system in the scene.
  61563. * (equal to name by default)
  61564. */
  61565. id: string;
  61566. private _scene;
  61567. private _emitter;
  61568. private _vertexBuffers;
  61569. private _indexBuffer;
  61570. private _effect;
  61571. private _positionX;
  61572. private _positionY;
  61573. private _isEnabled;
  61574. /** @hidden */
  61575. static _SceneComponentInitialization: (scene: Scene) => void;
  61576. /**
  61577. * Instantiates a lens flare system.
  61578. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61579. * It is usually composed of several `lensFlare`.
  61580. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61581. * @param name Define the name of the lens flare system in the scene
  61582. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  61583. * @param scene Define the scene the lens flare system belongs to
  61584. */
  61585. constructor(
  61586. /**
  61587. * Define the name of the lens flare system
  61588. */
  61589. name: string, emitter: any, scene: Scene);
  61590. /**
  61591. * Define if the lens flare system is enabled.
  61592. */
  61593. get isEnabled(): boolean;
  61594. set isEnabled(value: boolean);
  61595. /**
  61596. * Get the scene the effects belongs to.
  61597. * @returns the scene holding the lens flare system
  61598. */
  61599. getScene(): Scene;
  61600. /**
  61601. * Get the emitter of the lens flare system.
  61602. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61603. * @returns the emitter of the lens flare system
  61604. */
  61605. getEmitter(): any;
  61606. /**
  61607. * Set the emitter of the lens flare system.
  61608. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  61609. * @param newEmitter Define the new emitter of the system
  61610. */
  61611. setEmitter(newEmitter: any): void;
  61612. /**
  61613. * Get the lens flare system emitter position.
  61614. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  61615. * @returns the position
  61616. */
  61617. getEmitterPosition(): Vector3;
  61618. /**
  61619. * @hidden
  61620. */
  61621. computeEffectivePosition(globalViewport: Viewport): boolean;
  61622. /** @hidden */
  61623. _isVisible(): boolean;
  61624. /**
  61625. * @hidden
  61626. */
  61627. render(): boolean;
  61628. /**
  61629. * Dispose and release the lens flare with its associated resources.
  61630. */
  61631. dispose(): void;
  61632. /**
  61633. * Parse a lens flare system from a JSON repressentation
  61634. * @param parsedLensFlareSystem Define the JSON to parse
  61635. * @param scene Define the scene the parsed system should be instantiated in
  61636. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  61637. * @returns the parsed system
  61638. */
  61639. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  61640. /**
  61641. * Serialize the current Lens Flare System into a JSON representation.
  61642. * @returns the serialized JSON
  61643. */
  61644. serialize(): any;
  61645. }
  61646. }
  61647. declare module "babylonjs/LensFlares/lensFlare" {
  61648. import { Nullable } from "babylonjs/types";
  61649. import { Color3 } from "babylonjs/Maths/math.color";
  61650. import { Texture } from "babylonjs/Materials/Textures/texture";
  61651. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61652. /**
  61653. * This represents one of the lens effect in a `lensFlareSystem`.
  61654. * It controls one of the indiviual texture used in the effect.
  61655. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61656. */
  61657. export class LensFlare {
  61658. /**
  61659. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61660. */
  61661. size: number;
  61662. /**
  61663. * 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.
  61664. */
  61665. position: number;
  61666. /**
  61667. * Define the lens color.
  61668. */
  61669. color: Color3;
  61670. /**
  61671. * Define the lens texture.
  61672. */
  61673. texture: Nullable<Texture>;
  61674. /**
  61675. * Define the alpha mode to render this particular lens.
  61676. */
  61677. alphaMode: number;
  61678. private _system;
  61679. /**
  61680. * Creates a new Lens Flare.
  61681. * This represents one of the lens effect in a `lensFlareSystem`.
  61682. * It controls one of the indiviual texture used in the effect.
  61683. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61684. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61685. * @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.
  61686. * @param color Define the lens color
  61687. * @param imgUrl Define the lens texture url
  61688. * @param system Define the `lensFlareSystem` this flare is part of
  61689. * @returns The newly created Lens Flare
  61690. */
  61691. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61692. /**
  61693. * Instantiates a new Lens Flare.
  61694. * This represents one of the lens effect in a `lensFlareSystem`.
  61695. * It controls one of the indiviual texture used in the effect.
  61696. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61697. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61698. * @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.
  61699. * @param color Define the lens color
  61700. * @param imgUrl Define the lens texture url
  61701. * @param system Define the `lensFlareSystem` this flare is part of
  61702. */
  61703. constructor(
  61704. /**
  61705. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61706. */
  61707. size: number,
  61708. /**
  61709. * 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.
  61710. */
  61711. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61712. /**
  61713. * Dispose and release the lens flare with its associated resources.
  61714. */
  61715. dispose(): void;
  61716. }
  61717. }
  61718. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  61719. import { Nullable } from "babylonjs/types";
  61720. import { Scene } from "babylonjs/scene";
  61721. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61722. import { AbstractScene } from "babylonjs/abstractScene";
  61723. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  61724. module "babylonjs/abstractScene" {
  61725. interface AbstractScene {
  61726. /**
  61727. * The list of lens flare system added to the scene
  61728. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61729. */
  61730. lensFlareSystems: Array<LensFlareSystem>;
  61731. /**
  61732. * Removes the given lens flare system from this scene.
  61733. * @param toRemove The lens flare system to remove
  61734. * @returns The index of the removed lens flare system
  61735. */
  61736. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61737. /**
  61738. * Adds the given lens flare system to this scene
  61739. * @param newLensFlareSystem The lens flare system to add
  61740. */
  61741. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61742. /**
  61743. * Gets a lens flare system using its name
  61744. * @param name defines the name to look for
  61745. * @returns the lens flare system or null if not found
  61746. */
  61747. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61748. /**
  61749. * Gets a lens flare system using its id
  61750. * @param id defines the id to look for
  61751. * @returns the lens flare system or null if not found
  61752. */
  61753. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61754. }
  61755. }
  61756. /**
  61757. * Defines the lens flare scene component responsible to manage any lens flares
  61758. * in a given scene.
  61759. */
  61760. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61761. /**
  61762. * The component name helpfull to identify the component in the list of scene components.
  61763. */
  61764. readonly name: string;
  61765. /**
  61766. * The scene the component belongs to.
  61767. */
  61768. scene: Scene;
  61769. /**
  61770. * Creates a new instance of the component for the given scene
  61771. * @param scene Defines the scene to register the component in
  61772. */
  61773. constructor(scene: Scene);
  61774. /**
  61775. * Registers the component in a given scene
  61776. */
  61777. register(): void;
  61778. /**
  61779. * Rebuilds the elements related to this component in case of
  61780. * context lost for instance.
  61781. */
  61782. rebuild(): void;
  61783. /**
  61784. * Adds all the elements from the container to the scene
  61785. * @param container the container holding the elements
  61786. */
  61787. addFromContainer(container: AbstractScene): void;
  61788. /**
  61789. * Removes all the elements in the container from the scene
  61790. * @param container contains the elements to remove
  61791. * @param dispose if the removed element should be disposed (default: false)
  61792. */
  61793. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61794. /**
  61795. * Serializes the component data to the specified json object
  61796. * @param serializationObject The object to serialize to
  61797. */
  61798. serialize(serializationObject: any): void;
  61799. /**
  61800. * Disposes the component and the associated ressources.
  61801. */
  61802. dispose(): void;
  61803. private _draw;
  61804. }
  61805. }
  61806. declare module "babylonjs/LensFlares/index" {
  61807. export * from "babylonjs/LensFlares/lensFlare";
  61808. export * from "babylonjs/LensFlares/lensFlareSystem";
  61809. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61810. }
  61811. declare module "babylonjs/Shaders/depth.fragment" {
  61812. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61813. /** @hidden */
  61814. export var depthPixelShader: {
  61815. name: string;
  61816. shader: string;
  61817. };
  61818. }
  61819. declare module "babylonjs/Shaders/depth.vertex" {
  61820. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61821. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61822. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61823. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61824. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61825. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61826. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61827. /** @hidden */
  61828. export var depthVertexShader: {
  61829. name: string;
  61830. shader: string;
  61831. };
  61832. }
  61833. declare module "babylonjs/Rendering/depthRenderer" {
  61834. import { Nullable } from "babylonjs/types";
  61835. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61836. import { Scene } from "babylonjs/scene";
  61837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61838. import { Camera } from "babylonjs/Cameras/camera";
  61839. import "babylonjs/Shaders/depth.fragment";
  61840. import "babylonjs/Shaders/depth.vertex";
  61841. /**
  61842. * This represents a depth renderer in Babylon.
  61843. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61844. */
  61845. export class DepthRenderer {
  61846. private _scene;
  61847. private _depthMap;
  61848. private _effect;
  61849. private readonly _storeNonLinearDepth;
  61850. private readonly _clearColor;
  61851. /** Get if the depth renderer is using packed depth or not */
  61852. readonly isPacked: boolean;
  61853. private _cachedDefines;
  61854. private _camera;
  61855. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61856. enabled: boolean;
  61857. /**
  61858. * Specifiess that the depth renderer will only be used within
  61859. * the camera it is created for.
  61860. * This can help forcing its rendering during the camera processing.
  61861. */
  61862. useOnlyInActiveCamera: boolean;
  61863. /** @hidden */
  61864. static _SceneComponentInitialization: (scene: Scene) => void;
  61865. /**
  61866. * Instantiates a depth renderer
  61867. * @param scene The scene the renderer belongs to
  61868. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61869. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61870. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61871. */
  61872. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61873. /**
  61874. * Creates the depth rendering effect and checks if the effect is ready.
  61875. * @param subMesh The submesh to be used to render the depth map of
  61876. * @param useInstances If multiple world instances should be used
  61877. * @returns if the depth renderer is ready to render the depth map
  61878. */
  61879. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61880. /**
  61881. * Gets the texture which the depth map will be written to.
  61882. * @returns The depth map texture
  61883. */
  61884. getDepthMap(): RenderTargetTexture;
  61885. /**
  61886. * Disposes of the depth renderer.
  61887. */
  61888. dispose(): void;
  61889. }
  61890. }
  61891. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61892. /** @hidden */
  61893. export var minmaxReduxPixelShader: {
  61894. name: string;
  61895. shader: string;
  61896. };
  61897. }
  61898. declare module "babylonjs/Misc/minMaxReducer" {
  61899. import { Nullable } from "babylonjs/types";
  61900. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61901. import { Camera } from "babylonjs/Cameras/camera";
  61902. import { Observer } from "babylonjs/Misc/observable";
  61903. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61904. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61905. import { Observable } from "babylonjs/Misc/observable";
  61906. import "babylonjs/Shaders/minmaxRedux.fragment";
  61907. /**
  61908. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61909. * and maximum values from all values of the texture.
  61910. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61911. * The source values are read from the red channel of the texture.
  61912. */
  61913. export class MinMaxReducer {
  61914. /**
  61915. * Observable triggered when the computation has been performed
  61916. */
  61917. onAfterReductionPerformed: Observable<{
  61918. min: number;
  61919. max: number;
  61920. }>;
  61921. protected _camera: Camera;
  61922. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61923. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61924. protected _postProcessManager: PostProcessManager;
  61925. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61926. protected _forceFullscreenViewport: boolean;
  61927. /**
  61928. * Creates a min/max reducer
  61929. * @param camera The camera to use for the post processes
  61930. */
  61931. constructor(camera: Camera);
  61932. /**
  61933. * Gets the texture used to read the values from.
  61934. */
  61935. get sourceTexture(): Nullable<RenderTargetTexture>;
  61936. /**
  61937. * Sets the source texture to read the values from.
  61938. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61939. * because in such textures '1' value must not be taken into account to compute the maximum
  61940. * as this value is used to clear the texture.
  61941. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61942. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61943. * @param depthRedux Indicates if the texture is a depth texture or not
  61944. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61945. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61946. */
  61947. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61948. /**
  61949. * Defines the refresh rate of the computation.
  61950. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61951. */
  61952. get refreshRate(): number;
  61953. set refreshRate(value: number);
  61954. protected _activated: boolean;
  61955. /**
  61956. * Gets the activation status of the reducer
  61957. */
  61958. get activated(): boolean;
  61959. /**
  61960. * Activates the reduction computation.
  61961. * When activated, the observers registered in onAfterReductionPerformed are
  61962. * called after the compuation is performed
  61963. */
  61964. activate(): void;
  61965. /**
  61966. * Deactivates the reduction computation.
  61967. */
  61968. deactivate(): void;
  61969. /**
  61970. * Disposes the min/max reducer
  61971. * @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.
  61972. */
  61973. dispose(disposeAll?: boolean): void;
  61974. }
  61975. }
  61976. declare module "babylonjs/Misc/depthReducer" {
  61977. import { Nullable } from "babylonjs/types";
  61978. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61979. import { Camera } from "babylonjs/Cameras/camera";
  61980. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61981. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61982. /**
  61983. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61984. */
  61985. export class DepthReducer extends MinMaxReducer {
  61986. private _depthRenderer;
  61987. private _depthRendererId;
  61988. /**
  61989. * Gets the depth renderer used for the computation.
  61990. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61991. */
  61992. get depthRenderer(): Nullable<DepthRenderer>;
  61993. /**
  61994. * Creates a depth reducer
  61995. * @param camera The camera used to render the depth texture
  61996. */
  61997. constructor(camera: Camera);
  61998. /**
  61999. * Sets the depth renderer to use to generate the depth map
  62000. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62001. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62002. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62003. */
  62004. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62005. /** @hidden */
  62006. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62007. /**
  62008. * Activates the reduction computation.
  62009. * When activated, the observers registered in onAfterReductionPerformed are
  62010. * called after the compuation is performed
  62011. */
  62012. activate(): void;
  62013. /**
  62014. * Deactivates the reduction computation.
  62015. */
  62016. deactivate(): void;
  62017. /**
  62018. * Disposes the depth reducer
  62019. * @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.
  62020. */
  62021. dispose(disposeAll?: boolean): void;
  62022. }
  62023. }
  62024. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62025. import { Nullable } from "babylonjs/types";
  62026. import { Scene } from "babylonjs/scene";
  62027. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62030. import { Effect } from "babylonjs/Materials/effect";
  62031. import "babylonjs/Shaders/shadowMap.fragment";
  62032. import "babylonjs/Shaders/shadowMap.vertex";
  62033. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62034. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62035. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62036. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62037. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62038. /**
  62039. * A CSM implementation allowing casting shadows on large scenes.
  62040. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62041. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62042. */
  62043. export class CascadedShadowGenerator extends ShadowGenerator {
  62044. private static readonly frustumCornersNDCSpace;
  62045. /**
  62046. * Name of the CSM class
  62047. */
  62048. static CLASSNAME: string;
  62049. /**
  62050. * Defines the default number of cascades used by the CSM.
  62051. */
  62052. static readonly DEFAULT_CASCADES_COUNT: number;
  62053. /**
  62054. * Defines the minimum number of cascades used by the CSM.
  62055. */
  62056. static readonly MIN_CASCADES_COUNT: number;
  62057. /**
  62058. * Defines the maximum number of cascades used by the CSM.
  62059. */
  62060. static readonly MAX_CASCADES_COUNT: number;
  62061. protected _validateFilter(filter: number): number;
  62062. /**
  62063. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62064. */
  62065. penumbraDarkness: number;
  62066. private _numCascades;
  62067. /**
  62068. * Gets or set the number of cascades used by the CSM.
  62069. */
  62070. get numCascades(): number;
  62071. set numCascades(value: number);
  62072. /**
  62073. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62074. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62075. */
  62076. stabilizeCascades: boolean;
  62077. private _freezeShadowCastersBoundingInfo;
  62078. private _freezeShadowCastersBoundingInfoObservable;
  62079. /**
  62080. * Enables or disables the shadow casters bounding info computation.
  62081. * If your shadow casters don't move, you can disable this feature.
  62082. * If it is enabled, the bounding box computation is done every frame.
  62083. */
  62084. get freezeShadowCastersBoundingInfo(): boolean;
  62085. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62086. private _scbiMin;
  62087. private _scbiMax;
  62088. protected _computeShadowCastersBoundingInfo(): void;
  62089. protected _shadowCastersBoundingInfo: BoundingInfo;
  62090. /**
  62091. * Gets or sets the shadow casters bounding info.
  62092. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62093. * so that the system won't overwrite the bounds you provide
  62094. */
  62095. get shadowCastersBoundingInfo(): BoundingInfo;
  62096. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62097. protected _breaksAreDirty: boolean;
  62098. protected _minDistance: number;
  62099. protected _maxDistance: number;
  62100. /**
  62101. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62102. *
  62103. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62104. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62105. * @param min minimal distance for the breaks (default to 0.)
  62106. * @param max maximal distance for the breaks (default to 1.)
  62107. */
  62108. setMinMaxDistance(min: number, max: number): void;
  62109. /** Gets the minimal distance used in the cascade break computation */
  62110. get minDistance(): number;
  62111. /** Gets the maximal distance used in the cascade break computation */
  62112. get maxDistance(): number;
  62113. /**
  62114. * Gets the class name of that object
  62115. * @returns "CascadedShadowGenerator"
  62116. */
  62117. getClassName(): string;
  62118. private _cascadeMinExtents;
  62119. private _cascadeMaxExtents;
  62120. /**
  62121. * Gets a cascade minimum extents
  62122. * @param cascadeIndex index of the cascade
  62123. * @returns the minimum cascade extents
  62124. */
  62125. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62126. /**
  62127. * Gets a cascade maximum extents
  62128. * @param cascadeIndex index of the cascade
  62129. * @returns the maximum cascade extents
  62130. */
  62131. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62132. private _cascades;
  62133. private _currentLayer;
  62134. private _viewSpaceFrustumsZ;
  62135. private _viewMatrices;
  62136. private _projectionMatrices;
  62137. private _transformMatrices;
  62138. private _transformMatricesAsArray;
  62139. private _frustumLengths;
  62140. private _lightSizeUVCorrection;
  62141. private _depthCorrection;
  62142. private _frustumCornersWorldSpace;
  62143. private _frustumCenter;
  62144. private _shadowCameraPos;
  62145. private _shadowMaxZ;
  62146. /**
  62147. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62148. * It defaults to camera.maxZ
  62149. */
  62150. get shadowMaxZ(): number;
  62151. /**
  62152. * Sets the shadow max z distance.
  62153. */
  62154. set shadowMaxZ(value: number);
  62155. protected _debug: boolean;
  62156. /**
  62157. * Gets or sets the debug flag.
  62158. * When enabled, the cascades are materialized by different colors on the screen.
  62159. */
  62160. get debug(): boolean;
  62161. set debug(dbg: boolean);
  62162. private _depthClamp;
  62163. /**
  62164. * Gets or sets the depth clamping value.
  62165. *
  62166. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62167. * to account for the shadow casters far away.
  62168. *
  62169. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62170. */
  62171. get depthClamp(): boolean;
  62172. set depthClamp(value: boolean);
  62173. private _cascadeBlendPercentage;
  62174. /**
  62175. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62176. * It defaults to 0.1 (10% blending).
  62177. */
  62178. get cascadeBlendPercentage(): number;
  62179. set cascadeBlendPercentage(value: number);
  62180. private _lambda;
  62181. /**
  62182. * Gets or set the lambda parameter.
  62183. * This parameter is used to split the camera frustum and create the cascades.
  62184. * 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.
  62185. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62186. */
  62187. get lambda(): number;
  62188. set lambda(value: number);
  62189. /**
  62190. * Gets the view matrix corresponding to a given cascade
  62191. * @param cascadeNum cascade to retrieve the view matrix from
  62192. * @returns the cascade view matrix
  62193. */
  62194. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62195. /**
  62196. * Gets the projection matrix corresponding to a given cascade
  62197. * @param cascadeNum cascade to retrieve the projection matrix from
  62198. * @returns the cascade projection matrix
  62199. */
  62200. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62201. /**
  62202. * Gets the transformation matrix corresponding to a given cascade
  62203. * @param cascadeNum cascade to retrieve the transformation matrix from
  62204. * @returns the cascade transformation matrix
  62205. */
  62206. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62207. private _depthRenderer;
  62208. /**
  62209. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62210. *
  62211. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62212. *
  62213. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62214. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62215. * @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
  62216. */
  62217. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62218. private _depthReducer;
  62219. private _autoCalcDepthBounds;
  62220. /**
  62221. * Gets or sets the autoCalcDepthBounds property.
  62222. *
  62223. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62224. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62225. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62226. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62227. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62228. */
  62229. get autoCalcDepthBounds(): boolean;
  62230. set autoCalcDepthBounds(value: boolean);
  62231. /**
  62232. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62233. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62234. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62235. * for setting the refresh rate on the renderer yourself!
  62236. */
  62237. get autoCalcDepthBoundsRefreshRate(): number;
  62238. set autoCalcDepthBoundsRefreshRate(value: number);
  62239. /**
  62240. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62241. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62242. * you change the camera near/far planes!
  62243. */
  62244. splitFrustum(): void;
  62245. private _splitFrustum;
  62246. private _computeMatrices;
  62247. private _computeFrustumInWorldSpace;
  62248. private _computeCascadeFrustum;
  62249. /**
  62250. * Support test.
  62251. */
  62252. static get IsSupported(): boolean;
  62253. /** @hidden */
  62254. static _SceneComponentInitialization: (scene: Scene) => void;
  62255. /**
  62256. * Creates a Cascaded Shadow Generator object.
  62257. * A ShadowGenerator is the required tool to use the shadows.
  62258. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62259. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62260. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62261. * @param light The directional light object generating the shadows.
  62262. * @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.
  62263. */
  62264. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62265. protected _initializeGenerator(): void;
  62266. protected _createTargetRenderTexture(): void;
  62267. protected _initializeShadowMap(): void;
  62268. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62269. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62270. /**
  62271. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62272. * @param defines Defines of the material we want to update
  62273. * @param lightIndex Index of the light in the enabled light list of the material
  62274. */
  62275. prepareDefines(defines: any, lightIndex: number): void;
  62276. /**
  62277. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62278. * defined in the generator but impacting the effect).
  62279. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62280. * @param effect The effect we are binfing the information for
  62281. */
  62282. bindShadowLight(lightIndex: string, effect: Effect): void;
  62283. /**
  62284. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62285. * (eq to view projection * shadow projection matrices)
  62286. * @returns The transform matrix used to create the shadow map
  62287. */
  62288. getTransformMatrix(): Matrix;
  62289. /**
  62290. * Disposes the ShadowGenerator.
  62291. * Returns nothing.
  62292. */
  62293. dispose(): void;
  62294. /**
  62295. * Serializes the shadow generator setup to a json object.
  62296. * @returns The serialized JSON object
  62297. */
  62298. serialize(): any;
  62299. /**
  62300. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62301. * @param parsedShadowGenerator The JSON object to parse
  62302. * @param scene The scene to create the shadow map for
  62303. * @returns The parsed shadow generator
  62304. */
  62305. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62306. }
  62307. }
  62308. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62309. import { Scene } from "babylonjs/scene";
  62310. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62311. import { AbstractScene } from "babylonjs/abstractScene";
  62312. /**
  62313. * Defines the shadow generator component responsible to manage any shadow generators
  62314. * in a given scene.
  62315. */
  62316. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62317. /**
  62318. * The component name helpfull to identify the component in the list of scene components.
  62319. */
  62320. readonly name: string;
  62321. /**
  62322. * The scene the component belongs to.
  62323. */
  62324. scene: Scene;
  62325. /**
  62326. * Creates a new instance of the component for the given scene
  62327. * @param scene Defines the scene to register the component in
  62328. */
  62329. constructor(scene: Scene);
  62330. /**
  62331. * Registers the component in a given scene
  62332. */
  62333. register(): void;
  62334. /**
  62335. * Rebuilds the elements related to this component in case of
  62336. * context lost for instance.
  62337. */
  62338. rebuild(): void;
  62339. /**
  62340. * Serializes the component data to the specified json object
  62341. * @param serializationObject The object to serialize to
  62342. */
  62343. serialize(serializationObject: any): void;
  62344. /**
  62345. * Adds all the elements from the container to the scene
  62346. * @param container the container holding the elements
  62347. */
  62348. addFromContainer(container: AbstractScene): void;
  62349. /**
  62350. * Removes all the elements in the container from the scene
  62351. * @param container contains the elements to remove
  62352. * @param dispose if the removed element should be disposed (default: false)
  62353. */
  62354. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62355. /**
  62356. * Rebuilds the elements related to this component in case of
  62357. * context lost for instance.
  62358. */
  62359. dispose(): void;
  62360. private _gatherRenderTargets;
  62361. }
  62362. }
  62363. declare module "babylonjs/Lights/Shadows/index" {
  62364. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62365. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62366. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62367. }
  62368. declare module "babylonjs/Lights/pointLight" {
  62369. import { Scene } from "babylonjs/scene";
  62370. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62372. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62373. import { Effect } from "babylonjs/Materials/effect";
  62374. /**
  62375. * A point light is a light defined by an unique point in world space.
  62376. * The light is emitted in every direction from this point.
  62377. * A good example of a point light is a standard light bulb.
  62378. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62379. */
  62380. export class PointLight extends ShadowLight {
  62381. private _shadowAngle;
  62382. /**
  62383. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62384. * This specifies what angle the shadow will use to be created.
  62385. *
  62386. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62387. */
  62388. get shadowAngle(): number;
  62389. /**
  62390. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62391. * This specifies what angle the shadow will use to be created.
  62392. *
  62393. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62394. */
  62395. set shadowAngle(value: number);
  62396. /**
  62397. * Gets the direction if it has been set.
  62398. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62399. */
  62400. get direction(): Vector3;
  62401. /**
  62402. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62403. */
  62404. set direction(value: Vector3);
  62405. /**
  62406. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62407. * A PointLight emits the light in every direction.
  62408. * It can cast shadows.
  62409. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62410. * ```javascript
  62411. * var pointLight = new PointLight("pl", camera.position, scene);
  62412. * ```
  62413. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62414. * @param name The light friendly name
  62415. * @param position The position of the point light in the scene
  62416. * @param scene The scene the lights belongs to
  62417. */
  62418. constructor(name: string, position: Vector3, scene: Scene);
  62419. /**
  62420. * Returns the string "PointLight"
  62421. * @returns the class name
  62422. */
  62423. getClassName(): string;
  62424. /**
  62425. * Returns the integer 0.
  62426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62427. */
  62428. getTypeID(): number;
  62429. /**
  62430. * Specifies wether or not the shadowmap should be a cube texture.
  62431. * @returns true if the shadowmap needs to be a cube texture.
  62432. */
  62433. needCube(): boolean;
  62434. /**
  62435. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62436. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62437. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62438. */
  62439. getShadowDirection(faceIndex?: number): Vector3;
  62440. /**
  62441. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62442. * - fov = PI / 2
  62443. * - aspect ratio : 1.0
  62444. * - z-near and far equal to the active camera minZ and maxZ.
  62445. * Returns the PointLight.
  62446. */
  62447. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62448. protected _buildUniformLayout(): void;
  62449. /**
  62450. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62451. * @param effect The effect to update
  62452. * @param lightIndex The index of the light in the effect to update
  62453. * @returns The point light
  62454. */
  62455. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62456. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62457. /**
  62458. * Prepares the list of defines specific to the light type.
  62459. * @param defines the list of defines
  62460. * @param lightIndex defines the index of the light for the effect
  62461. */
  62462. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62463. }
  62464. }
  62465. declare module "babylonjs/Lights/index" {
  62466. export * from "babylonjs/Lights/light";
  62467. export * from "babylonjs/Lights/shadowLight";
  62468. export * from "babylonjs/Lights/Shadows/index";
  62469. export * from "babylonjs/Lights/directionalLight";
  62470. export * from "babylonjs/Lights/hemisphericLight";
  62471. export * from "babylonjs/Lights/pointLight";
  62472. export * from "babylonjs/Lights/spotLight";
  62473. }
  62474. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62475. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62476. /**
  62477. * Header information of HDR texture files.
  62478. */
  62479. export interface HDRInfo {
  62480. /**
  62481. * The height of the texture in pixels.
  62482. */
  62483. height: number;
  62484. /**
  62485. * The width of the texture in pixels.
  62486. */
  62487. width: number;
  62488. /**
  62489. * The index of the beginning of the data in the binary file.
  62490. */
  62491. dataPosition: number;
  62492. }
  62493. /**
  62494. * This groups tools to convert HDR texture to native colors array.
  62495. */
  62496. export class HDRTools {
  62497. private static Ldexp;
  62498. private static Rgbe2float;
  62499. private static readStringLine;
  62500. /**
  62501. * Reads header information from an RGBE texture stored in a native array.
  62502. * More information on this format are available here:
  62503. * https://en.wikipedia.org/wiki/RGBE_image_format
  62504. *
  62505. * @param uint8array The binary file stored in native array.
  62506. * @return The header information.
  62507. */
  62508. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62509. /**
  62510. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62511. * This RGBE texture needs to store the information as a panorama.
  62512. *
  62513. * More information on this format are available here:
  62514. * https://en.wikipedia.org/wiki/RGBE_image_format
  62515. *
  62516. * @param buffer The binary file stored in an array buffer.
  62517. * @param size The expected size of the extracted cubemap.
  62518. * @return The Cube Map information.
  62519. */
  62520. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62521. /**
  62522. * Returns the pixels data extracted from an RGBE texture.
  62523. * This pixels will be stored left to right up to down in the R G B order in one array.
  62524. *
  62525. * More information on this format are available here:
  62526. * https://en.wikipedia.org/wiki/RGBE_image_format
  62527. *
  62528. * @param uint8array The binary file stored in an array buffer.
  62529. * @param hdrInfo The header information of the file.
  62530. * @return The pixels data in RGB right to left up to down order.
  62531. */
  62532. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62533. private static RGBE_ReadPixels_RLE;
  62534. private static RGBE_ReadPixels_NOT_RLE;
  62535. }
  62536. }
  62537. declare module "babylonjs/Materials/effectRenderer" {
  62538. import { Nullable } from "babylonjs/types";
  62539. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62540. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62541. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62542. import { Viewport } from "babylonjs/Maths/math.viewport";
  62543. import { Observable } from "babylonjs/Misc/observable";
  62544. import { Effect } from "babylonjs/Materials/effect";
  62545. import "babylonjs/Shaders/postprocess.vertex";
  62546. /**
  62547. * Effect Render Options
  62548. */
  62549. export interface IEffectRendererOptions {
  62550. /**
  62551. * Defines the vertices positions.
  62552. */
  62553. positions?: number[];
  62554. /**
  62555. * Defines the indices.
  62556. */
  62557. indices?: number[];
  62558. }
  62559. /**
  62560. * Helper class to render one or more effects.
  62561. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62562. */
  62563. export class EffectRenderer {
  62564. private engine;
  62565. private static _DefaultOptions;
  62566. private _vertexBuffers;
  62567. private _indexBuffer;
  62568. private _fullscreenViewport;
  62569. /**
  62570. * Creates an effect renderer
  62571. * @param engine the engine to use for rendering
  62572. * @param options defines the options of the effect renderer
  62573. */
  62574. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62575. /**
  62576. * Sets the current viewport in normalized coordinates 0-1
  62577. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62578. */
  62579. setViewport(viewport?: Viewport): void;
  62580. /**
  62581. * Binds the embedded attributes buffer to the effect.
  62582. * @param effect Defines the effect to bind the attributes for
  62583. */
  62584. bindBuffers(effect: Effect): void;
  62585. /**
  62586. * Sets the current effect wrapper to use during draw.
  62587. * The effect needs to be ready before calling this api.
  62588. * This also sets the default full screen position attribute.
  62589. * @param effectWrapper Defines the effect to draw with
  62590. */
  62591. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62592. /**
  62593. * Restores engine states
  62594. */
  62595. restoreStates(): void;
  62596. /**
  62597. * Draws a full screen quad.
  62598. */
  62599. draw(): void;
  62600. private isRenderTargetTexture;
  62601. /**
  62602. * renders one or more effects to a specified texture
  62603. * @param effectWrapper the effect to renderer
  62604. * @param outputTexture texture to draw to, if null it will render to the screen.
  62605. */
  62606. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62607. /**
  62608. * Disposes of the effect renderer
  62609. */
  62610. dispose(): void;
  62611. }
  62612. /**
  62613. * Options to create an EffectWrapper
  62614. */
  62615. interface EffectWrapperCreationOptions {
  62616. /**
  62617. * Engine to use to create the effect
  62618. */
  62619. engine: ThinEngine;
  62620. /**
  62621. * Fragment shader for the effect
  62622. */
  62623. fragmentShader: string;
  62624. /**
  62625. * Use the shader store instead of direct source code
  62626. */
  62627. useShaderStore?: boolean;
  62628. /**
  62629. * Vertex shader for the effect
  62630. */
  62631. vertexShader?: string;
  62632. /**
  62633. * Attributes to use in the shader
  62634. */
  62635. attributeNames?: Array<string>;
  62636. /**
  62637. * Uniforms to use in the shader
  62638. */
  62639. uniformNames?: Array<string>;
  62640. /**
  62641. * Texture sampler names to use in the shader
  62642. */
  62643. samplerNames?: Array<string>;
  62644. /**
  62645. * Defines to use in the shader
  62646. */
  62647. defines?: Array<string>;
  62648. /**
  62649. * Callback when effect is compiled
  62650. */
  62651. onCompiled?: Nullable<(effect: Effect) => void>;
  62652. /**
  62653. * The friendly name of the effect displayed in Spector.
  62654. */
  62655. name?: string;
  62656. }
  62657. /**
  62658. * Wraps an effect to be used for rendering
  62659. */
  62660. export class EffectWrapper {
  62661. /**
  62662. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62663. */
  62664. onApplyObservable: Observable<{}>;
  62665. /**
  62666. * The underlying effect
  62667. */
  62668. effect: Effect;
  62669. /**
  62670. * Creates an effect to be renderer
  62671. * @param creationOptions options to create the effect
  62672. */
  62673. constructor(creationOptions: EffectWrapperCreationOptions);
  62674. /**
  62675. * Disposes of the effect wrapper
  62676. */
  62677. dispose(): void;
  62678. }
  62679. }
  62680. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  62681. /** @hidden */
  62682. export var hdrFilteringVertexShader: {
  62683. name: string;
  62684. shader: string;
  62685. };
  62686. }
  62687. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  62688. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62689. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  62690. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  62691. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  62692. /** @hidden */
  62693. export var hdrFilteringPixelShader: {
  62694. name: string;
  62695. shader: string;
  62696. };
  62697. }
  62698. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  62699. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62700. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62701. import { Nullable } from "babylonjs/types";
  62702. import "babylonjs/Shaders/hdrFiltering.vertex";
  62703. import "babylonjs/Shaders/hdrFiltering.fragment";
  62704. /**
  62705. * Options for texture filtering
  62706. */
  62707. interface IHDRFilteringOptions {
  62708. /**
  62709. * Scales pixel intensity for the input HDR map.
  62710. */
  62711. hdrScale?: number;
  62712. /**
  62713. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  62714. */
  62715. quality?: number;
  62716. }
  62717. /**
  62718. * Filters HDR maps to get correct renderings of PBR reflections
  62719. */
  62720. export class HDRFiltering {
  62721. private _engine;
  62722. private _effectRenderer;
  62723. private _effectWrapper;
  62724. private _lodGenerationOffset;
  62725. private _lodGenerationScale;
  62726. /**
  62727. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  62728. * you care about baking speed.
  62729. */
  62730. quality: number;
  62731. /**
  62732. * Scales pixel intensity for the input HDR map.
  62733. */
  62734. hdrScale: number;
  62735. /**
  62736. * Instantiates HDR filter for reflection maps
  62737. *
  62738. * @param engine Thin engine
  62739. * @param options Options
  62740. */
  62741. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  62742. private _createRenderTarget;
  62743. private _prefilterInternal;
  62744. private _createEffect;
  62745. /**
  62746. * Get a value indicating if the filter is ready to be used
  62747. * @param texture Texture to filter
  62748. * @returns true if the filter is ready
  62749. */
  62750. isReady(texture: BaseTexture): boolean;
  62751. /**
  62752. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62753. * Prefiltering will be invoked at the end of next rendering pass.
  62754. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62755. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62756. * @param texture Texture to filter
  62757. * @param onFinished Callback when filtering is done
  62758. * @return Promise called when prefiltering is done
  62759. */
  62760. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  62761. }
  62762. }
  62763. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  62764. import { Nullable } from "babylonjs/types";
  62765. import { Scene } from "babylonjs/scene";
  62766. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62767. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62768. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62769. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62770. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62771. /**
  62772. * This represents a texture coming from an HDR input.
  62773. *
  62774. * The only supported format is currently panorama picture stored in RGBE format.
  62775. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62776. */
  62777. export class HDRCubeTexture extends BaseTexture {
  62778. private static _facesMapping;
  62779. private _generateHarmonics;
  62780. private _noMipmap;
  62781. private _prefilterOnLoad;
  62782. private _textureMatrix;
  62783. private _size;
  62784. private _onLoad;
  62785. private _onError;
  62786. /**
  62787. * The texture URL.
  62788. */
  62789. url: string;
  62790. /**
  62791. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62792. */
  62793. coordinatesMode: number;
  62794. protected _isBlocking: boolean;
  62795. /**
  62796. * Sets wether or not the texture is blocking during loading.
  62797. */
  62798. set isBlocking(value: boolean);
  62799. /**
  62800. * Gets wether or not the texture is blocking during loading.
  62801. */
  62802. get isBlocking(): boolean;
  62803. protected _rotationY: number;
  62804. /**
  62805. * Sets texture matrix rotation angle around Y axis in radians.
  62806. */
  62807. set rotationY(value: number);
  62808. /**
  62809. * Gets texture matrix rotation angle around Y axis radians.
  62810. */
  62811. get rotationY(): number;
  62812. /**
  62813. * Gets or sets the center of the bounding box associated with the cube texture
  62814. * It must define where the camera used to render the texture was set
  62815. */
  62816. boundingBoxPosition: Vector3;
  62817. private _boundingBoxSize;
  62818. /**
  62819. * Gets or sets the size of the bounding box associated with the cube texture
  62820. * When defined, the cubemap will switch to local mode
  62821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62822. * @example https://www.babylonjs-playground.com/#RNASML
  62823. */
  62824. set boundingBoxSize(value: Vector3);
  62825. get boundingBoxSize(): Vector3;
  62826. /**
  62827. * Instantiates an HDRTexture from the following parameters.
  62828. *
  62829. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62830. * @param sceneOrEngine The scene or engine the texture will be used in
  62831. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62832. * @param noMipmap Forces to not generate the mipmap if true
  62833. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62834. * @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)
  62835. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62836. */
  62837. 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>);
  62838. /**
  62839. * Get the current class name of the texture useful for serialization or dynamic coding.
  62840. * @returns "HDRCubeTexture"
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Occurs when the file is raw .hdr file.
  62845. */
  62846. private loadTexture;
  62847. clone(): HDRCubeTexture;
  62848. delayLoad(): void;
  62849. /**
  62850. * Get the texture reflection matrix used to rotate/transform the reflection.
  62851. * @returns the reflection matrix
  62852. */
  62853. getReflectionTextureMatrix(): Matrix;
  62854. /**
  62855. * Set the texture reflection matrix used to rotate/transform the reflection.
  62856. * @param value Define the reflection matrix to set
  62857. */
  62858. setReflectionTextureMatrix(value: Matrix): void;
  62859. /**
  62860. * Parses a JSON representation of an HDR Texture in order to create the texture
  62861. * @param parsedTexture Define the JSON representation
  62862. * @param scene Define the scene the texture should be created in
  62863. * @param rootUrl Define the root url in case we need to load relative dependencies
  62864. * @returns the newly created texture after parsing
  62865. */
  62866. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62867. serialize(): any;
  62868. }
  62869. }
  62870. declare module "babylonjs/Physics/physicsEngine" {
  62871. import { Nullable } from "babylonjs/types";
  62872. import { Vector3 } from "babylonjs/Maths/math.vector";
  62873. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62874. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62875. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62876. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62877. /**
  62878. * Class used to control physics engine
  62879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62880. */
  62881. export class PhysicsEngine implements IPhysicsEngine {
  62882. private _physicsPlugin;
  62883. /**
  62884. * Global value used to control the smallest number supported by the simulation
  62885. */
  62886. static Epsilon: number;
  62887. private _impostors;
  62888. private _joints;
  62889. private _subTimeStep;
  62890. /**
  62891. * Gets the gravity vector used by the simulation
  62892. */
  62893. gravity: Vector3;
  62894. /**
  62895. * Factory used to create the default physics plugin.
  62896. * @returns The default physics plugin
  62897. */
  62898. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62899. /**
  62900. * Creates a new Physics Engine
  62901. * @param gravity defines the gravity vector used by the simulation
  62902. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62903. */
  62904. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62905. /**
  62906. * Sets the gravity vector used by the simulation
  62907. * @param gravity defines the gravity vector to use
  62908. */
  62909. setGravity(gravity: Vector3): void;
  62910. /**
  62911. * Set the time step of the physics engine.
  62912. * Default is 1/60.
  62913. * To slow it down, enter 1/600 for example.
  62914. * To speed it up, 1/30
  62915. * @param newTimeStep defines the new timestep to apply to this world.
  62916. */
  62917. setTimeStep(newTimeStep?: number): void;
  62918. /**
  62919. * Get the time step of the physics engine.
  62920. * @returns the current time step
  62921. */
  62922. getTimeStep(): number;
  62923. /**
  62924. * Set the sub time step of the physics engine.
  62925. * Default is 0 meaning there is no sub steps
  62926. * To increase physics resolution precision, set a small value (like 1 ms)
  62927. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62928. */
  62929. setSubTimeStep(subTimeStep?: number): void;
  62930. /**
  62931. * Get the sub time step of the physics engine.
  62932. * @returns the current sub time step
  62933. */
  62934. getSubTimeStep(): number;
  62935. /**
  62936. * Release all resources
  62937. */
  62938. dispose(): void;
  62939. /**
  62940. * Gets the name of the current physics plugin
  62941. * @returns the name of the plugin
  62942. */
  62943. getPhysicsPluginName(): string;
  62944. /**
  62945. * Adding a new impostor for the impostor tracking.
  62946. * This will be done by the impostor itself.
  62947. * @param impostor the impostor to add
  62948. */
  62949. addImpostor(impostor: PhysicsImpostor): void;
  62950. /**
  62951. * Remove an impostor from the engine.
  62952. * This impostor and its mesh will not longer be updated by the physics engine.
  62953. * @param impostor the impostor to remove
  62954. */
  62955. removeImpostor(impostor: PhysicsImpostor): void;
  62956. /**
  62957. * Add a joint to the physics engine
  62958. * @param mainImpostor defines the main impostor to which the joint is added.
  62959. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62960. * @param joint defines the joint that will connect both impostors.
  62961. */
  62962. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62963. /**
  62964. * Removes a joint from the simulation
  62965. * @param mainImpostor defines the impostor used with the joint
  62966. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62967. * @param joint defines the joint to remove
  62968. */
  62969. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62970. /**
  62971. * Called by the scene. No need to call it.
  62972. * @param delta defines the timespam between frames
  62973. */
  62974. _step(delta: number): void;
  62975. /**
  62976. * Gets the current plugin used to run the simulation
  62977. * @returns current plugin
  62978. */
  62979. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62980. /**
  62981. * Gets the list of physic impostors
  62982. * @returns an array of PhysicsImpostor
  62983. */
  62984. getImpostors(): Array<PhysicsImpostor>;
  62985. /**
  62986. * Gets the impostor for a physics enabled object
  62987. * @param object defines the object impersonated by the impostor
  62988. * @returns the PhysicsImpostor or null if not found
  62989. */
  62990. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62991. /**
  62992. * Gets the impostor for a physics body object
  62993. * @param body defines physics body used by the impostor
  62994. * @returns the PhysicsImpostor or null if not found
  62995. */
  62996. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62997. /**
  62998. * Does a raycast in the physics world
  62999. * @param from when should the ray start?
  63000. * @param to when should the ray end?
  63001. * @returns PhysicsRaycastResult
  63002. */
  63003. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63004. }
  63005. }
  63006. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63007. import { Nullable } from "babylonjs/types";
  63008. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63010. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63011. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63012. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63013. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63014. /** @hidden */
  63015. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63016. private _useDeltaForWorldStep;
  63017. world: any;
  63018. name: string;
  63019. private _physicsMaterials;
  63020. private _fixedTimeStep;
  63021. private _cannonRaycastResult;
  63022. private _raycastResult;
  63023. private _physicsBodysToRemoveAfterStep;
  63024. private _firstFrame;
  63025. BJSCANNON: any;
  63026. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63027. setGravity(gravity: Vector3): void;
  63028. setTimeStep(timeStep: number): void;
  63029. getTimeStep(): number;
  63030. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63031. private _removeMarkedPhysicsBodiesFromWorld;
  63032. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63033. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63034. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63035. private _processChildMeshes;
  63036. removePhysicsBody(impostor: PhysicsImpostor): void;
  63037. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63038. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63039. private _addMaterial;
  63040. private _checkWithEpsilon;
  63041. private _createShape;
  63042. private _createHeightmap;
  63043. private _minus90X;
  63044. private _plus90X;
  63045. private _tmpPosition;
  63046. private _tmpDeltaPosition;
  63047. private _tmpUnityRotation;
  63048. private _updatePhysicsBodyTransformation;
  63049. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63050. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63051. isSupported(): boolean;
  63052. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63053. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63054. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63055. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63056. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63057. getBodyMass(impostor: PhysicsImpostor): number;
  63058. getBodyFriction(impostor: PhysicsImpostor): number;
  63059. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63060. getBodyRestitution(impostor: PhysicsImpostor): number;
  63061. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63062. sleepBody(impostor: PhysicsImpostor): void;
  63063. wakeUpBody(impostor: PhysicsImpostor): void;
  63064. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63065. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63066. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63067. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63068. getRadius(impostor: PhysicsImpostor): number;
  63069. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63070. dispose(): void;
  63071. private _extendNamespace;
  63072. /**
  63073. * Does a raycast in the physics world
  63074. * @param from when should the ray start?
  63075. * @param to when should the ray end?
  63076. * @returns PhysicsRaycastResult
  63077. */
  63078. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63079. }
  63080. }
  63081. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63082. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63083. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63084. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63086. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63087. import { Nullable } from "babylonjs/types";
  63088. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63089. /** @hidden */
  63090. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63091. private _useDeltaForWorldStep;
  63092. world: any;
  63093. name: string;
  63094. BJSOIMO: any;
  63095. private _raycastResult;
  63096. private _fixedTimeStep;
  63097. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63098. setGravity(gravity: Vector3): void;
  63099. setTimeStep(timeStep: number): void;
  63100. getTimeStep(): number;
  63101. private _tmpImpostorsArray;
  63102. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63103. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63104. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63105. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63106. private _tmpPositionVector;
  63107. removePhysicsBody(impostor: PhysicsImpostor): void;
  63108. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63109. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63110. isSupported(): boolean;
  63111. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63112. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63113. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63114. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63115. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63116. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63117. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63118. getBodyMass(impostor: PhysicsImpostor): number;
  63119. getBodyFriction(impostor: PhysicsImpostor): number;
  63120. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63121. getBodyRestitution(impostor: PhysicsImpostor): number;
  63122. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63123. sleepBody(impostor: PhysicsImpostor): void;
  63124. wakeUpBody(impostor: PhysicsImpostor): void;
  63125. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63126. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63127. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63129. getRadius(impostor: PhysicsImpostor): number;
  63130. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63131. dispose(): void;
  63132. /**
  63133. * Does a raycast in the physics world
  63134. * @param from when should the ray start?
  63135. * @param to when should the ray end?
  63136. * @returns PhysicsRaycastResult
  63137. */
  63138. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63139. }
  63140. }
  63141. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63142. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63143. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63144. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63145. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63146. import { Nullable } from "babylonjs/types";
  63147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63148. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63149. /**
  63150. * AmmoJS Physics plugin
  63151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63152. * @see https://github.com/kripken/ammo.js/
  63153. */
  63154. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63155. private _useDeltaForWorldStep;
  63156. /**
  63157. * Reference to the Ammo library
  63158. */
  63159. bjsAMMO: any;
  63160. /**
  63161. * Created ammoJS world which physics bodies are added to
  63162. */
  63163. world: any;
  63164. /**
  63165. * Name of the plugin
  63166. */
  63167. name: string;
  63168. private _timeStep;
  63169. private _fixedTimeStep;
  63170. private _maxSteps;
  63171. private _tmpQuaternion;
  63172. private _tmpAmmoTransform;
  63173. private _tmpAmmoQuaternion;
  63174. private _tmpAmmoConcreteContactResultCallback;
  63175. private _collisionConfiguration;
  63176. private _dispatcher;
  63177. private _overlappingPairCache;
  63178. private _solver;
  63179. private _softBodySolver;
  63180. private _tmpAmmoVectorA;
  63181. private _tmpAmmoVectorB;
  63182. private _tmpAmmoVectorC;
  63183. private _tmpAmmoVectorD;
  63184. private _tmpContactCallbackResult;
  63185. private _tmpAmmoVectorRCA;
  63186. private _tmpAmmoVectorRCB;
  63187. private _raycastResult;
  63188. private static readonly DISABLE_COLLISION_FLAG;
  63189. private static readonly KINEMATIC_FLAG;
  63190. private static readonly DISABLE_DEACTIVATION_FLAG;
  63191. /**
  63192. * Initializes the ammoJS plugin
  63193. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63194. * @param ammoInjection can be used to inject your own ammo reference
  63195. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63196. */
  63197. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63198. /**
  63199. * Sets the gravity of the physics world (m/(s^2))
  63200. * @param gravity Gravity to set
  63201. */
  63202. setGravity(gravity: Vector3): void;
  63203. /**
  63204. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63205. * @param timeStep timestep to use in seconds
  63206. */
  63207. setTimeStep(timeStep: number): void;
  63208. /**
  63209. * 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)
  63210. * @param fixedTimeStep fixedTimeStep to use in seconds
  63211. */
  63212. setFixedTimeStep(fixedTimeStep: number): void;
  63213. /**
  63214. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63215. * @param maxSteps the maximum number of steps by the physics engine per frame
  63216. */
  63217. setMaxSteps(maxSteps: number): void;
  63218. /**
  63219. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63220. * @returns the current timestep in seconds
  63221. */
  63222. getTimeStep(): number;
  63223. /**
  63224. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63225. */
  63226. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63227. private _isImpostorInContact;
  63228. private _isImpostorPairInContact;
  63229. private _stepSimulation;
  63230. /**
  63231. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63232. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63233. * After the step the babylon meshes are set to the position of the physics imposters
  63234. * @param delta amount of time to step forward
  63235. * @param impostors array of imposters to update before/after the step
  63236. */
  63237. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63238. /**
  63239. * Update babylon mesh to match physics world object
  63240. * @param impostor imposter to match
  63241. */
  63242. private _afterSoftStep;
  63243. /**
  63244. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63245. * @param impostor imposter to match
  63246. */
  63247. private _ropeStep;
  63248. /**
  63249. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63250. * @param impostor imposter to match
  63251. */
  63252. private _softbodyOrClothStep;
  63253. private _tmpMatrix;
  63254. /**
  63255. * Applies an impulse on the imposter
  63256. * @param impostor imposter to apply impulse to
  63257. * @param force amount of force to be applied to the imposter
  63258. * @param contactPoint the location to apply the impulse on the imposter
  63259. */
  63260. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63261. /**
  63262. * Applies a force on the imposter
  63263. * @param impostor imposter to apply force
  63264. * @param force amount of force to be applied to the imposter
  63265. * @param contactPoint the location to apply the force on the imposter
  63266. */
  63267. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63268. /**
  63269. * Creates a physics body using the plugin
  63270. * @param impostor the imposter to create the physics body on
  63271. */
  63272. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63273. /**
  63274. * Removes the physics body from the imposter and disposes of the body's memory
  63275. * @param impostor imposter to remove the physics body from
  63276. */
  63277. removePhysicsBody(impostor: PhysicsImpostor): void;
  63278. /**
  63279. * Generates a joint
  63280. * @param impostorJoint the imposter joint to create the joint with
  63281. */
  63282. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63283. /**
  63284. * Removes a joint
  63285. * @param impostorJoint the imposter joint to remove the joint from
  63286. */
  63287. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63288. private _addMeshVerts;
  63289. /**
  63290. * Initialise the soft body vertices to match its object's (mesh) vertices
  63291. * Softbody vertices (nodes) are in world space and to match this
  63292. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63293. * @param impostor to create the softbody for
  63294. */
  63295. private _softVertexData;
  63296. /**
  63297. * Create an impostor's soft body
  63298. * @param impostor to create the softbody for
  63299. */
  63300. private _createSoftbody;
  63301. /**
  63302. * Create cloth for an impostor
  63303. * @param impostor to create the softbody for
  63304. */
  63305. private _createCloth;
  63306. /**
  63307. * Create rope for an impostor
  63308. * @param impostor to create the softbody for
  63309. */
  63310. private _createRope;
  63311. /**
  63312. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63313. * @param impostor to create the custom physics shape for
  63314. */
  63315. private _createCustom;
  63316. private _addHullVerts;
  63317. private _createShape;
  63318. /**
  63319. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63320. * @param impostor imposter containing the physics body and babylon object
  63321. */
  63322. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63323. /**
  63324. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63325. * @param impostor imposter containing the physics body and babylon object
  63326. * @param newPosition new position
  63327. * @param newRotation new rotation
  63328. */
  63329. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63330. /**
  63331. * If this plugin is supported
  63332. * @returns true if its supported
  63333. */
  63334. isSupported(): boolean;
  63335. /**
  63336. * Sets the linear velocity of the physics body
  63337. * @param impostor imposter to set the velocity on
  63338. * @param velocity velocity to set
  63339. */
  63340. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63341. /**
  63342. * Sets the angular velocity of the physics body
  63343. * @param impostor imposter to set the velocity on
  63344. * @param velocity velocity to set
  63345. */
  63346. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63347. /**
  63348. * gets the linear velocity
  63349. * @param impostor imposter to get linear velocity from
  63350. * @returns linear velocity
  63351. */
  63352. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63353. /**
  63354. * gets the angular velocity
  63355. * @param impostor imposter to get angular velocity from
  63356. * @returns angular velocity
  63357. */
  63358. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63359. /**
  63360. * Sets the mass of physics body
  63361. * @param impostor imposter to set the mass on
  63362. * @param mass mass to set
  63363. */
  63364. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63365. /**
  63366. * Gets the mass of the physics body
  63367. * @param impostor imposter to get the mass from
  63368. * @returns mass
  63369. */
  63370. getBodyMass(impostor: PhysicsImpostor): number;
  63371. /**
  63372. * Gets friction of the impostor
  63373. * @param impostor impostor to get friction from
  63374. * @returns friction value
  63375. */
  63376. getBodyFriction(impostor: PhysicsImpostor): number;
  63377. /**
  63378. * Sets friction of the impostor
  63379. * @param impostor impostor to set friction on
  63380. * @param friction friction value
  63381. */
  63382. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63383. /**
  63384. * Gets restitution of the impostor
  63385. * @param impostor impostor to get restitution from
  63386. * @returns restitution value
  63387. */
  63388. getBodyRestitution(impostor: PhysicsImpostor): number;
  63389. /**
  63390. * Sets resitution of the impostor
  63391. * @param impostor impostor to set resitution on
  63392. * @param restitution resitution value
  63393. */
  63394. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63395. /**
  63396. * Gets pressure inside the impostor
  63397. * @param impostor impostor to get pressure from
  63398. * @returns pressure value
  63399. */
  63400. getBodyPressure(impostor: PhysicsImpostor): number;
  63401. /**
  63402. * Sets pressure inside a soft body impostor
  63403. * Cloth and rope must remain 0 pressure
  63404. * @param impostor impostor to set pressure on
  63405. * @param pressure pressure value
  63406. */
  63407. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63408. /**
  63409. * Gets stiffness of the impostor
  63410. * @param impostor impostor to get stiffness from
  63411. * @returns pressure value
  63412. */
  63413. getBodyStiffness(impostor: PhysicsImpostor): number;
  63414. /**
  63415. * Sets stiffness of the impostor
  63416. * @param impostor impostor to set stiffness on
  63417. * @param stiffness stiffness value from 0 to 1
  63418. */
  63419. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63420. /**
  63421. * Gets velocityIterations of the impostor
  63422. * @param impostor impostor to get velocity iterations from
  63423. * @returns velocityIterations value
  63424. */
  63425. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63426. /**
  63427. * Sets velocityIterations of the impostor
  63428. * @param impostor impostor to set velocity iterations on
  63429. * @param velocityIterations velocityIterations value
  63430. */
  63431. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63432. /**
  63433. * Gets positionIterations of the impostor
  63434. * @param impostor impostor to get position iterations from
  63435. * @returns positionIterations value
  63436. */
  63437. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63438. /**
  63439. * Sets positionIterations of the impostor
  63440. * @param impostor impostor to set position on
  63441. * @param positionIterations positionIterations value
  63442. */
  63443. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63444. /**
  63445. * Append an anchor to a cloth object
  63446. * @param impostor is the cloth impostor to add anchor to
  63447. * @param otherImpostor is the rigid impostor to anchor to
  63448. * @param width ratio across width from 0 to 1
  63449. * @param height ratio up height from 0 to 1
  63450. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63451. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63452. */
  63453. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63454. /**
  63455. * Append an hook to a rope object
  63456. * @param impostor is the rope impostor to add hook to
  63457. * @param otherImpostor is the rigid impostor to hook to
  63458. * @param length ratio along the rope from 0 to 1
  63459. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63460. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63461. */
  63462. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63463. /**
  63464. * Sleeps the physics body and stops it from being active
  63465. * @param impostor impostor to sleep
  63466. */
  63467. sleepBody(impostor: PhysicsImpostor): void;
  63468. /**
  63469. * Activates the physics body
  63470. * @param impostor impostor to activate
  63471. */
  63472. wakeUpBody(impostor: PhysicsImpostor): void;
  63473. /**
  63474. * Updates the distance parameters of the joint
  63475. * @param joint joint to update
  63476. * @param maxDistance maximum distance of the joint
  63477. * @param minDistance minimum distance of the joint
  63478. */
  63479. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63480. /**
  63481. * Sets a motor on the joint
  63482. * @param joint joint to set motor on
  63483. * @param speed speed of the motor
  63484. * @param maxForce maximum force of the motor
  63485. * @param motorIndex index of the motor
  63486. */
  63487. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63488. /**
  63489. * Sets the motors limit
  63490. * @param joint joint to set limit on
  63491. * @param upperLimit upper limit
  63492. * @param lowerLimit lower limit
  63493. */
  63494. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63495. /**
  63496. * Syncs the position and rotation of a mesh with the impostor
  63497. * @param mesh mesh to sync
  63498. * @param impostor impostor to update the mesh with
  63499. */
  63500. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63501. /**
  63502. * Gets the radius of the impostor
  63503. * @param impostor impostor to get radius from
  63504. * @returns the radius
  63505. */
  63506. getRadius(impostor: PhysicsImpostor): number;
  63507. /**
  63508. * Gets the box size of the impostor
  63509. * @param impostor impostor to get box size from
  63510. * @param result the resulting box size
  63511. */
  63512. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63513. /**
  63514. * Disposes of the impostor
  63515. */
  63516. dispose(): void;
  63517. /**
  63518. * Does a raycast in the physics world
  63519. * @param from when should the ray start?
  63520. * @param to when should the ray end?
  63521. * @returns PhysicsRaycastResult
  63522. */
  63523. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63524. }
  63525. }
  63526. declare module "babylonjs/Probes/reflectionProbe" {
  63527. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63528. import { Vector3 } from "babylonjs/Maths/math.vector";
  63529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63530. import { Nullable } from "babylonjs/types";
  63531. import { Scene } from "babylonjs/scene";
  63532. module "babylonjs/abstractScene" {
  63533. interface AbstractScene {
  63534. /**
  63535. * The list of reflection probes added to the scene
  63536. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63537. */
  63538. reflectionProbes: Array<ReflectionProbe>;
  63539. /**
  63540. * Removes the given reflection probe from this scene.
  63541. * @param toRemove The reflection probe to remove
  63542. * @returns The index of the removed reflection probe
  63543. */
  63544. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63545. /**
  63546. * Adds the given reflection probe to this scene.
  63547. * @param newReflectionProbe The reflection probe to add
  63548. */
  63549. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63550. }
  63551. }
  63552. /**
  63553. * Class used to generate realtime reflection / refraction cube textures
  63554. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63555. */
  63556. export class ReflectionProbe {
  63557. /** defines the name of the probe */
  63558. name: string;
  63559. private _scene;
  63560. private _renderTargetTexture;
  63561. private _projectionMatrix;
  63562. private _viewMatrix;
  63563. private _target;
  63564. private _add;
  63565. private _attachedMesh;
  63566. private _invertYAxis;
  63567. /** Gets or sets probe position (center of the cube map) */
  63568. position: Vector3;
  63569. /**
  63570. * Creates a new reflection probe
  63571. * @param name defines the name of the probe
  63572. * @param size defines the texture resolution (for each face)
  63573. * @param scene defines the hosting scene
  63574. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  63575. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  63576. */
  63577. constructor(
  63578. /** defines the name of the probe */
  63579. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  63580. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  63581. get samples(): number;
  63582. set samples(value: number);
  63583. /** Gets or sets the refresh rate to use (on every frame by default) */
  63584. get refreshRate(): number;
  63585. set refreshRate(value: number);
  63586. /**
  63587. * Gets the hosting scene
  63588. * @returns a Scene
  63589. */
  63590. getScene(): Scene;
  63591. /** Gets the internal CubeTexture used to render to */
  63592. get cubeTexture(): RenderTargetTexture;
  63593. /** Gets the list of meshes to render */
  63594. get renderList(): Nullable<AbstractMesh[]>;
  63595. /**
  63596. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  63597. * @param mesh defines the mesh to attach to
  63598. */
  63599. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  63600. /**
  63601. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  63602. * @param renderingGroupId The rendering group id corresponding to its index
  63603. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  63604. */
  63605. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  63606. /**
  63607. * Clean all associated resources
  63608. */
  63609. dispose(): void;
  63610. /**
  63611. * Converts the reflection probe information to a readable string for debug purpose.
  63612. * @param fullDetails Supports for multiple levels of logging within scene loading
  63613. * @returns the human readable reflection probe info
  63614. */
  63615. toString(fullDetails?: boolean): string;
  63616. /**
  63617. * Get the class name of the relfection probe.
  63618. * @returns "ReflectionProbe"
  63619. */
  63620. getClassName(): string;
  63621. /**
  63622. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  63623. * @returns The JSON representation of the texture
  63624. */
  63625. serialize(): any;
  63626. /**
  63627. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  63628. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  63629. * @param scene Define the scene the parsed reflection probe should be instantiated in
  63630. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  63631. * @returns The parsed reflection probe if successful
  63632. */
  63633. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63634. }
  63635. }
  63636. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63637. /** @hidden */
  63638. export var _BabylonLoaderRegistered: boolean;
  63639. /**
  63640. * Helps setting up some configuration for the babylon file loader.
  63641. */
  63642. export class BabylonFileLoaderConfiguration {
  63643. /**
  63644. * The loader does not allow injecting custom physix engine into the plugins.
  63645. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63646. * So you could set this variable to your engine import to make it work.
  63647. */
  63648. static LoaderInjectedPhysicsEngine: any;
  63649. }
  63650. }
  63651. declare module "babylonjs/Loading/Plugins/index" {
  63652. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63653. }
  63654. declare module "babylonjs/Loading/index" {
  63655. export * from "babylonjs/Loading/loadingScreen";
  63656. export * from "babylonjs/Loading/Plugins/index";
  63657. export * from "babylonjs/Loading/sceneLoader";
  63658. export * from "babylonjs/Loading/sceneLoaderFlags";
  63659. }
  63660. declare module "babylonjs/Materials/Background/index" {
  63661. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63662. }
  63663. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63664. import { Scene } from "babylonjs/scene";
  63665. import { Color3 } from "babylonjs/Maths/math.color";
  63666. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63667. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63668. /**
  63669. * The Physically based simple base material of BJS.
  63670. *
  63671. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63672. * It is used as the base class for both the specGloss and metalRough conventions.
  63673. */
  63674. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63675. /**
  63676. * Number of Simultaneous lights allowed on the material.
  63677. */
  63678. maxSimultaneousLights: number;
  63679. /**
  63680. * If sets to true, disables all the lights affecting the material.
  63681. */
  63682. disableLighting: boolean;
  63683. /**
  63684. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63685. */
  63686. environmentTexture: BaseTexture;
  63687. /**
  63688. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63689. */
  63690. invertNormalMapX: boolean;
  63691. /**
  63692. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63693. */
  63694. invertNormalMapY: boolean;
  63695. /**
  63696. * Normal map used in the model.
  63697. */
  63698. normalTexture: BaseTexture;
  63699. /**
  63700. * Emissivie color used to self-illuminate the model.
  63701. */
  63702. emissiveColor: Color3;
  63703. /**
  63704. * Emissivie texture used to self-illuminate the model.
  63705. */
  63706. emissiveTexture: BaseTexture;
  63707. /**
  63708. * Occlusion Channel Strenght.
  63709. */
  63710. occlusionStrength: number;
  63711. /**
  63712. * Occlusion Texture of the material (adding extra occlusion effects).
  63713. */
  63714. occlusionTexture: BaseTexture;
  63715. /**
  63716. * Defines the alpha limits in alpha test mode.
  63717. */
  63718. alphaCutOff: number;
  63719. /**
  63720. * Gets the current double sided mode.
  63721. */
  63722. get doubleSided(): boolean;
  63723. /**
  63724. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63725. */
  63726. set doubleSided(value: boolean);
  63727. /**
  63728. * Stores the pre-calculated light information of a mesh in a texture.
  63729. */
  63730. lightmapTexture: BaseTexture;
  63731. /**
  63732. * If true, the light map contains occlusion information instead of lighting info.
  63733. */
  63734. useLightmapAsShadowmap: boolean;
  63735. /**
  63736. * Instantiates a new PBRMaterial instance.
  63737. *
  63738. * @param name The material name
  63739. * @param scene The scene the material will be use in.
  63740. */
  63741. constructor(name: string, scene: Scene);
  63742. getClassName(): string;
  63743. }
  63744. }
  63745. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63746. import { Scene } from "babylonjs/scene";
  63747. import { Color3 } from "babylonjs/Maths/math.color";
  63748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63749. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63750. /**
  63751. * The PBR material of BJS following the metal roughness convention.
  63752. *
  63753. * This fits to the PBR convention in the GLTF definition:
  63754. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63755. */
  63756. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63757. /**
  63758. * The base color has two different interpretations depending on the value of metalness.
  63759. * When the material is a metal, the base color is the specific measured reflectance value
  63760. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63761. * of the material.
  63762. */
  63763. baseColor: Color3;
  63764. /**
  63765. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63766. * well as opacity information in the alpha channel.
  63767. */
  63768. baseTexture: BaseTexture;
  63769. /**
  63770. * Specifies the metallic scalar value of the material.
  63771. * Can also be used to scale the metalness values of the metallic texture.
  63772. */
  63773. metallic: number;
  63774. /**
  63775. * Specifies the roughness scalar value of the material.
  63776. * Can also be used to scale the roughness values of the metallic texture.
  63777. */
  63778. roughness: number;
  63779. /**
  63780. * Texture containing both the metallic value in the B channel and the
  63781. * roughness value in the G channel to keep better precision.
  63782. */
  63783. metallicRoughnessTexture: BaseTexture;
  63784. /**
  63785. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63786. *
  63787. * @param name The material name
  63788. * @param scene The scene the material will be use in.
  63789. */
  63790. constructor(name: string, scene: Scene);
  63791. /**
  63792. * Return the currrent class name of the material.
  63793. */
  63794. getClassName(): string;
  63795. /**
  63796. * Makes a duplicate of the current material.
  63797. * @param name - name to use for the new material.
  63798. */
  63799. clone(name: string): PBRMetallicRoughnessMaterial;
  63800. /**
  63801. * Serialize the material to a parsable JSON object.
  63802. */
  63803. serialize(): any;
  63804. /**
  63805. * Parses a JSON object correponding to the serialize function.
  63806. */
  63807. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63808. }
  63809. }
  63810. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63811. import { Scene } from "babylonjs/scene";
  63812. import { Color3 } from "babylonjs/Maths/math.color";
  63813. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63814. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63815. /**
  63816. * The PBR material of BJS following the specular glossiness convention.
  63817. *
  63818. * This fits to the PBR convention in the GLTF definition:
  63819. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63820. */
  63821. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63822. /**
  63823. * Specifies the diffuse color of the material.
  63824. */
  63825. diffuseColor: Color3;
  63826. /**
  63827. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63828. * channel.
  63829. */
  63830. diffuseTexture: BaseTexture;
  63831. /**
  63832. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63833. */
  63834. specularColor: Color3;
  63835. /**
  63836. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63837. */
  63838. glossiness: number;
  63839. /**
  63840. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63841. */
  63842. specularGlossinessTexture: BaseTexture;
  63843. /**
  63844. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63845. *
  63846. * @param name The material name
  63847. * @param scene The scene the material will be use in.
  63848. */
  63849. constructor(name: string, scene: Scene);
  63850. /**
  63851. * Return the currrent class name of the material.
  63852. */
  63853. getClassName(): string;
  63854. /**
  63855. * Makes a duplicate of the current material.
  63856. * @param name - name to use for the new material.
  63857. */
  63858. clone(name: string): PBRSpecularGlossinessMaterial;
  63859. /**
  63860. * Serialize the material to a parsable JSON object.
  63861. */
  63862. serialize(): any;
  63863. /**
  63864. * Parses a JSON object correponding to the serialize function.
  63865. */
  63866. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63867. }
  63868. }
  63869. declare module "babylonjs/Materials/PBR/index" {
  63870. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63871. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63872. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63873. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63874. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63875. }
  63876. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63877. import { Nullable } from "babylonjs/types";
  63878. import { Scene } from "babylonjs/scene";
  63879. import { Matrix } from "babylonjs/Maths/math.vector";
  63880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63881. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63882. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63883. /**
  63884. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63885. * It can help converting any input color in a desired output one. This can then be used to create effects
  63886. * from sepia, black and white to sixties or futuristic rendering...
  63887. *
  63888. * The only supported format is currently 3dl.
  63889. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63890. */
  63891. export class ColorGradingTexture extends BaseTexture {
  63892. /**
  63893. * The texture URL.
  63894. */
  63895. url: string;
  63896. /**
  63897. * Empty line regex stored for GC.
  63898. */
  63899. private static _noneEmptyLineRegex;
  63900. private _textureMatrix;
  63901. private _onLoad;
  63902. /**
  63903. * Instantiates a ColorGradingTexture from the following parameters.
  63904. *
  63905. * @param url The location of the color gradind data (currently only supporting 3dl)
  63906. * @param sceneOrEngine The scene or engine the texture will be used in
  63907. * @param onLoad defines a callback triggered when the texture has been loaded
  63908. */
  63909. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63910. /**
  63911. * Fires the onload event from the constructor if requested.
  63912. */
  63913. private _triggerOnLoad;
  63914. /**
  63915. * Returns the texture matrix used in most of the material.
  63916. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63917. */
  63918. getTextureMatrix(): Matrix;
  63919. /**
  63920. * Occurs when the file being loaded is a .3dl LUT file.
  63921. */
  63922. private load3dlTexture;
  63923. /**
  63924. * Starts the loading process of the texture.
  63925. */
  63926. private loadTexture;
  63927. /**
  63928. * Clones the color gradind texture.
  63929. */
  63930. clone(): ColorGradingTexture;
  63931. /**
  63932. * Called during delayed load for textures.
  63933. */
  63934. delayLoad(): void;
  63935. /**
  63936. * Parses a color grading texture serialized by Babylon.
  63937. * @param parsedTexture The texture information being parsedTexture
  63938. * @param scene The scene to load the texture in
  63939. * @param rootUrl The root url of the data assets to load
  63940. * @return A color gradind texture
  63941. */
  63942. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63943. /**
  63944. * Serializes the LUT texture to json format.
  63945. */
  63946. serialize(): any;
  63947. }
  63948. }
  63949. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63950. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63951. import { Scene } from "babylonjs/scene";
  63952. import { Nullable } from "babylonjs/types";
  63953. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63954. /**
  63955. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63956. */
  63957. export class EquiRectangularCubeTexture extends BaseTexture {
  63958. /** The six faces of the cube. */
  63959. private static _FacesMapping;
  63960. private _noMipmap;
  63961. private _onLoad;
  63962. private _onError;
  63963. /** The size of the cubemap. */
  63964. private _size;
  63965. /** The buffer of the image. */
  63966. private _buffer;
  63967. /** The width of the input image. */
  63968. private _width;
  63969. /** The height of the input image. */
  63970. private _height;
  63971. /** The URL to the image. */
  63972. url: string;
  63973. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63974. coordinatesMode: number;
  63975. /**
  63976. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63977. * @param url The location of the image
  63978. * @param scene The scene the texture will be used in
  63979. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63980. * @param noMipmap Forces to not generate the mipmap if true
  63981. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63982. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63983. * @param onLoad — defines a callback called when texture is loaded
  63984. * @param onError — defines a callback called if there is an error
  63985. */
  63986. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63987. /**
  63988. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63989. */
  63990. private loadImage;
  63991. /**
  63992. * Convert the image buffer into a cubemap and create a CubeTexture.
  63993. */
  63994. private loadTexture;
  63995. /**
  63996. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63997. * @param buffer The ArrayBuffer that should be converted.
  63998. * @returns The buffer as Float32Array.
  63999. */
  64000. private getFloat32ArrayFromArrayBuffer;
  64001. /**
  64002. * Get the current class name of the texture useful for serialization or dynamic coding.
  64003. * @returns "EquiRectangularCubeTexture"
  64004. */
  64005. getClassName(): string;
  64006. /**
  64007. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64008. * @returns A clone of the current EquiRectangularCubeTexture.
  64009. */
  64010. clone(): EquiRectangularCubeTexture;
  64011. }
  64012. }
  64013. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64014. import { Nullable } from "babylonjs/types";
  64015. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64016. import { Matrix } from "babylonjs/Maths/math.vector";
  64017. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64018. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64019. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64020. import { Scene } from "babylonjs/scene";
  64021. /**
  64022. * Defines the options related to the creation of an HtmlElementTexture
  64023. */
  64024. export interface IHtmlElementTextureOptions {
  64025. /**
  64026. * Defines wether mip maps should be created or not.
  64027. */
  64028. generateMipMaps?: boolean;
  64029. /**
  64030. * Defines the sampling mode of the texture.
  64031. */
  64032. samplingMode?: number;
  64033. /**
  64034. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64035. */
  64036. engine: Nullable<ThinEngine>;
  64037. /**
  64038. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64039. */
  64040. scene: Nullable<Scene>;
  64041. }
  64042. /**
  64043. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64044. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64045. * is automatically managed.
  64046. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64047. * in your application.
  64048. *
  64049. * As the update is not automatic, you need to call them manually.
  64050. */
  64051. export class HtmlElementTexture extends BaseTexture {
  64052. /**
  64053. * The texture URL.
  64054. */
  64055. element: HTMLVideoElement | HTMLCanvasElement;
  64056. private static readonly DefaultOptions;
  64057. private _textureMatrix;
  64058. private _isVideo;
  64059. private _generateMipMaps;
  64060. private _samplingMode;
  64061. /**
  64062. * Instantiates a HtmlElementTexture from the following parameters.
  64063. *
  64064. * @param name Defines the name of the texture
  64065. * @param element Defines the video or canvas the texture is filled with
  64066. * @param options Defines the other none mandatory texture creation options
  64067. */
  64068. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64069. private _createInternalTexture;
  64070. /**
  64071. * Returns the texture matrix used in most of the material.
  64072. */
  64073. getTextureMatrix(): Matrix;
  64074. /**
  64075. * Updates the content of the texture.
  64076. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64077. */
  64078. update(invertY?: Nullable<boolean>): void;
  64079. }
  64080. }
  64081. declare module "babylonjs/Misc/tga" {
  64082. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64083. /**
  64084. * Based on jsTGALoader - Javascript loader for TGA file
  64085. * By Vincent Thibault
  64086. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64087. */
  64088. export class TGATools {
  64089. private static _TYPE_INDEXED;
  64090. private static _TYPE_RGB;
  64091. private static _TYPE_GREY;
  64092. private static _TYPE_RLE_INDEXED;
  64093. private static _TYPE_RLE_RGB;
  64094. private static _TYPE_RLE_GREY;
  64095. private static _ORIGIN_MASK;
  64096. private static _ORIGIN_SHIFT;
  64097. private static _ORIGIN_BL;
  64098. private static _ORIGIN_BR;
  64099. private static _ORIGIN_UL;
  64100. private static _ORIGIN_UR;
  64101. /**
  64102. * Gets the header of a TGA file
  64103. * @param data defines the TGA data
  64104. * @returns the header
  64105. */
  64106. static GetTGAHeader(data: Uint8Array): any;
  64107. /**
  64108. * Uploads TGA content to a Babylon Texture
  64109. * @hidden
  64110. */
  64111. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64112. /** @hidden */
  64113. 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;
  64114. /** @hidden */
  64115. 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;
  64116. /** @hidden */
  64117. 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;
  64118. /** @hidden */
  64119. 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;
  64120. /** @hidden */
  64121. 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;
  64122. /** @hidden */
  64123. 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;
  64124. }
  64125. }
  64126. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64127. import { Nullable } from "babylonjs/types";
  64128. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64129. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64130. /**
  64131. * Implementation of the TGA Texture Loader.
  64132. * @hidden
  64133. */
  64134. export class _TGATextureLoader implements IInternalTextureLoader {
  64135. /**
  64136. * Defines wether the loader supports cascade loading the different faces.
  64137. */
  64138. readonly supportCascades: boolean;
  64139. /**
  64140. * This returns if the loader support the current file information.
  64141. * @param extension defines the file extension of the file being loaded
  64142. * @returns true if the loader can load the specified file
  64143. */
  64144. canLoad(extension: string): boolean;
  64145. /**
  64146. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64147. * @param data contains the texture data
  64148. * @param texture defines the BabylonJS internal texture
  64149. * @param createPolynomials will be true if polynomials have been requested
  64150. * @param onLoad defines the callback to trigger once the texture is ready
  64151. * @param onError defines the callback to trigger in case of error
  64152. */
  64153. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64154. /**
  64155. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64156. * @param data contains the texture data
  64157. * @param texture defines the BabylonJS internal texture
  64158. * @param callback defines the method to call once ready to upload
  64159. */
  64160. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64161. }
  64162. }
  64163. declare module "babylonjs/Misc/basis" {
  64164. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64165. /**
  64166. * Info about the .basis files
  64167. */
  64168. class BasisFileInfo {
  64169. /**
  64170. * If the file has alpha
  64171. */
  64172. hasAlpha: boolean;
  64173. /**
  64174. * Info about each image of the basis file
  64175. */
  64176. images: Array<{
  64177. levels: Array<{
  64178. width: number;
  64179. height: number;
  64180. transcodedPixels: ArrayBufferView;
  64181. }>;
  64182. }>;
  64183. }
  64184. /**
  64185. * Result of transcoding a basis file
  64186. */
  64187. class TranscodeResult {
  64188. /**
  64189. * Info about the .basis file
  64190. */
  64191. fileInfo: BasisFileInfo;
  64192. /**
  64193. * Format to use when loading the file
  64194. */
  64195. format: number;
  64196. }
  64197. /**
  64198. * Configuration options for the Basis transcoder
  64199. */
  64200. export class BasisTranscodeConfiguration {
  64201. /**
  64202. * Supported compression formats used to determine the supported output format of the transcoder
  64203. */
  64204. supportedCompressionFormats?: {
  64205. /**
  64206. * etc1 compression format
  64207. */
  64208. etc1?: boolean;
  64209. /**
  64210. * s3tc compression format
  64211. */
  64212. s3tc?: boolean;
  64213. /**
  64214. * pvrtc compression format
  64215. */
  64216. pvrtc?: boolean;
  64217. /**
  64218. * etc2 compression format
  64219. */
  64220. etc2?: boolean;
  64221. };
  64222. /**
  64223. * If mipmap levels should be loaded for transcoded images (Default: true)
  64224. */
  64225. loadMipmapLevels?: boolean;
  64226. /**
  64227. * Index of a single image to load (Default: all images)
  64228. */
  64229. loadSingleImage?: number;
  64230. }
  64231. /**
  64232. * Used to load .Basis files
  64233. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64234. */
  64235. export class BasisTools {
  64236. private static _IgnoreSupportedFormats;
  64237. /**
  64238. * URL to use when loading the basis transcoder
  64239. */
  64240. static JSModuleURL: string;
  64241. /**
  64242. * URL to use when loading the wasm module for the transcoder
  64243. */
  64244. static WasmModuleURL: string;
  64245. /**
  64246. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64247. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64248. * @returns internal format corresponding to the Basis format
  64249. */
  64250. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64251. private static _WorkerPromise;
  64252. private static _Worker;
  64253. private static _actionId;
  64254. private static _CreateWorkerAsync;
  64255. /**
  64256. * Transcodes a loaded image file to compressed pixel data
  64257. * @param data image data to transcode
  64258. * @param config configuration options for the transcoding
  64259. * @returns a promise resulting in the transcoded image
  64260. */
  64261. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64262. /**
  64263. * Loads a texture from the transcode result
  64264. * @param texture texture load to
  64265. * @param transcodeResult the result of transcoding the basis file to load from
  64266. */
  64267. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64268. }
  64269. }
  64270. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64271. import { Nullable } from "babylonjs/types";
  64272. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64273. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64274. /**
  64275. * Loader for .basis file format
  64276. */
  64277. export class _BasisTextureLoader implements IInternalTextureLoader {
  64278. /**
  64279. * Defines whether the loader supports cascade loading the different faces.
  64280. */
  64281. readonly supportCascades: boolean;
  64282. /**
  64283. * This returns if the loader support the current file information.
  64284. * @param extension defines the file extension of the file being loaded
  64285. * @returns true if the loader can load the specified file
  64286. */
  64287. canLoad(extension: string): boolean;
  64288. /**
  64289. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64290. * @param data contains the texture data
  64291. * @param texture defines the BabylonJS internal texture
  64292. * @param createPolynomials will be true if polynomials have been requested
  64293. * @param onLoad defines the callback to trigger once the texture is ready
  64294. * @param onError defines the callback to trigger in case of error
  64295. */
  64296. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64297. /**
  64298. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64299. * @param data contains the texture data
  64300. * @param texture defines the BabylonJS internal texture
  64301. * @param callback defines the method to call once ready to upload
  64302. */
  64303. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64304. }
  64305. }
  64306. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64307. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64308. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64309. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64310. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64311. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64312. }
  64313. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64314. import { Vector2 } from "babylonjs/Maths/math.vector";
  64315. /**
  64316. * Defines the basic options interface of a TexturePacker Frame
  64317. */
  64318. export interface ITexturePackerFrame {
  64319. /**
  64320. * The frame ID
  64321. */
  64322. id: number;
  64323. /**
  64324. * The frames Scale
  64325. */
  64326. scale: Vector2;
  64327. /**
  64328. * The Frames offset
  64329. */
  64330. offset: Vector2;
  64331. }
  64332. /**
  64333. * This is a support class for frame Data on texture packer sets.
  64334. */
  64335. export class TexturePackerFrame implements ITexturePackerFrame {
  64336. /**
  64337. * The frame ID
  64338. */
  64339. id: number;
  64340. /**
  64341. * The frames Scale
  64342. */
  64343. scale: Vector2;
  64344. /**
  64345. * The Frames offset
  64346. */
  64347. offset: Vector2;
  64348. /**
  64349. * Initializes a texture package frame.
  64350. * @param id The numerical frame identifier
  64351. * @param scale Scalar Vector2 for UV frame
  64352. * @param offset Vector2 for the frame position in UV units.
  64353. * @returns TexturePackerFrame
  64354. */
  64355. constructor(id: number, scale: Vector2, offset: Vector2);
  64356. }
  64357. }
  64358. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64360. import { Scene } from "babylonjs/scene";
  64361. import { Nullable } from "babylonjs/types";
  64362. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64363. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64364. /**
  64365. * Defines the basic options interface of a TexturePacker
  64366. */
  64367. export interface ITexturePackerOptions {
  64368. /**
  64369. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64370. */
  64371. map?: string[];
  64372. /**
  64373. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64374. */
  64375. uvsIn?: string;
  64376. /**
  64377. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64378. */
  64379. uvsOut?: string;
  64380. /**
  64381. * number representing the layout style. Defaults to LAYOUT_STRIP
  64382. */
  64383. layout?: number;
  64384. /**
  64385. * number of columns if using custom column count layout(2). This defaults to 4.
  64386. */
  64387. colnum?: number;
  64388. /**
  64389. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64390. */
  64391. updateInputMeshes?: boolean;
  64392. /**
  64393. * boolean flag to dispose all the source textures. Defaults to true.
  64394. */
  64395. disposeSources?: boolean;
  64396. /**
  64397. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64398. */
  64399. fillBlanks?: boolean;
  64400. /**
  64401. * string value representing the context fill style color. Defaults to 'black'.
  64402. */
  64403. customFillColor?: string;
  64404. /**
  64405. * Width and Height Value of each Frame in the TexturePacker Sets
  64406. */
  64407. frameSize?: number;
  64408. /**
  64409. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64410. */
  64411. paddingRatio?: number;
  64412. /**
  64413. * Number that declares the fill method for the padding gutter.
  64414. */
  64415. paddingMode?: number;
  64416. /**
  64417. * If in SUBUV_COLOR padding mode what color to use.
  64418. */
  64419. paddingColor?: Color3 | Color4;
  64420. }
  64421. /**
  64422. * Defines the basic interface of a TexturePacker JSON File
  64423. */
  64424. export interface ITexturePackerJSON {
  64425. /**
  64426. * The frame ID
  64427. */
  64428. name: string;
  64429. /**
  64430. * The base64 channel data
  64431. */
  64432. sets: any;
  64433. /**
  64434. * The options of the Packer
  64435. */
  64436. options: ITexturePackerOptions;
  64437. /**
  64438. * The frame data of the Packer
  64439. */
  64440. frames: Array<number>;
  64441. }
  64442. /**
  64443. * This is a support class that generates a series of packed texture sets.
  64444. * @see https://doc.babylonjs.com/babylon101/materials
  64445. */
  64446. export class TexturePacker {
  64447. /** Packer Layout Constant 0 */
  64448. static readonly LAYOUT_STRIP: number;
  64449. /** Packer Layout Constant 1 */
  64450. static readonly LAYOUT_POWER2: number;
  64451. /** Packer Layout Constant 2 */
  64452. static readonly LAYOUT_COLNUM: number;
  64453. /** Packer Layout Constant 0 */
  64454. static readonly SUBUV_WRAP: number;
  64455. /** Packer Layout Constant 1 */
  64456. static readonly SUBUV_EXTEND: number;
  64457. /** Packer Layout Constant 2 */
  64458. static readonly SUBUV_COLOR: number;
  64459. /** The Name of the Texture Package */
  64460. name: string;
  64461. /** The scene scope of the TexturePacker */
  64462. scene: Scene;
  64463. /** The Meshes to target */
  64464. meshes: AbstractMesh[];
  64465. /** Arguments passed with the Constructor */
  64466. options: ITexturePackerOptions;
  64467. /** The promise that is started upon initialization */
  64468. promise: Nullable<Promise<TexturePacker | string>>;
  64469. /** The Container object for the channel sets that are generated */
  64470. sets: object;
  64471. /** The Container array for the frames that are generated */
  64472. frames: TexturePackerFrame[];
  64473. /** The expected number of textures the system is parsing. */
  64474. private _expecting;
  64475. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64476. private _paddingValue;
  64477. /**
  64478. * Initializes a texture package series from an array of meshes or a single mesh.
  64479. * @param name The name of the package
  64480. * @param meshes The target meshes to compose the package from
  64481. * @param options The arguments that texture packer should follow while building.
  64482. * @param scene The scene which the textures are scoped to.
  64483. * @returns TexturePacker
  64484. */
  64485. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64486. /**
  64487. * Starts the package process
  64488. * @param resolve The promises resolution function
  64489. * @returns TexturePacker
  64490. */
  64491. private _createFrames;
  64492. /**
  64493. * Calculates the Size of the Channel Sets
  64494. * @returns Vector2
  64495. */
  64496. private _calculateSize;
  64497. /**
  64498. * Calculates the UV data for the frames.
  64499. * @param baseSize the base frameSize
  64500. * @param padding the base frame padding
  64501. * @param dtSize size of the Dynamic Texture for that channel
  64502. * @param dtUnits is 1/dtSize
  64503. * @param update flag to update the input meshes
  64504. */
  64505. private _calculateMeshUVFrames;
  64506. /**
  64507. * Calculates the frames Offset.
  64508. * @param index of the frame
  64509. * @returns Vector2
  64510. */
  64511. private _getFrameOffset;
  64512. /**
  64513. * Updates a Mesh to the frame data
  64514. * @param mesh that is the target
  64515. * @param frameID or the frame index
  64516. */
  64517. private _updateMeshUV;
  64518. /**
  64519. * Updates a Meshes materials to use the texture packer channels
  64520. * @param m is the mesh to target
  64521. * @param force all channels on the packer to be set.
  64522. */
  64523. private _updateTextureReferences;
  64524. /**
  64525. * Public method to set a Mesh to a frame
  64526. * @param m that is the target
  64527. * @param frameID or the frame index
  64528. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64529. */
  64530. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64531. /**
  64532. * Starts the async promise to compile the texture packer.
  64533. * @returns Promise<void>
  64534. */
  64535. processAsync(): Promise<void>;
  64536. /**
  64537. * Disposes all textures associated with this packer
  64538. */
  64539. dispose(): void;
  64540. /**
  64541. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64542. * @param imageType is the image type to use.
  64543. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64544. */
  64545. download(imageType?: string, quality?: number): void;
  64546. /**
  64547. * Public method to load a texturePacker JSON file.
  64548. * @param data of the JSON file in string format.
  64549. */
  64550. updateFromJSON(data: string): void;
  64551. }
  64552. }
  64553. declare module "babylonjs/Materials/Textures/Packer/index" {
  64554. export * from "babylonjs/Materials/Textures/Packer/packer";
  64555. export * from "babylonjs/Materials/Textures/Packer/frame";
  64556. }
  64557. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64558. import { Scene } from "babylonjs/scene";
  64559. import { Texture } from "babylonjs/Materials/Textures/texture";
  64560. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64561. /**
  64562. * 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.
  64563. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64564. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64565. */
  64566. export class CustomProceduralTexture extends ProceduralTexture {
  64567. private _animate;
  64568. private _time;
  64569. private _config;
  64570. private _texturePath;
  64571. /**
  64572. * Instantiates a new Custom Procedural Texture.
  64573. * 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.
  64574. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64575. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64576. * @param name Define the name of the texture
  64577. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  64578. * @param size Define the size of the texture to create
  64579. * @param scene Define the scene the texture belongs to
  64580. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  64581. * @param generateMipMaps Define if the texture should creates mip maps or not
  64582. */
  64583. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64584. private _loadJson;
  64585. /**
  64586. * Is the texture ready to be used ? (rendered at least once)
  64587. * @returns true if ready, otherwise, false.
  64588. */
  64589. isReady(): boolean;
  64590. /**
  64591. * Render the texture to its associated render target.
  64592. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  64593. */
  64594. render(useCameraPostProcess?: boolean): void;
  64595. /**
  64596. * Update the list of dependant textures samplers in the shader.
  64597. */
  64598. updateTextures(): void;
  64599. /**
  64600. * Update the uniform values of the procedural texture in the shader.
  64601. */
  64602. updateShaderUniforms(): void;
  64603. /**
  64604. * Define if the texture animates or not.
  64605. */
  64606. get animate(): boolean;
  64607. set animate(value: boolean);
  64608. }
  64609. }
  64610. declare module "babylonjs/Shaders/noise.fragment" {
  64611. /** @hidden */
  64612. export var noisePixelShader: {
  64613. name: string;
  64614. shader: string;
  64615. };
  64616. }
  64617. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  64618. import { Nullable } from "babylonjs/types";
  64619. import { Scene } from "babylonjs/scene";
  64620. import { Texture } from "babylonjs/Materials/Textures/texture";
  64621. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64622. import "babylonjs/Shaders/noise.fragment";
  64623. /**
  64624. * Class used to generate noise procedural textures
  64625. */
  64626. export class NoiseProceduralTexture extends ProceduralTexture {
  64627. private _time;
  64628. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  64629. brightness: number;
  64630. /** Defines the number of octaves to process */
  64631. octaves: number;
  64632. /** Defines the level of persistence (0.8 by default) */
  64633. persistence: number;
  64634. /** Gets or sets animation speed factor (default is 1) */
  64635. animationSpeedFactor: number;
  64636. /**
  64637. * Creates a new NoiseProceduralTexture
  64638. * @param name defines the name fo the texture
  64639. * @param size defines the size of the texture (default is 256)
  64640. * @param scene defines the hosting scene
  64641. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64642. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64643. */
  64644. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64645. private _updateShaderUniforms;
  64646. protected _getDefines(): string;
  64647. /** Generate the current state of the procedural texture */
  64648. render(useCameraPostProcess?: boolean): void;
  64649. /**
  64650. * Serializes this noise procedural texture
  64651. * @returns a serialized noise procedural texture object
  64652. */
  64653. serialize(): any;
  64654. /**
  64655. * Clone the texture.
  64656. * @returns the cloned texture
  64657. */
  64658. clone(): NoiseProceduralTexture;
  64659. /**
  64660. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64661. * @param parsedTexture defines parsed texture data
  64662. * @param scene defines the current scene
  64663. * @param rootUrl defines the root URL containing noise procedural texture information
  64664. * @returns a parsed NoiseProceduralTexture
  64665. */
  64666. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64667. }
  64668. }
  64669. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64670. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64671. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64672. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64673. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64674. }
  64675. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64676. import { Nullable } from "babylonjs/types";
  64677. import { Scene } from "babylonjs/scene";
  64678. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64679. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64680. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64681. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64682. /**
  64683. * Raw cube texture where the raw buffers are passed in
  64684. */
  64685. export class RawCubeTexture extends CubeTexture {
  64686. /**
  64687. * Creates a cube texture where the raw buffers are passed in.
  64688. * @param scene defines the scene the texture is attached to
  64689. * @param data defines the array of data to use to create each face
  64690. * @param size defines the size of the textures
  64691. * @param format defines the format of the data
  64692. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64693. * @param generateMipMaps defines if the engine should generate the mip levels
  64694. * @param invertY defines if data must be stored with Y axis inverted
  64695. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64696. * @param compression defines the compression used (null by default)
  64697. */
  64698. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64699. /**
  64700. * Updates the raw cube texture.
  64701. * @param data defines the data to store
  64702. * @param format defines the data format
  64703. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64704. * @param invertY defines if data must be stored with Y axis inverted
  64705. * @param compression defines the compression used (null by default)
  64706. * @param level defines which level of the texture to update
  64707. */
  64708. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64709. /**
  64710. * Updates a raw cube texture with RGBD encoded data.
  64711. * @param data defines the array of data [mipmap][face] to use to create each face
  64712. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64713. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64714. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64715. * @returns a promsie that resolves when the operation is complete
  64716. */
  64717. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64718. /**
  64719. * Clones the raw cube texture.
  64720. * @return a new cube texture
  64721. */
  64722. clone(): CubeTexture;
  64723. /** @hidden */
  64724. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64725. }
  64726. }
  64727. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64728. import { Scene } from "babylonjs/scene";
  64729. import { Texture } from "babylonjs/Materials/Textures/texture";
  64730. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64731. /**
  64732. * Class used to store 2D array textures containing user data
  64733. */
  64734. export class RawTexture2DArray extends Texture {
  64735. /** Gets or sets the texture format to use */
  64736. format: number;
  64737. /**
  64738. * Create a new RawTexture2DArray
  64739. * @param data defines the data of the texture
  64740. * @param width defines the width of the texture
  64741. * @param height defines the height of the texture
  64742. * @param depth defines the number of layers of the texture
  64743. * @param format defines the texture format to use
  64744. * @param scene defines the hosting scene
  64745. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64746. * @param invertY defines if texture must be stored with Y axis inverted
  64747. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64748. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64749. */
  64750. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64751. /** Gets or sets the texture format to use */
  64752. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64753. /**
  64754. * Update the texture with new data
  64755. * @param data defines the data to store in the texture
  64756. */
  64757. update(data: ArrayBufferView): void;
  64758. }
  64759. }
  64760. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64761. import { Scene } from "babylonjs/scene";
  64762. import { Texture } from "babylonjs/Materials/Textures/texture";
  64763. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64764. /**
  64765. * Class used to store 3D textures containing user data
  64766. */
  64767. export class RawTexture3D extends Texture {
  64768. /** Gets or sets the texture format to use */
  64769. format: number;
  64770. /**
  64771. * Create a new RawTexture3D
  64772. * @param data defines the data of the texture
  64773. * @param width defines the width of the texture
  64774. * @param height defines the height of the texture
  64775. * @param depth defines the depth of the texture
  64776. * @param format defines the texture format to use
  64777. * @param scene defines the hosting scene
  64778. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64779. * @param invertY defines if texture must be stored with Y axis inverted
  64780. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64781. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64782. */
  64783. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64784. /** Gets or sets the texture format to use */
  64785. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64786. /**
  64787. * Update the texture with new data
  64788. * @param data defines the data to store in the texture
  64789. */
  64790. update(data: ArrayBufferView): void;
  64791. }
  64792. }
  64793. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64794. import { Scene } from "babylonjs/scene";
  64795. import { Plane } from "babylonjs/Maths/math.plane";
  64796. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64797. /**
  64798. * Creates a refraction texture used by refraction channel of the standard material.
  64799. * It is like a mirror but to see through a material.
  64800. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64801. */
  64802. export class RefractionTexture extends RenderTargetTexture {
  64803. /**
  64804. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64805. * 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.
  64806. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64807. */
  64808. refractionPlane: Plane;
  64809. /**
  64810. * Define how deep under the surface we should see.
  64811. */
  64812. depth: number;
  64813. /**
  64814. * Creates a refraction texture used by refraction channel of the standard material.
  64815. * It is like a mirror but to see through a material.
  64816. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64817. * @param name Define the texture name
  64818. * @param size Define the size of the underlying texture
  64819. * @param scene Define the scene the refraction belongs to
  64820. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64821. */
  64822. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64823. /**
  64824. * Clone the refraction texture.
  64825. * @returns the cloned texture
  64826. */
  64827. clone(): RefractionTexture;
  64828. /**
  64829. * Serialize the texture to a JSON representation you could use in Parse later on
  64830. * @returns the serialized JSON representation
  64831. */
  64832. serialize(): any;
  64833. }
  64834. }
  64835. declare module "babylonjs/Materials/Textures/index" {
  64836. export * from "babylonjs/Materials/Textures/baseTexture";
  64837. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64838. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64839. export * from "babylonjs/Materials/Textures/cubeTexture";
  64840. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64841. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64842. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64843. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64844. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64845. export * from "babylonjs/Materials/Textures/internalTexture";
  64846. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64847. export * from "babylonjs/Materials/Textures/Loaders/index";
  64848. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64849. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64850. export * from "babylonjs/Materials/Textures/Packer/index";
  64851. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64852. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64853. export * from "babylonjs/Materials/Textures/rawTexture";
  64854. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64855. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64856. export * from "babylonjs/Materials/Textures/refractionTexture";
  64857. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64858. export * from "babylonjs/Materials/Textures/texture";
  64859. export * from "babylonjs/Materials/Textures/videoTexture";
  64860. }
  64861. declare module "babylonjs/Materials/Node/Enums/index" {
  64862. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64863. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64864. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64865. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64866. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64867. }
  64868. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64872. import { Mesh } from "babylonjs/Meshes/mesh";
  64873. import { Effect } from "babylonjs/Materials/effect";
  64874. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64875. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64876. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64877. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64878. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64879. /**
  64880. * Block used to add support for vertex skinning (bones)
  64881. */
  64882. export class BonesBlock extends NodeMaterialBlock {
  64883. /**
  64884. * Creates a new BonesBlock
  64885. * @param name defines the block name
  64886. */
  64887. constructor(name: string);
  64888. /**
  64889. * Initialize the block and prepare the context for build
  64890. * @param state defines the state that will be used for the build
  64891. */
  64892. initialize(state: NodeMaterialBuildState): void;
  64893. /**
  64894. * Gets the current class name
  64895. * @returns the class name
  64896. */
  64897. getClassName(): string;
  64898. /**
  64899. * Gets the matrix indices input component
  64900. */
  64901. get matricesIndices(): NodeMaterialConnectionPoint;
  64902. /**
  64903. * Gets the matrix weights input component
  64904. */
  64905. get matricesWeights(): NodeMaterialConnectionPoint;
  64906. /**
  64907. * Gets the extra matrix indices input component
  64908. */
  64909. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64910. /**
  64911. * Gets the extra matrix weights input component
  64912. */
  64913. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64914. /**
  64915. * Gets the world input component
  64916. */
  64917. get world(): NodeMaterialConnectionPoint;
  64918. /**
  64919. * Gets the output component
  64920. */
  64921. get output(): NodeMaterialConnectionPoint;
  64922. autoConfigure(material: NodeMaterial): void;
  64923. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64924. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64926. protected _buildBlock(state: NodeMaterialBuildState): this;
  64927. }
  64928. }
  64929. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64934. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64935. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64936. /**
  64937. * Block used to add support for instances
  64938. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64939. */
  64940. export class InstancesBlock extends NodeMaterialBlock {
  64941. /**
  64942. * Creates a new InstancesBlock
  64943. * @param name defines the block name
  64944. */
  64945. constructor(name: string);
  64946. /**
  64947. * Gets the current class name
  64948. * @returns the class name
  64949. */
  64950. getClassName(): string;
  64951. /**
  64952. * Gets the first world row input component
  64953. */
  64954. get world0(): NodeMaterialConnectionPoint;
  64955. /**
  64956. * Gets the second world row input component
  64957. */
  64958. get world1(): NodeMaterialConnectionPoint;
  64959. /**
  64960. * Gets the third world row input component
  64961. */
  64962. get world2(): NodeMaterialConnectionPoint;
  64963. /**
  64964. * Gets the forth world row input component
  64965. */
  64966. get world3(): NodeMaterialConnectionPoint;
  64967. /**
  64968. * Gets the world input component
  64969. */
  64970. get world(): NodeMaterialConnectionPoint;
  64971. /**
  64972. * Gets the output component
  64973. */
  64974. get output(): NodeMaterialConnectionPoint;
  64975. /**
  64976. * Gets the isntanceID component
  64977. */
  64978. get instanceID(): NodeMaterialConnectionPoint;
  64979. autoConfigure(material: NodeMaterial): void;
  64980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64981. protected _buildBlock(state: NodeMaterialBuildState): this;
  64982. }
  64983. }
  64984. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64985. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64986. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64989. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64990. import { Effect } from "babylonjs/Materials/effect";
  64991. import { Mesh } from "babylonjs/Meshes/mesh";
  64992. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64993. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64994. /**
  64995. * Block used to add morph targets support to vertex shader
  64996. */
  64997. export class MorphTargetsBlock extends NodeMaterialBlock {
  64998. private _repeatableContentAnchor;
  64999. /**
  65000. * Create a new MorphTargetsBlock
  65001. * @param name defines the block name
  65002. */
  65003. constructor(name: string);
  65004. /**
  65005. * Gets the current class name
  65006. * @returns the class name
  65007. */
  65008. getClassName(): string;
  65009. /**
  65010. * Gets the position input component
  65011. */
  65012. get position(): NodeMaterialConnectionPoint;
  65013. /**
  65014. * Gets the normal input component
  65015. */
  65016. get normal(): NodeMaterialConnectionPoint;
  65017. /**
  65018. * Gets the tangent input component
  65019. */
  65020. get tangent(): NodeMaterialConnectionPoint;
  65021. /**
  65022. * Gets the tangent input component
  65023. */
  65024. get uv(): NodeMaterialConnectionPoint;
  65025. /**
  65026. * Gets the position output component
  65027. */
  65028. get positionOutput(): NodeMaterialConnectionPoint;
  65029. /**
  65030. * Gets the normal output component
  65031. */
  65032. get normalOutput(): NodeMaterialConnectionPoint;
  65033. /**
  65034. * Gets the tangent output component
  65035. */
  65036. get tangentOutput(): NodeMaterialConnectionPoint;
  65037. /**
  65038. * Gets the tangent output component
  65039. */
  65040. get uvOutput(): NodeMaterialConnectionPoint;
  65041. initialize(state: NodeMaterialBuildState): void;
  65042. autoConfigure(material: NodeMaterial): void;
  65043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65044. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65045. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65046. protected _buildBlock(state: NodeMaterialBuildState): this;
  65047. }
  65048. }
  65049. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65053. import { Nullable } from "babylonjs/types";
  65054. import { Scene } from "babylonjs/scene";
  65055. import { Effect } from "babylonjs/Materials/effect";
  65056. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65057. import { Mesh } from "babylonjs/Meshes/mesh";
  65058. import { Light } from "babylonjs/Lights/light";
  65059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65060. /**
  65061. * Block used to get data information from a light
  65062. */
  65063. export class LightInformationBlock extends NodeMaterialBlock {
  65064. private _lightDataUniformName;
  65065. private _lightColorUniformName;
  65066. private _lightTypeDefineName;
  65067. /**
  65068. * Gets or sets the light associated with this block
  65069. */
  65070. light: Nullable<Light>;
  65071. /**
  65072. * Creates a new LightInformationBlock
  65073. * @param name defines the block name
  65074. */
  65075. constructor(name: string);
  65076. /**
  65077. * Gets the current class name
  65078. * @returns the class name
  65079. */
  65080. getClassName(): string;
  65081. /**
  65082. * Gets the world position input component
  65083. */
  65084. get worldPosition(): NodeMaterialConnectionPoint;
  65085. /**
  65086. * Gets the direction output component
  65087. */
  65088. get direction(): NodeMaterialConnectionPoint;
  65089. /**
  65090. * Gets the direction output component
  65091. */
  65092. get color(): NodeMaterialConnectionPoint;
  65093. /**
  65094. * Gets the direction output component
  65095. */
  65096. get intensity(): NodeMaterialConnectionPoint;
  65097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65099. protected _buildBlock(state: NodeMaterialBuildState): this;
  65100. serialize(): any;
  65101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65102. }
  65103. }
  65104. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65105. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65106. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65107. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65108. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65109. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65110. }
  65111. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65116. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65117. import { Effect } from "babylonjs/Materials/effect";
  65118. import { Mesh } from "babylonjs/Meshes/mesh";
  65119. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65120. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65121. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65122. /**
  65123. * Block used to add image processing support to fragment shader
  65124. */
  65125. export class ImageProcessingBlock extends NodeMaterialBlock {
  65126. /**
  65127. * Create a new ImageProcessingBlock
  65128. * @param name defines the block name
  65129. */
  65130. constructor(name: string);
  65131. /**
  65132. * Gets the current class name
  65133. * @returns the class name
  65134. */
  65135. getClassName(): string;
  65136. /**
  65137. * Gets the color input component
  65138. */
  65139. get color(): NodeMaterialConnectionPoint;
  65140. /**
  65141. * Gets the output component
  65142. */
  65143. get output(): NodeMaterialConnectionPoint;
  65144. /**
  65145. * Initialize the block and prepare the context for build
  65146. * @param state defines the state that will be used for the build
  65147. */
  65148. initialize(state: NodeMaterialBuildState): void;
  65149. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65151. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65152. protected _buildBlock(state: NodeMaterialBuildState): this;
  65153. }
  65154. }
  65155. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65159. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65161. import { Effect } from "babylonjs/Materials/effect";
  65162. import { Mesh } from "babylonjs/Meshes/mesh";
  65163. import { Scene } from "babylonjs/scene";
  65164. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65165. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65166. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65167. /**
  65168. * Block used to pertub normals based on a normal map
  65169. */
  65170. export class PerturbNormalBlock extends NodeMaterialBlock {
  65171. private _tangentSpaceParameterName;
  65172. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65173. invertX: boolean;
  65174. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65175. invertY: boolean;
  65176. /**
  65177. * Create a new PerturbNormalBlock
  65178. * @param name defines the block name
  65179. */
  65180. constructor(name: string);
  65181. /**
  65182. * Gets the current class name
  65183. * @returns the class name
  65184. */
  65185. getClassName(): string;
  65186. /**
  65187. * Gets the world position input component
  65188. */
  65189. get worldPosition(): NodeMaterialConnectionPoint;
  65190. /**
  65191. * Gets the world normal input component
  65192. */
  65193. get worldNormal(): NodeMaterialConnectionPoint;
  65194. /**
  65195. * Gets the world tangent input component
  65196. */
  65197. get worldTangent(): NodeMaterialConnectionPoint;
  65198. /**
  65199. * Gets the uv input component
  65200. */
  65201. get uv(): NodeMaterialConnectionPoint;
  65202. /**
  65203. * Gets the normal map color input component
  65204. */
  65205. get normalMapColor(): NodeMaterialConnectionPoint;
  65206. /**
  65207. * Gets the strength input component
  65208. */
  65209. get strength(): NodeMaterialConnectionPoint;
  65210. /**
  65211. * Gets the output component
  65212. */
  65213. get output(): NodeMaterialConnectionPoint;
  65214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65216. autoConfigure(material: NodeMaterial): void;
  65217. protected _buildBlock(state: NodeMaterialBuildState): this;
  65218. protected _dumpPropertiesCode(): string;
  65219. serialize(): any;
  65220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65221. }
  65222. }
  65223. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65227. /**
  65228. * Block used to discard a pixel if a value is smaller than a cutoff
  65229. */
  65230. export class DiscardBlock extends NodeMaterialBlock {
  65231. /**
  65232. * Create a new DiscardBlock
  65233. * @param name defines the block name
  65234. */
  65235. constructor(name: string);
  65236. /**
  65237. * Gets the current class name
  65238. * @returns the class name
  65239. */
  65240. getClassName(): string;
  65241. /**
  65242. * Gets the color input component
  65243. */
  65244. get value(): NodeMaterialConnectionPoint;
  65245. /**
  65246. * Gets the cutoff input component
  65247. */
  65248. get cutoff(): NodeMaterialConnectionPoint;
  65249. protected _buildBlock(state: NodeMaterialBuildState): this;
  65250. }
  65251. }
  65252. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65253. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65254. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65255. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65256. /**
  65257. * Block used to test if the fragment shader is front facing
  65258. */
  65259. export class FrontFacingBlock extends NodeMaterialBlock {
  65260. /**
  65261. * Creates a new FrontFacingBlock
  65262. * @param name defines the block name
  65263. */
  65264. constructor(name: string);
  65265. /**
  65266. * Gets the current class name
  65267. * @returns the class name
  65268. */
  65269. getClassName(): string;
  65270. /**
  65271. * Gets the output component
  65272. */
  65273. get output(): NodeMaterialConnectionPoint;
  65274. protected _buildBlock(state: NodeMaterialBuildState): this;
  65275. }
  65276. }
  65277. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65281. /**
  65282. * Block used to get the derivative value on x and y of a given input
  65283. */
  65284. export class DerivativeBlock extends NodeMaterialBlock {
  65285. /**
  65286. * Create a new DerivativeBlock
  65287. * @param name defines the block name
  65288. */
  65289. constructor(name: string);
  65290. /**
  65291. * Gets the current class name
  65292. * @returns the class name
  65293. */
  65294. getClassName(): string;
  65295. /**
  65296. * Gets the input component
  65297. */
  65298. get input(): NodeMaterialConnectionPoint;
  65299. /**
  65300. * Gets the derivative output on x
  65301. */
  65302. get dx(): NodeMaterialConnectionPoint;
  65303. /**
  65304. * Gets the derivative output on y
  65305. */
  65306. get dy(): NodeMaterialConnectionPoint;
  65307. protected _buildBlock(state: NodeMaterialBuildState): this;
  65308. }
  65309. }
  65310. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65311. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65312. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65313. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65314. /**
  65315. * Block used to make gl_FragCoord available
  65316. */
  65317. export class FragCoordBlock extends NodeMaterialBlock {
  65318. /**
  65319. * Creates a new FragCoordBlock
  65320. * @param name defines the block name
  65321. */
  65322. constructor(name: string);
  65323. /**
  65324. * Gets the current class name
  65325. * @returns the class name
  65326. */
  65327. getClassName(): string;
  65328. /**
  65329. * Gets the xy component
  65330. */
  65331. get xy(): NodeMaterialConnectionPoint;
  65332. /**
  65333. * Gets the xyz component
  65334. */
  65335. get xyz(): NodeMaterialConnectionPoint;
  65336. /**
  65337. * Gets the xyzw component
  65338. */
  65339. get xyzw(): NodeMaterialConnectionPoint;
  65340. /**
  65341. * Gets the x component
  65342. */
  65343. get x(): NodeMaterialConnectionPoint;
  65344. /**
  65345. * Gets the y component
  65346. */
  65347. get y(): NodeMaterialConnectionPoint;
  65348. /**
  65349. * Gets the z component
  65350. */
  65351. get z(): NodeMaterialConnectionPoint;
  65352. /**
  65353. * Gets the w component
  65354. */
  65355. get output(): NodeMaterialConnectionPoint;
  65356. protected writeOutputs(state: NodeMaterialBuildState): string;
  65357. protected _buildBlock(state: NodeMaterialBuildState): this;
  65358. }
  65359. }
  65360. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65364. import { Effect } from "babylonjs/Materials/effect";
  65365. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65366. import { Mesh } from "babylonjs/Meshes/mesh";
  65367. /**
  65368. * Block used to get the screen sizes
  65369. */
  65370. export class ScreenSizeBlock extends NodeMaterialBlock {
  65371. private _varName;
  65372. private _scene;
  65373. /**
  65374. * Creates a new ScreenSizeBlock
  65375. * @param name defines the block name
  65376. */
  65377. constructor(name: string);
  65378. /**
  65379. * Gets the current class name
  65380. * @returns the class name
  65381. */
  65382. getClassName(): string;
  65383. /**
  65384. * Gets the xy component
  65385. */
  65386. get xy(): NodeMaterialConnectionPoint;
  65387. /**
  65388. * Gets the x component
  65389. */
  65390. get x(): NodeMaterialConnectionPoint;
  65391. /**
  65392. * Gets the y component
  65393. */
  65394. get y(): NodeMaterialConnectionPoint;
  65395. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65396. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65397. protected _buildBlock(state: NodeMaterialBuildState): this;
  65398. }
  65399. }
  65400. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65401. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65402. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65403. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65404. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65405. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65406. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65407. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65408. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65409. }
  65410. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65413. import { Mesh } from "babylonjs/Meshes/mesh";
  65414. import { Effect } from "babylonjs/Materials/effect";
  65415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65417. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65418. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65419. /**
  65420. * Block used to add support for scene fog
  65421. */
  65422. export class FogBlock extends NodeMaterialBlock {
  65423. private _fogDistanceName;
  65424. private _fogParameters;
  65425. /**
  65426. * Create a new FogBlock
  65427. * @param name defines the block name
  65428. */
  65429. constructor(name: string);
  65430. /**
  65431. * Gets the current class name
  65432. * @returns the class name
  65433. */
  65434. getClassName(): string;
  65435. /**
  65436. * Gets the world position input component
  65437. */
  65438. get worldPosition(): NodeMaterialConnectionPoint;
  65439. /**
  65440. * Gets the view input component
  65441. */
  65442. get view(): NodeMaterialConnectionPoint;
  65443. /**
  65444. * Gets the color input component
  65445. */
  65446. get input(): NodeMaterialConnectionPoint;
  65447. /**
  65448. * Gets the fog color input component
  65449. */
  65450. get fogColor(): NodeMaterialConnectionPoint;
  65451. /**
  65452. * Gets the output component
  65453. */
  65454. get output(): NodeMaterialConnectionPoint;
  65455. autoConfigure(material: NodeMaterial): void;
  65456. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65458. protected _buildBlock(state: NodeMaterialBuildState): this;
  65459. }
  65460. }
  65461. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65466. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65467. import { Effect } from "babylonjs/Materials/effect";
  65468. import { Mesh } from "babylonjs/Meshes/mesh";
  65469. import { Light } from "babylonjs/Lights/light";
  65470. import { Nullable } from "babylonjs/types";
  65471. import { Scene } from "babylonjs/scene";
  65472. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65473. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65474. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65475. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65476. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65477. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65478. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65479. /**
  65480. * Block used to add light in the fragment shader
  65481. */
  65482. export class LightBlock extends NodeMaterialBlock {
  65483. private _lightId;
  65484. /**
  65485. * Gets or sets the light associated with this block
  65486. */
  65487. light: Nullable<Light>;
  65488. /**
  65489. * Create a new LightBlock
  65490. * @param name defines the block name
  65491. */
  65492. constructor(name: string);
  65493. /**
  65494. * Gets the current class name
  65495. * @returns the class name
  65496. */
  65497. getClassName(): string;
  65498. /**
  65499. * Gets the world position input component
  65500. */
  65501. get worldPosition(): NodeMaterialConnectionPoint;
  65502. /**
  65503. * Gets the world normal input component
  65504. */
  65505. get worldNormal(): NodeMaterialConnectionPoint;
  65506. /**
  65507. * Gets the camera (or eye) position component
  65508. */
  65509. get cameraPosition(): NodeMaterialConnectionPoint;
  65510. /**
  65511. * Gets the glossiness component
  65512. */
  65513. get glossiness(): NodeMaterialConnectionPoint;
  65514. /**
  65515. * Gets the glossinness power component
  65516. */
  65517. get glossPower(): NodeMaterialConnectionPoint;
  65518. /**
  65519. * Gets the diffuse color component
  65520. */
  65521. get diffuseColor(): NodeMaterialConnectionPoint;
  65522. /**
  65523. * Gets the specular color component
  65524. */
  65525. get specularColor(): NodeMaterialConnectionPoint;
  65526. /**
  65527. * Gets the diffuse output component
  65528. */
  65529. get diffuseOutput(): NodeMaterialConnectionPoint;
  65530. /**
  65531. * Gets the specular output component
  65532. */
  65533. get specularOutput(): NodeMaterialConnectionPoint;
  65534. /**
  65535. * Gets the shadow output component
  65536. */
  65537. get shadow(): NodeMaterialConnectionPoint;
  65538. autoConfigure(material: NodeMaterial): void;
  65539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65540. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65541. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65542. private _injectVertexCode;
  65543. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65544. serialize(): any;
  65545. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65546. }
  65547. }
  65548. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65551. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65552. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65553. /**
  65554. * Block used to read a reflection texture from a sampler
  65555. */
  65556. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65557. /**
  65558. * Create a new ReflectionTextureBlock
  65559. * @param name defines the block name
  65560. */
  65561. constructor(name: string);
  65562. /**
  65563. * Gets the current class name
  65564. * @returns the class name
  65565. */
  65566. getClassName(): string;
  65567. /**
  65568. * Gets the world position input component
  65569. */
  65570. get position(): NodeMaterialConnectionPoint;
  65571. /**
  65572. * Gets the world position input component
  65573. */
  65574. get worldPosition(): NodeMaterialConnectionPoint;
  65575. /**
  65576. * Gets the world normal input component
  65577. */
  65578. get worldNormal(): NodeMaterialConnectionPoint;
  65579. /**
  65580. * Gets the world input component
  65581. */
  65582. get world(): NodeMaterialConnectionPoint;
  65583. /**
  65584. * Gets the camera (or eye) position component
  65585. */
  65586. get cameraPosition(): NodeMaterialConnectionPoint;
  65587. /**
  65588. * Gets the view input component
  65589. */
  65590. get view(): NodeMaterialConnectionPoint;
  65591. /**
  65592. * Gets the rgb output component
  65593. */
  65594. get rgb(): NodeMaterialConnectionPoint;
  65595. /**
  65596. * Gets the rgba output component
  65597. */
  65598. get rgba(): NodeMaterialConnectionPoint;
  65599. /**
  65600. * Gets the r output component
  65601. */
  65602. get r(): NodeMaterialConnectionPoint;
  65603. /**
  65604. * Gets the g output component
  65605. */
  65606. get g(): NodeMaterialConnectionPoint;
  65607. /**
  65608. * Gets the b output component
  65609. */
  65610. get b(): NodeMaterialConnectionPoint;
  65611. /**
  65612. * Gets the a output component
  65613. */
  65614. get a(): NodeMaterialConnectionPoint;
  65615. autoConfigure(material: NodeMaterial): void;
  65616. protected _buildBlock(state: NodeMaterialBuildState): this;
  65617. }
  65618. }
  65619. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  65620. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  65621. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  65622. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  65623. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  65624. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  65625. }
  65626. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  65627. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  65628. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  65629. }
  65630. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  65631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65634. /**
  65635. * Block used to add 2 vectors
  65636. */
  65637. export class AddBlock extends NodeMaterialBlock {
  65638. /**
  65639. * Creates a new AddBlock
  65640. * @param name defines the block name
  65641. */
  65642. constructor(name: string);
  65643. /**
  65644. * Gets the current class name
  65645. * @returns the class name
  65646. */
  65647. getClassName(): string;
  65648. /**
  65649. * Gets the left operand input component
  65650. */
  65651. get left(): NodeMaterialConnectionPoint;
  65652. /**
  65653. * Gets the right operand input component
  65654. */
  65655. get right(): NodeMaterialConnectionPoint;
  65656. /**
  65657. * Gets the output component
  65658. */
  65659. get output(): NodeMaterialConnectionPoint;
  65660. protected _buildBlock(state: NodeMaterialBuildState): this;
  65661. }
  65662. }
  65663. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65667. /**
  65668. * Block used to scale a vector by a float
  65669. */
  65670. export class ScaleBlock extends NodeMaterialBlock {
  65671. /**
  65672. * Creates a new ScaleBlock
  65673. * @param name defines the block name
  65674. */
  65675. constructor(name: string);
  65676. /**
  65677. * Gets the current class name
  65678. * @returns the class name
  65679. */
  65680. getClassName(): string;
  65681. /**
  65682. * Gets the input component
  65683. */
  65684. get input(): NodeMaterialConnectionPoint;
  65685. /**
  65686. * Gets the factor input component
  65687. */
  65688. get factor(): NodeMaterialConnectionPoint;
  65689. /**
  65690. * Gets the output component
  65691. */
  65692. get output(): NodeMaterialConnectionPoint;
  65693. protected _buildBlock(state: NodeMaterialBuildState): this;
  65694. }
  65695. }
  65696. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65700. import { Scene } from "babylonjs/scene";
  65701. /**
  65702. * Block used to clamp a float
  65703. */
  65704. export class ClampBlock extends NodeMaterialBlock {
  65705. /** Gets or sets the minimum range */
  65706. minimum: number;
  65707. /** Gets or sets the maximum range */
  65708. maximum: number;
  65709. /**
  65710. * Creates a new ClampBlock
  65711. * @param name defines the block name
  65712. */
  65713. constructor(name: string);
  65714. /**
  65715. * Gets the current class name
  65716. * @returns the class name
  65717. */
  65718. getClassName(): string;
  65719. /**
  65720. * Gets the value input component
  65721. */
  65722. get value(): NodeMaterialConnectionPoint;
  65723. /**
  65724. * Gets the output component
  65725. */
  65726. get output(): NodeMaterialConnectionPoint;
  65727. protected _buildBlock(state: NodeMaterialBuildState): this;
  65728. protected _dumpPropertiesCode(): string;
  65729. serialize(): any;
  65730. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65731. }
  65732. }
  65733. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65737. /**
  65738. * Block used to apply a cross product between 2 vectors
  65739. */
  65740. export class CrossBlock extends NodeMaterialBlock {
  65741. /**
  65742. * Creates a new CrossBlock
  65743. * @param name defines the block name
  65744. */
  65745. constructor(name: string);
  65746. /**
  65747. * Gets the current class name
  65748. * @returns the class name
  65749. */
  65750. getClassName(): string;
  65751. /**
  65752. * Gets the left operand input component
  65753. */
  65754. get left(): NodeMaterialConnectionPoint;
  65755. /**
  65756. * Gets the right operand input component
  65757. */
  65758. get right(): NodeMaterialConnectionPoint;
  65759. /**
  65760. * Gets the output component
  65761. */
  65762. get output(): NodeMaterialConnectionPoint;
  65763. protected _buildBlock(state: NodeMaterialBuildState): this;
  65764. }
  65765. }
  65766. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65770. /**
  65771. * Block used to apply a dot product between 2 vectors
  65772. */
  65773. export class DotBlock extends NodeMaterialBlock {
  65774. /**
  65775. * Creates a new DotBlock
  65776. * @param name defines the block name
  65777. */
  65778. constructor(name: string);
  65779. /**
  65780. * Gets the current class name
  65781. * @returns the class name
  65782. */
  65783. getClassName(): string;
  65784. /**
  65785. * Gets the left operand input component
  65786. */
  65787. get left(): NodeMaterialConnectionPoint;
  65788. /**
  65789. * Gets the right operand input component
  65790. */
  65791. get right(): NodeMaterialConnectionPoint;
  65792. /**
  65793. * Gets the output component
  65794. */
  65795. get output(): NodeMaterialConnectionPoint;
  65796. protected _buildBlock(state: NodeMaterialBuildState): this;
  65797. }
  65798. }
  65799. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65803. /**
  65804. * Block used to normalize a vector
  65805. */
  65806. export class NormalizeBlock extends NodeMaterialBlock {
  65807. /**
  65808. * Creates a new NormalizeBlock
  65809. * @param name defines the block name
  65810. */
  65811. constructor(name: string);
  65812. /**
  65813. * Gets the current class name
  65814. * @returns the class name
  65815. */
  65816. getClassName(): string;
  65817. /**
  65818. * Gets the input component
  65819. */
  65820. get input(): NodeMaterialConnectionPoint;
  65821. /**
  65822. * Gets the output component
  65823. */
  65824. get output(): NodeMaterialConnectionPoint;
  65825. protected _buildBlock(state: NodeMaterialBuildState): this;
  65826. }
  65827. }
  65828. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65829. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65830. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65831. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65832. import { Scene } from "babylonjs/scene";
  65833. /**
  65834. * Operations supported by the Trigonometry block
  65835. */
  65836. export enum TrigonometryBlockOperations {
  65837. /** Cos */
  65838. Cos = 0,
  65839. /** Sin */
  65840. Sin = 1,
  65841. /** Abs */
  65842. Abs = 2,
  65843. /** Exp */
  65844. Exp = 3,
  65845. /** Exp2 */
  65846. Exp2 = 4,
  65847. /** Round */
  65848. Round = 5,
  65849. /** Floor */
  65850. Floor = 6,
  65851. /** Ceiling */
  65852. Ceiling = 7,
  65853. /** Square root */
  65854. Sqrt = 8,
  65855. /** Log */
  65856. Log = 9,
  65857. /** Tangent */
  65858. Tan = 10,
  65859. /** Arc tangent */
  65860. ArcTan = 11,
  65861. /** Arc cosinus */
  65862. ArcCos = 12,
  65863. /** Arc sinus */
  65864. ArcSin = 13,
  65865. /** Fraction */
  65866. Fract = 14,
  65867. /** Sign */
  65868. Sign = 15,
  65869. /** To radians (from degrees) */
  65870. Radians = 16,
  65871. /** To degrees (from radians) */
  65872. Degrees = 17
  65873. }
  65874. /**
  65875. * Block used to apply trigonometry operation to floats
  65876. */
  65877. export class TrigonometryBlock extends NodeMaterialBlock {
  65878. /**
  65879. * Gets or sets the operation applied by the block
  65880. */
  65881. operation: TrigonometryBlockOperations;
  65882. /**
  65883. * Creates a new TrigonometryBlock
  65884. * @param name defines the block name
  65885. */
  65886. constructor(name: string);
  65887. /**
  65888. * Gets the current class name
  65889. * @returns the class name
  65890. */
  65891. getClassName(): string;
  65892. /**
  65893. * Gets the input component
  65894. */
  65895. get input(): NodeMaterialConnectionPoint;
  65896. /**
  65897. * Gets the output component
  65898. */
  65899. get output(): NodeMaterialConnectionPoint;
  65900. protected _buildBlock(state: NodeMaterialBuildState): this;
  65901. serialize(): any;
  65902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65903. protected _dumpPropertiesCode(): string;
  65904. }
  65905. }
  65906. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65910. /**
  65911. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65912. */
  65913. export class ColorMergerBlock extends NodeMaterialBlock {
  65914. /**
  65915. * Create a new ColorMergerBlock
  65916. * @param name defines the block name
  65917. */
  65918. constructor(name: string);
  65919. /**
  65920. * Gets the current class name
  65921. * @returns the class name
  65922. */
  65923. getClassName(): string;
  65924. /**
  65925. * Gets the rgb component (input)
  65926. */
  65927. get rgbIn(): NodeMaterialConnectionPoint;
  65928. /**
  65929. * Gets the r component (input)
  65930. */
  65931. get r(): NodeMaterialConnectionPoint;
  65932. /**
  65933. * Gets the g component (input)
  65934. */
  65935. get g(): NodeMaterialConnectionPoint;
  65936. /**
  65937. * Gets the b component (input)
  65938. */
  65939. get b(): NodeMaterialConnectionPoint;
  65940. /**
  65941. * Gets the a component (input)
  65942. */
  65943. get a(): NodeMaterialConnectionPoint;
  65944. /**
  65945. * Gets the rgba component (output)
  65946. */
  65947. get rgba(): NodeMaterialConnectionPoint;
  65948. /**
  65949. * Gets the rgb component (output)
  65950. */
  65951. get rgbOut(): NodeMaterialConnectionPoint;
  65952. /**
  65953. * Gets the rgb component (output)
  65954. * @deprecated Please use rgbOut instead.
  65955. */
  65956. get rgb(): NodeMaterialConnectionPoint;
  65957. protected _buildBlock(state: NodeMaterialBuildState): this;
  65958. }
  65959. }
  65960. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65961. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65962. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65963. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65964. /**
  65965. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65966. */
  65967. export class VectorSplitterBlock extends NodeMaterialBlock {
  65968. /**
  65969. * Create a new VectorSplitterBlock
  65970. * @param name defines the block name
  65971. */
  65972. constructor(name: string);
  65973. /**
  65974. * Gets the current class name
  65975. * @returns the class name
  65976. */
  65977. getClassName(): string;
  65978. /**
  65979. * Gets the xyzw component (input)
  65980. */
  65981. get xyzw(): NodeMaterialConnectionPoint;
  65982. /**
  65983. * Gets the xyz component (input)
  65984. */
  65985. get xyzIn(): NodeMaterialConnectionPoint;
  65986. /**
  65987. * Gets the xy component (input)
  65988. */
  65989. get xyIn(): NodeMaterialConnectionPoint;
  65990. /**
  65991. * Gets the xyz component (output)
  65992. */
  65993. get xyzOut(): NodeMaterialConnectionPoint;
  65994. /**
  65995. * Gets the xy component (output)
  65996. */
  65997. get xyOut(): NodeMaterialConnectionPoint;
  65998. /**
  65999. * Gets the x component (output)
  66000. */
  66001. get x(): NodeMaterialConnectionPoint;
  66002. /**
  66003. * Gets the y component (output)
  66004. */
  66005. get y(): NodeMaterialConnectionPoint;
  66006. /**
  66007. * Gets the z component (output)
  66008. */
  66009. get z(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the w component (output)
  66012. */
  66013. get w(): NodeMaterialConnectionPoint;
  66014. protected _inputRename(name: string): string;
  66015. protected _outputRename(name: string): string;
  66016. protected _buildBlock(state: NodeMaterialBuildState): this;
  66017. }
  66018. }
  66019. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66023. /**
  66024. * Block used to lerp between 2 values
  66025. */
  66026. export class LerpBlock extends NodeMaterialBlock {
  66027. /**
  66028. * Creates a new LerpBlock
  66029. * @param name defines the block name
  66030. */
  66031. constructor(name: string);
  66032. /**
  66033. * Gets the current class name
  66034. * @returns the class name
  66035. */
  66036. getClassName(): string;
  66037. /**
  66038. * Gets the left operand input component
  66039. */
  66040. get left(): NodeMaterialConnectionPoint;
  66041. /**
  66042. * Gets the right operand input component
  66043. */
  66044. get right(): NodeMaterialConnectionPoint;
  66045. /**
  66046. * Gets the gradient operand input component
  66047. */
  66048. get gradient(): NodeMaterialConnectionPoint;
  66049. /**
  66050. * Gets the output component
  66051. */
  66052. get output(): NodeMaterialConnectionPoint;
  66053. protected _buildBlock(state: NodeMaterialBuildState): this;
  66054. }
  66055. }
  66056. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66060. /**
  66061. * Block used to divide 2 vectors
  66062. */
  66063. export class DivideBlock extends NodeMaterialBlock {
  66064. /**
  66065. * Creates a new DivideBlock
  66066. * @param name defines the block name
  66067. */
  66068. constructor(name: string);
  66069. /**
  66070. * Gets the current class name
  66071. * @returns the class name
  66072. */
  66073. getClassName(): string;
  66074. /**
  66075. * Gets the left operand input component
  66076. */
  66077. get left(): NodeMaterialConnectionPoint;
  66078. /**
  66079. * Gets the right operand input component
  66080. */
  66081. get right(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the output component
  66084. */
  66085. get output(): NodeMaterialConnectionPoint;
  66086. protected _buildBlock(state: NodeMaterialBuildState): this;
  66087. }
  66088. }
  66089. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66093. /**
  66094. * Block used to subtract 2 vectors
  66095. */
  66096. export class SubtractBlock extends NodeMaterialBlock {
  66097. /**
  66098. * Creates a new SubtractBlock
  66099. * @param name defines the block name
  66100. */
  66101. constructor(name: string);
  66102. /**
  66103. * Gets the current class name
  66104. * @returns the class name
  66105. */
  66106. getClassName(): string;
  66107. /**
  66108. * Gets the left operand input component
  66109. */
  66110. get left(): NodeMaterialConnectionPoint;
  66111. /**
  66112. * Gets the right operand input component
  66113. */
  66114. get right(): NodeMaterialConnectionPoint;
  66115. /**
  66116. * Gets the output component
  66117. */
  66118. get output(): NodeMaterialConnectionPoint;
  66119. protected _buildBlock(state: NodeMaterialBuildState): this;
  66120. }
  66121. }
  66122. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66126. /**
  66127. * Block used to step a value
  66128. */
  66129. export class StepBlock extends NodeMaterialBlock {
  66130. /**
  66131. * Creates a new StepBlock
  66132. * @param name defines the block name
  66133. */
  66134. constructor(name: string);
  66135. /**
  66136. * Gets the current class name
  66137. * @returns the class name
  66138. */
  66139. getClassName(): string;
  66140. /**
  66141. * Gets the value operand input component
  66142. */
  66143. get value(): NodeMaterialConnectionPoint;
  66144. /**
  66145. * Gets the edge operand input component
  66146. */
  66147. get edge(): NodeMaterialConnectionPoint;
  66148. /**
  66149. * Gets the output component
  66150. */
  66151. get output(): NodeMaterialConnectionPoint;
  66152. protected _buildBlock(state: NodeMaterialBuildState): this;
  66153. }
  66154. }
  66155. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66159. /**
  66160. * Block used to get the opposite (1 - x) of a value
  66161. */
  66162. export class OneMinusBlock extends NodeMaterialBlock {
  66163. /**
  66164. * Creates a new OneMinusBlock
  66165. * @param name defines the block name
  66166. */
  66167. constructor(name: string);
  66168. /**
  66169. * Gets the current class name
  66170. * @returns the class name
  66171. */
  66172. getClassName(): string;
  66173. /**
  66174. * Gets the input component
  66175. */
  66176. get input(): NodeMaterialConnectionPoint;
  66177. /**
  66178. * Gets the output component
  66179. */
  66180. get output(): NodeMaterialConnectionPoint;
  66181. protected _buildBlock(state: NodeMaterialBuildState): this;
  66182. }
  66183. }
  66184. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66188. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66189. /**
  66190. * Block used to get the view direction
  66191. */
  66192. export class ViewDirectionBlock extends NodeMaterialBlock {
  66193. /**
  66194. * Creates a new ViewDirectionBlock
  66195. * @param name defines the block name
  66196. */
  66197. constructor(name: string);
  66198. /**
  66199. * Gets the current class name
  66200. * @returns the class name
  66201. */
  66202. getClassName(): string;
  66203. /**
  66204. * Gets the world position component
  66205. */
  66206. get worldPosition(): NodeMaterialConnectionPoint;
  66207. /**
  66208. * Gets the camera position component
  66209. */
  66210. get cameraPosition(): NodeMaterialConnectionPoint;
  66211. /**
  66212. * Gets the output component
  66213. */
  66214. get output(): NodeMaterialConnectionPoint;
  66215. autoConfigure(material: NodeMaterial): void;
  66216. protected _buildBlock(state: NodeMaterialBuildState): this;
  66217. }
  66218. }
  66219. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66220. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66221. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66222. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66223. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66224. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66225. /**
  66226. * Block used to compute fresnel value
  66227. */
  66228. export class FresnelBlock extends NodeMaterialBlock {
  66229. /**
  66230. * Create a new FresnelBlock
  66231. * @param name defines the block name
  66232. */
  66233. constructor(name: string);
  66234. /**
  66235. * Gets the current class name
  66236. * @returns the class name
  66237. */
  66238. getClassName(): string;
  66239. /**
  66240. * Gets the world normal input component
  66241. */
  66242. get worldNormal(): NodeMaterialConnectionPoint;
  66243. /**
  66244. * Gets the view direction input component
  66245. */
  66246. get viewDirection(): NodeMaterialConnectionPoint;
  66247. /**
  66248. * Gets the bias input component
  66249. */
  66250. get bias(): NodeMaterialConnectionPoint;
  66251. /**
  66252. * Gets the camera (or eye) position component
  66253. */
  66254. get power(): NodeMaterialConnectionPoint;
  66255. /**
  66256. * Gets the fresnel output component
  66257. */
  66258. get fresnel(): NodeMaterialConnectionPoint;
  66259. autoConfigure(material: NodeMaterial): void;
  66260. protected _buildBlock(state: NodeMaterialBuildState): this;
  66261. }
  66262. }
  66263. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66267. /**
  66268. * Block used to get the max of 2 values
  66269. */
  66270. export class MaxBlock extends NodeMaterialBlock {
  66271. /**
  66272. * Creates a new MaxBlock
  66273. * @param name defines the block name
  66274. */
  66275. constructor(name: string);
  66276. /**
  66277. * Gets the current class name
  66278. * @returns the class name
  66279. */
  66280. getClassName(): string;
  66281. /**
  66282. * Gets the left operand input component
  66283. */
  66284. get left(): NodeMaterialConnectionPoint;
  66285. /**
  66286. * Gets the right operand input component
  66287. */
  66288. get right(): NodeMaterialConnectionPoint;
  66289. /**
  66290. * Gets the output component
  66291. */
  66292. get output(): NodeMaterialConnectionPoint;
  66293. protected _buildBlock(state: NodeMaterialBuildState): this;
  66294. }
  66295. }
  66296. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66300. /**
  66301. * Block used to get the min of 2 values
  66302. */
  66303. export class MinBlock extends NodeMaterialBlock {
  66304. /**
  66305. * Creates a new MinBlock
  66306. * @param name defines the block name
  66307. */
  66308. constructor(name: string);
  66309. /**
  66310. * Gets the current class name
  66311. * @returns the class name
  66312. */
  66313. getClassName(): string;
  66314. /**
  66315. * Gets the left operand input component
  66316. */
  66317. get left(): NodeMaterialConnectionPoint;
  66318. /**
  66319. * Gets the right operand input component
  66320. */
  66321. get right(): NodeMaterialConnectionPoint;
  66322. /**
  66323. * Gets the output component
  66324. */
  66325. get output(): NodeMaterialConnectionPoint;
  66326. protected _buildBlock(state: NodeMaterialBuildState): this;
  66327. }
  66328. }
  66329. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66333. /**
  66334. * Block used to get the distance between 2 values
  66335. */
  66336. export class DistanceBlock extends NodeMaterialBlock {
  66337. /**
  66338. * Creates a new DistanceBlock
  66339. * @param name defines the block name
  66340. */
  66341. constructor(name: string);
  66342. /**
  66343. * Gets the current class name
  66344. * @returns the class name
  66345. */
  66346. getClassName(): string;
  66347. /**
  66348. * Gets the left operand input component
  66349. */
  66350. get left(): NodeMaterialConnectionPoint;
  66351. /**
  66352. * Gets the right operand input component
  66353. */
  66354. get right(): NodeMaterialConnectionPoint;
  66355. /**
  66356. * Gets the output component
  66357. */
  66358. get output(): NodeMaterialConnectionPoint;
  66359. protected _buildBlock(state: NodeMaterialBuildState): this;
  66360. }
  66361. }
  66362. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66363. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66364. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66366. /**
  66367. * Block used to get the length of a vector
  66368. */
  66369. export class LengthBlock extends NodeMaterialBlock {
  66370. /**
  66371. * Creates a new LengthBlock
  66372. * @param name defines the block name
  66373. */
  66374. constructor(name: string);
  66375. /**
  66376. * Gets the current class name
  66377. * @returns the class name
  66378. */
  66379. getClassName(): string;
  66380. /**
  66381. * Gets the value input component
  66382. */
  66383. get value(): 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/negateBlock" {
  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 get negative version of a value (i.e. x * -1)
  66397. */
  66398. export class NegateBlock extends NodeMaterialBlock {
  66399. /**
  66400. * Creates a new NegateBlock
  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 value input component
  66411. */
  66412. get value(): 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/powBlock" {
  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 get the value of the first parameter raised to the power of the second
  66426. */
  66427. export class PowBlock extends NodeMaterialBlock {
  66428. /**
  66429. * Creates a new PowBlock
  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 value operand input component
  66440. */
  66441. get value(): NodeMaterialConnectionPoint;
  66442. /**
  66443. * Gets the power operand input component
  66444. */
  66445. get power(): NodeMaterialConnectionPoint;
  66446. /**
  66447. * Gets the output component
  66448. */
  66449. get output(): NodeMaterialConnectionPoint;
  66450. protected _buildBlock(state: NodeMaterialBuildState): this;
  66451. }
  66452. }
  66453. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66454. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66455. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66456. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66457. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66458. /**
  66459. * Block used to get a random number
  66460. */
  66461. export class RandomNumberBlock extends NodeMaterialBlock {
  66462. /**
  66463. * Creates a new RandomNumberBlock
  66464. * @param name defines the block name
  66465. */
  66466. constructor(name: string);
  66467. /**
  66468. * Gets the current class name
  66469. * @returns the class name
  66470. */
  66471. getClassName(): string;
  66472. /**
  66473. * Gets the seed input component
  66474. */
  66475. get seed(): NodeMaterialConnectionPoint;
  66476. /**
  66477. * Gets the output component
  66478. */
  66479. get output(): NodeMaterialConnectionPoint;
  66480. protected _buildBlock(state: NodeMaterialBuildState): this;
  66481. }
  66482. }
  66483. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66487. /**
  66488. * Block used to compute arc tangent of 2 values
  66489. */
  66490. export class ArcTan2Block extends NodeMaterialBlock {
  66491. /**
  66492. * Creates a new ArcTan2Block
  66493. * @param name defines the block name
  66494. */
  66495. constructor(name: string);
  66496. /**
  66497. * Gets the current class name
  66498. * @returns the class name
  66499. */
  66500. getClassName(): string;
  66501. /**
  66502. * Gets the x operand input component
  66503. */
  66504. get x(): NodeMaterialConnectionPoint;
  66505. /**
  66506. * Gets the y operand input component
  66507. */
  66508. get y(): NodeMaterialConnectionPoint;
  66509. /**
  66510. * Gets the output component
  66511. */
  66512. get output(): NodeMaterialConnectionPoint;
  66513. protected _buildBlock(state: NodeMaterialBuildState): this;
  66514. }
  66515. }
  66516. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  66517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66519. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66520. /**
  66521. * Block used to smooth step a value
  66522. */
  66523. export class SmoothStepBlock extends NodeMaterialBlock {
  66524. /**
  66525. * Creates a new SmoothStepBlock
  66526. * @param name defines the block name
  66527. */
  66528. constructor(name: string);
  66529. /**
  66530. * Gets the current class name
  66531. * @returns the class name
  66532. */
  66533. getClassName(): string;
  66534. /**
  66535. * Gets the value operand input component
  66536. */
  66537. get value(): NodeMaterialConnectionPoint;
  66538. /**
  66539. * Gets the first edge operand input component
  66540. */
  66541. get edge0(): NodeMaterialConnectionPoint;
  66542. /**
  66543. * Gets the second edge operand input component
  66544. */
  66545. get edge1(): NodeMaterialConnectionPoint;
  66546. /**
  66547. * Gets the output component
  66548. */
  66549. get output(): NodeMaterialConnectionPoint;
  66550. protected _buildBlock(state: NodeMaterialBuildState): this;
  66551. }
  66552. }
  66553. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66557. /**
  66558. * Block used to get the reciprocal (1 / x) of a value
  66559. */
  66560. export class ReciprocalBlock extends NodeMaterialBlock {
  66561. /**
  66562. * Creates a new ReciprocalBlock
  66563. * @param name defines the block name
  66564. */
  66565. constructor(name: string);
  66566. /**
  66567. * Gets the current class name
  66568. * @returns the class name
  66569. */
  66570. getClassName(): string;
  66571. /**
  66572. * Gets the input component
  66573. */
  66574. get input(): NodeMaterialConnectionPoint;
  66575. /**
  66576. * Gets the output component
  66577. */
  66578. get output(): NodeMaterialConnectionPoint;
  66579. protected _buildBlock(state: NodeMaterialBuildState): this;
  66580. }
  66581. }
  66582. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  66583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66586. /**
  66587. * Block used to replace a color by another one
  66588. */
  66589. export class ReplaceColorBlock extends NodeMaterialBlock {
  66590. /**
  66591. * Creates a new ReplaceColorBlock
  66592. * @param name defines the block name
  66593. */
  66594. constructor(name: string);
  66595. /**
  66596. * Gets the current class name
  66597. * @returns the class name
  66598. */
  66599. getClassName(): string;
  66600. /**
  66601. * Gets the value input component
  66602. */
  66603. get value(): NodeMaterialConnectionPoint;
  66604. /**
  66605. * Gets the reference input component
  66606. */
  66607. get reference(): NodeMaterialConnectionPoint;
  66608. /**
  66609. * Gets the distance input component
  66610. */
  66611. get distance(): NodeMaterialConnectionPoint;
  66612. /**
  66613. * Gets the replacement input component
  66614. */
  66615. get replacement(): NodeMaterialConnectionPoint;
  66616. /**
  66617. * Gets the output component
  66618. */
  66619. get output(): NodeMaterialConnectionPoint;
  66620. protected _buildBlock(state: NodeMaterialBuildState): this;
  66621. }
  66622. }
  66623. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  66624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66625. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66626. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66627. /**
  66628. * Block used to posterize a value
  66629. * @see https://en.wikipedia.org/wiki/Posterization
  66630. */
  66631. export class PosterizeBlock extends NodeMaterialBlock {
  66632. /**
  66633. * Creates a new PosterizeBlock
  66634. * @param name defines the block name
  66635. */
  66636. constructor(name: string);
  66637. /**
  66638. * Gets the current class name
  66639. * @returns the class name
  66640. */
  66641. getClassName(): string;
  66642. /**
  66643. * Gets the value input component
  66644. */
  66645. get value(): NodeMaterialConnectionPoint;
  66646. /**
  66647. * Gets the steps input component
  66648. */
  66649. get steps(): NodeMaterialConnectionPoint;
  66650. /**
  66651. * Gets the output component
  66652. */
  66653. get output(): NodeMaterialConnectionPoint;
  66654. protected _buildBlock(state: NodeMaterialBuildState): this;
  66655. }
  66656. }
  66657. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66661. import { Scene } from "babylonjs/scene";
  66662. /**
  66663. * Operations supported by the Wave block
  66664. */
  66665. export enum WaveBlockKind {
  66666. /** SawTooth */
  66667. SawTooth = 0,
  66668. /** Square */
  66669. Square = 1,
  66670. /** Triangle */
  66671. Triangle = 2
  66672. }
  66673. /**
  66674. * Block used to apply wave operation to floats
  66675. */
  66676. export class WaveBlock extends NodeMaterialBlock {
  66677. /**
  66678. * Gets or sets the kibnd of wave to be applied by the block
  66679. */
  66680. kind: WaveBlockKind;
  66681. /**
  66682. * Creates a new WaveBlock
  66683. * @param name defines the block name
  66684. */
  66685. constructor(name: string);
  66686. /**
  66687. * Gets the current class name
  66688. * @returns the class name
  66689. */
  66690. getClassName(): string;
  66691. /**
  66692. * Gets the input component
  66693. */
  66694. get input(): NodeMaterialConnectionPoint;
  66695. /**
  66696. * Gets the output component
  66697. */
  66698. get output(): NodeMaterialConnectionPoint;
  66699. protected _buildBlock(state: NodeMaterialBuildState): this;
  66700. serialize(): any;
  66701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66702. }
  66703. }
  66704. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66708. import { Color3 } from "babylonjs/Maths/math.color";
  66709. import { Scene } from "babylonjs/scene";
  66710. /**
  66711. * Class used to store a color step for the GradientBlock
  66712. */
  66713. export class GradientBlockColorStep {
  66714. /**
  66715. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66716. */
  66717. step: number;
  66718. /**
  66719. * Gets or sets the color associated with this step
  66720. */
  66721. color: Color3;
  66722. /**
  66723. * Creates a new GradientBlockColorStep
  66724. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66725. * @param color defines the color associated with this step
  66726. */
  66727. constructor(
  66728. /**
  66729. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66730. */
  66731. step: number,
  66732. /**
  66733. * Gets or sets the color associated with this step
  66734. */
  66735. color: Color3);
  66736. }
  66737. /**
  66738. * Block used to return a color from a gradient based on an input value between 0 and 1
  66739. */
  66740. export class GradientBlock extends NodeMaterialBlock {
  66741. /**
  66742. * Gets or sets the list of color steps
  66743. */
  66744. colorSteps: GradientBlockColorStep[];
  66745. /**
  66746. * Creates a new GradientBlock
  66747. * @param name defines the block name
  66748. */
  66749. constructor(name: string);
  66750. /**
  66751. * Gets the current class name
  66752. * @returns the class name
  66753. */
  66754. getClassName(): string;
  66755. /**
  66756. * Gets the gradient input component
  66757. */
  66758. get gradient(): NodeMaterialConnectionPoint;
  66759. /**
  66760. * Gets the output component
  66761. */
  66762. get output(): NodeMaterialConnectionPoint;
  66763. private _writeColorConstant;
  66764. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66765. serialize(): any;
  66766. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66767. protected _dumpPropertiesCode(): string;
  66768. }
  66769. }
  66770. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66773. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66774. /**
  66775. * Block used to normalize lerp between 2 values
  66776. */
  66777. export class NLerpBlock extends NodeMaterialBlock {
  66778. /**
  66779. * Creates a new NLerpBlock
  66780. * @param name defines the block name
  66781. */
  66782. constructor(name: string);
  66783. /**
  66784. * Gets the current class name
  66785. * @returns the class name
  66786. */
  66787. getClassName(): string;
  66788. /**
  66789. * Gets the left operand input component
  66790. */
  66791. get left(): NodeMaterialConnectionPoint;
  66792. /**
  66793. * Gets the right operand input component
  66794. */
  66795. get right(): NodeMaterialConnectionPoint;
  66796. /**
  66797. * Gets the gradient operand input component
  66798. */
  66799. get gradient(): NodeMaterialConnectionPoint;
  66800. /**
  66801. * Gets the output component
  66802. */
  66803. get output(): NodeMaterialConnectionPoint;
  66804. protected _buildBlock(state: NodeMaterialBuildState): this;
  66805. }
  66806. }
  66807. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66811. import { Scene } from "babylonjs/scene";
  66812. /**
  66813. * block used to Generate a Worley Noise 3D Noise Pattern
  66814. */
  66815. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66816. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66817. manhattanDistance: boolean;
  66818. /**
  66819. * Creates a new WorleyNoise3DBlock
  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 seed input component
  66830. */
  66831. get seed(): NodeMaterialConnectionPoint;
  66832. /**
  66833. * Gets the jitter input component
  66834. */
  66835. get jitter(): NodeMaterialConnectionPoint;
  66836. /**
  66837. * Gets the output component
  66838. */
  66839. get output(): NodeMaterialConnectionPoint;
  66840. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66841. /**
  66842. * Exposes the properties to the UI?
  66843. */
  66844. protected _dumpPropertiesCode(): string;
  66845. /**
  66846. * Exposes the properties to the Seralize?
  66847. */
  66848. serialize(): any;
  66849. /**
  66850. * Exposes the properties to the deseralize?
  66851. */
  66852. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66853. }
  66854. }
  66855. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66859. /**
  66860. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66861. */
  66862. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66863. /**
  66864. * Creates a new SimplexPerlin3DBlock
  66865. * @param name defines the block name
  66866. */
  66867. constructor(name: string);
  66868. /**
  66869. * Gets the current class name
  66870. * @returns the class name
  66871. */
  66872. getClassName(): string;
  66873. /**
  66874. * Gets the seed operand input component
  66875. */
  66876. get seed(): NodeMaterialConnectionPoint;
  66877. /**
  66878. * Gets the output component
  66879. */
  66880. get output(): NodeMaterialConnectionPoint;
  66881. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66882. }
  66883. }
  66884. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66888. /**
  66889. * Block used to blend normals
  66890. */
  66891. export class NormalBlendBlock extends NodeMaterialBlock {
  66892. /**
  66893. * Creates a new NormalBlendBlock
  66894. * @param name defines the block name
  66895. */
  66896. constructor(name: string);
  66897. /**
  66898. * Gets the current class name
  66899. * @returns the class name
  66900. */
  66901. getClassName(): string;
  66902. /**
  66903. * Gets the first input component
  66904. */
  66905. get normalMap0(): NodeMaterialConnectionPoint;
  66906. /**
  66907. * Gets the second input component
  66908. */
  66909. get normalMap1(): NodeMaterialConnectionPoint;
  66910. /**
  66911. * Gets the output component
  66912. */
  66913. get output(): NodeMaterialConnectionPoint;
  66914. protected _buildBlock(state: NodeMaterialBuildState): this;
  66915. }
  66916. }
  66917. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66921. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66922. /**
  66923. * Block used to rotate a 2d vector by a given angle
  66924. */
  66925. export class Rotate2dBlock extends NodeMaterialBlock {
  66926. /**
  66927. * Creates a new Rotate2dBlock
  66928. * @param name defines the block name
  66929. */
  66930. constructor(name: string);
  66931. /**
  66932. * Gets the current class name
  66933. * @returns the class name
  66934. */
  66935. getClassName(): string;
  66936. /**
  66937. * Gets the input vector
  66938. */
  66939. get input(): NodeMaterialConnectionPoint;
  66940. /**
  66941. * Gets the input angle
  66942. */
  66943. get angle(): NodeMaterialConnectionPoint;
  66944. /**
  66945. * Gets the output component
  66946. */
  66947. get output(): NodeMaterialConnectionPoint;
  66948. autoConfigure(material: NodeMaterial): void;
  66949. protected _buildBlock(state: NodeMaterialBuildState): this;
  66950. }
  66951. }
  66952. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66955. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66956. /**
  66957. * Block used to get the reflected vector from a direction and a normal
  66958. */
  66959. export class ReflectBlock extends NodeMaterialBlock {
  66960. /**
  66961. * Creates a new ReflectBlock
  66962. * @param name defines the block name
  66963. */
  66964. constructor(name: string);
  66965. /**
  66966. * Gets the current class name
  66967. * @returns the class name
  66968. */
  66969. getClassName(): string;
  66970. /**
  66971. * Gets the incident component
  66972. */
  66973. get incident(): NodeMaterialConnectionPoint;
  66974. /**
  66975. * Gets the normal component
  66976. */
  66977. get normal(): NodeMaterialConnectionPoint;
  66978. /**
  66979. * Gets the output component
  66980. */
  66981. get output(): NodeMaterialConnectionPoint;
  66982. protected _buildBlock(state: NodeMaterialBuildState): this;
  66983. }
  66984. }
  66985. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66986. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66987. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66988. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66989. /**
  66990. * Block used to get the refracted vector from a direction and a normal
  66991. */
  66992. export class RefractBlock extends NodeMaterialBlock {
  66993. /**
  66994. * Creates a new RefractBlock
  66995. * @param name defines the block name
  66996. */
  66997. constructor(name: string);
  66998. /**
  66999. * Gets the current class name
  67000. * @returns the class name
  67001. */
  67002. getClassName(): string;
  67003. /**
  67004. * Gets the incident component
  67005. */
  67006. get incident(): NodeMaterialConnectionPoint;
  67007. /**
  67008. * Gets the normal component
  67009. */
  67010. get normal(): NodeMaterialConnectionPoint;
  67011. /**
  67012. * Gets the index of refraction component
  67013. */
  67014. get ior(): NodeMaterialConnectionPoint;
  67015. /**
  67016. * Gets the output component
  67017. */
  67018. get output(): NodeMaterialConnectionPoint;
  67019. protected _buildBlock(state: NodeMaterialBuildState): this;
  67020. }
  67021. }
  67022. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67026. /**
  67027. * Block used to desaturate a color
  67028. */
  67029. export class DesaturateBlock extends NodeMaterialBlock {
  67030. /**
  67031. * Creates a new DesaturateBlock
  67032. * @param name defines the block name
  67033. */
  67034. constructor(name: string);
  67035. /**
  67036. * Gets the current class name
  67037. * @returns the class name
  67038. */
  67039. getClassName(): string;
  67040. /**
  67041. * Gets the color operand input component
  67042. */
  67043. get color(): NodeMaterialConnectionPoint;
  67044. /**
  67045. * Gets the level operand input component
  67046. */
  67047. get level(): NodeMaterialConnectionPoint;
  67048. /**
  67049. * Gets the output component
  67050. */
  67051. get output(): NodeMaterialConnectionPoint;
  67052. protected _buildBlock(state: NodeMaterialBuildState): this;
  67053. }
  67054. }
  67055. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67059. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67060. import { Nullable } from "babylonjs/types";
  67061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67062. import { Scene } from "babylonjs/scene";
  67063. /**
  67064. * Block used to implement the ambient occlusion module of the PBR material
  67065. */
  67066. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67067. /**
  67068. * Create a new AmbientOcclusionBlock
  67069. * @param name defines the block name
  67070. */
  67071. constructor(name: string);
  67072. /**
  67073. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67074. */
  67075. useAmbientInGrayScale: boolean;
  67076. /**
  67077. * Initialize the block and prepare the context for build
  67078. * @param state defines the state that will be used for the build
  67079. */
  67080. initialize(state: NodeMaterialBuildState): void;
  67081. /**
  67082. * Gets the current class name
  67083. * @returns the class name
  67084. */
  67085. getClassName(): string;
  67086. /**
  67087. * Gets the texture input component
  67088. */
  67089. get texture(): NodeMaterialConnectionPoint;
  67090. /**
  67091. * Gets the texture intensity component
  67092. */
  67093. get intensity(): NodeMaterialConnectionPoint;
  67094. /**
  67095. * Gets the direct light intensity input component
  67096. */
  67097. get directLightIntensity(): NodeMaterialConnectionPoint;
  67098. /**
  67099. * Gets the ambient occlusion object output component
  67100. */
  67101. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67102. /**
  67103. * Gets the main code of the block (fragment side)
  67104. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67105. * @returns the shader code
  67106. */
  67107. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67109. protected _buildBlock(state: NodeMaterialBuildState): this;
  67110. protected _dumpPropertiesCode(): string;
  67111. serialize(): any;
  67112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67113. }
  67114. }
  67115. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67118. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67119. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67121. import { Nullable } from "babylonjs/types";
  67122. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67123. import { Mesh } from "babylonjs/Meshes/mesh";
  67124. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67125. import { Effect } from "babylonjs/Materials/effect";
  67126. import { Scene } from "babylonjs/scene";
  67127. /**
  67128. * Block used to implement the reflection module of the PBR material
  67129. */
  67130. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67131. /** @hidden */
  67132. _defineLODReflectionAlpha: string;
  67133. /** @hidden */
  67134. _defineLinearSpecularReflection: string;
  67135. private _vEnvironmentIrradianceName;
  67136. /** @hidden */
  67137. _vReflectionMicrosurfaceInfosName: string;
  67138. /** @hidden */
  67139. _vReflectionInfosName: string;
  67140. /** @hidden */
  67141. _vReflectionFilteringInfoName: string;
  67142. private _scene;
  67143. /**
  67144. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67145. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67146. * It's less burden on the user side in the editor part.
  67147. */
  67148. /** @hidden */
  67149. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67150. /** @hidden */
  67151. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67152. /** @hidden */
  67153. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67154. /**
  67155. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67156. * diffuse part of the IBL.
  67157. */
  67158. useSphericalHarmonics: boolean;
  67159. /**
  67160. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67161. */
  67162. forceIrradianceInFragment: boolean;
  67163. /**
  67164. * Create a new ReflectionBlock
  67165. * @param name defines the block name
  67166. */
  67167. constructor(name: string);
  67168. /**
  67169. * Gets the current class name
  67170. * @returns the class name
  67171. */
  67172. getClassName(): string;
  67173. /**
  67174. * Gets the position input component
  67175. */
  67176. get position(): NodeMaterialConnectionPoint;
  67177. /**
  67178. * Gets the world position input component
  67179. */
  67180. get worldPosition(): NodeMaterialConnectionPoint;
  67181. /**
  67182. * Gets the world normal input component
  67183. */
  67184. get worldNormal(): NodeMaterialConnectionPoint;
  67185. /**
  67186. * Gets the world input component
  67187. */
  67188. get world(): NodeMaterialConnectionPoint;
  67189. /**
  67190. * Gets the camera (or eye) position component
  67191. */
  67192. get cameraPosition(): NodeMaterialConnectionPoint;
  67193. /**
  67194. * Gets the view input component
  67195. */
  67196. get view(): NodeMaterialConnectionPoint;
  67197. /**
  67198. * Gets the color input component
  67199. */
  67200. get color(): NodeMaterialConnectionPoint;
  67201. /**
  67202. * Gets the reflection object output component
  67203. */
  67204. get reflection(): NodeMaterialConnectionPoint;
  67205. /**
  67206. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67207. */
  67208. get hasTexture(): boolean;
  67209. /**
  67210. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67211. */
  67212. get reflectionColor(): string;
  67213. protected _getTexture(): Nullable<BaseTexture>;
  67214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67216. /**
  67217. * Gets the code to inject in the vertex shader
  67218. * @param state current state of the node material building
  67219. * @returns the shader code
  67220. */
  67221. handleVertexSide(state: NodeMaterialBuildState): string;
  67222. /**
  67223. * Gets the main code of the block (fragment side)
  67224. * @param state current state of the node material building
  67225. * @param normalVarName name of the existing variable corresponding to the normal
  67226. * @returns the shader code
  67227. */
  67228. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67229. protected _buildBlock(state: NodeMaterialBuildState): this;
  67230. protected _dumpPropertiesCode(): string;
  67231. serialize(): any;
  67232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67233. }
  67234. }
  67235. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67239. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67241. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67242. import { Scene } from "babylonjs/scene";
  67243. import { Nullable } from "babylonjs/types";
  67244. /**
  67245. * Block used to implement the sheen module of the PBR material
  67246. */
  67247. export class SheenBlock extends NodeMaterialBlock {
  67248. /**
  67249. * Create a new SheenBlock
  67250. * @param name defines the block name
  67251. */
  67252. constructor(name: string);
  67253. /**
  67254. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67255. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67256. * making it easier to setup and tweak the effect
  67257. */
  67258. albedoScaling: boolean;
  67259. /**
  67260. * Defines if the sheen is linked to the sheen color.
  67261. */
  67262. linkSheenWithAlbedo: boolean;
  67263. /**
  67264. * Initialize the block and prepare the context for build
  67265. * @param state defines the state that will be used for the build
  67266. */
  67267. initialize(state: NodeMaterialBuildState): void;
  67268. /**
  67269. * Gets the current class name
  67270. * @returns the class name
  67271. */
  67272. getClassName(): string;
  67273. /**
  67274. * Gets the intensity input component
  67275. */
  67276. get intensity(): NodeMaterialConnectionPoint;
  67277. /**
  67278. * Gets the color input component
  67279. */
  67280. get color(): NodeMaterialConnectionPoint;
  67281. /**
  67282. * Gets the roughness input component
  67283. */
  67284. get roughness(): NodeMaterialConnectionPoint;
  67285. /**
  67286. * Gets the sheen object output component
  67287. */
  67288. get sheen(): NodeMaterialConnectionPoint;
  67289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67290. /**
  67291. * Gets the main code of the block (fragment side)
  67292. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67293. * @returns the shader code
  67294. */
  67295. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67296. protected _buildBlock(state: NodeMaterialBuildState): this;
  67297. protected _dumpPropertiesCode(): string;
  67298. serialize(): any;
  67299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67300. }
  67301. }
  67302. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67303. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67304. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67305. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67307. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67308. import { Scene } from "babylonjs/scene";
  67309. import { Nullable } from "babylonjs/types";
  67310. import { Mesh } from "babylonjs/Meshes/mesh";
  67311. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67312. import { Effect } from "babylonjs/Materials/effect";
  67313. /**
  67314. * Block used to implement the reflectivity module of the PBR material
  67315. */
  67316. export class ReflectivityBlock extends NodeMaterialBlock {
  67317. private _metallicReflectanceColor;
  67318. private _metallicF0Factor;
  67319. /** @hidden */
  67320. _vMetallicReflectanceFactorsName: string;
  67321. /**
  67322. * The property below is set by the main PBR block prior to calling methods of this class.
  67323. */
  67324. /** @hidden */
  67325. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67326. /**
  67327. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67328. */
  67329. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67330. /**
  67331. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67332. */
  67333. useMetallnessFromMetallicTextureBlue: boolean;
  67334. /**
  67335. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67336. */
  67337. useRoughnessFromMetallicTextureAlpha: boolean;
  67338. /**
  67339. * Specifies if the metallic texture contains the roughness information in its green channel.
  67340. */
  67341. useRoughnessFromMetallicTextureGreen: boolean;
  67342. /**
  67343. * Create a new ReflectivityBlock
  67344. * @param name defines the block name
  67345. */
  67346. constructor(name: string);
  67347. /**
  67348. * Initialize the block and prepare the context for build
  67349. * @param state defines the state that will be used for the build
  67350. */
  67351. initialize(state: NodeMaterialBuildState): void;
  67352. /**
  67353. * Gets the current class name
  67354. * @returns the class name
  67355. */
  67356. getClassName(): string;
  67357. /**
  67358. * Gets the metallic input component
  67359. */
  67360. get metallic(): NodeMaterialConnectionPoint;
  67361. /**
  67362. * Gets the roughness input component
  67363. */
  67364. get roughness(): NodeMaterialConnectionPoint;
  67365. /**
  67366. * Gets the texture input component
  67367. */
  67368. get texture(): NodeMaterialConnectionPoint;
  67369. /**
  67370. * Gets the reflectivity object output component
  67371. */
  67372. get reflectivity(): NodeMaterialConnectionPoint;
  67373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67374. /**
  67375. * Gets the main code of the block (fragment side)
  67376. * @param state current state of the node material building
  67377. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67378. * @returns the shader code
  67379. */
  67380. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67382. protected _buildBlock(state: NodeMaterialBuildState): this;
  67383. protected _dumpPropertiesCode(): string;
  67384. serialize(): any;
  67385. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67386. }
  67387. }
  67388. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67389. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67391. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67394. /**
  67395. * Block used to implement the anisotropy module of the PBR material
  67396. */
  67397. export class AnisotropyBlock extends NodeMaterialBlock {
  67398. /**
  67399. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67400. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67401. * It's less burden on the user side in the editor part.
  67402. */
  67403. /** @hidden */
  67404. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67405. /** @hidden */
  67406. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67407. /**
  67408. * Create a new AnisotropyBlock
  67409. * @param name defines the block name
  67410. */
  67411. constructor(name: string);
  67412. /**
  67413. * Initialize the block and prepare the context for build
  67414. * @param state defines the state that will be used for the build
  67415. */
  67416. initialize(state: NodeMaterialBuildState): void;
  67417. /**
  67418. * Gets the current class name
  67419. * @returns the class name
  67420. */
  67421. getClassName(): string;
  67422. /**
  67423. * Gets the intensity input component
  67424. */
  67425. get intensity(): NodeMaterialConnectionPoint;
  67426. /**
  67427. * Gets the direction input component
  67428. */
  67429. get direction(): NodeMaterialConnectionPoint;
  67430. /**
  67431. * Gets the texture input component
  67432. */
  67433. get texture(): NodeMaterialConnectionPoint;
  67434. /**
  67435. * Gets the uv input component
  67436. */
  67437. get uv(): NodeMaterialConnectionPoint;
  67438. /**
  67439. * Gets the worldTangent input component
  67440. */
  67441. get worldTangent(): NodeMaterialConnectionPoint;
  67442. /**
  67443. * Gets the anisotropy object output component
  67444. */
  67445. get anisotropy(): NodeMaterialConnectionPoint;
  67446. private _generateTBNSpace;
  67447. /**
  67448. * Gets the main code of the block (fragment side)
  67449. * @param state current state of the node material building
  67450. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67451. * @returns the shader code
  67452. */
  67453. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67454. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67455. protected _buildBlock(state: NodeMaterialBuildState): this;
  67456. }
  67457. }
  67458. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67462. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67464. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67465. import { Nullable } from "babylonjs/types";
  67466. import { Mesh } from "babylonjs/Meshes/mesh";
  67467. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67468. import { Effect } from "babylonjs/Materials/effect";
  67469. /**
  67470. * Block used to implement the clear coat module of the PBR material
  67471. */
  67472. export class ClearCoatBlock extends NodeMaterialBlock {
  67473. private _scene;
  67474. /**
  67475. * Create a new ClearCoatBlock
  67476. * @param name defines the block name
  67477. */
  67478. constructor(name: string);
  67479. /**
  67480. * Initialize the block and prepare the context for build
  67481. * @param state defines the state that will be used for the build
  67482. */
  67483. initialize(state: NodeMaterialBuildState): void;
  67484. /**
  67485. * Gets the current class name
  67486. * @returns the class name
  67487. */
  67488. getClassName(): string;
  67489. /**
  67490. * Gets the intensity input component
  67491. */
  67492. get intensity(): NodeMaterialConnectionPoint;
  67493. /**
  67494. * Gets the roughness input component
  67495. */
  67496. get roughness(): NodeMaterialConnectionPoint;
  67497. /**
  67498. * Gets the ior input component
  67499. */
  67500. get ior(): NodeMaterialConnectionPoint;
  67501. /**
  67502. * Gets the texture input component
  67503. */
  67504. get texture(): NodeMaterialConnectionPoint;
  67505. /**
  67506. * Gets the bump texture input component
  67507. */
  67508. get bumpTexture(): NodeMaterialConnectionPoint;
  67509. /**
  67510. * Gets the uv input component
  67511. */
  67512. get uv(): NodeMaterialConnectionPoint;
  67513. /**
  67514. * Gets the tint color input component
  67515. */
  67516. get tintColor(): NodeMaterialConnectionPoint;
  67517. /**
  67518. * Gets the tint "at distance" input component
  67519. */
  67520. get tintAtDistance(): NodeMaterialConnectionPoint;
  67521. /**
  67522. * Gets the tint thickness input component
  67523. */
  67524. get tintThickness(): NodeMaterialConnectionPoint;
  67525. /**
  67526. * Gets the world tangent input component
  67527. */
  67528. get worldTangent(): NodeMaterialConnectionPoint;
  67529. /**
  67530. * Gets the clear coat object output component
  67531. */
  67532. get clearcoat(): NodeMaterialConnectionPoint;
  67533. autoConfigure(material: NodeMaterial): void;
  67534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67535. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67536. private _generateTBNSpace;
  67537. /**
  67538. * Gets the main code of the block (fragment side)
  67539. * @param state current state of the node material building
  67540. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67541. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67542. * @param worldPosVarName name of the variable holding the world position
  67543. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67544. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67545. * @param worldNormalVarName name of the variable holding the world normal
  67546. * @returns the shader code
  67547. */
  67548. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67549. protected _buildBlock(state: NodeMaterialBuildState): this;
  67550. }
  67551. }
  67552. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67556. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67558. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67559. import { Nullable } from "babylonjs/types";
  67560. /**
  67561. * Block used to implement the sub surface module of the PBR material
  67562. */
  67563. export class SubSurfaceBlock extends NodeMaterialBlock {
  67564. /**
  67565. * Create a new SubSurfaceBlock
  67566. * @param name defines the block name
  67567. */
  67568. constructor(name: string);
  67569. /**
  67570. * Stores the intensity of the different subsurface effects in the thickness texture.
  67571. * * the green channel is the translucency intensity.
  67572. * * the blue channel is the scattering intensity.
  67573. * * the alpha channel is the refraction intensity.
  67574. */
  67575. useMaskFromThicknessTexture: boolean;
  67576. /**
  67577. * Initialize the block and prepare the context for build
  67578. * @param state defines the state that will be used for the build
  67579. */
  67580. initialize(state: NodeMaterialBuildState): void;
  67581. /**
  67582. * Gets the current class name
  67583. * @returns the class name
  67584. */
  67585. getClassName(): string;
  67586. /**
  67587. * Gets the min thickness input component
  67588. */
  67589. get minThickness(): NodeMaterialConnectionPoint;
  67590. /**
  67591. * Gets the max thickness input component
  67592. */
  67593. get maxThickness(): NodeMaterialConnectionPoint;
  67594. /**
  67595. * Gets the thickness texture component
  67596. */
  67597. get thicknessTexture(): NodeMaterialConnectionPoint;
  67598. /**
  67599. * Gets the tint color input component
  67600. */
  67601. get tintColor(): NodeMaterialConnectionPoint;
  67602. /**
  67603. * Gets the translucency intensity input component
  67604. */
  67605. get translucencyIntensity(): NodeMaterialConnectionPoint;
  67606. /**
  67607. * Gets the translucency diffusion distance input component
  67608. */
  67609. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  67610. /**
  67611. * Gets the refraction object parameters
  67612. */
  67613. get refraction(): NodeMaterialConnectionPoint;
  67614. /**
  67615. * Gets the sub surface object output component
  67616. */
  67617. get subsurface(): NodeMaterialConnectionPoint;
  67618. autoConfigure(material: NodeMaterial): void;
  67619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67620. /**
  67621. * Gets the main code of the block (fragment side)
  67622. * @param state current state of the node material building
  67623. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  67624. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67625. * @param worldPosVarName name of the variable holding the world position
  67626. * @returns the shader code
  67627. */
  67628. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  67629. protected _buildBlock(state: NodeMaterialBuildState): this;
  67630. }
  67631. }
  67632. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67636. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67637. import { Light } from "babylonjs/Lights/light";
  67638. import { Nullable } from "babylonjs/types";
  67639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67640. import { Effect } from "babylonjs/Materials/effect";
  67641. import { Mesh } from "babylonjs/Meshes/mesh";
  67642. import { Scene } from "babylonjs/scene";
  67643. /**
  67644. * Block used to implement the PBR metallic/roughness model
  67645. */
  67646. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67647. /**
  67648. * Gets or sets the light associated with this block
  67649. */
  67650. light: Nullable<Light>;
  67651. private _lightId;
  67652. private _scene;
  67653. private _environmentBRDFTexture;
  67654. private _environmentBrdfSamplerName;
  67655. private _vNormalWName;
  67656. private _invertNormalName;
  67657. /**
  67658. * Create a new ReflectionBlock
  67659. * @param name defines the block name
  67660. */
  67661. constructor(name: string);
  67662. /**
  67663. * Intensity of the direct lights e.g. the four lights available in your scene.
  67664. * This impacts both the direct diffuse and specular highlights.
  67665. */
  67666. directIntensity: number;
  67667. /**
  67668. * Intensity of the environment e.g. how much the environment will light the object
  67669. * either through harmonics for rough material or through the refelction for shiny ones.
  67670. */
  67671. environmentIntensity: number;
  67672. /**
  67673. * This is a special control allowing the reduction of the specular highlights coming from the
  67674. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67675. */
  67676. specularIntensity: number;
  67677. /**
  67678. * Defines the falloff type used in this material.
  67679. * It by default is Physical.
  67680. */
  67681. lightFalloff: number;
  67682. /**
  67683. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67684. */
  67685. useAlphaFromAlbedoTexture: boolean;
  67686. /**
  67687. * Specifies that alpha test should be used
  67688. */
  67689. useAlphaTest: boolean;
  67690. /**
  67691. * Defines the alpha limits in alpha test mode.
  67692. */
  67693. alphaTestCutoff: number;
  67694. /**
  67695. * Specifies that alpha blending should be used
  67696. */
  67697. useAlphaBlending: boolean;
  67698. /**
  67699. * Defines if the alpha value should be determined via the rgb values.
  67700. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67701. */
  67702. opacityRGB: boolean;
  67703. /**
  67704. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67705. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67706. */
  67707. useRadianceOverAlpha: boolean;
  67708. /**
  67709. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67710. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67711. */
  67712. useSpecularOverAlpha: boolean;
  67713. /**
  67714. * Enables specular anti aliasing in the PBR shader.
  67715. * It will both interacts on the Geometry for analytical and IBL lighting.
  67716. * It also prefilter the roughness map based on the bump values.
  67717. */
  67718. enableSpecularAntiAliasing: boolean;
  67719. /**
  67720. * Enables realtime filtering on the texture.
  67721. */
  67722. realTimeFiltering: boolean;
  67723. /**
  67724. * Quality switch for realtime filtering
  67725. */
  67726. realTimeFilteringQuality: number;
  67727. /**
  67728. * Defines if the material uses energy conservation.
  67729. */
  67730. useEnergyConservation: boolean;
  67731. /**
  67732. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67733. * too much the area relying on ambient texture to define their ambient occlusion.
  67734. */
  67735. useRadianceOcclusion: boolean;
  67736. /**
  67737. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67738. * makes the reflect vector face the model (under horizon).
  67739. */
  67740. useHorizonOcclusion: boolean;
  67741. /**
  67742. * If set to true, no lighting calculations will be applied.
  67743. */
  67744. unlit: boolean;
  67745. /**
  67746. * Force normal to face away from face.
  67747. */
  67748. forceNormalForward: boolean;
  67749. /**
  67750. * Defines the material debug mode.
  67751. * It helps seeing only some components of the material while troubleshooting.
  67752. */
  67753. debugMode: number;
  67754. /**
  67755. * Specify from where on screen the debug mode should start.
  67756. * The value goes from -1 (full screen) to 1 (not visible)
  67757. * It helps with side by side comparison against the final render
  67758. * This defaults to 0
  67759. */
  67760. debugLimit: number;
  67761. /**
  67762. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67763. * You can use the factor to better multiply the final value.
  67764. */
  67765. debugFactor: number;
  67766. /**
  67767. * Initialize the block and prepare the context for build
  67768. * @param state defines the state that will be used for the build
  67769. */
  67770. initialize(state: NodeMaterialBuildState): void;
  67771. /**
  67772. * Gets the current class name
  67773. * @returns the class name
  67774. */
  67775. getClassName(): string;
  67776. /**
  67777. * Gets the world position input component
  67778. */
  67779. get worldPosition(): NodeMaterialConnectionPoint;
  67780. /**
  67781. * Gets the world normal input component
  67782. */
  67783. get worldNormal(): NodeMaterialConnectionPoint;
  67784. /**
  67785. * Gets the perturbed normal input component
  67786. */
  67787. get perturbedNormal(): NodeMaterialConnectionPoint;
  67788. /**
  67789. * Gets the camera position input component
  67790. */
  67791. get cameraPosition(): NodeMaterialConnectionPoint;
  67792. /**
  67793. * Gets the base color input component
  67794. */
  67795. get baseColor(): NodeMaterialConnectionPoint;
  67796. /**
  67797. * Gets the opacity texture input component
  67798. */
  67799. get opacityTexture(): NodeMaterialConnectionPoint;
  67800. /**
  67801. * Gets the ambient color input component
  67802. */
  67803. get ambientColor(): NodeMaterialConnectionPoint;
  67804. /**
  67805. * Gets the reflectivity object parameters
  67806. */
  67807. get reflectivity(): NodeMaterialConnectionPoint;
  67808. /**
  67809. * Gets the ambient occlusion object parameters
  67810. */
  67811. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67812. /**
  67813. * Gets the reflection object parameters
  67814. */
  67815. get reflection(): NodeMaterialConnectionPoint;
  67816. /**
  67817. * Gets the sheen object parameters
  67818. */
  67819. get sheen(): NodeMaterialConnectionPoint;
  67820. /**
  67821. * Gets the clear coat object parameters
  67822. */
  67823. get clearcoat(): NodeMaterialConnectionPoint;
  67824. /**
  67825. * Gets the sub surface object parameters
  67826. */
  67827. get subsurface(): NodeMaterialConnectionPoint;
  67828. /**
  67829. * Gets the anisotropy object parameters
  67830. */
  67831. get anisotropy(): NodeMaterialConnectionPoint;
  67832. /**
  67833. * Gets the ambient output component
  67834. */
  67835. get ambient(): NodeMaterialConnectionPoint;
  67836. /**
  67837. * Gets the diffuse output component
  67838. */
  67839. get diffuse(): NodeMaterialConnectionPoint;
  67840. /**
  67841. * Gets the specular output component
  67842. */
  67843. get specular(): NodeMaterialConnectionPoint;
  67844. /**
  67845. * Gets the sheen output component
  67846. */
  67847. get sheenDir(): NodeMaterialConnectionPoint;
  67848. /**
  67849. * Gets the clear coat output component
  67850. */
  67851. get clearcoatDir(): NodeMaterialConnectionPoint;
  67852. /**
  67853. * Gets the indirect diffuse output component
  67854. */
  67855. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67856. /**
  67857. * Gets the indirect specular output component
  67858. */
  67859. get specularIndirect(): NodeMaterialConnectionPoint;
  67860. /**
  67861. * Gets the indirect sheen output component
  67862. */
  67863. get sheenIndirect(): NodeMaterialConnectionPoint;
  67864. /**
  67865. * Gets the indirect clear coat output component
  67866. */
  67867. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67868. /**
  67869. * Gets the refraction output component
  67870. */
  67871. get refraction(): NodeMaterialConnectionPoint;
  67872. /**
  67873. * Gets the global lighting output component
  67874. */
  67875. get lighting(): NodeMaterialConnectionPoint;
  67876. /**
  67877. * Gets the shadow output component
  67878. */
  67879. get shadow(): NodeMaterialConnectionPoint;
  67880. /**
  67881. * Gets the alpha output component
  67882. */
  67883. get alpha(): NodeMaterialConnectionPoint;
  67884. autoConfigure(material: NodeMaterial): void;
  67885. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67886. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67887. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67888. private _injectVertexCode;
  67889. /**
  67890. * Gets the code corresponding to the albedo/opacity module
  67891. * @returns the shader code
  67892. */
  67893. getAlbedoOpacityCode(): string;
  67894. protected _buildBlock(state: NodeMaterialBuildState): this;
  67895. protected _dumpPropertiesCode(): string;
  67896. serialize(): any;
  67897. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67898. }
  67899. }
  67900. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67901. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67902. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67903. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67904. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67905. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67906. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67907. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67908. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67909. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67910. }
  67911. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67912. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67913. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67914. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67915. }
  67916. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67920. /**
  67921. * Block used to compute value of one parameter modulo another
  67922. */
  67923. export class ModBlock extends NodeMaterialBlock {
  67924. /**
  67925. * Creates a new ModBlock
  67926. * @param name defines the block name
  67927. */
  67928. constructor(name: string);
  67929. /**
  67930. * Gets the current class name
  67931. * @returns the class name
  67932. */
  67933. getClassName(): string;
  67934. /**
  67935. * Gets the left operand input component
  67936. */
  67937. get left(): NodeMaterialConnectionPoint;
  67938. /**
  67939. * Gets the right operand input component
  67940. */
  67941. get right(): NodeMaterialConnectionPoint;
  67942. /**
  67943. * Gets the output component
  67944. */
  67945. get output(): NodeMaterialConnectionPoint;
  67946. protected _buildBlock(state: NodeMaterialBuildState): this;
  67947. }
  67948. }
  67949. declare module "babylonjs/Materials/Node/Blocks/index" {
  67950. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67951. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67952. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67953. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67954. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67955. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67956. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67957. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67958. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67959. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67960. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67961. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67962. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67963. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67964. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67965. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67966. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67967. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67968. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67969. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67970. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67971. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67972. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67973. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67974. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67975. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67976. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67977. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67978. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67979. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67980. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67981. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67982. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67983. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67984. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67985. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67986. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67987. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67988. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67989. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67990. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67991. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67992. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67993. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67994. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67995. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67996. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67997. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67998. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67999. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68000. }
  68001. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68002. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68003. }
  68004. declare module "babylonjs/Materials/Node/index" {
  68005. export * from "babylonjs/Materials/Node/Enums/index";
  68006. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68007. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68008. export * from "babylonjs/Materials/Node/nodeMaterial";
  68009. export * from "babylonjs/Materials/Node/Blocks/index";
  68010. export * from "babylonjs/Materials/Node/Optimizers/index";
  68011. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68012. }
  68013. declare module "babylonjs/Materials/index" {
  68014. export * from "babylonjs/Materials/Background/index";
  68015. export * from "babylonjs/Materials/colorCurves";
  68016. export * from "babylonjs/Materials/iEffectFallbacks";
  68017. export * from "babylonjs/Materials/effectFallbacks";
  68018. export * from "babylonjs/Materials/effect";
  68019. export * from "babylonjs/Materials/fresnelParameters";
  68020. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68021. export * from "babylonjs/Materials/material";
  68022. export * from "babylonjs/Materials/materialDefines";
  68023. export * from "babylonjs/Materials/materialHelper";
  68024. export * from "babylonjs/Materials/multiMaterial";
  68025. export * from "babylonjs/Materials/PBR/index";
  68026. export * from "babylonjs/Materials/pushMaterial";
  68027. export * from "babylonjs/Materials/shaderMaterial";
  68028. export * from "babylonjs/Materials/standardMaterial";
  68029. export * from "babylonjs/Materials/Textures/index";
  68030. export * from "babylonjs/Materials/uniformBuffer";
  68031. export * from "babylonjs/Materials/materialFlags";
  68032. export * from "babylonjs/Materials/Node/index";
  68033. export * from "babylonjs/Materials/effectRenderer";
  68034. export * from "babylonjs/Materials/shadowDepthWrapper";
  68035. }
  68036. declare module "babylonjs/Maths/index" {
  68037. export * from "babylonjs/Maths/math.scalar";
  68038. export * from "babylonjs/Maths/math";
  68039. export * from "babylonjs/Maths/sphericalPolynomial";
  68040. }
  68041. declare module "babylonjs/Misc/workerPool" {
  68042. import { IDisposable } from "babylonjs/scene";
  68043. /**
  68044. * Helper class to push actions to a pool of workers.
  68045. */
  68046. export class WorkerPool implements IDisposable {
  68047. private _workerInfos;
  68048. private _pendingActions;
  68049. /**
  68050. * Constructor
  68051. * @param workers Array of workers to use for actions
  68052. */
  68053. constructor(workers: Array<Worker>);
  68054. /**
  68055. * Terminates all workers and clears any pending actions.
  68056. */
  68057. dispose(): void;
  68058. /**
  68059. * Pushes an action to the worker pool. If all the workers are active, the action will be
  68060. * pended until a worker has completed its action.
  68061. * @param action The action to perform. Call onComplete when the action is complete.
  68062. */
  68063. push(action: (worker: Worker, onComplete: () => void) => void): void;
  68064. private _execute;
  68065. }
  68066. }
  68067. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68068. import { IDisposable } from "babylonjs/scene";
  68069. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68070. /**
  68071. * Configuration for Draco compression
  68072. */
  68073. export interface IDracoCompressionConfiguration {
  68074. /**
  68075. * Configuration for the decoder.
  68076. */
  68077. decoder: {
  68078. /**
  68079. * The url to the WebAssembly module.
  68080. */
  68081. wasmUrl?: string;
  68082. /**
  68083. * The url to the WebAssembly binary.
  68084. */
  68085. wasmBinaryUrl?: string;
  68086. /**
  68087. * The url to the fallback JavaScript module.
  68088. */
  68089. fallbackUrl?: string;
  68090. };
  68091. }
  68092. /**
  68093. * Draco compression (https://google.github.io/draco/)
  68094. *
  68095. * This class wraps the Draco module.
  68096. *
  68097. * **Encoder**
  68098. *
  68099. * The encoder is not currently implemented.
  68100. *
  68101. * **Decoder**
  68102. *
  68103. * 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.
  68104. *
  68105. * To update the configuration, use the following code:
  68106. * ```javascript
  68107. * DracoCompression.Configuration = {
  68108. * decoder: {
  68109. * wasmUrl: "<url to the WebAssembly library>",
  68110. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68111. * fallbackUrl: "<url to the fallback JavaScript library>",
  68112. * }
  68113. * };
  68114. * ```
  68115. *
  68116. * 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.
  68117. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68118. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68119. *
  68120. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68121. * ```javascript
  68122. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68123. * ```
  68124. *
  68125. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68126. */
  68127. export class DracoCompression implements IDisposable {
  68128. private _workerPoolPromise?;
  68129. private _decoderModulePromise?;
  68130. /**
  68131. * The configuration. Defaults to the following urls:
  68132. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68133. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68134. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68135. */
  68136. static Configuration: IDracoCompressionConfiguration;
  68137. /**
  68138. * Returns true if the decoder configuration is available.
  68139. */
  68140. static get DecoderAvailable(): boolean;
  68141. /**
  68142. * Default number of workers to create when creating the draco compression object.
  68143. */
  68144. static DefaultNumWorkers: number;
  68145. private static GetDefaultNumWorkers;
  68146. private static _Default;
  68147. /**
  68148. * Default instance for the draco compression object.
  68149. */
  68150. static get Default(): DracoCompression;
  68151. /**
  68152. * Constructor
  68153. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68154. */
  68155. constructor(numWorkers?: number);
  68156. /**
  68157. * Stop all async operations and release resources.
  68158. */
  68159. dispose(): void;
  68160. /**
  68161. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68162. * @returns a promise that resolves when ready
  68163. */
  68164. whenReadyAsync(): Promise<void>;
  68165. /**
  68166. * Decode Draco compressed mesh data to vertex data.
  68167. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68168. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68169. * @returns A promise that resolves with the decoded vertex data
  68170. */
  68171. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68172. [kind: string]: number;
  68173. }): Promise<VertexData>;
  68174. }
  68175. }
  68176. declare module "babylonjs/Meshes/Compression/index" {
  68177. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68178. }
  68179. declare module "babylonjs/Meshes/csg" {
  68180. import { Nullable } from "babylonjs/types";
  68181. import { Scene } from "babylonjs/scene";
  68182. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68183. import { Mesh } from "babylonjs/Meshes/mesh";
  68184. import { Material } from "babylonjs/Materials/material";
  68185. /**
  68186. * Class for building Constructive Solid Geometry
  68187. */
  68188. export class CSG {
  68189. private polygons;
  68190. /**
  68191. * The world matrix
  68192. */
  68193. matrix: Matrix;
  68194. /**
  68195. * Stores the position
  68196. */
  68197. position: Vector3;
  68198. /**
  68199. * Stores the rotation
  68200. */
  68201. rotation: Vector3;
  68202. /**
  68203. * Stores the rotation quaternion
  68204. */
  68205. rotationQuaternion: Nullable<Quaternion>;
  68206. /**
  68207. * Stores the scaling vector
  68208. */
  68209. scaling: Vector3;
  68210. /**
  68211. * Convert the Mesh to CSG
  68212. * @param mesh The Mesh to convert to CSG
  68213. * @returns A new CSG from the Mesh
  68214. */
  68215. static FromMesh(mesh: Mesh): CSG;
  68216. /**
  68217. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68218. * @param polygons Polygons used to construct a CSG solid
  68219. */
  68220. private static FromPolygons;
  68221. /**
  68222. * Clones, or makes a deep copy, of the CSG
  68223. * @returns A new CSG
  68224. */
  68225. clone(): CSG;
  68226. /**
  68227. * Unions this CSG with another CSG
  68228. * @param csg The CSG to union against this CSG
  68229. * @returns The unioned CSG
  68230. */
  68231. union(csg: CSG): CSG;
  68232. /**
  68233. * Unions this CSG with another CSG in place
  68234. * @param csg The CSG to union against this CSG
  68235. */
  68236. unionInPlace(csg: CSG): void;
  68237. /**
  68238. * Subtracts this CSG with another CSG
  68239. * @param csg The CSG to subtract against this CSG
  68240. * @returns A new CSG
  68241. */
  68242. subtract(csg: CSG): CSG;
  68243. /**
  68244. * Subtracts this CSG with another CSG in place
  68245. * @param csg The CSG to subtact against this CSG
  68246. */
  68247. subtractInPlace(csg: CSG): void;
  68248. /**
  68249. * Intersect this CSG with another CSG
  68250. * @param csg The CSG to intersect against this CSG
  68251. * @returns A new CSG
  68252. */
  68253. intersect(csg: CSG): CSG;
  68254. /**
  68255. * Intersects this CSG with another CSG in place
  68256. * @param csg The CSG to intersect against this CSG
  68257. */
  68258. intersectInPlace(csg: CSG): void;
  68259. /**
  68260. * Return a new CSG solid with solid and empty space switched. This solid is
  68261. * not modified.
  68262. * @returns A new CSG solid with solid and empty space switched
  68263. */
  68264. inverse(): CSG;
  68265. /**
  68266. * Inverses the CSG in place
  68267. */
  68268. inverseInPlace(): void;
  68269. /**
  68270. * This is used to keep meshes transformations so they can be restored
  68271. * when we build back a Babylon Mesh
  68272. * NB : All CSG operations are performed in world coordinates
  68273. * @param csg The CSG to copy the transform attributes from
  68274. * @returns This CSG
  68275. */
  68276. copyTransformAttributes(csg: CSG): CSG;
  68277. /**
  68278. * Build Raw mesh from CSG
  68279. * Coordinates here are in world space
  68280. * @param name The name of the mesh geometry
  68281. * @param scene The Scene
  68282. * @param keepSubMeshes Specifies if the submeshes should be kept
  68283. * @returns A new Mesh
  68284. */
  68285. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68286. /**
  68287. * Build Mesh from CSG taking material and transforms into account
  68288. * @param name The name of the Mesh
  68289. * @param material The material of the Mesh
  68290. * @param scene The Scene
  68291. * @param keepSubMeshes Specifies if submeshes should be kept
  68292. * @returns The new Mesh
  68293. */
  68294. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68295. }
  68296. }
  68297. declare module "babylonjs/Meshes/trailMesh" {
  68298. import { Mesh } from "babylonjs/Meshes/mesh";
  68299. import { Scene } from "babylonjs/scene";
  68300. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68301. /**
  68302. * Class used to create a trail following a mesh
  68303. */
  68304. export class TrailMesh extends Mesh {
  68305. private _generator;
  68306. private _autoStart;
  68307. private _running;
  68308. private _diameter;
  68309. private _length;
  68310. private _sectionPolygonPointsCount;
  68311. private _sectionVectors;
  68312. private _sectionNormalVectors;
  68313. private _beforeRenderObserver;
  68314. /**
  68315. * @constructor
  68316. * @param name The value used by scene.getMeshByName() to do a lookup.
  68317. * @param generator The mesh or transform node to generate a trail.
  68318. * @param scene The scene to add this mesh to.
  68319. * @param diameter Diameter of trailing mesh. Default is 1.
  68320. * @param length Length of trailing mesh. Default is 60.
  68321. * @param autoStart Automatically start trailing mesh. Default true.
  68322. */
  68323. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68324. /**
  68325. * "TrailMesh"
  68326. * @returns "TrailMesh"
  68327. */
  68328. getClassName(): string;
  68329. private _createMesh;
  68330. /**
  68331. * Start trailing mesh.
  68332. */
  68333. start(): void;
  68334. /**
  68335. * Stop trailing mesh.
  68336. */
  68337. stop(): void;
  68338. /**
  68339. * Update trailing mesh geometry.
  68340. */
  68341. update(): void;
  68342. /**
  68343. * Returns a new TrailMesh object.
  68344. * @param name is a string, the name given to the new mesh
  68345. * @param newGenerator use new generator object for cloned trail mesh
  68346. * @returns a new mesh
  68347. */
  68348. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68349. /**
  68350. * Serializes this trail mesh
  68351. * @param serializationObject object to write serialization to
  68352. */
  68353. serialize(serializationObject: any): void;
  68354. /**
  68355. * Parses a serialized trail mesh
  68356. * @param parsedMesh the serialized mesh
  68357. * @param scene the scene to create the trail mesh in
  68358. * @returns the created trail mesh
  68359. */
  68360. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68361. }
  68362. }
  68363. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68364. import { Nullable } from "babylonjs/types";
  68365. import { Scene } from "babylonjs/scene";
  68366. import { Vector4 } from "babylonjs/Maths/math.vector";
  68367. import { Color4 } from "babylonjs/Maths/math.color";
  68368. import { Mesh } from "babylonjs/Meshes/mesh";
  68369. /**
  68370. * Class containing static functions to help procedurally build meshes
  68371. */
  68372. export class TiledBoxBuilder {
  68373. /**
  68374. * Creates a box mesh
  68375. * 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)
  68376. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68380. * @param name defines the name of the mesh
  68381. * @param options defines the options used to create the mesh
  68382. * @param scene defines the hosting scene
  68383. * @returns the box mesh
  68384. */
  68385. static CreateTiledBox(name: string, options: {
  68386. pattern?: number;
  68387. width?: number;
  68388. height?: number;
  68389. depth?: number;
  68390. tileSize?: number;
  68391. tileWidth?: number;
  68392. tileHeight?: number;
  68393. alignHorizontal?: number;
  68394. alignVertical?: number;
  68395. faceUV?: Vector4[];
  68396. faceColors?: Color4[];
  68397. sideOrientation?: number;
  68398. updatable?: boolean;
  68399. }, scene?: Nullable<Scene>): Mesh;
  68400. }
  68401. }
  68402. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68403. import { Vector4 } from "babylonjs/Maths/math.vector";
  68404. import { Mesh } from "babylonjs/Meshes/mesh";
  68405. /**
  68406. * Class containing static functions to help procedurally build meshes
  68407. */
  68408. export class TorusKnotBuilder {
  68409. /**
  68410. * Creates a torus knot mesh
  68411. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68412. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68413. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68414. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68418. * @param name defines the name of the mesh
  68419. * @param options defines the options used to create the mesh
  68420. * @param scene defines the hosting scene
  68421. * @returns the torus knot mesh
  68422. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68423. */
  68424. static CreateTorusKnot(name: string, options: {
  68425. radius?: number;
  68426. tube?: number;
  68427. radialSegments?: number;
  68428. tubularSegments?: number;
  68429. p?: number;
  68430. q?: number;
  68431. updatable?: boolean;
  68432. sideOrientation?: number;
  68433. frontUVs?: Vector4;
  68434. backUVs?: Vector4;
  68435. }, scene: any): Mesh;
  68436. }
  68437. }
  68438. declare module "babylonjs/Meshes/polygonMesh" {
  68439. import { Scene } from "babylonjs/scene";
  68440. import { Vector2 } from "babylonjs/Maths/math.vector";
  68441. import { Mesh } from "babylonjs/Meshes/mesh";
  68442. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68443. import { Path2 } from "babylonjs/Maths/math.path";
  68444. /**
  68445. * Polygon
  68446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68447. */
  68448. export class Polygon {
  68449. /**
  68450. * Creates a rectangle
  68451. * @param xmin bottom X coord
  68452. * @param ymin bottom Y coord
  68453. * @param xmax top X coord
  68454. * @param ymax top Y coord
  68455. * @returns points that make the resulting rectation
  68456. */
  68457. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68458. /**
  68459. * Creates a circle
  68460. * @param radius radius of circle
  68461. * @param cx scale in x
  68462. * @param cy scale in y
  68463. * @param numberOfSides number of sides that make up the circle
  68464. * @returns points that make the resulting circle
  68465. */
  68466. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68467. /**
  68468. * Creates a polygon from input string
  68469. * @param input Input polygon data
  68470. * @returns the parsed points
  68471. */
  68472. static Parse(input: string): Vector2[];
  68473. /**
  68474. * Starts building a polygon from x and y coordinates
  68475. * @param x x coordinate
  68476. * @param y y coordinate
  68477. * @returns the started path2
  68478. */
  68479. static StartingAt(x: number, y: number): Path2;
  68480. }
  68481. /**
  68482. * Builds a polygon
  68483. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68484. */
  68485. export class PolygonMeshBuilder {
  68486. private _points;
  68487. private _outlinepoints;
  68488. private _holes;
  68489. private _name;
  68490. private _scene;
  68491. private _epoints;
  68492. private _eholes;
  68493. private _addToepoint;
  68494. /**
  68495. * Babylon reference to the earcut plugin.
  68496. */
  68497. bjsEarcut: any;
  68498. /**
  68499. * Creates a PolygonMeshBuilder
  68500. * @param name name of the builder
  68501. * @param contours Path of the polygon
  68502. * @param scene scene to add to when creating the mesh
  68503. * @param earcutInjection can be used to inject your own earcut reference
  68504. */
  68505. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68506. /**
  68507. * Adds a whole within the polygon
  68508. * @param hole Array of points defining the hole
  68509. * @returns this
  68510. */
  68511. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68512. /**
  68513. * Creates the polygon
  68514. * @param updatable If the mesh should be updatable
  68515. * @param depth The depth of the mesh created
  68516. * @returns the created mesh
  68517. */
  68518. build(updatable?: boolean, depth?: number): Mesh;
  68519. /**
  68520. * Creates the polygon
  68521. * @param depth The depth of the mesh created
  68522. * @returns the created VertexData
  68523. */
  68524. buildVertexData(depth?: number): VertexData;
  68525. /**
  68526. * Adds a side to the polygon
  68527. * @param positions points that make the polygon
  68528. * @param normals normals of the polygon
  68529. * @param uvs uvs of the polygon
  68530. * @param indices indices of the polygon
  68531. * @param bounds bounds of the polygon
  68532. * @param points points of the polygon
  68533. * @param depth depth of the polygon
  68534. * @param flip flip of the polygon
  68535. */
  68536. private addSide;
  68537. }
  68538. }
  68539. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68540. import { Scene } from "babylonjs/scene";
  68541. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68542. import { Color4 } from "babylonjs/Maths/math.color";
  68543. import { Mesh } from "babylonjs/Meshes/mesh";
  68544. import { Nullable } from "babylonjs/types";
  68545. /**
  68546. * Class containing static functions to help procedurally build meshes
  68547. */
  68548. export class PolygonBuilder {
  68549. /**
  68550. * Creates a polygon mesh
  68551. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68552. * * 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
  68553. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68556. * * Remember you can only change the shape positions, not their number when updating a polygon
  68557. * @param name defines the name of the mesh
  68558. * @param options defines the options used to create the mesh
  68559. * @param scene defines the hosting scene
  68560. * @param earcutInjection can be used to inject your own earcut reference
  68561. * @returns the polygon mesh
  68562. */
  68563. static CreatePolygon(name: string, options: {
  68564. shape: Vector3[];
  68565. holes?: Vector3[][];
  68566. depth?: number;
  68567. faceUV?: Vector4[];
  68568. faceColors?: Color4[];
  68569. updatable?: boolean;
  68570. sideOrientation?: number;
  68571. frontUVs?: Vector4;
  68572. backUVs?: Vector4;
  68573. wrap?: boolean;
  68574. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68575. /**
  68576. * Creates an extruded polygon mesh, with depth in the Y direction.
  68577. * * 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)
  68578. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68579. * @param name defines the name of the mesh
  68580. * @param options defines the options used to create the mesh
  68581. * @param scene defines the hosting scene
  68582. * @param earcutInjection can be used to inject your own earcut reference
  68583. * @returns the polygon mesh
  68584. */
  68585. static ExtrudePolygon(name: string, options: {
  68586. shape: Vector3[];
  68587. holes?: Vector3[][];
  68588. depth?: number;
  68589. faceUV?: Vector4[];
  68590. faceColors?: Color4[];
  68591. updatable?: boolean;
  68592. sideOrientation?: number;
  68593. frontUVs?: Vector4;
  68594. backUVs?: Vector4;
  68595. wrap?: boolean;
  68596. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68597. }
  68598. }
  68599. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  68600. import { Scene } from "babylonjs/scene";
  68601. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68602. import { Mesh } from "babylonjs/Meshes/mesh";
  68603. import { Nullable } from "babylonjs/types";
  68604. /**
  68605. * Class containing static functions to help procedurally build meshes
  68606. */
  68607. export class LatheBuilder {
  68608. /**
  68609. * Creates lathe mesh.
  68610. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68611. * * 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
  68612. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68613. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68614. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68615. * * 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
  68616. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68617. * * 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
  68618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68620. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68622. * @param name defines the name of the mesh
  68623. * @param options defines the options used to create the mesh
  68624. * @param scene defines the hosting scene
  68625. * @returns the lathe mesh
  68626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68627. */
  68628. static CreateLathe(name: string, options: {
  68629. shape: Vector3[];
  68630. radius?: number;
  68631. tessellation?: number;
  68632. clip?: number;
  68633. arc?: number;
  68634. closed?: boolean;
  68635. updatable?: boolean;
  68636. sideOrientation?: number;
  68637. frontUVs?: Vector4;
  68638. backUVs?: Vector4;
  68639. cap?: number;
  68640. invertUV?: boolean;
  68641. }, scene?: Nullable<Scene>): Mesh;
  68642. }
  68643. }
  68644. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68645. import { Nullable } from "babylonjs/types";
  68646. import { Scene } from "babylonjs/scene";
  68647. import { Vector4 } from "babylonjs/Maths/math.vector";
  68648. import { Mesh } from "babylonjs/Meshes/mesh";
  68649. /**
  68650. * Class containing static functions to help procedurally build meshes
  68651. */
  68652. export class TiledPlaneBuilder {
  68653. /**
  68654. * Creates a tiled plane mesh
  68655. * * The parameter `pattern` will, depending on value, do nothing or
  68656. * * * flip (reflect about central vertical) alternate tiles across and up
  68657. * * * flip every tile on alternate rows
  68658. * * * rotate (180 degs) alternate tiles across and up
  68659. * * * rotate every tile on alternate rows
  68660. * * * flip and rotate alternate tiles across and up
  68661. * * * flip and rotate every tile on alternate rows
  68662. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68663. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68666. * * 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)
  68667. * * 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)
  68668. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68669. * @param name defines the name of the mesh
  68670. * @param options defines the options used to create the mesh
  68671. * @param scene defines the hosting scene
  68672. * @returns the box mesh
  68673. */
  68674. static CreateTiledPlane(name: string, options: {
  68675. pattern?: number;
  68676. tileSize?: number;
  68677. tileWidth?: number;
  68678. tileHeight?: number;
  68679. size?: number;
  68680. width?: number;
  68681. height?: number;
  68682. alignHorizontal?: number;
  68683. alignVertical?: number;
  68684. sideOrientation?: number;
  68685. frontUVs?: Vector4;
  68686. backUVs?: Vector4;
  68687. updatable?: boolean;
  68688. }, scene?: Nullable<Scene>): Mesh;
  68689. }
  68690. }
  68691. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68692. import { Nullable } from "babylonjs/types";
  68693. import { Scene } from "babylonjs/scene";
  68694. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68695. import { Mesh } from "babylonjs/Meshes/mesh";
  68696. /**
  68697. * Class containing static functions to help procedurally build meshes
  68698. */
  68699. export class TubeBuilder {
  68700. /**
  68701. * Creates a tube mesh.
  68702. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68703. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68704. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68705. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68706. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68707. * * 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)
  68708. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68709. * * 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
  68710. * * 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
  68711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68715. * @param name defines the name of the mesh
  68716. * @param options defines the options used to create the mesh
  68717. * @param scene defines the hosting scene
  68718. * @returns the tube mesh
  68719. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68720. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68721. */
  68722. static CreateTube(name: string, options: {
  68723. path: Vector3[];
  68724. radius?: number;
  68725. tessellation?: number;
  68726. radiusFunction?: {
  68727. (i: number, distance: number): number;
  68728. };
  68729. cap?: number;
  68730. arc?: number;
  68731. updatable?: boolean;
  68732. sideOrientation?: number;
  68733. frontUVs?: Vector4;
  68734. backUVs?: Vector4;
  68735. instance?: Mesh;
  68736. invertUV?: boolean;
  68737. }, scene?: Nullable<Scene>): Mesh;
  68738. }
  68739. }
  68740. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68741. import { Scene } from "babylonjs/scene";
  68742. import { Vector4 } from "babylonjs/Maths/math.vector";
  68743. import { Mesh } from "babylonjs/Meshes/mesh";
  68744. import { Nullable } from "babylonjs/types";
  68745. /**
  68746. * Class containing static functions to help procedurally build meshes
  68747. */
  68748. export class IcoSphereBuilder {
  68749. /**
  68750. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68751. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68752. * * 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`)
  68753. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68754. * * 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
  68755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68758. * @param name defines the name of the mesh
  68759. * @param options defines the options used to create the mesh
  68760. * @param scene defines the hosting scene
  68761. * @returns the icosahedron mesh
  68762. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68763. */
  68764. static CreateIcoSphere(name: string, options: {
  68765. radius?: number;
  68766. radiusX?: number;
  68767. radiusY?: number;
  68768. radiusZ?: number;
  68769. flat?: boolean;
  68770. subdivisions?: number;
  68771. sideOrientation?: number;
  68772. frontUVs?: Vector4;
  68773. backUVs?: Vector4;
  68774. updatable?: boolean;
  68775. }, scene?: Nullable<Scene>): Mesh;
  68776. }
  68777. }
  68778. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68779. import { Vector3 } from "babylonjs/Maths/math.vector";
  68780. import { Mesh } from "babylonjs/Meshes/mesh";
  68781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68782. /**
  68783. * Class containing static functions to help procedurally build meshes
  68784. */
  68785. export class DecalBuilder {
  68786. /**
  68787. * Creates a decal mesh.
  68788. * 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
  68789. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68790. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68791. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68792. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68793. * @param name defines the name of the mesh
  68794. * @param sourceMesh defines the mesh where the decal must be applied
  68795. * @param options defines the options used to create the mesh
  68796. * @param scene defines the hosting scene
  68797. * @returns the decal mesh
  68798. * @see https://doc.babylonjs.com/how_to/decals
  68799. */
  68800. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68801. position?: Vector3;
  68802. normal?: Vector3;
  68803. size?: Vector3;
  68804. angle?: number;
  68805. }): Mesh;
  68806. }
  68807. }
  68808. declare module "babylonjs/Meshes/meshBuilder" {
  68809. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68810. import { Nullable } from "babylonjs/types";
  68811. import { Scene } from "babylonjs/scene";
  68812. import { Mesh } from "babylonjs/Meshes/mesh";
  68813. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68814. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68816. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68817. import { Plane } from "babylonjs/Maths/math.plane";
  68818. /**
  68819. * Class containing static functions to help procedurally build meshes
  68820. */
  68821. export class MeshBuilder {
  68822. /**
  68823. * Creates a box mesh
  68824. * * The parameter `size` sets the size (float) of each box side (default 1)
  68825. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68826. * * 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)
  68827. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68831. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68832. * @param name defines the name of the mesh
  68833. * @param options defines the options used to create the mesh
  68834. * @param scene defines the hosting scene
  68835. * @returns the box mesh
  68836. */
  68837. static CreateBox(name: string, options: {
  68838. size?: number;
  68839. width?: number;
  68840. height?: number;
  68841. depth?: number;
  68842. faceUV?: Vector4[];
  68843. faceColors?: Color4[];
  68844. sideOrientation?: number;
  68845. frontUVs?: Vector4;
  68846. backUVs?: Vector4;
  68847. wrap?: boolean;
  68848. topBaseAt?: number;
  68849. bottomBaseAt?: number;
  68850. updatable?: boolean;
  68851. }, scene?: Nullable<Scene>): Mesh;
  68852. /**
  68853. * Creates a tiled box mesh
  68854. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68856. * @param name defines the name of the mesh
  68857. * @param options defines the options used to create the mesh
  68858. * @param scene defines the hosting scene
  68859. * @returns the tiled box mesh
  68860. */
  68861. static CreateTiledBox(name: string, options: {
  68862. pattern?: number;
  68863. size?: number;
  68864. width?: number;
  68865. height?: number;
  68866. depth: number;
  68867. tileSize?: number;
  68868. tileWidth?: number;
  68869. tileHeight?: number;
  68870. faceUV?: Vector4[];
  68871. faceColors?: Color4[];
  68872. alignHorizontal?: number;
  68873. alignVertical?: number;
  68874. sideOrientation?: number;
  68875. updatable?: boolean;
  68876. }, scene?: Nullable<Scene>): Mesh;
  68877. /**
  68878. * Creates a sphere mesh
  68879. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68880. * * 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`)
  68881. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68882. * * 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
  68883. * * 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)
  68884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68887. * @param name defines the name of the mesh
  68888. * @param options defines the options used to create the mesh
  68889. * @param scene defines the hosting scene
  68890. * @returns the sphere mesh
  68891. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68892. */
  68893. static CreateSphere(name: string, options: {
  68894. segments?: number;
  68895. diameter?: number;
  68896. diameterX?: number;
  68897. diameterY?: number;
  68898. diameterZ?: number;
  68899. arc?: number;
  68900. slice?: number;
  68901. sideOrientation?: number;
  68902. frontUVs?: Vector4;
  68903. backUVs?: Vector4;
  68904. updatable?: boolean;
  68905. }, scene?: Nullable<Scene>): Mesh;
  68906. /**
  68907. * Creates a plane polygonal mesh. By default, this is a disc
  68908. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68909. * * 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
  68910. * * 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
  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 plane polygonal mesh
  68918. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68919. */
  68920. static CreateDisc(name: string, options: {
  68921. radius?: number;
  68922. tessellation?: number;
  68923. arc?: number;
  68924. updatable?: boolean;
  68925. sideOrientation?: number;
  68926. frontUVs?: Vector4;
  68927. backUVs?: Vector4;
  68928. }, scene?: Nullable<Scene>): Mesh;
  68929. /**
  68930. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68931. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68932. * * 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`)
  68933. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68934. * * 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
  68935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68938. * @param name defines the name of the mesh
  68939. * @param options defines the options used to create the mesh
  68940. * @param scene defines the hosting scene
  68941. * @returns the icosahedron mesh
  68942. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68943. */
  68944. static CreateIcoSphere(name: string, options: {
  68945. radius?: number;
  68946. radiusX?: number;
  68947. radiusY?: number;
  68948. radiusZ?: number;
  68949. flat?: boolean;
  68950. subdivisions?: number;
  68951. sideOrientation?: number;
  68952. frontUVs?: Vector4;
  68953. backUVs?: Vector4;
  68954. updatable?: boolean;
  68955. }, scene?: Nullable<Scene>): Mesh;
  68956. /**
  68957. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68958. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68959. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68960. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68961. * * 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
  68962. * * 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
  68963. * * 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
  68964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68966. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68967. * * 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
  68968. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68969. * * 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
  68970. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68972. * @param name defines the name of the mesh
  68973. * @param options defines the options used to create the mesh
  68974. * @param scene defines the hosting scene
  68975. * @returns the ribbon mesh
  68976. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68977. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68978. */
  68979. static CreateRibbon(name: string, options: {
  68980. pathArray: Vector3[][];
  68981. closeArray?: boolean;
  68982. closePath?: boolean;
  68983. offset?: number;
  68984. updatable?: boolean;
  68985. sideOrientation?: number;
  68986. frontUVs?: Vector4;
  68987. backUVs?: Vector4;
  68988. instance?: Mesh;
  68989. invertUV?: boolean;
  68990. uvs?: Vector2[];
  68991. colors?: Color4[];
  68992. }, scene?: Nullable<Scene>): Mesh;
  68993. /**
  68994. * Creates a cylinder or a cone mesh
  68995. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68996. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68997. * * 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.
  68998. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68999. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69000. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69001. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69002. * * 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).
  69003. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69004. * * 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).
  69005. * * 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
  69006. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69007. * * 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
  69008. * * 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.
  69009. * * If `enclose` is false, a ring surface is one element.
  69010. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69011. * * 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
  69012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69015. * @param name defines the name of the mesh
  69016. * @param options defines the options used to create the mesh
  69017. * @param scene defines the hosting scene
  69018. * @returns the cylinder mesh
  69019. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69020. */
  69021. static CreateCylinder(name: string, options: {
  69022. height?: number;
  69023. diameterTop?: number;
  69024. diameterBottom?: number;
  69025. diameter?: number;
  69026. tessellation?: number;
  69027. subdivisions?: number;
  69028. arc?: number;
  69029. faceColors?: Color4[];
  69030. faceUV?: Vector4[];
  69031. updatable?: boolean;
  69032. hasRings?: boolean;
  69033. enclose?: boolean;
  69034. cap?: number;
  69035. sideOrientation?: number;
  69036. frontUVs?: Vector4;
  69037. backUVs?: Vector4;
  69038. }, scene?: Nullable<Scene>): Mesh;
  69039. /**
  69040. * Creates a torus mesh
  69041. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69042. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69043. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69047. * @param name defines the name of the mesh
  69048. * @param options defines the options used to create the mesh
  69049. * @param scene defines the hosting scene
  69050. * @returns the torus mesh
  69051. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69052. */
  69053. static CreateTorus(name: string, options: {
  69054. diameter?: number;
  69055. thickness?: number;
  69056. tessellation?: number;
  69057. updatable?: boolean;
  69058. sideOrientation?: number;
  69059. frontUVs?: Vector4;
  69060. backUVs?: Vector4;
  69061. }, scene?: Nullable<Scene>): Mesh;
  69062. /**
  69063. * Creates a torus knot mesh
  69064. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69065. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69066. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69067. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69071. * @param name defines the name of the mesh
  69072. * @param options defines the options used to create the mesh
  69073. * @param scene defines the hosting scene
  69074. * @returns the torus knot mesh
  69075. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69076. */
  69077. static CreateTorusKnot(name: string, options: {
  69078. radius?: number;
  69079. tube?: number;
  69080. radialSegments?: number;
  69081. tubularSegments?: number;
  69082. p?: number;
  69083. q?: number;
  69084. updatable?: boolean;
  69085. sideOrientation?: number;
  69086. frontUVs?: Vector4;
  69087. backUVs?: Vector4;
  69088. }, scene?: Nullable<Scene>): Mesh;
  69089. /**
  69090. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69091. * * 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
  69092. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69093. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69094. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69095. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69096. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69097. * * 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
  69098. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69101. * @param name defines the name of the new line system
  69102. * @param options defines the options used to create the line system
  69103. * @param scene defines the hosting scene
  69104. * @returns a new line system mesh
  69105. */
  69106. static CreateLineSystem(name: string, options: {
  69107. lines: Vector3[][];
  69108. updatable?: boolean;
  69109. instance?: Nullable<LinesMesh>;
  69110. colors?: Nullable<Color4[][]>;
  69111. useVertexAlpha?: boolean;
  69112. }, scene: Nullable<Scene>): LinesMesh;
  69113. /**
  69114. * Creates a line mesh
  69115. * 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
  69116. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69117. * * The parameter `points` is an array successive Vector3
  69118. * * 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
  69119. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69120. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69121. * * When updating an instance, remember that only point positions can change, not the number of points
  69122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69124. * @param name defines the name of the new line system
  69125. * @param options defines the options used to create the line system
  69126. * @param scene defines the hosting scene
  69127. * @returns a new line mesh
  69128. */
  69129. static CreateLines(name: string, options: {
  69130. points: Vector3[];
  69131. updatable?: boolean;
  69132. instance?: Nullable<LinesMesh>;
  69133. colors?: Color4[];
  69134. useVertexAlpha?: boolean;
  69135. }, scene?: Nullable<Scene>): LinesMesh;
  69136. /**
  69137. * Creates a dashed line mesh
  69138. * * 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
  69139. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69140. * * The parameter `points` is an array successive Vector3
  69141. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69142. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69143. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69144. * * 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
  69145. * * When updating an instance, remember that only point positions can change, not the number of points
  69146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69147. * @param name defines the name of the mesh
  69148. * @param options defines the options used to create the mesh
  69149. * @param scene defines the hosting scene
  69150. * @returns the dashed line mesh
  69151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69152. */
  69153. static CreateDashedLines(name: string, options: {
  69154. points: Vector3[];
  69155. dashSize?: number;
  69156. gapSize?: number;
  69157. dashNb?: number;
  69158. updatable?: boolean;
  69159. instance?: LinesMesh;
  69160. }, scene?: Nullable<Scene>): LinesMesh;
  69161. /**
  69162. * 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.
  69163. * * 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.
  69164. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69165. * * 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.
  69166. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69167. * * 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
  69168. * * 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
  69169. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69172. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69174. * @param name defines the name of the mesh
  69175. * @param options defines the options used to create the mesh
  69176. * @param scene defines the hosting scene
  69177. * @returns the extruded shape mesh
  69178. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69180. */
  69181. static ExtrudeShape(name: string, options: {
  69182. shape: Vector3[];
  69183. path: Vector3[];
  69184. scale?: number;
  69185. rotation?: number;
  69186. cap?: number;
  69187. updatable?: boolean;
  69188. sideOrientation?: number;
  69189. frontUVs?: Vector4;
  69190. backUVs?: Vector4;
  69191. instance?: Mesh;
  69192. invertUV?: boolean;
  69193. }, scene?: Nullable<Scene>): Mesh;
  69194. /**
  69195. * Creates an custom extruded shape mesh.
  69196. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69197. * * 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.
  69198. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69199. * * 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
  69200. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69201. * * 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
  69202. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69203. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69204. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  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 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
  69207. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69210. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69212. * @param name defines the name of the mesh
  69213. * @param options defines the options used to create the mesh
  69214. * @param scene defines the hosting scene
  69215. * @returns the custom extruded shape mesh
  69216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69217. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69218. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69219. */
  69220. static ExtrudeShapeCustom(name: string, options: {
  69221. shape: Vector3[];
  69222. path: Vector3[];
  69223. scaleFunction?: any;
  69224. rotationFunction?: any;
  69225. ribbonCloseArray?: boolean;
  69226. ribbonClosePath?: boolean;
  69227. cap?: number;
  69228. updatable?: boolean;
  69229. sideOrientation?: number;
  69230. frontUVs?: Vector4;
  69231. backUVs?: Vector4;
  69232. instance?: Mesh;
  69233. invertUV?: boolean;
  69234. }, scene?: Nullable<Scene>): Mesh;
  69235. /**
  69236. * Creates lathe mesh.
  69237. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69238. * * 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
  69239. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69240. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69241. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69242. * * 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
  69243. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69244. * * 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
  69245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69247. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69249. * @param name defines the name of the mesh
  69250. * @param options defines the options used to create the mesh
  69251. * @param scene defines the hosting scene
  69252. * @returns the lathe mesh
  69253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69254. */
  69255. static CreateLathe(name: string, options: {
  69256. shape: Vector3[];
  69257. radius?: number;
  69258. tessellation?: number;
  69259. clip?: number;
  69260. arc?: number;
  69261. closed?: boolean;
  69262. updatable?: boolean;
  69263. sideOrientation?: number;
  69264. frontUVs?: Vector4;
  69265. backUVs?: Vector4;
  69266. cap?: number;
  69267. invertUV?: boolean;
  69268. }, scene?: Nullable<Scene>): Mesh;
  69269. /**
  69270. * Creates a tiled plane mesh
  69271. * * You can set a limited pattern arrangement with the tiles
  69272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69275. * @param name defines the name of the mesh
  69276. * @param options defines the options used to create the mesh
  69277. * @param scene defines the hosting scene
  69278. * @returns the plane mesh
  69279. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69280. */
  69281. static CreateTiledPlane(name: string, options: {
  69282. pattern?: number;
  69283. tileSize?: number;
  69284. tileWidth?: number;
  69285. tileHeight?: number;
  69286. size?: number;
  69287. width?: number;
  69288. height?: number;
  69289. alignHorizontal?: number;
  69290. alignVertical?: number;
  69291. sideOrientation?: number;
  69292. frontUVs?: Vector4;
  69293. backUVs?: Vector4;
  69294. updatable?: boolean;
  69295. }, scene?: Nullable<Scene>): Mesh;
  69296. /**
  69297. * Creates a plane mesh
  69298. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69299. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69300. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69304. * @param name defines the name of the mesh
  69305. * @param options defines the options used to create the mesh
  69306. * @param scene defines the hosting scene
  69307. * @returns the plane mesh
  69308. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69309. */
  69310. static CreatePlane(name: string, options: {
  69311. size?: number;
  69312. width?: number;
  69313. height?: number;
  69314. sideOrientation?: number;
  69315. frontUVs?: Vector4;
  69316. backUVs?: Vector4;
  69317. updatable?: boolean;
  69318. sourcePlane?: Plane;
  69319. }, scene?: Nullable<Scene>): Mesh;
  69320. /**
  69321. * Creates a ground mesh
  69322. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69323. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69325. * @param name defines the name of the mesh
  69326. * @param options defines the options used to create the mesh
  69327. * @param scene defines the hosting scene
  69328. * @returns the ground mesh
  69329. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69330. */
  69331. static CreateGround(name: string, options: {
  69332. width?: number;
  69333. height?: number;
  69334. subdivisions?: number;
  69335. subdivisionsX?: number;
  69336. subdivisionsY?: number;
  69337. updatable?: boolean;
  69338. }, scene?: Nullable<Scene>): Mesh;
  69339. /**
  69340. * Creates a tiled ground mesh
  69341. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69342. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69343. * * 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
  69344. * * 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
  69345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69346. * @param name defines the name of the mesh
  69347. * @param options defines the options used to create the mesh
  69348. * @param scene defines the hosting scene
  69349. * @returns the tiled ground mesh
  69350. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69351. */
  69352. static CreateTiledGround(name: string, options: {
  69353. xmin: number;
  69354. zmin: number;
  69355. xmax: number;
  69356. zmax: number;
  69357. subdivisions?: {
  69358. w: number;
  69359. h: number;
  69360. };
  69361. precision?: {
  69362. w: number;
  69363. h: number;
  69364. };
  69365. updatable?: boolean;
  69366. }, scene?: Nullable<Scene>): Mesh;
  69367. /**
  69368. * Creates a ground mesh from a height map
  69369. * * The parameter `url` sets the URL of the height map image resource.
  69370. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69371. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69372. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69373. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69374. * * 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.
  69375. * * 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).
  69376. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69378. * @param name defines the name of the mesh
  69379. * @param url defines the url to the height map
  69380. * @param options defines the options used to create the mesh
  69381. * @param scene defines the hosting scene
  69382. * @returns the ground mesh
  69383. * @see https://doc.babylonjs.com/babylon101/height_map
  69384. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69385. */
  69386. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69387. width?: number;
  69388. height?: number;
  69389. subdivisions?: number;
  69390. minHeight?: number;
  69391. maxHeight?: number;
  69392. colorFilter?: Color3;
  69393. alphaFilter?: number;
  69394. updatable?: boolean;
  69395. onReady?: (mesh: GroundMesh) => void;
  69396. }, scene?: Nullable<Scene>): GroundMesh;
  69397. /**
  69398. * Creates a polygon mesh
  69399. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69400. * * 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
  69401. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69404. * * Remember you can only change the shape positions, not their number when updating a polygon
  69405. * @param name defines the name of the mesh
  69406. * @param options defines the options used to create the mesh
  69407. * @param scene defines the hosting scene
  69408. * @param earcutInjection can be used to inject your own earcut reference
  69409. * @returns the polygon mesh
  69410. */
  69411. static CreatePolygon(name: string, options: {
  69412. shape: Vector3[];
  69413. holes?: Vector3[][];
  69414. depth?: number;
  69415. faceUV?: Vector4[];
  69416. faceColors?: Color4[];
  69417. updatable?: boolean;
  69418. sideOrientation?: number;
  69419. frontUVs?: Vector4;
  69420. backUVs?: Vector4;
  69421. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69422. /**
  69423. * Creates an extruded polygon mesh, with depth in the Y direction.
  69424. * * 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)
  69425. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69426. * @param name defines the name of the mesh
  69427. * @param options defines the options used to create the mesh
  69428. * @param scene defines the hosting scene
  69429. * @param earcutInjection can be used to inject your own earcut reference
  69430. * @returns the polygon mesh
  69431. */
  69432. static ExtrudePolygon(name: string, options: {
  69433. shape: Vector3[];
  69434. holes?: Vector3[][];
  69435. depth?: number;
  69436. faceUV?: Vector4[];
  69437. faceColors?: Color4[];
  69438. updatable?: boolean;
  69439. sideOrientation?: number;
  69440. frontUVs?: Vector4;
  69441. backUVs?: Vector4;
  69442. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69443. /**
  69444. * Creates a tube mesh.
  69445. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69446. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69447. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69448. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69449. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69450. * * 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)
  69451. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69452. * * 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
  69453. * * 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
  69454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69458. * @param name defines the name of the mesh
  69459. * @param options defines the options used to create the mesh
  69460. * @param scene defines the hosting scene
  69461. * @returns the tube mesh
  69462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69463. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69464. */
  69465. static CreateTube(name: string, options: {
  69466. path: Vector3[];
  69467. radius?: number;
  69468. tessellation?: number;
  69469. radiusFunction?: {
  69470. (i: number, distance: number): number;
  69471. };
  69472. cap?: number;
  69473. arc?: number;
  69474. updatable?: boolean;
  69475. sideOrientation?: number;
  69476. frontUVs?: Vector4;
  69477. backUVs?: Vector4;
  69478. instance?: Mesh;
  69479. invertUV?: boolean;
  69480. }, scene?: Nullable<Scene>): Mesh;
  69481. /**
  69482. * Creates a polyhedron mesh
  69483. * * 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
  69484. * * The parameter `size` (positive float, default 1) sets the polygon size
  69485. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69486. * * 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`
  69487. * * 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
  69488. * * 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)`)
  69489. * * 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
  69490. * * 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
  69491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69494. * @param name defines the name of the mesh
  69495. * @param options defines the options used to create the mesh
  69496. * @param scene defines the hosting scene
  69497. * @returns the polyhedron mesh
  69498. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69499. */
  69500. static CreatePolyhedron(name: string, options: {
  69501. type?: number;
  69502. size?: number;
  69503. sizeX?: number;
  69504. sizeY?: number;
  69505. sizeZ?: number;
  69506. custom?: any;
  69507. faceUV?: Vector4[];
  69508. faceColors?: Color4[];
  69509. flat?: boolean;
  69510. updatable?: boolean;
  69511. sideOrientation?: number;
  69512. frontUVs?: Vector4;
  69513. backUVs?: Vector4;
  69514. }, scene?: Nullable<Scene>): Mesh;
  69515. /**
  69516. * Creates a decal mesh.
  69517. * 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
  69518. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69519. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69520. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69521. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69522. * @param name defines the name of the mesh
  69523. * @param sourceMesh defines the mesh where the decal must be applied
  69524. * @param options defines the options used to create the mesh
  69525. * @param scene defines the hosting scene
  69526. * @returns the decal mesh
  69527. * @see https://doc.babylonjs.com/how_to/decals
  69528. */
  69529. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69530. position?: Vector3;
  69531. normal?: Vector3;
  69532. size?: Vector3;
  69533. angle?: number;
  69534. }): Mesh;
  69535. }
  69536. }
  69537. declare module "babylonjs/Meshes/meshSimplification" {
  69538. import { Mesh } from "babylonjs/Meshes/mesh";
  69539. /**
  69540. * A simplifier interface for future simplification implementations
  69541. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69542. */
  69543. export interface ISimplifier {
  69544. /**
  69545. * Simplification of a given mesh according to the given settings.
  69546. * Since this requires computation, it is assumed that the function runs async.
  69547. * @param settings The settings of the simplification, including quality and distance
  69548. * @param successCallback A callback that will be called after the mesh was simplified.
  69549. * @param errorCallback in case of an error, this callback will be called. optional.
  69550. */
  69551. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69552. }
  69553. /**
  69554. * Expected simplification settings.
  69555. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69556. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69557. */
  69558. export interface ISimplificationSettings {
  69559. /**
  69560. * Gets or sets the expected quality
  69561. */
  69562. quality: number;
  69563. /**
  69564. * Gets or sets the distance when this optimized version should be used
  69565. */
  69566. distance: number;
  69567. /**
  69568. * Gets an already optimized mesh
  69569. */
  69570. optimizeMesh?: boolean;
  69571. }
  69572. /**
  69573. * Class used to specify simplification options
  69574. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69575. */
  69576. export class SimplificationSettings implements ISimplificationSettings {
  69577. /** expected quality */
  69578. quality: number;
  69579. /** distance when this optimized version should be used */
  69580. distance: number;
  69581. /** already optimized mesh */
  69582. optimizeMesh?: boolean | undefined;
  69583. /**
  69584. * Creates a SimplificationSettings
  69585. * @param quality expected quality
  69586. * @param distance distance when this optimized version should be used
  69587. * @param optimizeMesh already optimized mesh
  69588. */
  69589. constructor(
  69590. /** expected quality */
  69591. quality: number,
  69592. /** distance when this optimized version should be used */
  69593. distance: number,
  69594. /** already optimized mesh */
  69595. optimizeMesh?: boolean | undefined);
  69596. }
  69597. /**
  69598. * Interface used to define a simplification task
  69599. */
  69600. export interface ISimplificationTask {
  69601. /**
  69602. * Array of settings
  69603. */
  69604. settings: Array<ISimplificationSettings>;
  69605. /**
  69606. * Simplification type
  69607. */
  69608. simplificationType: SimplificationType;
  69609. /**
  69610. * Mesh to simplify
  69611. */
  69612. mesh: Mesh;
  69613. /**
  69614. * Callback called on success
  69615. */
  69616. successCallback?: () => void;
  69617. /**
  69618. * Defines if parallel processing can be used
  69619. */
  69620. parallelProcessing: boolean;
  69621. }
  69622. /**
  69623. * Queue used to order the simplification tasks
  69624. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69625. */
  69626. export class SimplificationQueue {
  69627. private _simplificationArray;
  69628. /**
  69629. * Gets a boolean indicating that the process is still running
  69630. */
  69631. running: boolean;
  69632. /**
  69633. * Creates a new queue
  69634. */
  69635. constructor();
  69636. /**
  69637. * Adds a new simplification task
  69638. * @param task defines a task to add
  69639. */
  69640. addTask(task: ISimplificationTask): void;
  69641. /**
  69642. * Execute next task
  69643. */
  69644. executeNext(): void;
  69645. /**
  69646. * Execute a simplification task
  69647. * @param task defines the task to run
  69648. */
  69649. runSimplification(task: ISimplificationTask): void;
  69650. private getSimplifier;
  69651. }
  69652. /**
  69653. * The implemented types of simplification
  69654. * At the moment only Quadratic Error Decimation is implemented
  69655. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69656. */
  69657. export enum SimplificationType {
  69658. /** Quadratic error decimation */
  69659. QUADRATIC = 0
  69660. }
  69661. /**
  69662. * An implementation of the Quadratic Error simplification algorithm.
  69663. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69664. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69665. * @author RaananW
  69666. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69667. */
  69668. export class QuadraticErrorSimplification implements ISimplifier {
  69669. private _mesh;
  69670. private triangles;
  69671. private vertices;
  69672. private references;
  69673. private _reconstructedMesh;
  69674. /** Gets or sets the number pf sync interations */
  69675. syncIterations: number;
  69676. /** Gets or sets the aggressiveness of the simplifier */
  69677. aggressiveness: number;
  69678. /** Gets or sets the number of allowed iterations for decimation */
  69679. decimationIterations: number;
  69680. /** Gets or sets the espilon to use for bounding box computation */
  69681. boundingBoxEpsilon: number;
  69682. /**
  69683. * Creates a new QuadraticErrorSimplification
  69684. * @param _mesh defines the target mesh
  69685. */
  69686. constructor(_mesh: Mesh);
  69687. /**
  69688. * Simplification of a given mesh according to the given settings.
  69689. * Since this requires computation, it is assumed that the function runs async.
  69690. * @param settings The settings of the simplification, including quality and distance
  69691. * @param successCallback A callback that will be called after the mesh was simplified.
  69692. */
  69693. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69694. private runDecimation;
  69695. private initWithMesh;
  69696. private init;
  69697. private reconstructMesh;
  69698. private initDecimatedMesh;
  69699. private isFlipped;
  69700. private updateTriangles;
  69701. private identifyBorder;
  69702. private updateMesh;
  69703. private vertexError;
  69704. private calculateError;
  69705. }
  69706. }
  69707. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69708. import { Scene } from "babylonjs/scene";
  69709. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69710. import { ISceneComponent } from "babylonjs/sceneComponent";
  69711. module "babylonjs/scene" {
  69712. interface Scene {
  69713. /** @hidden (Backing field) */
  69714. _simplificationQueue: SimplificationQueue;
  69715. /**
  69716. * Gets or sets the simplification queue attached to the scene
  69717. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69718. */
  69719. simplificationQueue: SimplificationQueue;
  69720. }
  69721. }
  69722. module "babylonjs/Meshes/mesh" {
  69723. interface Mesh {
  69724. /**
  69725. * Simplify the mesh according to the given array of settings.
  69726. * Function will return immediately and will simplify async
  69727. * @param settings a collection of simplification settings
  69728. * @param parallelProcessing should all levels calculate parallel or one after the other
  69729. * @param simplificationType the type of simplification to run
  69730. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69731. * @returns the current mesh
  69732. */
  69733. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69734. }
  69735. }
  69736. /**
  69737. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69738. * created in a scene
  69739. */
  69740. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69741. /**
  69742. * The component name helpfull to identify the component in the list of scene components.
  69743. */
  69744. readonly name: string;
  69745. /**
  69746. * The scene the component belongs to.
  69747. */
  69748. scene: Scene;
  69749. /**
  69750. * Creates a new instance of the component for the given scene
  69751. * @param scene Defines the scene to register the component in
  69752. */
  69753. constructor(scene: Scene);
  69754. /**
  69755. * Registers the component in a given scene
  69756. */
  69757. register(): void;
  69758. /**
  69759. * Rebuilds the elements related to this component in case of
  69760. * context lost for instance.
  69761. */
  69762. rebuild(): void;
  69763. /**
  69764. * Disposes the component and the associated ressources
  69765. */
  69766. dispose(): void;
  69767. private _beforeCameraUpdate;
  69768. }
  69769. }
  69770. declare module "babylonjs/Meshes/Builders/index" {
  69771. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69772. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69773. export * from "babylonjs/Meshes/Builders/discBuilder";
  69774. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69775. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69776. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69777. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69778. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69779. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69780. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69781. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69782. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69783. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69784. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69785. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69786. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69787. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69788. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69789. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69790. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69791. }
  69792. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69793. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69794. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69795. import { Matrix } from "babylonjs/Maths/math.vector";
  69796. module "babylonjs/Meshes/mesh" {
  69797. interface Mesh {
  69798. /**
  69799. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  69800. */
  69801. thinInstanceEnablePicking: boolean;
  69802. /**
  69803. * Creates a new thin instance
  69804. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69805. * @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
  69806. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69807. */
  69808. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69809. /**
  69810. * Adds the transformation (matrix) of the current mesh as a thin instance
  69811. * @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
  69812. * @returns the thin instance index number
  69813. */
  69814. thinInstanceAddSelf(refresh: boolean): number;
  69815. /**
  69816. * Registers a custom attribute to be used with thin instances
  69817. * @param kind name of the attribute
  69818. * @param stride size in floats of the attribute
  69819. */
  69820. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69821. /**
  69822. * Sets the matrix of a thin instance
  69823. * @param index index of the thin instance
  69824. * @param matrix matrix to set
  69825. * @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
  69826. */
  69827. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69828. /**
  69829. * Sets the value of a custom attribute for a thin instance
  69830. * @param kind name of the attribute
  69831. * @param index index of the thin instance
  69832. * @param value value to set
  69833. * @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
  69834. */
  69835. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69836. /**
  69837. * 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.
  69838. */
  69839. thinInstanceCount: number;
  69840. /**
  69841. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69842. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69843. * @param buffer buffer to set
  69844. * @param stride size in floats of each value of the buffer
  69845. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69846. */
  69847. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69848. /**
  69849. * Gets the list of world matrices
  69850. * @return an array containing all the world matrices from the thin instances
  69851. */
  69852. thinInstanceGetWorldMatrices(): Matrix[];
  69853. /**
  69854. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69855. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69856. */
  69857. thinInstanceBufferUpdated(kind: string): void;
  69858. /**
  69859. * Refreshes the bounding info, taking into account all the thin instances defined
  69860. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69861. */
  69862. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69863. /** @hidden */
  69864. _thinInstanceInitializeUserStorage(): void;
  69865. /** @hidden */
  69866. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69867. /** @hidden */
  69868. _userThinInstanceBuffersStorage: {
  69869. data: {
  69870. [key: string]: Float32Array;
  69871. };
  69872. sizes: {
  69873. [key: string]: number;
  69874. };
  69875. vertexBuffers: {
  69876. [key: string]: Nullable<VertexBuffer>;
  69877. };
  69878. strides: {
  69879. [key: string]: number;
  69880. };
  69881. };
  69882. }
  69883. }
  69884. }
  69885. declare module "babylonjs/Meshes/index" {
  69886. export * from "babylonjs/Meshes/abstractMesh";
  69887. export * from "babylonjs/Meshes/buffer";
  69888. export * from "babylonjs/Meshes/Compression/index";
  69889. export * from "babylonjs/Meshes/csg";
  69890. export * from "babylonjs/Meshes/geometry";
  69891. export * from "babylonjs/Meshes/groundMesh";
  69892. export * from "babylonjs/Meshes/trailMesh";
  69893. export * from "babylonjs/Meshes/instancedMesh";
  69894. export * from "babylonjs/Meshes/linesMesh";
  69895. export * from "babylonjs/Meshes/mesh";
  69896. export * from "babylonjs/Meshes/mesh.vertexData";
  69897. export * from "babylonjs/Meshes/meshBuilder";
  69898. export * from "babylonjs/Meshes/meshSimplification";
  69899. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69900. export * from "babylonjs/Meshes/polygonMesh";
  69901. export * from "babylonjs/Meshes/subMesh";
  69902. export * from "babylonjs/Meshes/meshLODLevel";
  69903. export * from "babylonjs/Meshes/transformNode";
  69904. export * from "babylonjs/Meshes/Builders/index";
  69905. export * from "babylonjs/Meshes/dataBuffer";
  69906. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69907. import "babylonjs/Meshes/thinInstanceMesh";
  69908. export * from "babylonjs/Meshes/thinInstanceMesh";
  69909. }
  69910. declare module "babylonjs/Morph/index" {
  69911. export * from "babylonjs/Morph/morphTarget";
  69912. export * from "babylonjs/Morph/morphTargetManager";
  69913. }
  69914. declare module "babylonjs/Navigation/INavigationEngine" {
  69915. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69916. import { Vector3 } from "babylonjs/Maths/math";
  69917. import { Mesh } from "babylonjs/Meshes/mesh";
  69918. import { Scene } from "babylonjs/scene";
  69919. /**
  69920. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69921. */
  69922. export interface INavigationEnginePlugin {
  69923. /**
  69924. * plugin name
  69925. */
  69926. name: string;
  69927. /**
  69928. * Creates a navigation mesh
  69929. * @param meshes array of all the geometry used to compute the navigatio mesh
  69930. * @param parameters bunch of parameters used to filter geometry
  69931. */
  69932. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69933. /**
  69934. * Create a navigation mesh debug mesh
  69935. * @param scene is where the mesh will be added
  69936. * @returns debug display mesh
  69937. */
  69938. createDebugNavMesh(scene: Scene): Mesh;
  69939. /**
  69940. * Get a navigation mesh constrained position, closest to the parameter position
  69941. * @param position world position
  69942. * @returns the closest point to position constrained by the navigation mesh
  69943. */
  69944. getClosestPoint(position: Vector3): Vector3;
  69945. /**
  69946. * Get a navigation mesh constrained position, closest to the parameter position
  69947. * @param position world position
  69948. * @param result output the closest point to position constrained by the navigation mesh
  69949. */
  69950. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69951. /**
  69952. * Get a navigation mesh constrained position, within a particular radius
  69953. * @param position world position
  69954. * @param maxRadius the maximum distance to the constrained world position
  69955. * @returns the closest point to position constrained by the navigation mesh
  69956. */
  69957. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69958. /**
  69959. * Get a navigation mesh constrained position, within a particular radius
  69960. * @param position world position
  69961. * @param maxRadius the maximum distance to the constrained world position
  69962. * @param result output the closest point to position constrained by the navigation mesh
  69963. */
  69964. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69965. /**
  69966. * Compute the final position from a segment made of destination-position
  69967. * @param position world position
  69968. * @param destination world position
  69969. * @returns the resulting point along the navmesh
  69970. */
  69971. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69972. /**
  69973. * Compute the final position from a segment made of destination-position
  69974. * @param position world position
  69975. * @param destination world position
  69976. * @param result output the resulting point along the navmesh
  69977. */
  69978. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69979. /**
  69980. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69981. * @param start world position
  69982. * @param end world position
  69983. * @returns array containing world position composing the path
  69984. */
  69985. computePath(start: Vector3, end: Vector3): Vector3[];
  69986. /**
  69987. * If this plugin is supported
  69988. * @returns true if plugin is supported
  69989. */
  69990. isSupported(): boolean;
  69991. /**
  69992. * Create a new Crowd so you can add agents
  69993. * @param maxAgents the maximum agent count in the crowd
  69994. * @param maxAgentRadius the maximum radius an agent can have
  69995. * @param scene to attach the crowd to
  69996. * @returns the crowd you can add agents to
  69997. */
  69998. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69999. /**
  70000. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70001. * The queries will try to find a solution within those bounds
  70002. * default is (1,1,1)
  70003. * @param extent x,y,z value that define the extent around the queries point of reference
  70004. */
  70005. setDefaultQueryExtent(extent: Vector3): void;
  70006. /**
  70007. * Get the Bounding box extent specified by setDefaultQueryExtent
  70008. * @returns the box extent values
  70009. */
  70010. getDefaultQueryExtent(): Vector3;
  70011. /**
  70012. * build the navmesh from a previously saved state using getNavmeshData
  70013. * @param data the Uint8Array returned by getNavmeshData
  70014. */
  70015. buildFromNavmeshData(data: Uint8Array): void;
  70016. /**
  70017. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70018. * @returns data the Uint8Array that can be saved and reused
  70019. */
  70020. getNavmeshData(): Uint8Array;
  70021. /**
  70022. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70023. * @param result output the box extent values
  70024. */
  70025. getDefaultQueryExtentToRef(result: Vector3): void;
  70026. /**
  70027. * Release all resources
  70028. */
  70029. dispose(): void;
  70030. }
  70031. /**
  70032. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70033. */
  70034. export interface ICrowd {
  70035. /**
  70036. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70037. * You can attach anything to that node. The node position is updated in the scene update tick.
  70038. * @param pos world position that will be constrained by the navigation mesh
  70039. * @param parameters agent parameters
  70040. * @param transform hooked to the agent that will be update by the scene
  70041. * @returns agent index
  70042. */
  70043. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70044. /**
  70045. * Returns the agent position in world space
  70046. * @param index agent index returned by addAgent
  70047. * @returns world space position
  70048. */
  70049. getAgentPosition(index: number): Vector3;
  70050. /**
  70051. * Gets the agent position result in world space
  70052. * @param index agent index returned by addAgent
  70053. * @param result output world space position
  70054. */
  70055. getAgentPositionToRef(index: number, result: Vector3): void;
  70056. /**
  70057. * Gets the agent velocity in world space
  70058. * @param index agent index returned by addAgent
  70059. * @returns world space velocity
  70060. */
  70061. getAgentVelocity(index: number): Vector3;
  70062. /**
  70063. * Gets the agent velocity result in world space
  70064. * @param index agent index returned by addAgent
  70065. * @param result output world space velocity
  70066. */
  70067. getAgentVelocityToRef(index: number, result: Vector3): void;
  70068. /**
  70069. * remove a particular agent previously created
  70070. * @param index agent index returned by addAgent
  70071. */
  70072. removeAgent(index: number): void;
  70073. /**
  70074. * get the list of all agents attached to this crowd
  70075. * @returns list of agent indices
  70076. */
  70077. getAgents(): number[];
  70078. /**
  70079. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70080. * @param deltaTime in seconds
  70081. */
  70082. update(deltaTime: number): void;
  70083. /**
  70084. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70085. * @param index agent index returned by addAgent
  70086. * @param destination targeted world position
  70087. */
  70088. agentGoto(index: number, destination: Vector3): void;
  70089. /**
  70090. * Teleport the agent to a new position
  70091. * @param index agent index returned by addAgent
  70092. * @param destination targeted world position
  70093. */
  70094. agentTeleport(index: number, destination: Vector3): void;
  70095. /**
  70096. * Update agent parameters
  70097. * @param index agent index returned by addAgent
  70098. * @param parameters agent parameters
  70099. */
  70100. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70101. /**
  70102. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70103. * The queries will try to find a solution within those bounds
  70104. * default is (1,1,1)
  70105. * @param extent x,y,z value that define the extent around the queries point of reference
  70106. */
  70107. setDefaultQueryExtent(extent: Vector3): void;
  70108. /**
  70109. * Get the Bounding box extent specified by setDefaultQueryExtent
  70110. * @returns the box extent values
  70111. */
  70112. getDefaultQueryExtent(): Vector3;
  70113. /**
  70114. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70115. * @param result output the box extent values
  70116. */
  70117. getDefaultQueryExtentToRef(result: Vector3): void;
  70118. /**
  70119. * Release all resources
  70120. */
  70121. dispose(): void;
  70122. }
  70123. /**
  70124. * Configures an agent
  70125. */
  70126. export interface IAgentParameters {
  70127. /**
  70128. * Agent radius. [Limit: >= 0]
  70129. */
  70130. radius: number;
  70131. /**
  70132. * Agent height. [Limit: > 0]
  70133. */
  70134. height: number;
  70135. /**
  70136. * Maximum allowed acceleration. [Limit: >= 0]
  70137. */
  70138. maxAcceleration: number;
  70139. /**
  70140. * Maximum allowed speed. [Limit: >= 0]
  70141. */
  70142. maxSpeed: number;
  70143. /**
  70144. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70145. */
  70146. collisionQueryRange: number;
  70147. /**
  70148. * The path visibility optimization range. [Limit: > 0]
  70149. */
  70150. pathOptimizationRange: number;
  70151. /**
  70152. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70153. */
  70154. separationWeight: number;
  70155. }
  70156. /**
  70157. * Configures the navigation mesh creation
  70158. */
  70159. export interface INavMeshParameters {
  70160. /**
  70161. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70162. */
  70163. cs: number;
  70164. /**
  70165. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70166. */
  70167. ch: number;
  70168. /**
  70169. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70170. */
  70171. walkableSlopeAngle: number;
  70172. /**
  70173. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70174. * be considered walkable. [Limit: >= 3] [Units: vx]
  70175. */
  70176. walkableHeight: number;
  70177. /**
  70178. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70179. */
  70180. walkableClimb: number;
  70181. /**
  70182. * The distance to erode/shrink the walkable area of the heightfield away from
  70183. * obstructions. [Limit: >=0] [Units: vx]
  70184. */
  70185. walkableRadius: number;
  70186. /**
  70187. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70188. */
  70189. maxEdgeLen: number;
  70190. /**
  70191. * The maximum distance a simplfied contour's border edges should deviate
  70192. * the original raw contour. [Limit: >=0] [Units: vx]
  70193. */
  70194. maxSimplificationError: number;
  70195. /**
  70196. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70197. */
  70198. minRegionArea: number;
  70199. /**
  70200. * Any regions with a span count smaller than this value will, if possible,
  70201. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70202. */
  70203. mergeRegionArea: number;
  70204. /**
  70205. * The maximum number of vertices allowed for polygons generated during the
  70206. * contour to polygon conversion process. [Limit: >= 3]
  70207. */
  70208. maxVertsPerPoly: number;
  70209. /**
  70210. * Sets the sampling distance to use when generating the detail mesh.
  70211. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70212. */
  70213. detailSampleDist: number;
  70214. /**
  70215. * The maximum distance the detail mesh surface should deviate from heightfield
  70216. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70217. */
  70218. detailSampleMaxError: number;
  70219. }
  70220. }
  70221. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70222. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70223. import { Mesh } from "babylonjs/Meshes/mesh";
  70224. import { Scene } from "babylonjs/scene";
  70225. import { Vector3 } from "babylonjs/Maths/math";
  70226. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70227. /**
  70228. * RecastJS navigation plugin
  70229. */
  70230. export class RecastJSPlugin implements INavigationEnginePlugin {
  70231. /**
  70232. * Reference to the Recast library
  70233. */
  70234. bjsRECAST: any;
  70235. /**
  70236. * plugin name
  70237. */
  70238. name: string;
  70239. /**
  70240. * the first navmesh created. We might extend this to support multiple navmeshes
  70241. */
  70242. navMesh: any;
  70243. /**
  70244. * Initializes the recastJS plugin
  70245. * @param recastInjection can be used to inject your own recast reference
  70246. */
  70247. constructor(recastInjection?: any);
  70248. /**
  70249. * Creates a navigation mesh
  70250. * @param meshes array of all the geometry used to compute the navigatio mesh
  70251. * @param parameters bunch of parameters used to filter geometry
  70252. */
  70253. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70254. /**
  70255. * Create a navigation mesh debug mesh
  70256. * @param scene is where the mesh will be added
  70257. * @returns debug display mesh
  70258. */
  70259. createDebugNavMesh(scene: Scene): Mesh;
  70260. /**
  70261. * Get a navigation mesh constrained position, closest to the parameter position
  70262. * @param position world position
  70263. * @returns the closest point to position constrained by the navigation mesh
  70264. */
  70265. getClosestPoint(position: Vector3): Vector3;
  70266. /**
  70267. * Get a navigation mesh constrained position, closest to the parameter position
  70268. * @param position world position
  70269. * @param result output the closest point to position constrained by the navigation mesh
  70270. */
  70271. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70272. /**
  70273. * Get a navigation mesh constrained position, within a particular radius
  70274. * @param position world position
  70275. * @param maxRadius the maximum distance to the constrained world position
  70276. * @returns the closest point to position constrained by the navigation mesh
  70277. */
  70278. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70279. /**
  70280. * Get a navigation mesh constrained position, within a particular radius
  70281. * @param position world position
  70282. * @param maxRadius the maximum distance to the constrained world position
  70283. * @param result output the closest point to position constrained by the navigation mesh
  70284. */
  70285. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70286. /**
  70287. * Compute the final position from a segment made of destination-position
  70288. * @param position world position
  70289. * @param destination world position
  70290. * @returns the resulting point along the navmesh
  70291. */
  70292. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70293. /**
  70294. * Compute the final position from a segment made of destination-position
  70295. * @param position world position
  70296. * @param destination world position
  70297. * @param result output the resulting point along the navmesh
  70298. */
  70299. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70300. /**
  70301. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70302. * @param start world position
  70303. * @param end world position
  70304. * @returns array containing world position composing the path
  70305. */
  70306. computePath(start: Vector3, end: Vector3): Vector3[];
  70307. /**
  70308. * Create a new Crowd so you can add agents
  70309. * @param maxAgents the maximum agent count in the crowd
  70310. * @param maxAgentRadius the maximum radius an agent can have
  70311. * @param scene to attach the crowd to
  70312. * @returns the crowd you can add agents to
  70313. */
  70314. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70315. /**
  70316. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70317. * The queries will try to find a solution within those bounds
  70318. * default is (1,1,1)
  70319. * @param extent x,y,z value that define the extent around the queries point of reference
  70320. */
  70321. setDefaultQueryExtent(extent: Vector3): void;
  70322. /**
  70323. * Get the Bounding box extent specified by setDefaultQueryExtent
  70324. * @returns the box extent values
  70325. */
  70326. getDefaultQueryExtent(): Vector3;
  70327. /**
  70328. * build the navmesh from a previously saved state using getNavmeshData
  70329. * @param data the Uint8Array returned by getNavmeshData
  70330. */
  70331. buildFromNavmeshData(data: Uint8Array): void;
  70332. /**
  70333. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70334. * @returns data the Uint8Array that can be saved and reused
  70335. */
  70336. getNavmeshData(): Uint8Array;
  70337. /**
  70338. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70339. * @param result output the box extent values
  70340. */
  70341. getDefaultQueryExtentToRef(result: Vector3): void;
  70342. /**
  70343. * Disposes
  70344. */
  70345. dispose(): void;
  70346. /**
  70347. * If this plugin is supported
  70348. * @returns true if plugin is supported
  70349. */
  70350. isSupported(): boolean;
  70351. }
  70352. /**
  70353. * Recast detour crowd implementation
  70354. */
  70355. export class RecastJSCrowd implements ICrowd {
  70356. /**
  70357. * Recast/detour plugin
  70358. */
  70359. bjsRECASTPlugin: RecastJSPlugin;
  70360. /**
  70361. * Link to the detour crowd
  70362. */
  70363. recastCrowd: any;
  70364. /**
  70365. * One transform per agent
  70366. */
  70367. transforms: TransformNode[];
  70368. /**
  70369. * All agents created
  70370. */
  70371. agents: number[];
  70372. /**
  70373. * Link to the scene is kept to unregister the crowd from the scene
  70374. */
  70375. private _scene;
  70376. /**
  70377. * Observer for crowd updates
  70378. */
  70379. private _onBeforeAnimationsObserver;
  70380. /**
  70381. * Constructor
  70382. * @param plugin recastJS plugin
  70383. * @param maxAgents the maximum agent count in the crowd
  70384. * @param maxAgentRadius the maximum radius an agent can have
  70385. * @param scene to attach the crowd to
  70386. * @returns the crowd you can add agents to
  70387. */
  70388. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70389. /**
  70390. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70391. * You can attach anything to that node. The node position is updated in the scene update tick.
  70392. * @param pos world position that will be constrained by the navigation mesh
  70393. * @param parameters agent parameters
  70394. * @param transform hooked to the agent that will be update by the scene
  70395. * @returns agent index
  70396. */
  70397. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70398. /**
  70399. * Returns the agent position in world space
  70400. * @param index agent index returned by addAgent
  70401. * @returns world space position
  70402. */
  70403. getAgentPosition(index: number): Vector3;
  70404. /**
  70405. * Returns the agent position result in world space
  70406. * @param index agent index returned by addAgent
  70407. * @param result output world space position
  70408. */
  70409. getAgentPositionToRef(index: number, result: Vector3): void;
  70410. /**
  70411. * Returns the agent velocity in world space
  70412. * @param index agent index returned by addAgent
  70413. * @returns world space velocity
  70414. */
  70415. getAgentVelocity(index: number): Vector3;
  70416. /**
  70417. * Returns the agent velocity result in world space
  70418. * @param index agent index returned by addAgent
  70419. * @param result output world space velocity
  70420. */
  70421. getAgentVelocityToRef(index: number, result: Vector3): void;
  70422. /**
  70423. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70424. * @param index agent index returned by addAgent
  70425. * @param destination targeted world position
  70426. */
  70427. agentGoto(index: number, destination: Vector3): void;
  70428. /**
  70429. * Teleport the agent to a new position
  70430. * @param index agent index returned by addAgent
  70431. * @param destination targeted world position
  70432. */
  70433. agentTeleport(index: number, destination: Vector3): void;
  70434. /**
  70435. * Update agent parameters
  70436. * @param index agent index returned by addAgent
  70437. * @param parameters agent parameters
  70438. */
  70439. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70440. /**
  70441. * remove a particular agent previously created
  70442. * @param index agent index returned by addAgent
  70443. */
  70444. removeAgent(index: number): void;
  70445. /**
  70446. * get the list of all agents attached to this crowd
  70447. * @returns list of agent indices
  70448. */
  70449. getAgents(): number[];
  70450. /**
  70451. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70452. * @param deltaTime in seconds
  70453. */
  70454. update(deltaTime: number): void;
  70455. /**
  70456. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70457. * The queries will try to find a solution within those bounds
  70458. * default is (1,1,1)
  70459. * @param extent x,y,z value that define the extent around the queries point of reference
  70460. */
  70461. setDefaultQueryExtent(extent: Vector3): void;
  70462. /**
  70463. * Get the Bounding box extent specified by setDefaultQueryExtent
  70464. * @returns the box extent values
  70465. */
  70466. getDefaultQueryExtent(): Vector3;
  70467. /**
  70468. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70469. * @param result output the box extent values
  70470. */
  70471. getDefaultQueryExtentToRef(result: Vector3): void;
  70472. /**
  70473. * Release all resources
  70474. */
  70475. dispose(): void;
  70476. }
  70477. }
  70478. declare module "babylonjs/Navigation/Plugins/index" {
  70479. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70480. }
  70481. declare module "babylonjs/Navigation/index" {
  70482. export * from "babylonjs/Navigation/INavigationEngine";
  70483. export * from "babylonjs/Navigation/Plugins/index";
  70484. }
  70485. declare module "babylonjs/Offline/database" {
  70486. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70487. /**
  70488. * Class used to enable access to IndexedDB
  70489. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70490. */
  70491. export class Database implements IOfflineProvider {
  70492. private _callbackManifestChecked;
  70493. private _currentSceneUrl;
  70494. private _db;
  70495. private _enableSceneOffline;
  70496. private _enableTexturesOffline;
  70497. private _manifestVersionFound;
  70498. private _mustUpdateRessources;
  70499. private _hasReachedQuota;
  70500. private _isSupported;
  70501. private _idbFactory;
  70502. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70503. private static IsUASupportingBlobStorage;
  70504. /**
  70505. * Gets a boolean indicating if Database storate is enabled (off by default)
  70506. */
  70507. static IDBStorageEnabled: boolean;
  70508. /**
  70509. * Gets a boolean indicating if scene must be saved in the database
  70510. */
  70511. get enableSceneOffline(): boolean;
  70512. /**
  70513. * Gets a boolean indicating if textures must be saved in the database
  70514. */
  70515. get enableTexturesOffline(): boolean;
  70516. /**
  70517. * Creates a new Database
  70518. * @param urlToScene defines the url to load the scene
  70519. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70520. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70521. */
  70522. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70523. private static _ParseURL;
  70524. private static _ReturnFullUrlLocation;
  70525. private _checkManifestFile;
  70526. /**
  70527. * Open the database and make it available
  70528. * @param successCallback defines the callback to call on success
  70529. * @param errorCallback defines the callback to call on error
  70530. */
  70531. open(successCallback: () => void, errorCallback: () => void): void;
  70532. /**
  70533. * Loads an image from the database
  70534. * @param url defines the url to load from
  70535. * @param image defines the target DOM image
  70536. */
  70537. loadImage(url: string, image: HTMLImageElement): void;
  70538. private _loadImageFromDBAsync;
  70539. private _saveImageIntoDBAsync;
  70540. private _checkVersionFromDB;
  70541. private _loadVersionFromDBAsync;
  70542. private _saveVersionIntoDBAsync;
  70543. /**
  70544. * Loads a file from database
  70545. * @param url defines the URL to load from
  70546. * @param sceneLoaded defines a callback to call on success
  70547. * @param progressCallBack defines a callback to call when progress changed
  70548. * @param errorCallback defines a callback to call on error
  70549. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70550. */
  70551. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70552. private _loadFileAsync;
  70553. private _saveFileAsync;
  70554. /**
  70555. * Validates if xhr data is correct
  70556. * @param xhr defines the request to validate
  70557. * @param dataType defines the expected data type
  70558. * @returns true if data is correct
  70559. */
  70560. private static _ValidateXHRData;
  70561. }
  70562. }
  70563. declare module "babylonjs/Offline/index" {
  70564. export * from "babylonjs/Offline/database";
  70565. export * from "babylonjs/Offline/IOfflineProvider";
  70566. }
  70567. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70568. /** @hidden */
  70569. export var gpuUpdateParticlesPixelShader: {
  70570. name: string;
  70571. shader: string;
  70572. };
  70573. }
  70574. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70575. /** @hidden */
  70576. export var gpuUpdateParticlesVertexShader: {
  70577. name: string;
  70578. shader: string;
  70579. };
  70580. }
  70581. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  70582. /** @hidden */
  70583. export var clipPlaneFragmentDeclaration2: {
  70584. name: string;
  70585. shader: string;
  70586. };
  70587. }
  70588. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  70589. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  70590. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  70591. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  70592. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  70593. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  70594. /** @hidden */
  70595. export var gpuRenderParticlesPixelShader: {
  70596. name: string;
  70597. shader: string;
  70598. };
  70599. }
  70600. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  70601. /** @hidden */
  70602. export var clipPlaneVertexDeclaration2: {
  70603. name: string;
  70604. shader: string;
  70605. };
  70606. }
  70607. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  70608. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  70609. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  70610. /** @hidden */
  70611. export var gpuRenderParticlesVertexShader: {
  70612. name: string;
  70613. shader: string;
  70614. };
  70615. }
  70616. declare module "babylonjs/Particles/gpuParticleSystem" {
  70617. import { Nullable } from "babylonjs/types";
  70618. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  70619. import { Observable } from "babylonjs/Misc/observable";
  70620. import { Matrix } from "babylonjs/Maths/math.vector";
  70621. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70622. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70623. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  70624. import { IDisposable } from "babylonjs/scene";
  70625. import { Effect } from "babylonjs/Materials/effect";
  70626. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70627. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70628. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  70629. import { Scene } from "babylonjs/scene";
  70630. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  70631. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  70632. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  70633. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  70634. /**
  70635. * This represents a GPU particle system in Babylon
  70636. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  70637. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  70638. */
  70639. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  70640. /**
  70641. * The layer mask we are rendering the particles through.
  70642. */
  70643. layerMask: number;
  70644. private _capacity;
  70645. private _activeCount;
  70646. private _currentActiveCount;
  70647. private _accumulatedCount;
  70648. private _renderEffect;
  70649. private _updateEffect;
  70650. private _buffer0;
  70651. private _buffer1;
  70652. private _spriteBuffer;
  70653. private _updateVAO;
  70654. private _renderVAO;
  70655. private _targetIndex;
  70656. private _sourceBuffer;
  70657. private _targetBuffer;
  70658. private _currentRenderId;
  70659. private _started;
  70660. private _stopped;
  70661. private _timeDelta;
  70662. private _randomTexture;
  70663. private _randomTexture2;
  70664. private _attributesStrideSize;
  70665. private _updateEffectOptions;
  70666. private _randomTextureSize;
  70667. private _actualFrame;
  70668. private _customEffect;
  70669. private readonly _rawTextureWidth;
  70670. /**
  70671. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70672. */
  70673. static get IsSupported(): boolean;
  70674. /**
  70675. * An event triggered when the system is disposed.
  70676. */
  70677. onDisposeObservable: Observable<IParticleSystem>;
  70678. /**
  70679. * Gets the maximum number of particles active at the same time.
  70680. * @returns The max number of active particles.
  70681. */
  70682. getCapacity(): number;
  70683. /**
  70684. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70685. * to override the particles.
  70686. */
  70687. forceDepthWrite: boolean;
  70688. /**
  70689. * Gets or set the number of active particles
  70690. */
  70691. get activeParticleCount(): number;
  70692. set activeParticleCount(value: number);
  70693. private _preWarmDone;
  70694. /**
  70695. * Specifies if the particles are updated in emitter local space or world space.
  70696. */
  70697. isLocal: boolean;
  70698. /** Gets or sets a matrix to use to compute projection */
  70699. defaultProjectionMatrix: Matrix;
  70700. /**
  70701. * Is this system ready to be used/rendered
  70702. * @return true if the system is ready
  70703. */
  70704. isReady(): boolean;
  70705. /**
  70706. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70707. * @returns True if it has been started, otherwise false.
  70708. */
  70709. isStarted(): boolean;
  70710. /**
  70711. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70712. * @returns True if it has been stopped, otherwise false.
  70713. */
  70714. isStopped(): boolean;
  70715. /**
  70716. * Gets a boolean indicating that the system is stopping
  70717. * @returns true if the system is currently stopping
  70718. */
  70719. isStopping(): boolean;
  70720. /**
  70721. * Gets the number of particles active at the same time.
  70722. * @returns The number of active particles.
  70723. */
  70724. getActiveCount(): number;
  70725. /**
  70726. * Starts the particle system and begins to emit
  70727. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70728. */
  70729. start(delay?: number): void;
  70730. /**
  70731. * Stops the particle system.
  70732. */
  70733. stop(): void;
  70734. /**
  70735. * Remove all active particles
  70736. */
  70737. reset(): void;
  70738. /**
  70739. * Returns the string "GPUParticleSystem"
  70740. * @returns a string containing the class name
  70741. */
  70742. getClassName(): string;
  70743. /**
  70744. * Gets the custom effect used to render the particles
  70745. * @param blendMode Blend mode for which the effect should be retrieved
  70746. * @returns The effect
  70747. */
  70748. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70749. /**
  70750. * Sets the custom effect used to render the particles
  70751. * @param effect The effect to set
  70752. * @param blendMode Blend mode for which the effect should be set
  70753. */
  70754. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70755. /** @hidden */
  70756. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70757. /**
  70758. * Observable that will be called just before the particles are drawn
  70759. */
  70760. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70761. /**
  70762. * Gets the name of the particle vertex shader
  70763. */
  70764. get vertexShaderName(): string;
  70765. private _colorGradientsTexture;
  70766. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70767. /**
  70768. * Adds a new color gradient
  70769. * @param gradient defines the gradient to use (between 0 and 1)
  70770. * @param color1 defines the color to affect to the specified gradient
  70771. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70772. * @returns the current particle system
  70773. */
  70774. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70775. private _refreshColorGradient;
  70776. /** Force the system to rebuild all gradients that need to be resync */
  70777. forceRefreshGradients(): void;
  70778. /**
  70779. * Remove a specific color gradient
  70780. * @param gradient defines the gradient to remove
  70781. * @returns the current particle system
  70782. */
  70783. removeColorGradient(gradient: number): GPUParticleSystem;
  70784. private _angularSpeedGradientsTexture;
  70785. private _sizeGradientsTexture;
  70786. private _velocityGradientsTexture;
  70787. private _limitVelocityGradientsTexture;
  70788. private _dragGradientsTexture;
  70789. private _addFactorGradient;
  70790. /**
  70791. * Adds a new size gradient
  70792. * @param gradient defines the gradient to use (between 0 and 1)
  70793. * @param factor defines the size factor to affect to the specified gradient
  70794. * @returns the current particle system
  70795. */
  70796. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70797. /**
  70798. * Remove a specific size gradient
  70799. * @param gradient defines the gradient to remove
  70800. * @returns the current particle system
  70801. */
  70802. removeSizeGradient(gradient: number): GPUParticleSystem;
  70803. private _refreshFactorGradient;
  70804. /**
  70805. * Adds a new angular speed gradient
  70806. * @param gradient defines the gradient to use (between 0 and 1)
  70807. * @param factor defines the angular speed to affect to the specified gradient
  70808. * @returns the current particle system
  70809. */
  70810. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70811. /**
  70812. * Remove a specific angular speed gradient
  70813. * @param gradient defines the gradient to remove
  70814. * @returns the current particle system
  70815. */
  70816. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70817. /**
  70818. * Adds a new velocity gradient
  70819. * @param gradient defines the gradient to use (between 0 and 1)
  70820. * @param factor defines the velocity to affect to the specified gradient
  70821. * @returns the current particle system
  70822. */
  70823. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70824. /**
  70825. * Remove a specific velocity gradient
  70826. * @param gradient defines the gradient to remove
  70827. * @returns the current particle system
  70828. */
  70829. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70830. /**
  70831. * Adds a new limit velocity gradient
  70832. * @param gradient defines the gradient to use (between 0 and 1)
  70833. * @param factor defines the limit velocity value to affect to the specified gradient
  70834. * @returns the current particle system
  70835. */
  70836. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70837. /**
  70838. * Remove a specific limit velocity gradient
  70839. * @param gradient defines the gradient to remove
  70840. * @returns the current particle system
  70841. */
  70842. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70843. /**
  70844. * Adds a new drag gradient
  70845. * @param gradient defines the gradient to use (between 0 and 1)
  70846. * @param factor defines the drag value to affect to the specified gradient
  70847. * @returns the current particle system
  70848. */
  70849. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70850. /**
  70851. * Remove a specific drag gradient
  70852. * @param gradient defines the gradient to remove
  70853. * @returns the current particle system
  70854. */
  70855. removeDragGradient(gradient: number): GPUParticleSystem;
  70856. /**
  70857. * Not supported by GPUParticleSystem
  70858. * @param gradient defines the gradient to use (between 0 and 1)
  70859. * @param factor defines the emit rate value to affect to the specified gradient
  70860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70861. * @returns the current particle system
  70862. */
  70863. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70864. /**
  70865. * Not supported by GPUParticleSystem
  70866. * @param gradient defines the gradient to remove
  70867. * @returns the current particle system
  70868. */
  70869. removeEmitRateGradient(gradient: number): IParticleSystem;
  70870. /**
  70871. * Not supported by GPUParticleSystem
  70872. * @param gradient defines the gradient to use (between 0 and 1)
  70873. * @param factor defines the start size value to affect to the specified gradient
  70874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70875. * @returns the current particle system
  70876. */
  70877. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70878. /**
  70879. * Not supported by GPUParticleSystem
  70880. * @param gradient defines the gradient to remove
  70881. * @returns the current particle system
  70882. */
  70883. removeStartSizeGradient(gradient: number): IParticleSystem;
  70884. /**
  70885. * Not supported by GPUParticleSystem
  70886. * @param gradient defines the gradient to use (between 0 and 1)
  70887. * @param min defines the color remap minimal range
  70888. * @param max defines the color remap maximal range
  70889. * @returns the current particle system
  70890. */
  70891. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70892. /**
  70893. * Not supported by GPUParticleSystem
  70894. * @param gradient defines the gradient to remove
  70895. * @returns the current particle system
  70896. */
  70897. removeColorRemapGradient(): IParticleSystem;
  70898. /**
  70899. * Not supported by GPUParticleSystem
  70900. * @param gradient defines the gradient to use (between 0 and 1)
  70901. * @param min defines the alpha remap minimal range
  70902. * @param max defines the alpha remap maximal range
  70903. * @returns the current particle system
  70904. */
  70905. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70906. /**
  70907. * Not supported by GPUParticleSystem
  70908. * @param gradient defines the gradient to remove
  70909. * @returns the current particle system
  70910. */
  70911. removeAlphaRemapGradient(): IParticleSystem;
  70912. /**
  70913. * Not supported by GPUParticleSystem
  70914. * @param gradient defines the gradient to use (between 0 and 1)
  70915. * @param color defines the color to affect to the specified gradient
  70916. * @returns the current particle system
  70917. */
  70918. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70919. /**
  70920. * Not supported by GPUParticleSystem
  70921. * @param gradient defines the gradient to remove
  70922. * @returns the current particle system
  70923. */
  70924. removeRampGradient(): IParticleSystem;
  70925. /**
  70926. * Not supported by GPUParticleSystem
  70927. * @returns the list of ramp gradients
  70928. */
  70929. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70930. /**
  70931. * Not supported by GPUParticleSystem
  70932. * Gets or sets a boolean indicating that ramp gradients must be used
  70933. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70934. */
  70935. get useRampGradients(): boolean;
  70936. set useRampGradients(value: boolean);
  70937. /**
  70938. * Not supported by GPUParticleSystem
  70939. * @param gradient defines the gradient to use (between 0 and 1)
  70940. * @param factor defines the life time factor to affect to the specified gradient
  70941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70942. * @returns the current particle system
  70943. */
  70944. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70945. /**
  70946. * Not supported by GPUParticleSystem
  70947. * @param gradient defines the gradient to remove
  70948. * @returns the current particle system
  70949. */
  70950. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70951. /**
  70952. * Instantiates a GPU particle system.
  70953. * 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.
  70954. * @param name The name of the particle system
  70955. * @param options The options used to create the system
  70956. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  70957. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70958. * @param customEffect a custom effect used to change the way particles are rendered by default
  70959. */
  70960. constructor(name: string, options: Partial<{
  70961. capacity: number;
  70962. randomTextureSize: number;
  70963. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70964. protected _reset(): void;
  70965. private _createUpdateVAO;
  70966. private _createRenderVAO;
  70967. private _initialize;
  70968. /** @hidden */
  70969. _recreateUpdateEffect(): void;
  70970. private _getEffect;
  70971. /**
  70972. * Fill the defines array according to the current settings of the particle system
  70973. * @param defines Array to be updated
  70974. * @param blendMode blend mode to take into account when updating the array
  70975. */
  70976. fillDefines(defines: Array<string>, blendMode?: number): void;
  70977. /**
  70978. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70979. * @param uniforms Uniforms array to fill
  70980. * @param attributes Attributes array to fill
  70981. * @param samplers Samplers array to fill
  70982. */
  70983. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70984. /** @hidden */
  70985. _recreateRenderEffect(): Effect;
  70986. /**
  70987. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70988. * @param preWarm defines if we are in the pre-warmimg phase
  70989. */
  70990. animate(preWarm?: boolean): void;
  70991. private _createFactorGradientTexture;
  70992. private _createSizeGradientTexture;
  70993. private _createAngularSpeedGradientTexture;
  70994. private _createVelocityGradientTexture;
  70995. private _createLimitVelocityGradientTexture;
  70996. private _createDragGradientTexture;
  70997. private _createColorGradientTexture;
  70998. /**
  70999. * Renders the particle system in its current state
  71000. * @param preWarm defines if the system should only update the particles but not render them
  71001. * @returns the current number of particles
  71002. */
  71003. render(preWarm?: boolean): number;
  71004. /**
  71005. * Rebuilds the particle system
  71006. */
  71007. rebuild(): void;
  71008. private _releaseBuffers;
  71009. private _releaseVAOs;
  71010. /**
  71011. * Disposes the particle system and free the associated resources
  71012. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71013. */
  71014. dispose(disposeTexture?: boolean): void;
  71015. /**
  71016. * Clones the particle system.
  71017. * @param name The name of the cloned object
  71018. * @param newEmitter The new emitter to use
  71019. * @returns the cloned particle system
  71020. */
  71021. clone(name: string, newEmitter: any): GPUParticleSystem;
  71022. /**
  71023. * Serializes the particle system to a JSON object
  71024. * @param serializeTexture defines if the texture must be serialized as well
  71025. * @returns the JSON object
  71026. */
  71027. serialize(serializeTexture?: boolean): any;
  71028. /**
  71029. * Parses a JSON object to create a GPU particle system.
  71030. * @param parsedParticleSystem The JSON object to parse
  71031. * @param sceneOrEngine The scene or the engine to create the particle system in
  71032. * @param rootUrl The root url to use to load external dependencies like texture
  71033. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71034. * @returns the parsed GPU particle system
  71035. */
  71036. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71037. }
  71038. }
  71039. declare module "babylonjs/Particles/particleSystemSet" {
  71040. import { Nullable } from "babylonjs/types";
  71041. import { Color3 } from "babylonjs/Maths/math.color";
  71042. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71044. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71045. import { Scene, IDisposable } from "babylonjs/scene";
  71046. /**
  71047. * Represents a set of particle systems working together to create a specific effect
  71048. */
  71049. export class ParticleSystemSet implements IDisposable {
  71050. /**
  71051. * Gets or sets base Assets URL
  71052. */
  71053. static BaseAssetsUrl: string;
  71054. private _emitterCreationOptions;
  71055. private _emitterNode;
  71056. /**
  71057. * Gets the particle system list
  71058. */
  71059. systems: IParticleSystem[];
  71060. /**
  71061. * Gets the emitter node used with this set
  71062. */
  71063. get emitterNode(): Nullable<TransformNode>;
  71064. /**
  71065. * Creates a new emitter mesh as a sphere
  71066. * @param options defines the options used to create the sphere
  71067. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71068. * @param scene defines the hosting scene
  71069. */
  71070. setEmitterAsSphere(options: {
  71071. diameter: number;
  71072. segments: number;
  71073. color: Color3;
  71074. }, renderingGroupId: number, scene: Scene): void;
  71075. /**
  71076. * Starts all particle systems of the set
  71077. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71078. */
  71079. start(emitter?: AbstractMesh): void;
  71080. /**
  71081. * Release all associated resources
  71082. */
  71083. dispose(): void;
  71084. /**
  71085. * Serialize the set into a JSON compatible object
  71086. * @param serializeTexture defines if the texture must be serialized as well
  71087. * @returns a JSON compatible representation of the set
  71088. */
  71089. serialize(serializeTexture?: boolean): any;
  71090. /**
  71091. * Parse a new ParticleSystemSet from a serialized source
  71092. * @param data defines a JSON compatible representation of the set
  71093. * @param scene defines the hosting scene
  71094. * @param gpu defines if we want GPU particles or CPU particles
  71095. * @returns a new ParticleSystemSet
  71096. */
  71097. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71098. }
  71099. }
  71100. declare module "babylonjs/Particles/particleHelper" {
  71101. import { Nullable } from "babylonjs/types";
  71102. import { Scene } from "babylonjs/scene";
  71103. import { Vector3 } from "babylonjs/Maths/math.vector";
  71104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71105. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71106. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71107. /**
  71108. * This class is made for on one-liner static method to help creating particle system set.
  71109. */
  71110. export class ParticleHelper {
  71111. /**
  71112. * Gets or sets base Assets URL
  71113. */
  71114. static BaseAssetsUrl: string;
  71115. /** Define the Url to load snippets */
  71116. static SnippetUrl: string;
  71117. /**
  71118. * Create a default particle system that you can tweak
  71119. * @param emitter defines the emitter to use
  71120. * @param capacity defines the system capacity (default is 500 particles)
  71121. * @param scene defines the hosting scene
  71122. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71123. * @returns the new Particle system
  71124. */
  71125. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71126. /**
  71127. * This is the main static method (one-liner) of this helper to create different particle systems
  71128. * @param type This string represents the type to the particle system to create
  71129. * @param scene The scene where the particle system should live
  71130. * @param gpu If the system will use gpu
  71131. * @returns the ParticleSystemSet created
  71132. */
  71133. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71134. /**
  71135. * Static function used to export a particle system to a ParticleSystemSet variable.
  71136. * Please note that the emitter shape is not exported
  71137. * @param systems defines the particle systems to export
  71138. * @returns the created particle system set
  71139. */
  71140. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71141. /**
  71142. * Creates a particle system from a snippet saved in a remote file
  71143. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71144. * @param url defines the url to load from
  71145. * @param scene defines the hosting scene
  71146. * @param gpu If the system will use gpu
  71147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71148. * @returns a promise that will resolve to the new particle system
  71149. */
  71150. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71151. /**
  71152. * Creates a particle system from a snippet saved by the particle system editor
  71153. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71154. * @param scene defines the hosting scene
  71155. * @param gpu If the system will use gpu
  71156. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71157. * @returns a promise that will resolve to the new particle system
  71158. */
  71159. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71160. }
  71161. }
  71162. declare module "babylonjs/Particles/particleSystemComponent" {
  71163. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71164. import { Effect } from "babylonjs/Materials/effect";
  71165. import "babylonjs/Shaders/particles.vertex";
  71166. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71167. module "babylonjs/Engines/engine" {
  71168. interface Engine {
  71169. /**
  71170. * Create an effect to use with particle systems.
  71171. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71172. * the particle system for which you want to create a custom effect in the last parameter
  71173. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71174. * @param uniformsNames defines a list of attribute names
  71175. * @param samplers defines an array of string used to represent textures
  71176. * @param defines defines the string containing the defines to use to compile the shaders
  71177. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71178. * @param onCompiled defines a function to call when the effect creation is successful
  71179. * @param onError defines a function to call when the effect creation has failed
  71180. * @param particleSystem the particle system you want to create the effect for
  71181. * @returns the new Effect
  71182. */
  71183. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71184. }
  71185. }
  71186. module "babylonjs/Meshes/mesh" {
  71187. interface Mesh {
  71188. /**
  71189. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71190. * @returns an array of IParticleSystem
  71191. */
  71192. getEmittedParticleSystems(): IParticleSystem[];
  71193. /**
  71194. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71195. * @returns an array of IParticleSystem
  71196. */
  71197. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71198. }
  71199. }
  71200. }
  71201. declare module "babylonjs/Particles/pointsCloudSystem" {
  71202. import { Color4 } from "babylonjs/Maths/math";
  71203. import { Mesh } from "babylonjs/Meshes/mesh";
  71204. import { Scene, IDisposable } from "babylonjs/scene";
  71205. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71206. /** Defines the 4 color options */
  71207. export enum PointColor {
  71208. /** color value */
  71209. Color = 2,
  71210. /** uv value */
  71211. UV = 1,
  71212. /** random value */
  71213. Random = 0,
  71214. /** stated value */
  71215. Stated = 3
  71216. }
  71217. /**
  71218. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71219. * 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.
  71220. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71221. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71222. *
  71223. * Full documentation here : TO BE ENTERED
  71224. */
  71225. export class PointsCloudSystem implements IDisposable {
  71226. /**
  71227. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71228. * Example : var p = SPS.particles[i];
  71229. */
  71230. particles: CloudPoint[];
  71231. /**
  71232. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71233. */
  71234. nbParticles: number;
  71235. /**
  71236. * This a counter for your own usage. It's not set by any SPS functions.
  71237. */
  71238. counter: number;
  71239. /**
  71240. * The PCS name. This name is also given to the underlying mesh.
  71241. */
  71242. name: string;
  71243. /**
  71244. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71245. */
  71246. mesh: Mesh;
  71247. /**
  71248. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71249. * Please read :
  71250. */
  71251. vars: any;
  71252. /**
  71253. * @hidden
  71254. */
  71255. _size: number;
  71256. private _scene;
  71257. private _promises;
  71258. private _positions;
  71259. private _indices;
  71260. private _normals;
  71261. private _colors;
  71262. private _uvs;
  71263. private _indices32;
  71264. private _positions32;
  71265. private _colors32;
  71266. private _uvs32;
  71267. private _updatable;
  71268. private _isVisibilityBoxLocked;
  71269. private _alwaysVisible;
  71270. private _groups;
  71271. private _groupCounter;
  71272. private _computeParticleColor;
  71273. private _computeParticleTexture;
  71274. private _computeParticleRotation;
  71275. private _computeBoundingBox;
  71276. private _isReady;
  71277. /**
  71278. * Creates a PCS (Points Cloud System) object
  71279. * @param name (String) is the PCS name, this will be the underlying mesh name
  71280. * @param pointSize (number) is the size for each point
  71281. * @param scene (Scene) is the scene in which the PCS is added
  71282. * @param options defines the options of the PCS e.g.
  71283. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71284. */
  71285. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71286. updatable?: boolean;
  71287. });
  71288. /**
  71289. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71290. * If no points were added to the PCS, the returned mesh is just a single point.
  71291. * @returns a promise for the created mesh
  71292. */
  71293. buildMeshAsync(): Promise<Mesh>;
  71294. /**
  71295. * @hidden
  71296. */
  71297. private _buildMesh;
  71298. private _addParticle;
  71299. private _randomUnitVector;
  71300. private _getColorIndicesForCoord;
  71301. private _setPointsColorOrUV;
  71302. private _colorFromTexture;
  71303. private _calculateDensity;
  71304. /**
  71305. * Adds points to the PCS in random positions within a unit sphere
  71306. * @param nb (positive integer) the number of particles to be created from this model
  71307. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71308. * @returns the number of groups in the system
  71309. */
  71310. addPoints(nb: number, pointFunction?: any): number;
  71311. /**
  71312. * Adds points to the PCS from the surface of the model shape
  71313. * @param mesh is any Mesh object that will be used as a surface model for the points
  71314. * @param nb (positive integer) the number of particles to be created from this model
  71315. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71316. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71317. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71318. * @returns the number of groups in the system
  71319. */
  71320. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71321. /**
  71322. * Adds points to the PCS inside the model shape
  71323. * @param mesh is any Mesh object that will be used as a surface model for the points
  71324. * @param nb (positive integer) the number of particles to be created from this model
  71325. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71326. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71327. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71328. * @returns the number of groups in the system
  71329. */
  71330. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71331. /**
  71332. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71333. * This method calls `updateParticle()` for each particle of the SPS.
  71334. * For an animated SPS, it is usually called within the render loop.
  71335. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71336. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71337. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71338. * @returns the PCS.
  71339. */
  71340. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71341. /**
  71342. * Disposes the PCS.
  71343. */
  71344. dispose(): void;
  71345. /**
  71346. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71347. * doc :
  71348. * @returns the PCS.
  71349. */
  71350. refreshVisibleSize(): PointsCloudSystem;
  71351. /**
  71352. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71353. * @param size the size (float) of the visibility box
  71354. * note : this doesn't lock the PCS mesh bounding box.
  71355. * doc :
  71356. */
  71357. setVisibilityBox(size: number): void;
  71358. /**
  71359. * Gets whether the PCS is always visible or not
  71360. * doc :
  71361. */
  71362. get isAlwaysVisible(): boolean;
  71363. /**
  71364. * Sets the PCS as always visible or not
  71365. * doc :
  71366. */
  71367. set isAlwaysVisible(val: boolean);
  71368. /**
  71369. * Tells to `setParticles()` to compute the particle rotations or not
  71370. * Default value : false. The PCS is faster when it's set to false
  71371. * Note : particle rotations are only applied to parent particles
  71372. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71373. */
  71374. set computeParticleRotation(val: boolean);
  71375. /**
  71376. * Tells to `setParticles()` to compute the particle colors or not.
  71377. * Default value : true. The PCS is faster when it's set to false.
  71378. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71379. */
  71380. set computeParticleColor(val: boolean);
  71381. set computeParticleTexture(val: boolean);
  71382. /**
  71383. * Gets if `setParticles()` computes the particle colors or not.
  71384. * Default value : false. The PCS is faster when it's set to false.
  71385. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71386. */
  71387. get computeParticleColor(): boolean;
  71388. /**
  71389. * Gets if `setParticles()` computes the particle textures or not.
  71390. * Default value : false. The PCS is faster when it's set to false.
  71391. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71392. */
  71393. get computeParticleTexture(): boolean;
  71394. /**
  71395. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71396. */
  71397. set computeBoundingBox(val: boolean);
  71398. /**
  71399. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71400. */
  71401. get computeBoundingBox(): boolean;
  71402. /**
  71403. * This function does nothing. It may be overwritten to set all the particle first values.
  71404. * The PCS doesn't call this function, you may have to call it by your own.
  71405. * doc :
  71406. */
  71407. initParticles(): void;
  71408. /**
  71409. * This function does nothing. It may be overwritten to recycle a particle
  71410. * The PCS doesn't call this function, you can to call it
  71411. * doc :
  71412. * @param particle The particle to recycle
  71413. * @returns the recycled particle
  71414. */
  71415. recycleParticle(particle: CloudPoint): CloudPoint;
  71416. /**
  71417. * Updates a particle : this function should be overwritten by the user.
  71418. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71419. * doc :
  71420. * @example : just set a particle position or velocity and recycle conditions
  71421. * @param particle The particle to update
  71422. * @returns the updated particle
  71423. */
  71424. updateParticle(particle: CloudPoint): CloudPoint;
  71425. /**
  71426. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71427. * This does nothing and may be overwritten by the user.
  71428. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71429. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71430. * @param update the boolean update value actually passed to setParticles()
  71431. */
  71432. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71433. /**
  71434. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71435. * This will be passed three parameters.
  71436. * This does nothing and may be overwritten by the user.
  71437. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71438. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71439. * @param update the boolean update value actually passed to setParticles()
  71440. */
  71441. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71442. }
  71443. }
  71444. declare module "babylonjs/Particles/cloudPoint" {
  71445. import { Nullable } from "babylonjs/types";
  71446. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71447. import { Mesh } from "babylonjs/Meshes/mesh";
  71448. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71449. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71450. /**
  71451. * Represents one particle of a points cloud system.
  71452. */
  71453. export class CloudPoint {
  71454. /**
  71455. * particle global index
  71456. */
  71457. idx: number;
  71458. /**
  71459. * The color of the particle
  71460. */
  71461. color: Nullable<Color4>;
  71462. /**
  71463. * The world space position of the particle.
  71464. */
  71465. position: Vector3;
  71466. /**
  71467. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71468. */
  71469. rotation: Vector3;
  71470. /**
  71471. * The world space rotation quaternion of the particle.
  71472. */
  71473. rotationQuaternion: Nullable<Quaternion>;
  71474. /**
  71475. * The uv of the particle.
  71476. */
  71477. uv: Nullable<Vector2>;
  71478. /**
  71479. * The current speed of the particle.
  71480. */
  71481. velocity: Vector3;
  71482. /**
  71483. * The pivot point in the particle local space.
  71484. */
  71485. pivot: Vector3;
  71486. /**
  71487. * Must the particle be translated from its pivot point in its local space ?
  71488. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71489. * Default : false
  71490. */
  71491. translateFromPivot: boolean;
  71492. /**
  71493. * Index of this particle in the global "positions" array (Internal use)
  71494. * @hidden
  71495. */
  71496. _pos: number;
  71497. /**
  71498. * @hidden Index of this particle in the global "indices" array (Internal use)
  71499. */
  71500. _ind: number;
  71501. /**
  71502. * Group this particle belongs to
  71503. */
  71504. _group: PointsGroup;
  71505. /**
  71506. * Group id of this particle
  71507. */
  71508. groupId: number;
  71509. /**
  71510. * Index of the particle in its group id (Internal use)
  71511. */
  71512. idxInGroup: number;
  71513. /**
  71514. * @hidden Particle BoundingInfo object (Internal use)
  71515. */
  71516. _boundingInfo: BoundingInfo;
  71517. /**
  71518. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71519. */
  71520. _pcs: PointsCloudSystem;
  71521. /**
  71522. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71523. */
  71524. _stillInvisible: boolean;
  71525. /**
  71526. * @hidden Last computed particle rotation matrix
  71527. */
  71528. _rotationMatrix: number[];
  71529. /**
  71530. * Parent particle Id, if any.
  71531. * Default null.
  71532. */
  71533. parentId: Nullable<number>;
  71534. /**
  71535. * @hidden Internal global position in the PCS.
  71536. */
  71537. _globalPosition: Vector3;
  71538. /**
  71539. * Creates a Point Cloud object.
  71540. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71541. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71542. * @param group (PointsGroup) is the group the particle belongs to
  71543. * @param groupId (integer) is the group identifier in the PCS.
  71544. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71545. * @param pcs defines the PCS it is associated to
  71546. */
  71547. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71548. /**
  71549. * get point size
  71550. */
  71551. get size(): Vector3;
  71552. /**
  71553. * Set point size
  71554. */
  71555. set size(scale: Vector3);
  71556. /**
  71557. * Legacy support, changed quaternion to rotationQuaternion
  71558. */
  71559. get quaternion(): Nullable<Quaternion>;
  71560. /**
  71561. * Legacy support, changed quaternion to rotationQuaternion
  71562. */
  71563. set quaternion(q: Nullable<Quaternion>);
  71564. /**
  71565. * Returns a boolean. True if the particle intersects a mesh, else false
  71566. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71567. * @param target is the object (point or mesh) what the intersection is computed against
  71568. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71569. * @returns true if it intersects
  71570. */
  71571. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71572. /**
  71573. * get the rotation matrix of the particle
  71574. * @hidden
  71575. */
  71576. getRotationMatrix(m: Matrix): void;
  71577. }
  71578. /**
  71579. * Represents a group of points in a points cloud system
  71580. * * PCS internal tool, don't use it manually.
  71581. */
  71582. export class PointsGroup {
  71583. /**
  71584. * The group id
  71585. * @hidden
  71586. */
  71587. groupID: number;
  71588. /**
  71589. * image data for group (internal use)
  71590. * @hidden
  71591. */
  71592. _groupImageData: Nullable<ArrayBufferView>;
  71593. /**
  71594. * Image Width (internal use)
  71595. * @hidden
  71596. */
  71597. _groupImgWidth: number;
  71598. /**
  71599. * Image Height (internal use)
  71600. * @hidden
  71601. */
  71602. _groupImgHeight: number;
  71603. /**
  71604. * Custom position function (internal use)
  71605. * @hidden
  71606. */
  71607. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  71608. /**
  71609. * density per facet for surface points
  71610. * @hidden
  71611. */
  71612. _groupDensity: number[];
  71613. /**
  71614. * Only when points are colored by texture carries pointer to texture list array
  71615. * @hidden
  71616. */
  71617. _textureNb: number;
  71618. /**
  71619. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  71620. * PCS internal tool, don't use it manually.
  71621. * @hidden
  71622. */
  71623. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  71624. }
  71625. }
  71626. declare module "babylonjs/Particles/index" {
  71627. export * from "babylonjs/Particles/baseParticleSystem";
  71628. export * from "babylonjs/Particles/EmitterTypes/index";
  71629. export * from "babylonjs/Particles/gpuParticleSystem";
  71630. export * from "babylonjs/Particles/IParticleSystem";
  71631. export * from "babylonjs/Particles/particle";
  71632. export * from "babylonjs/Particles/particleHelper";
  71633. export * from "babylonjs/Particles/particleSystem";
  71634. import "babylonjs/Particles/particleSystemComponent";
  71635. export * from "babylonjs/Particles/particleSystemComponent";
  71636. export * from "babylonjs/Particles/particleSystemSet";
  71637. export * from "babylonjs/Particles/solidParticle";
  71638. export * from "babylonjs/Particles/solidParticleSystem";
  71639. export * from "babylonjs/Particles/cloudPoint";
  71640. export * from "babylonjs/Particles/pointsCloudSystem";
  71641. export * from "babylonjs/Particles/subEmitter";
  71642. }
  71643. declare module "babylonjs/Physics/physicsEngineComponent" {
  71644. import { Nullable } from "babylonjs/types";
  71645. import { Observable, Observer } from "babylonjs/Misc/observable";
  71646. import { Vector3 } from "babylonjs/Maths/math.vector";
  71647. import { Mesh } from "babylonjs/Meshes/mesh";
  71648. import { ISceneComponent } from "babylonjs/sceneComponent";
  71649. import { Scene } from "babylonjs/scene";
  71650. import { Node } from "babylonjs/node";
  71651. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71652. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71653. module "babylonjs/scene" {
  71654. interface Scene {
  71655. /** @hidden (Backing field) */
  71656. _physicsEngine: Nullable<IPhysicsEngine>;
  71657. /** @hidden */
  71658. _physicsTimeAccumulator: number;
  71659. /**
  71660. * Gets the current physics engine
  71661. * @returns a IPhysicsEngine or null if none attached
  71662. */
  71663. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71664. /**
  71665. * Enables physics to the current scene
  71666. * @param gravity defines the scene's gravity for the physics engine
  71667. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71668. * @return a boolean indicating if the physics engine was initialized
  71669. */
  71670. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71671. /**
  71672. * Disables and disposes the physics engine associated with the scene
  71673. */
  71674. disablePhysicsEngine(): void;
  71675. /**
  71676. * Gets a boolean indicating if there is an active physics engine
  71677. * @returns a boolean indicating if there is an active physics engine
  71678. */
  71679. isPhysicsEnabled(): boolean;
  71680. /**
  71681. * Deletes a physics compound impostor
  71682. * @param compound defines the compound to delete
  71683. */
  71684. deleteCompoundImpostor(compound: any): void;
  71685. /**
  71686. * An event triggered when physic simulation is about to be run
  71687. */
  71688. onBeforePhysicsObservable: Observable<Scene>;
  71689. /**
  71690. * An event triggered when physic simulation has been done
  71691. */
  71692. onAfterPhysicsObservable: Observable<Scene>;
  71693. }
  71694. }
  71695. module "babylonjs/Meshes/abstractMesh" {
  71696. interface AbstractMesh {
  71697. /** @hidden */
  71698. _physicsImpostor: Nullable<PhysicsImpostor>;
  71699. /**
  71700. * Gets or sets impostor used for physic simulation
  71701. * @see https://doc.babylonjs.com/features/physics_engine
  71702. */
  71703. physicsImpostor: Nullable<PhysicsImpostor>;
  71704. /**
  71705. * Gets the current physics impostor
  71706. * @see https://doc.babylonjs.com/features/physics_engine
  71707. * @returns a physics impostor or null
  71708. */
  71709. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71710. /** Apply a physic impulse to the mesh
  71711. * @param force defines the force to apply
  71712. * @param contactPoint defines where to apply the force
  71713. * @returns the current mesh
  71714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71715. */
  71716. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71717. /**
  71718. * Creates a physic joint between two meshes
  71719. * @param otherMesh defines the other mesh to use
  71720. * @param pivot1 defines the pivot to use on this mesh
  71721. * @param pivot2 defines the pivot to use on the other mesh
  71722. * @param options defines additional options (can be plugin dependent)
  71723. * @returns the current mesh
  71724. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71725. */
  71726. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71727. /** @hidden */
  71728. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71729. }
  71730. }
  71731. /**
  71732. * Defines the physics engine scene component responsible to manage a physics engine
  71733. */
  71734. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71735. /**
  71736. * The component name helpful to identify the component in the list of scene components.
  71737. */
  71738. readonly name: string;
  71739. /**
  71740. * The scene the component belongs to.
  71741. */
  71742. scene: Scene;
  71743. /**
  71744. * Creates a new instance of the component for the given scene
  71745. * @param scene Defines the scene to register the component in
  71746. */
  71747. constructor(scene: Scene);
  71748. /**
  71749. * Registers the component in a given scene
  71750. */
  71751. register(): void;
  71752. /**
  71753. * Rebuilds the elements related to this component in case of
  71754. * context lost for instance.
  71755. */
  71756. rebuild(): void;
  71757. /**
  71758. * Disposes the component and the associated ressources
  71759. */
  71760. dispose(): void;
  71761. }
  71762. }
  71763. declare module "babylonjs/Physics/physicsHelper" {
  71764. import { Nullable } from "babylonjs/types";
  71765. import { Vector3 } from "babylonjs/Maths/math.vector";
  71766. import { Mesh } from "babylonjs/Meshes/mesh";
  71767. import { Scene } from "babylonjs/scene";
  71768. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71769. /**
  71770. * A helper for physics simulations
  71771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71772. */
  71773. export class PhysicsHelper {
  71774. private _scene;
  71775. private _physicsEngine;
  71776. /**
  71777. * Initializes the Physics helper
  71778. * @param scene Babylon.js scene
  71779. */
  71780. constructor(scene: Scene);
  71781. /**
  71782. * Applies a radial explosion impulse
  71783. * @param origin the origin of the explosion
  71784. * @param radiusOrEventOptions the radius or the options of radial explosion
  71785. * @param strength the explosion strength
  71786. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71787. * @returns A physics radial explosion event, or null
  71788. */
  71789. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71790. /**
  71791. * Applies a radial explosion force
  71792. * @param origin the origin of the explosion
  71793. * @param radiusOrEventOptions the radius or the options of radial explosion
  71794. * @param strength the explosion strength
  71795. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71796. * @returns A physics radial explosion event, or null
  71797. */
  71798. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71799. /**
  71800. * Creates a gravitational field
  71801. * @param origin the origin of the explosion
  71802. * @param radiusOrEventOptions the radius or the options of radial explosion
  71803. * @param strength the explosion strength
  71804. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71805. * @returns A physics gravitational field event, or null
  71806. */
  71807. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71808. /**
  71809. * Creates a physics updraft event
  71810. * @param origin the origin of the updraft
  71811. * @param radiusOrEventOptions the radius or the options of the updraft
  71812. * @param strength the strength of the updraft
  71813. * @param height the height of the updraft
  71814. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71815. * @returns A physics updraft event, or null
  71816. */
  71817. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71818. /**
  71819. * Creates a physics vortex event
  71820. * @param origin the of the vortex
  71821. * @param radiusOrEventOptions the radius or the options of the vortex
  71822. * @param strength the strength of the vortex
  71823. * @param height the height of the vortex
  71824. * @returns a Physics vortex event, or null
  71825. * A physics vortex event or null
  71826. */
  71827. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71828. }
  71829. /**
  71830. * Represents a physics radial explosion event
  71831. */
  71832. class PhysicsRadialExplosionEvent {
  71833. private _scene;
  71834. private _options;
  71835. private _sphere;
  71836. private _dataFetched;
  71837. /**
  71838. * Initializes a radial explosioin event
  71839. * @param _scene BabylonJS scene
  71840. * @param _options The options for the vortex event
  71841. */
  71842. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71843. /**
  71844. * Returns the data related to the radial explosion event (sphere).
  71845. * @returns The radial explosion event data
  71846. */
  71847. getData(): PhysicsRadialExplosionEventData;
  71848. /**
  71849. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71850. * @param impostor A physics imposter
  71851. * @param origin the origin of the explosion
  71852. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71853. */
  71854. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71855. /**
  71856. * Triggers affecterd impostors callbacks
  71857. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71858. */
  71859. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71860. /**
  71861. * Disposes the sphere.
  71862. * @param force Specifies if the sphere should be disposed by force
  71863. */
  71864. dispose(force?: boolean): void;
  71865. /*** Helpers ***/
  71866. private _prepareSphere;
  71867. private _intersectsWithSphere;
  71868. }
  71869. /**
  71870. * Represents a gravitational field event
  71871. */
  71872. class PhysicsGravitationalFieldEvent {
  71873. private _physicsHelper;
  71874. private _scene;
  71875. private _origin;
  71876. private _options;
  71877. private _tickCallback;
  71878. private _sphere;
  71879. private _dataFetched;
  71880. /**
  71881. * Initializes the physics gravitational field event
  71882. * @param _physicsHelper A physics helper
  71883. * @param _scene BabylonJS scene
  71884. * @param _origin The origin position of the gravitational field event
  71885. * @param _options The options for the vortex event
  71886. */
  71887. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71888. /**
  71889. * Returns the data related to the gravitational field event (sphere).
  71890. * @returns A gravitational field event
  71891. */
  71892. getData(): PhysicsGravitationalFieldEventData;
  71893. /**
  71894. * Enables the gravitational field.
  71895. */
  71896. enable(): void;
  71897. /**
  71898. * Disables the gravitational field.
  71899. */
  71900. disable(): void;
  71901. /**
  71902. * Disposes the sphere.
  71903. * @param force The force to dispose from the gravitational field event
  71904. */
  71905. dispose(force?: boolean): void;
  71906. private _tick;
  71907. }
  71908. /**
  71909. * Represents a physics updraft event
  71910. */
  71911. class PhysicsUpdraftEvent {
  71912. private _scene;
  71913. private _origin;
  71914. private _options;
  71915. private _physicsEngine;
  71916. private _originTop;
  71917. private _originDirection;
  71918. private _tickCallback;
  71919. private _cylinder;
  71920. private _cylinderPosition;
  71921. private _dataFetched;
  71922. /**
  71923. * Initializes the physics updraft event
  71924. * @param _scene BabylonJS scene
  71925. * @param _origin The origin position of the updraft
  71926. * @param _options The options for the updraft event
  71927. */
  71928. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71929. /**
  71930. * Returns the data related to the updraft event (cylinder).
  71931. * @returns A physics updraft event
  71932. */
  71933. getData(): PhysicsUpdraftEventData;
  71934. /**
  71935. * Enables the updraft.
  71936. */
  71937. enable(): void;
  71938. /**
  71939. * Disables the updraft.
  71940. */
  71941. disable(): void;
  71942. /**
  71943. * Disposes the cylinder.
  71944. * @param force Specifies if the updraft should be disposed by force
  71945. */
  71946. dispose(force?: boolean): void;
  71947. private getImpostorHitData;
  71948. private _tick;
  71949. /*** Helpers ***/
  71950. private _prepareCylinder;
  71951. private _intersectsWithCylinder;
  71952. }
  71953. /**
  71954. * Represents a physics vortex event
  71955. */
  71956. class PhysicsVortexEvent {
  71957. private _scene;
  71958. private _origin;
  71959. private _options;
  71960. private _physicsEngine;
  71961. private _originTop;
  71962. private _tickCallback;
  71963. private _cylinder;
  71964. private _cylinderPosition;
  71965. private _dataFetched;
  71966. /**
  71967. * Initializes the physics vortex event
  71968. * @param _scene The BabylonJS scene
  71969. * @param _origin The origin position of the vortex
  71970. * @param _options The options for the vortex event
  71971. */
  71972. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71973. /**
  71974. * Returns the data related to the vortex event (cylinder).
  71975. * @returns The physics vortex event data
  71976. */
  71977. getData(): PhysicsVortexEventData;
  71978. /**
  71979. * Enables the vortex.
  71980. */
  71981. enable(): void;
  71982. /**
  71983. * Disables the cortex.
  71984. */
  71985. disable(): void;
  71986. /**
  71987. * Disposes the sphere.
  71988. * @param force
  71989. */
  71990. dispose(force?: boolean): void;
  71991. private getImpostorHitData;
  71992. private _tick;
  71993. /*** Helpers ***/
  71994. private _prepareCylinder;
  71995. private _intersectsWithCylinder;
  71996. }
  71997. /**
  71998. * Options fot the radial explosion event
  71999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72000. */
  72001. export class PhysicsRadialExplosionEventOptions {
  72002. /**
  72003. * The radius of the sphere for the radial explosion.
  72004. */
  72005. radius: number;
  72006. /**
  72007. * The strenth of the explosion.
  72008. */
  72009. strength: number;
  72010. /**
  72011. * The strenght of the force in correspondence to the distance of the affected object
  72012. */
  72013. falloff: PhysicsRadialImpulseFalloff;
  72014. /**
  72015. * Sphere options for the radial explosion.
  72016. */
  72017. sphere: {
  72018. segments: number;
  72019. diameter: number;
  72020. };
  72021. /**
  72022. * Sphere options for the radial explosion.
  72023. */
  72024. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72025. }
  72026. /**
  72027. * Options fot the updraft event
  72028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72029. */
  72030. export class PhysicsUpdraftEventOptions {
  72031. /**
  72032. * The radius of the cylinder for the vortex
  72033. */
  72034. radius: number;
  72035. /**
  72036. * The strenth of the updraft.
  72037. */
  72038. strength: number;
  72039. /**
  72040. * The height of the cylinder for the updraft.
  72041. */
  72042. height: number;
  72043. /**
  72044. * The mode for the the updraft.
  72045. */
  72046. updraftMode: PhysicsUpdraftMode;
  72047. }
  72048. /**
  72049. * Options fot the vortex event
  72050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72051. */
  72052. export class PhysicsVortexEventOptions {
  72053. /**
  72054. * The radius of the cylinder for the vortex
  72055. */
  72056. radius: number;
  72057. /**
  72058. * The strenth of the vortex.
  72059. */
  72060. strength: number;
  72061. /**
  72062. * The height of the cylinder for the vortex.
  72063. */
  72064. height: number;
  72065. /**
  72066. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72067. */
  72068. centripetalForceThreshold: number;
  72069. /**
  72070. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72071. */
  72072. centripetalForceMultiplier: number;
  72073. /**
  72074. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72075. */
  72076. centrifugalForceMultiplier: number;
  72077. /**
  72078. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72079. */
  72080. updraftForceMultiplier: number;
  72081. }
  72082. /**
  72083. * The strenght of the force in correspondence to the distance of the affected object
  72084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72085. */
  72086. export enum PhysicsRadialImpulseFalloff {
  72087. /** Defines that impulse is constant in strength across it's whole radius */
  72088. Constant = 0,
  72089. /** Defines that impulse gets weaker if it's further from the origin */
  72090. Linear = 1
  72091. }
  72092. /**
  72093. * The strength of the force in correspondence to the distance of the affected object
  72094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72095. */
  72096. export enum PhysicsUpdraftMode {
  72097. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72098. Center = 0,
  72099. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72100. Perpendicular = 1
  72101. }
  72102. /**
  72103. * Interface for a physics hit data
  72104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72105. */
  72106. export interface PhysicsHitData {
  72107. /**
  72108. * The force applied at the contact point
  72109. */
  72110. force: Vector3;
  72111. /**
  72112. * The contact point
  72113. */
  72114. contactPoint: Vector3;
  72115. /**
  72116. * The distance from the origin to the contact point
  72117. */
  72118. distanceFromOrigin: number;
  72119. }
  72120. /**
  72121. * Interface for radial explosion event data
  72122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72123. */
  72124. export interface PhysicsRadialExplosionEventData {
  72125. /**
  72126. * A sphere used for the radial explosion event
  72127. */
  72128. sphere: Mesh;
  72129. }
  72130. /**
  72131. * Interface for gravitational field event data
  72132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72133. */
  72134. export interface PhysicsGravitationalFieldEventData {
  72135. /**
  72136. * A sphere mesh used for the gravitational field event
  72137. */
  72138. sphere: Mesh;
  72139. }
  72140. /**
  72141. * Interface for updraft event data
  72142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72143. */
  72144. export interface PhysicsUpdraftEventData {
  72145. /**
  72146. * A cylinder used for the updraft event
  72147. */
  72148. cylinder: Mesh;
  72149. }
  72150. /**
  72151. * Interface for vortex event data
  72152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72153. */
  72154. export interface PhysicsVortexEventData {
  72155. /**
  72156. * A cylinder used for the vortex event
  72157. */
  72158. cylinder: Mesh;
  72159. }
  72160. /**
  72161. * Interface for an affected physics impostor
  72162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72163. */
  72164. export interface PhysicsAffectedImpostorWithData {
  72165. /**
  72166. * The impostor affected by the effect
  72167. */
  72168. impostor: PhysicsImpostor;
  72169. /**
  72170. * The data about the hit/horce from the explosion
  72171. */
  72172. hitData: PhysicsHitData;
  72173. }
  72174. }
  72175. declare module "babylonjs/Physics/Plugins/index" {
  72176. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72177. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72178. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72179. }
  72180. declare module "babylonjs/Physics/index" {
  72181. export * from "babylonjs/Physics/IPhysicsEngine";
  72182. export * from "babylonjs/Physics/physicsEngine";
  72183. export * from "babylonjs/Physics/physicsEngineComponent";
  72184. export * from "babylonjs/Physics/physicsHelper";
  72185. export * from "babylonjs/Physics/physicsImpostor";
  72186. export * from "babylonjs/Physics/physicsJoint";
  72187. export * from "babylonjs/Physics/Plugins/index";
  72188. }
  72189. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72190. /** @hidden */
  72191. export var blackAndWhitePixelShader: {
  72192. name: string;
  72193. shader: string;
  72194. };
  72195. }
  72196. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72197. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72198. import { Camera } from "babylonjs/Cameras/camera";
  72199. import { Engine } from "babylonjs/Engines/engine";
  72200. import "babylonjs/Shaders/blackAndWhite.fragment";
  72201. /**
  72202. * Post process used to render in black and white
  72203. */
  72204. export class BlackAndWhitePostProcess extends PostProcess {
  72205. /**
  72206. * Linear about to convert he result to black and white (default: 1)
  72207. */
  72208. degree: number;
  72209. /**
  72210. * Creates a black and white post process
  72211. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72212. * @param name The name of the effect.
  72213. * @param options The required width/height ratio to downsize to before computing the render pass.
  72214. * @param camera The camera to apply the render pass to.
  72215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72216. * @param engine The engine which the post process will be applied. (default: current engine)
  72217. * @param reusable If the post process can be reused on the same frame. (default: false)
  72218. */
  72219. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72220. }
  72221. }
  72222. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72223. import { Nullable } from "babylonjs/types";
  72224. import { Camera } from "babylonjs/Cameras/camera";
  72225. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72226. import { Engine } from "babylonjs/Engines/engine";
  72227. /**
  72228. * This represents a set of one or more post processes in Babylon.
  72229. * A post process can be used to apply a shader to a texture after it is rendered.
  72230. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72231. */
  72232. export class PostProcessRenderEffect {
  72233. private _postProcesses;
  72234. private _getPostProcesses;
  72235. private _singleInstance;
  72236. private _cameras;
  72237. private _indicesForCamera;
  72238. /**
  72239. * Name of the effect
  72240. * @hidden
  72241. */
  72242. _name: string;
  72243. /**
  72244. * Instantiates a post process render effect.
  72245. * A post process can be used to apply a shader to a texture after it is rendered.
  72246. * @param engine The engine the effect is tied to
  72247. * @param name The name of the effect
  72248. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72249. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72250. */
  72251. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72252. /**
  72253. * Checks if all the post processes in the effect are supported.
  72254. */
  72255. get isSupported(): boolean;
  72256. /**
  72257. * Updates the current state of the effect
  72258. * @hidden
  72259. */
  72260. _update(): void;
  72261. /**
  72262. * Attaches the effect on cameras
  72263. * @param cameras The camera to attach to.
  72264. * @hidden
  72265. */
  72266. _attachCameras(cameras: Camera): void;
  72267. /**
  72268. * Attaches the effect on cameras
  72269. * @param cameras The camera to attach to.
  72270. * @hidden
  72271. */
  72272. _attachCameras(cameras: Camera[]): void;
  72273. /**
  72274. * Detaches the effect on cameras
  72275. * @param cameras The camera to detatch from.
  72276. * @hidden
  72277. */
  72278. _detachCameras(cameras: Camera): void;
  72279. /**
  72280. * Detatches the effect on cameras
  72281. * @param cameras The camera to detatch from.
  72282. * @hidden
  72283. */
  72284. _detachCameras(cameras: Camera[]): void;
  72285. /**
  72286. * Enables the effect on given cameras
  72287. * @param cameras The camera to enable.
  72288. * @hidden
  72289. */
  72290. _enable(cameras: Camera): void;
  72291. /**
  72292. * Enables the effect on given cameras
  72293. * @param cameras The camera to enable.
  72294. * @hidden
  72295. */
  72296. _enable(cameras: Nullable<Camera[]>): void;
  72297. /**
  72298. * Disables the effect on the given cameras
  72299. * @param cameras The camera to disable.
  72300. * @hidden
  72301. */
  72302. _disable(cameras: Camera): void;
  72303. /**
  72304. * Disables the effect on the given cameras
  72305. * @param cameras The camera to disable.
  72306. * @hidden
  72307. */
  72308. _disable(cameras: Nullable<Camera[]>): void;
  72309. /**
  72310. * Gets a list of the post processes contained in the effect.
  72311. * @param camera The camera to get the post processes on.
  72312. * @returns The list of the post processes in the effect.
  72313. */
  72314. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72315. }
  72316. }
  72317. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72318. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72319. /** @hidden */
  72320. export var extractHighlightsPixelShader: {
  72321. name: string;
  72322. shader: string;
  72323. };
  72324. }
  72325. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72326. import { Nullable } from "babylonjs/types";
  72327. import { Camera } from "babylonjs/Cameras/camera";
  72328. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72329. import { Engine } from "babylonjs/Engines/engine";
  72330. import "babylonjs/Shaders/extractHighlights.fragment";
  72331. /**
  72332. * 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.
  72333. */
  72334. export class ExtractHighlightsPostProcess extends PostProcess {
  72335. /**
  72336. * The luminance threshold, pixels below this value will be set to black.
  72337. */
  72338. threshold: number;
  72339. /** @hidden */
  72340. _exposure: number;
  72341. /**
  72342. * Post process which has the input texture to be used when performing highlight extraction
  72343. * @hidden
  72344. */
  72345. _inputPostProcess: Nullable<PostProcess>;
  72346. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72347. }
  72348. }
  72349. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72350. /** @hidden */
  72351. export var bloomMergePixelShader: {
  72352. name: string;
  72353. shader: string;
  72354. };
  72355. }
  72356. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72357. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72358. import { Nullable } from "babylonjs/types";
  72359. import { Engine } from "babylonjs/Engines/engine";
  72360. import { Camera } from "babylonjs/Cameras/camera";
  72361. import "babylonjs/Shaders/bloomMerge.fragment";
  72362. /**
  72363. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72364. */
  72365. export class BloomMergePostProcess extends PostProcess {
  72366. /** Weight of the bloom to be added to the original input. */
  72367. weight: number;
  72368. /**
  72369. * Creates a new instance of @see BloomMergePostProcess
  72370. * @param name The name of the effect.
  72371. * @param originalFromInput Post process which's input will be used for the merge.
  72372. * @param blurred Blurred highlights post process which's output will be used.
  72373. * @param weight Weight of the bloom to be added to the original input.
  72374. * @param options The required width/height ratio to downsize to before computing the render pass.
  72375. * @param camera The camera to apply the render pass to.
  72376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72377. * @param engine The engine which the post process will be applied. (default: current engine)
  72378. * @param reusable If the post process can be reused on the same frame. (default: false)
  72379. * @param textureType Type of textures used when performing the post process. (default: 0)
  72380. * @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)
  72381. */
  72382. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72383. /** Weight of the bloom to be added to the original input. */
  72384. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72385. }
  72386. }
  72387. declare module "babylonjs/PostProcesses/bloomEffect" {
  72388. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72389. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72390. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72391. import { Camera } from "babylonjs/Cameras/camera";
  72392. import { Scene } from "babylonjs/scene";
  72393. /**
  72394. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72395. */
  72396. export class BloomEffect extends PostProcessRenderEffect {
  72397. private bloomScale;
  72398. /**
  72399. * @hidden Internal
  72400. */
  72401. _effects: Array<PostProcess>;
  72402. /**
  72403. * @hidden Internal
  72404. */
  72405. _downscale: ExtractHighlightsPostProcess;
  72406. private _blurX;
  72407. private _blurY;
  72408. private _merge;
  72409. /**
  72410. * The luminance threshold to find bright areas of the image to bloom.
  72411. */
  72412. get threshold(): number;
  72413. set threshold(value: number);
  72414. /**
  72415. * The strength of the bloom.
  72416. */
  72417. get weight(): number;
  72418. set weight(value: number);
  72419. /**
  72420. * Specifies the size of the bloom blur kernel, relative to the final output size
  72421. */
  72422. get kernel(): number;
  72423. set kernel(value: number);
  72424. /**
  72425. * Creates a new instance of @see BloomEffect
  72426. * @param scene The scene the effect belongs to.
  72427. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72428. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72429. * @param bloomWeight The the strength of bloom.
  72430. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72431. * @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)
  72432. */
  72433. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72434. /**
  72435. * Disposes each of the internal effects for a given camera.
  72436. * @param camera The camera to dispose the effect on.
  72437. */
  72438. disposeEffects(camera: Camera): void;
  72439. /**
  72440. * @hidden Internal
  72441. */
  72442. _updateEffects(): void;
  72443. /**
  72444. * Internal
  72445. * @returns if all the contained post processes are ready.
  72446. * @hidden
  72447. */
  72448. _isReady(): boolean;
  72449. }
  72450. }
  72451. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72452. /** @hidden */
  72453. export var chromaticAberrationPixelShader: {
  72454. name: string;
  72455. shader: string;
  72456. };
  72457. }
  72458. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72459. import { Vector2 } from "babylonjs/Maths/math.vector";
  72460. import { Nullable } from "babylonjs/types";
  72461. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72462. import { Camera } from "babylonjs/Cameras/camera";
  72463. import { Engine } from "babylonjs/Engines/engine";
  72464. import "babylonjs/Shaders/chromaticAberration.fragment";
  72465. /**
  72466. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72467. */
  72468. export class ChromaticAberrationPostProcess extends PostProcess {
  72469. /**
  72470. * The amount of seperation of rgb channels (default: 30)
  72471. */
  72472. aberrationAmount: number;
  72473. /**
  72474. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72475. */
  72476. radialIntensity: number;
  72477. /**
  72478. * 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))
  72479. */
  72480. direction: Vector2;
  72481. /**
  72482. * 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))
  72483. */
  72484. centerPosition: Vector2;
  72485. /**
  72486. * Creates a new instance ChromaticAberrationPostProcess
  72487. * @param name The name of the effect.
  72488. * @param screenWidth The width of the screen to apply the effect on.
  72489. * @param screenHeight The height of the screen to apply the effect on.
  72490. * @param options The required width/height ratio to downsize to before computing the render pass.
  72491. * @param camera The camera to apply the render pass to.
  72492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72493. * @param engine The engine which the post process will be applied. (default: current engine)
  72494. * @param reusable If the post process can be reused on the same frame. (default: false)
  72495. * @param textureType Type of textures used when performing the post process. (default: 0)
  72496. * @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)
  72497. */
  72498. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72499. }
  72500. }
  72501. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72502. /** @hidden */
  72503. export var circleOfConfusionPixelShader: {
  72504. name: string;
  72505. shader: string;
  72506. };
  72507. }
  72508. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72509. import { Nullable } from "babylonjs/types";
  72510. import { Engine } from "babylonjs/Engines/engine";
  72511. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72512. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72513. import { Camera } from "babylonjs/Cameras/camera";
  72514. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72515. /**
  72516. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72517. */
  72518. export class CircleOfConfusionPostProcess extends PostProcess {
  72519. /**
  72520. * 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.
  72521. */
  72522. lensSize: number;
  72523. /**
  72524. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72525. */
  72526. fStop: number;
  72527. /**
  72528. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72529. */
  72530. focusDistance: number;
  72531. /**
  72532. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72533. */
  72534. focalLength: number;
  72535. private _depthTexture;
  72536. /**
  72537. * Creates a new instance CircleOfConfusionPostProcess
  72538. * @param name The name of the effect.
  72539. * @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.
  72540. * @param options The required width/height ratio to downsize to before computing the render pass.
  72541. * @param camera The camera to apply the render pass to.
  72542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72543. * @param engine The engine which the post process will be applied. (default: current engine)
  72544. * @param reusable If the post process can be reused on the same frame. (default: false)
  72545. * @param textureType Type of textures used when performing the post process. (default: 0)
  72546. * @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)
  72547. */
  72548. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72549. /**
  72550. * 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.
  72551. */
  72552. set depthTexture(value: RenderTargetTexture);
  72553. }
  72554. }
  72555. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  72556. /** @hidden */
  72557. export var colorCorrectionPixelShader: {
  72558. name: string;
  72559. shader: string;
  72560. };
  72561. }
  72562. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  72563. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72564. import { Engine } from "babylonjs/Engines/engine";
  72565. import { Camera } from "babylonjs/Cameras/camera";
  72566. import "babylonjs/Shaders/colorCorrection.fragment";
  72567. /**
  72568. *
  72569. * This post-process allows the modification of rendered colors by using
  72570. * a 'look-up table' (LUT). This effect is also called Color Grading.
  72571. *
  72572. * The object needs to be provided an url to a texture containing the color
  72573. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  72574. * Use an image editing software to tweak the LUT to match your needs.
  72575. *
  72576. * For an example of a color LUT, see here:
  72577. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  72578. * For explanations on color grading, see here:
  72579. * @see http://udn.epicgames.com/Three/ColorGrading.html
  72580. *
  72581. */
  72582. export class ColorCorrectionPostProcess extends PostProcess {
  72583. private _colorTableTexture;
  72584. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72585. }
  72586. }
  72587. declare module "babylonjs/Shaders/convolution.fragment" {
  72588. /** @hidden */
  72589. export var convolutionPixelShader: {
  72590. name: string;
  72591. shader: string;
  72592. };
  72593. }
  72594. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  72595. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72596. import { Nullable } from "babylonjs/types";
  72597. import { Camera } from "babylonjs/Cameras/camera";
  72598. import { Engine } from "babylonjs/Engines/engine";
  72599. import "babylonjs/Shaders/convolution.fragment";
  72600. /**
  72601. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  72602. * input texture to perform effects such as edge detection or sharpening
  72603. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72604. */
  72605. export class ConvolutionPostProcess extends PostProcess {
  72606. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72607. kernel: number[];
  72608. /**
  72609. * Creates a new instance ConvolutionPostProcess
  72610. * @param name The name of the effect.
  72611. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  72612. * @param options The required width/height ratio to downsize to before computing the render pass.
  72613. * @param camera The camera to apply the render pass to.
  72614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72615. * @param engine The engine which the post process will be applied. (default: current engine)
  72616. * @param reusable If the post process can be reused on the same frame. (default: false)
  72617. * @param textureType Type of textures used when performing the post process. (default: 0)
  72618. */
  72619. constructor(name: string,
  72620. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  72621. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72622. /**
  72623. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72624. */
  72625. static EdgeDetect0Kernel: number[];
  72626. /**
  72627. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72628. */
  72629. static EdgeDetect1Kernel: number[];
  72630. /**
  72631. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72632. */
  72633. static EdgeDetect2Kernel: number[];
  72634. /**
  72635. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72636. */
  72637. static SharpenKernel: number[];
  72638. /**
  72639. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72640. */
  72641. static EmbossKernel: number[];
  72642. /**
  72643. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  72644. */
  72645. static GaussianKernel: number[];
  72646. }
  72647. }
  72648. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72649. import { Nullable } from "babylonjs/types";
  72650. import { Vector2 } from "babylonjs/Maths/math.vector";
  72651. import { Camera } from "babylonjs/Cameras/camera";
  72652. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72653. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72654. import { Engine } from "babylonjs/Engines/engine";
  72655. import { Scene } from "babylonjs/scene";
  72656. /**
  72657. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72658. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72659. * based on samples that have a large difference in distance than the center pixel.
  72660. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72661. */
  72662. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72663. direction: Vector2;
  72664. /**
  72665. * Creates a new instance CircleOfConfusionPostProcess
  72666. * @param name The name of the effect.
  72667. * @param scene The scene the effect belongs to.
  72668. * @param direction The direction the blur should be applied.
  72669. * @param kernel The size of the kernel used to blur.
  72670. * @param options The required width/height ratio to downsize to before computing the render pass.
  72671. * @param camera The camera to apply the render pass to.
  72672. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72673. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72675. * @param engine The engine which the post process will be applied. (default: current engine)
  72676. * @param reusable If the post process can be reused on the same frame. (default: false)
  72677. * @param textureType Type of textures used when performing the post process. (default: 0)
  72678. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  72679. */
  72680. constructor(name: string, 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);
  72681. }
  72682. }
  72683. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72684. /** @hidden */
  72685. export var depthOfFieldMergePixelShader: {
  72686. name: string;
  72687. shader: string;
  72688. };
  72689. }
  72690. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72691. import { Nullable } from "babylonjs/types";
  72692. import { Camera } from "babylonjs/Cameras/camera";
  72693. import { Effect } from "babylonjs/Materials/effect";
  72694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72695. import { Engine } from "babylonjs/Engines/engine";
  72696. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72697. /**
  72698. * Options to be set when merging outputs from the default pipeline.
  72699. */
  72700. export class DepthOfFieldMergePostProcessOptions {
  72701. /**
  72702. * The original image to merge on top of
  72703. */
  72704. originalFromInput: PostProcess;
  72705. /**
  72706. * Parameters to perform the merge of the depth of field effect
  72707. */
  72708. depthOfField?: {
  72709. circleOfConfusion: PostProcess;
  72710. blurSteps: Array<PostProcess>;
  72711. };
  72712. /**
  72713. * Parameters to perform the merge of bloom effect
  72714. */
  72715. bloom?: {
  72716. blurred: PostProcess;
  72717. weight: number;
  72718. };
  72719. }
  72720. /**
  72721. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72722. */
  72723. export class DepthOfFieldMergePostProcess extends PostProcess {
  72724. private blurSteps;
  72725. /**
  72726. * Creates a new instance of DepthOfFieldMergePostProcess
  72727. * @param name The name of the effect.
  72728. * @param originalFromInput Post process which's input will be used for the merge.
  72729. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72730. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72731. * @param options The required width/height ratio to downsize to before computing the render pass.
  72732. * @param camera The camera to apply the render pass to.
  72733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72734. * @param engine The engine which the post process will be applied. (default: current engine)
  72735. * @param reusable If the post process can be reused on the same frame. (default: false)
  72736. * @param textureType Type of textures used when performing the post process. (default: 0)
  72737. * @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)
  72738. */
  72739. 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);
  72740. /**
  72741. * Updates the effect with the current post process compile time values and recompiles the shader.
  72742. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72743. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72744. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72745. * @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
  72746. * @param onCompiled Called when the shader has been compiled.
  72747. * @param onError Called if there is an error when compiling a shader.
  72748. */
  72749. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72750. }
  72751. }
  72752. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72753. import { Nullable } from "babylonjs/types";
  72754. import { Camera } from "babylonjs/Cameras/camera";
  72755. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72756. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72757. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72758. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72759. import { Scene } from "babylonjs/scene";
  72760. /**
  72761. * Specifies the level of max blur that should be applied when using the depth of field effect
  72762. */
  72763. export enum DepthOfFieldEffectBlurLevel {
  72764. /**
  72765. * Subtle blur
  72766. */
  72767. Low = 0,
  72768. /**
  72769. * Medium blur
  72770. */
  72771. Medium = 1,
  72772. /**
  72773. * Large blur
  72774. */
  72775. High = 2
  72776. }
  72777. /**
  72778. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72779. */
  72780. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72781. private _circleOfConfusion;
  72782. /**
  72783. * @hidden Internal, blurs from high to low
  72784. */
  72785. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72786. private _depthOfFieldBlurY;
  72787. private _dofMerge;
  72788. /**
  72789. * @hidden Internal post processes in depth of field effect
  72790. */
  72791. _effects: Array<PostProcess>;
  72792. /**
  72793. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72794. */
  72795. set focalLength(value: number);
  72796. get focalLength(): number;
  72797. /**
  72798. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72799. */
  72800. set fStop(value: number);
  72801. get fStop(): number;
  72802. /**
  72803. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72804. */
  72805. set focusDistance(value: number);
  72806. get focusDistance(): number;
  72807. /**
  72808. * 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.
  72809. */
  72810. set lensSize(value: number);
  72811. get lensSize(): number;
  72812. /**
  72813. * Creates a new instance DepthOfFieldEffect
  72814. * @param scene The scene the effect belongs to.
  72815. * @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.
  72816. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72817. * @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)
  72818. */
  72819. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72820. /**
  72821. * Get the current class name of the current effet
  72822. * @returns "DepthOfFieldEffect"
  72823. */
  72824. getClassName(): string;
  72825. /**
  72826. * 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.
  72827. */
  72828. set depthTexture(value: RenderTargetTexture);
  72829. /**
  72830. * Disposes each of the internal effects for a given camera.
  72831. * @param camera The camera to dispose the effect on.
  72832. */
  72833. disposeEffects(camera: Camera): void;
  72834. /**
  72835. * @hidden Internal
  72836. */
  72837. _updateEffects(): void;
  72838. /**
  72839. * Internal
  72840. * @returns if all the contained post processes are ready.
  72841. * @hidden
  72842. */
  72843. _isReady(): boolean;
  72844. }
  72845. }
  72846. declare module "babylonjs/Shaders/displayPass.fragment" {
  72847. /** @hidden */
  72848. export var displayPassPixelShader: {
  72849. name: string;
  72850. shader: string;
  72851. };
  72852. }
  72853. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72854. import { Nullable } from "babylonjs/types";
  72855. import { Camera } from "babylonjs/Cameras/camera";
  72856. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72857. import { Engine } from "babylonjs/Engines/engine";
  72858. import "babylonjs/Shaders/displayPass.fragment";
  72859. /**
  72860. * DisplayPassPostProcess which produces an output the same as it's input
  72861. */
  72862. export class DisplayPassPostProcess extends PostProcess {
  72863. /**
  72864. * Creates the DisplayPassPostProcess
  72865. * @param name The name of the effect.
  72866. * @param options The required width/height ratio to downsize to before computing the render pass.
  72867. * @param camera The camera to apply the render pass to.
  72868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72869. * @param engine The engine which the post process will be applied. (default: current engine)
  72870. * @param reusable If the post process can be reused on the same frame. (default: false)
  72871. */
  72872. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72873. }
  72874. }
  72875. declare module "babylonjs/Shaders/filter.fragment" {
  72876. /** @hidden */
  72877. export var filterPixelShader: {
  72878. name: string;
  72879. shader: string;
  72880. };
  72881. }
  72882. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72883. import { Nullable } from "babylonjs/types";
  72884. import { Matrix } from "babylonjs/Maths/math.vector";
  72885. import { Camera } from "babylonjs/Cameras/camera";
  72886. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72887. import { Engine } from "babylonjs/Engines/engine";
  72888. import "babylonjs/Shaders/filter.fragment";
  72889. /**
  72890. * Applies a kernel filter to the image
  72891. */
  72892. export class FilterPostProcess extends PostProcess {
  72893. /** The matrix to be applied to the image */
  72894. kernelMatrix: Matrix;
  72895. /**
  72896. *
  72897. * @param name The name of the effect.
  72898. * @param kernelMatrix The matrix to be applied to the image
  72899. * @param options The required width/height ratio to downsize to before computing the render pass.
  72900. * @param camera The camera to apply the render pass to.
  72901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72902. * @param engine The engine which the post process will be applied. (default: current engine)
  72903. * @param reusable If the post process can be reused on the same frame. (default: false)
  72904. */
  72905. constructor(name: string,
  72906. /** The matrix to be applied to the image */
  72907. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72908. }
  72909. }
  72910. declare module "babylonjs/Shaders/fxaa.fragment" {
  72911. /** @hidden */
  72912. export var fxaaPixelShader: {
  72913. name: string;
  72914. shader: string;
  72915. };
  72916. }
  72917. declare module "babylonjs/Shaders/fxaa.vertex" {
  72918. /** @hidden */
  72919. export var fxaaVertexShader: {
  72920. name: string;
  72921. shader: string;
  72922. };
  72923. }
  72924. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72925. import { Nullable } from "babylonjs/types";
  72926. import { Camera } from "babylonjs/Cameras/camera";
  72927. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72928. import { Engine } from "babylonjs/Engines/engine";
  72929. import "babylonjs/Shaders/fxaa.fragment";
  72930. import "babylonjs/Shaders/fxaa.vertex";
  72931. /**
  72932. * Fxaa post process
  72933. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72934. */
  72935. export class FxaaPostProcess extends PostProcess {
  72936. /** @hidden */
  72937. texelWidth: number;
  72938. /** @hidden */
  72939. texelHeight: number;
  72940. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72941. private _getDefines;
  72942. }
  72943. }
  72944. declare module "babylonjs/Shaders/grain.fragment" {
  72945. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72946. /** @hidden */
  72947. export var grainPixelShader: {
  72948. name: string;
  72949. shader: string;
  72950. };
  72951. }
  72952. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72953. import { Nullable } from "babylonjs/types";
  72954. import { Camera } from "babylonjs/Cameras/camera";
  72955. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72956. import { Engine } from "babylonjs/Engines/engine";
  72957. import "babylonjs/Shaders/grain.fragment";
  72958. /**
  72959. * The GrainPostProcess adds noise to the image at mid luminance levels
  72960. */
  72961. export class GrainPostProcess extends PostProcess {
  72962. /**
  72963. * The intensity of the grain added (default: 30)
  72964. */
  72965. intensity: number;
  72966. /**
  72967. * If the grain should be randomized on every frame
  72968. */
  72969. animated: boolean;
  72970. /**
  72971. * Creates a new instance of @see GrainPostProcess
  72972. * @param name The name of the effect.
  72973. * @param options The required width/height ratio to downsize to before computing the render pass.
  72974. * @param camera The camera to apply the render pass to.
  72975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72976. * @param engine The engine which the post process will be applied. (default: current engine)
  72977. * @param reusable If the post process can be reused on the same frame. (default: false)
  72978. * @param textureType Type of textures used when performing the post process. (default: 0)
  72979. * @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)
  72980. */
  72981. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72982. }
  72983. }
  72984. declare module "babylonjs/Shaders/highlights.fragment" {
  72985. /** @hidden */
  72986. export var highlightsPixelShader: {
  72987. name: string;
  72988. shader: string;
  72989. };
  72990. }
  72991. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72992. import { Nullable } from "babylonjs/types";
  72993. import { Camera } from "babylonjs/Cameras/camera";
  72994. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72995. import { Engine } from "babylonjs/Engines/engine";
  72996. import "babylonjs/Shaders/highlights.fragment";
  72997. /**
  72998. * Extracts highlights from the image
  72999. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73000. */
  73001. export class HighlightsPostProcess extends PostProcess {
  73002. /**
  73003. * Extracts highlights from the image
  73004. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73005. * @param name The name of the effect.
  73006. * @param options The required width/height ratio to downsize to before computing the render pass.
  73007. * @param camera The camera to apply the render pass to.
  73008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73009. * @param engine The engine which the post process will be applied. (default: current engine)
  73010. * @param reusable If the post process can be reused on the same frame. (default: false)
  73011. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73012. */
  73013. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73014. }
  73015. }
  73016. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73017. /** @hidden */
  73018. export var mrtFragmentDeclaration: {
  73019. name: string;
  73020. shader: string;
  73021. };
  73022. }
  73023. declare module "babylonjs/Shaders/geometry.fragment" {
  73024. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73025. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73026. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73027. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73028. /** @hidden */
  73029. export var geometryPixelShader: {
  73030. name: string;
  73031. shader: string;
  73032. };
  73033. }
  73034. declare module "babylonjs/Shaders/geometry.vertex" {
  73035. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73038. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73039. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73040. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73041. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73042. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73043. /** @hidden */
  73044. export var geometryVertexShader: {
  73045. name: string;
  73046. shader: string;
  73047. };
  73048. }
  73049. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73050. import { Matrix } from "babylonjs/Maths/math.vector";
  73051. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73052. import { Mesh } from "babylonjs/Meshes/mesh";
  73053. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73054. import { Effect } from "babylonjs/Materials/effect";
  73055. import { Scene } from "babylonjs/scene";
  73056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73057. import "babylonjs/Shaders/geometry.fragment";
  73058. import "babylonjs/Shaders/geometry.vertex";
  73059. /** @hidden */
  73060. interface ISavedTransformationMatrix {
  73061. world: Matrix;
  73062. viewProjection: Matrix;
  73063. }
  73064. /**
  73065. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73066. */
  73067. export class GeometryBufferRenderer {
  73068. /**
  73069. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73070. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73071. */
  73072. static readonly POSITION_TEXTURE_TYPE: number;
  73073. /**
  73074. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73075. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73076. */
  73077. static readonly VELOCITY_TEXTURE_TYPE: number;
  73078. /**
  73079. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73080. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73081. */
  73082. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73083. /**
  73084. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73085. * in order to compute objects velocities when enableVelocity is set to "true"
  73086. * @hidden
  73087. */
  73088. _previousTransformationMatrices: {
  73089. [index: number]: ISavedTransformationMatrix;
  73090. };
  73091. /**
  73092. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73093. * in order to compute objects velocities when enableVelocity is set to "true"
  73094. * @hidden
  73095. */
  73096. _previousBonesTransformationMatrices: {
  73097. [index: number]: Float32Array;
  73098. };
  73099. /**
  73100. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73101. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73102. */
  73103. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73104. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73105. renderTransparentMeshes: boolean;
  73106. private _scene;
  73107. private _resizeObserver;
  73108. private _multiRenderTarget;
  73109. private _ratio;
  73110. private _enablePosition;
  73111. private _enableVelocity;
  73112. private _enableReflectivity;
  73113. private _positionIndex;
  73114. private _velocityIndex;
  73115. private _reflectivityIndex;
  73116. protected _effect: Effect;
  73117. protected _cachedDefines: string;
  73118. /**
  73119. * Set the render list (meshes to be rendered) used in the G buffer.
  73120. */
  73121. set renderList(meshes: Mesh[]);
  73122. /**
  73123. * Gets wether or not G buffer are supported by the running hardware.
  73124. * This requires draw buffer supports
  73125. */
  73126. get isSupported(): boolean;
  73127. /**
  73128. * Returns the index of the given texture type in the G-Buffer textures array
  73129. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73130. * @returns the index of the given texture type in the G-Buffer textures array
  73131. */
  73132. getTextureIndex(textureType: number): number;
  73133. /**
  73134. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73135. */
  73136. get enablePosition(): boolean;
  73137. /**
  73138. * Sets whether or not objects positions are enabled for the G buffer.
  73139. */
  73140. set enablePosition(enable: boolean);
  73141. /**
  73142. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73143. */
  73144. get enableVelocity(): boolean;
  73145. /**
  73146. * Sets wether or not objects velocities are enabled for the G buffer.
  73147. */
  73148. set enableVelocity(enable: boolean);
  73149. /**
  73150. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73151. */
  73152. get enableReflectivity(): boolean;
  73153. /**
  73154. * Sets wether or not objects roughness are enabled for the G buffer.
  73155. */
  73156. set enableReflectivity(enable: boolean);
  73157. /**
  73158. * Gets the scene associated with the buffer.
  73159. */
  73160. get scene(): Scene;
  73161. /**
  73162. * Gets the ratio used by the buffer during its creation.
  73163. * How big is the buffer related to the main canvas.
  73164. */
  73165. get ratio(): number;
  73166. /** @hidden */
  73167. static _SceneComponentInitialization: (scene: Scene) => void;
  73168. /**
  73169. * Creates a new G Buffer for the scene
  73170. * @param scene The scene the buffer belongs to
  73171. * @param ratio How big is the buffer related to the main canvas.
  73172. */
  73173. constructor(scene: Scene, ratio?: number);
  73174. /**
  73175. * Checks wether everything is ready to render a submesh to the G buffer.
  73176. * @param subMesh the submesh to check readiness for
  73177. * @param useInstances is the mesh drawn using instance or not
  73178. * @returns true if ready otherwise false
  73179. */
  73180. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73181. /**
  73182. * Gets the current underlying G Buffer.
  73183. * @returns the buffer
  73184. */
  73185. getGBuffer(): MultiRenderTarget;
  73186. /**
  73187. * Gets the number of samples used to render the buffer (anti aliasing).
  73188. */
  73189. get samples(): number;
  73190. /**
  73191. * Sets the number of samples used to render the buffer (anti aliasing).
  73192. */
  73193. set samples(value: number);
  73194. /**
  73195. * Disposes the renderer and frees up associated resources.
  73196. */
  73197. dispose(): void;
  73198. protected _createRenderTargets(): void;
  73199. private _copyBonesTransformationMatrices;
  73200. }
  73201. }
  73202. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73203. import { Nullable } from "babylonjs/types";
  73204. import { Scene } from "babylonjs/scene";
  73205. import { ISceneComponent } from "babylonjs/sceneComponent";
  73206. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73207. module "babylonjs/scene" {
  73208. interface Scene {
  73209. /** @hidden (Backing field) */
  73210. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73211. /**
  73212. * Gets or Sets the current geometry buffer associated to the scene.
  73213. */
  73214. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73215. /**
  73216. * Enables a GeometryBufferRender and associates it with the scene
  73217. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73218. * @returns the GeometryBufferRenderer
  73219. */
  73220. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73221. /**
  73222. * Disables the GeometryBufferRender associated with the scene
  73223. */
  73224. disableGeometryBufferRenderer(): void;
  73225. }
  73226. }
  73227. /**
  73228. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73229. * in several rendering techniques.
  73230. */
  73231. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73232. /**
  73233. * The component name helpful to identify the component in the list of scene components.
  73234. */
  73235. readonly name: string;
  73236. /**
  73237. * The scene the component belongs to.
  73238. */
  73239. scene: Scene;
  73240. /**
  73241. * Creates a new instance of the component for the given scene
  73242. * @param scene Defines the scene to register the component in
  73243. */
  73244. constructor(scene: Scene);
  73245. /**
  73246. * Registers the component in a given scene
  73247. */
  73248. register(): void;
  73249. /**
  73250. * Rebuilds the elements related to this component in case of
  73251. * context lost for instance.
  73252. */
  73253. rebuild(): void;
  73254. /**
  73255. * Disposes the component and the associated ressources
  73256. */
  73257. dispose(): void;
  73258. private _gatherRenderTargets;
  73259. }
  73260. }
  73261. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73262. /** @hidden */
  73263. export var motionBlurPixelShader: {
  73264. name: string;
  73265. shader: string;
  73266. };
  73267. }
  73268. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73269. import { Nullable } from "babylonjs/types";
  73270. import { Camera } from "babylonjs/Cameras/camera";
  73271. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73272. import { Scene } from "babylonjs/scene";
  73273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73274. import "babylonjs/Animations/animatable";
  73275. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73276. import "babylonjs/Shaders/motionBlur.fragment";
  73277. import { Engine } from "babylonjs/Engines/engine";
  73278. /**
  73279. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73280. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73281. * As an example, all you have to do is to create the post-process:
  73282. * var mb = new BABYLON.MotionBlurPostProcess(
  73283. * 'mb', // The name of the effect.
  73284. * scene, // The scene containing the objects to blur according to their velocity.
  73285. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73286. * camera // The camera to apply the render pass to.
  73287. * );
  73288. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73289. */
  73290. export class MotionBlurPostProcess extends PostProcess {
  73291. /**
  73292. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73293. */
  73294. motionStrength: number;
  73295. /**
  73296. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73297. */
  73298. get motionBlurSamples(): number;
  73299. /**
  73300. * Sets the number of iterations to be used for motion blur quality
  73301. */
  73302. set motionBlurSamples(samples: number);
  73303. private _motionBlurSamples;
  73304. private _geometryBufferRenderer;
  73305. /**
  73306. * Creates a new instance MotionBlurPostProcess
  73307. * @param name The name of the effect.
  73308. * @param scene The scene containing the objects to blur according to their velocity.
  73309. * @param options The required width/height ratio to downsize to before computing the render pass.
  73310. * @param camera The camera to apply the render pass to.
  73311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73312. * @param engine The engine which the post process will be applied. (default: current engine)
  73313. * @param reusable If the post process can be reused on the same frame. (default: false)
  73314. * @param textureType Type of textures used when performing the post process. (default: 0)
  73315. * @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)
  73316. */
  73317. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73318. /**
  73319. * Excludes the given skinned mesh from computing bones velocities.
  73320. * 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.
  73321. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73322. */
  73323. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73324. /**
  73325. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73326. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73327. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73328. */
  73329. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73330. /**
  73331. * Disposes the post process.
  73332. * @param camera The camera to dispose the post process on.
  73333. */
  73334. dispose(camera?: Camera): void;
  73335. }
  73336. }
  73337. declare module "babylonjs/Shaders/refraction.fragment" {
  73338. /** @hidden */
  73339. export var refractionPixelShader: {
  73340. name: string;
  73341. shader: string;
  73342. };
  73343. }
  73344. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73345. import { Color3 } from "babylonjs/Maths/math.color";
  73346. import { Camera } from "babylonjs/Cameras/camera";
  73347. import { Texture } from "babylonjs/Materials/Textures/texture";
  73348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73349. import { Engine } from "babylonjs/Engines/engine";
  73350. import "babylonjs/Shaders/refraction.fragment";
  73351. /**
  73352. * Post process which applies a refractin texture
  73353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73354. */
  73355. export class RefractionPostProcess extends PostProcess {
  73356. /** the base color of the refraction (used to taint the rendering) */
  73357. color: Color3;
  73358. /** simulated refraction depth */
  73359. depth: number;
  73360. /** the coefficient of the base color (0 to remove base color tainting) */
  73361. colorLevel: number;
  73362. private _refTexture;
  73363. private _ownRefractionTexture;
  73364. /**
  73365. * Gets or sets the refraction texture
  73366. * Please note that you are responsible for disposing the texture if you set it manually
  73367. */
  73368. get refractionTexture(): Texture;
  73369. set refractionTexture(value: Texture);
  73370. /**
  73371. * Initializes the RefractionPostProcess
  73372. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73373. * @param name The name of the effect.
  73374. * @param refractionTextureUrl Url of the refraction texture to use
  73375. * @param color the base color of the refraction (used to taint the rendering)
  73376. * @param depth simulated refraction depth
  73377. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73378. * @param camera The camera to apply the render pass to.
  73379. * @param options The required width/height ratio to downsize to before computing the render pass.
  73380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73381. * @param engine The engine which the post process will be applied. (default: current engine)
  73382. * @param reusable If the post process can be reused on the same frame. (default: false)
  73383. */
  73384. constructor(name: string, refractionTextureUrl: string,
  73385. /** the base color of the refraction (used to taint the rendering) */
  73386. color: Color3,
  73387. /** simulated refraction depth */
  73388. depth: number,
  73389. /** the coefficient of the base color (0 to remove base color tainting) */
  73390. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73391. /**
  73392. * Disposes of the post process
  73393. * @param camera Camera to dispose post process on
  73394. */
  73395. dispose(camera: Camera): void;
  73396. }
  73397. }
  73398. declare module "babylonjs/Shaders/sharpen.fragment" {
  73399. /** @hidden */
  73400. export var sharpenPixelShader: {
  73401. name: string;
  73402. shader: string;
  73403. };
  73404. }
  73405. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73406. import { Nullable } from "babylonjs/types";
  73407. import { Camera } from "babylonjs/Cameras/camera";
  73408. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73409. import "babylonjs/Shaders/sharpen.fragment";
  73410. import { Engine } from "babylonjs/Engines/engine";
  73411. /**
  73412. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73413. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73414. */
  73415. export class SharpenPostProcess extends PostProcess {
  73416. /**
  73417. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73418. */
  73419. colorAmount: number;
  73420. /**
  73421. * How much sharpness should be applied (default: 0.3)
  73422. */
  73423. edgeAmount: number;
  73424. /**
  73425. * Creates a new instance ConvolutionPostProcess
  73426. * @param name The name of the effect.
  73427. * @param options The required width/height ratio to downsize to before computing the render pass.
  73428. * @param camera The camera to apply the render pass to.
  73429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73430. * @param engine The engine which the post process will be applied. (default: current engine)
  73431. * @param reusable If the post process can be reused on the same frame. (default: false)
  73432. * @param textureType Type of textures used when performing the post process. (default: 0)
  73433. * @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)
  73434. */
  73435. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73436. }
  73437. }
  73438. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73439. import { Nullable } from "babylonjs/types";
  73440. import { Camera } from "babylonjs/Cameras/camera";
  73441. import { Engine } from "babylonjs/Engines/engine";
  73442. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73443. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73444. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73445. /**
  73446. * PostProcessRenderPipeline
  73447. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73448. */
  73449. export class PostProcessRenderPipeline {
  73450. private engine;
  73451. private _renderEffects;
  73452. private _renderEffectsForIsolatedPass;
  73453. /**
  73454. * List of inspectable custom properties (used by the Inspector)
  73455. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73456. */
  73457. inspectableCustomProperties: IInspectable[];
  73458. /**
  73459. * @hidden
  73460. */
  73461. protected _cameras: Camera[];
  73462. /** @hidden */
  73463. _name: string;
  73464. /**
  73465. * Gets pipeline name
  73466. */
  73467. get name(): string;
  73468. /** Gets the list of attached cameras */
  73469. get cameras(): Camera[];
  73470. /**
  73471. * Initializes a PostProcessRenderPipeline
  73472. * @param engine engine to add the pipeline to
  73473. * @param name name of the pipeline
  73474. */
  73475. constructor(engine: Engine, name: string);
  73476. /**
  73477. * Gets the class name
  73478. * @returns "PostProcessRenderPipeline"
  73479. */
  73480. getClassName(): string;
  73481. /**
  73482. * If all the render effects in the pipeline are supported
  73483. */
  73484. get isSupported(): boolean;
  73485. /**
  73486. * Adds an effect to the pipeline
  73487. * @param renderEffect the effect to add
  73488. */
  73489. addEffect(renderEffect: PostProcessRenderEffect): void;
  73490. /** @hidden */
  73491. _rebuild(): void;
  73492. /** @hidden */
  73493. _enableEffect(renderEffectName: string, cameras: Camera): void;
  73494. /** @hidden */
  73495. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  73496. /** @hidden */
  73497. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73498. /** @hidden */
  73499. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  73500. /** @hidden */
  73501. _attachCameras(cameras: Camera, unique: boolean): void;
  73502. /** @hidden */
  73503. _attachCameras(cameras: Camera[], unique: boolean): void;
  73504. /** @hidden */
  73505. _detachCameras(cameras: Camera): void;
  73506. /** @hidden */
  73507. _detachCameras(cameras: Nullable<Camera[]>): void;
  73508. /** @hidden */
  73509. _update(): void;
  73510. /** @hidden */
  73511. _reset(): void;
  73512. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  73513. /**
  73514. * Sets the required values to the prepass renderer.
  73515. * @param prePassRenderer defines the prepass renderer to setup.
  73516. * @returns true if the pre pass is needed.
  73517. */
  73518. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  73519. /**
  73520. * Disposes of the pipeline
  73521. */
  73522. dispose(): void;
  73523. }
  73524. }
  73525. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  73526. import { Camera } from "babylonjs/Cameras/camera";
  73527. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73528. /**
  73529. * PostProcessRenderPipelineManager class
  73530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73531. */
  73532. export class PostProcessRenderPipelineManager {
  73533. private _renderPipelines;
  73534. /**
  73535. * Initializes a PostProcessRenderPipelineManager
  73536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73537. */
  73538. constructor();
  73539. /**
  73540. * Gets the list of supported render pipelines
  73541. */
  73542. get supportedPipelines(): PostProcessRenderPipeline[];
  73543. /**
  73544. * Adds a pipeline to the manager
  73545. * @param renderPipeline The pipeline to add
  73546. */
  73547. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  73548. /**
  73549. * Attaches a camera to the pipeline
  73550. * @param renderPipelineName The name of the pipeline to attach to
  73551. * @param cameras the camera to attach
  73552. * @param unique if the camera can be attached multiple times to the pipeline
  73553. */
  73554. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  73555. /**
  73556. * Detaches a camera from the pipeline
  73557. * @param renderPipelineName The name of the pipeline to detach from
  73558. * @param cameras the camera to detach
  73559. */
  73560. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  73561. /**
  73562. * Enables an effect by name on a pipeline
  73563. * @param renderPipelineName the name of the pipeline to enable the effect in
  73564. * @param renderEffectName the name of the effect to enable
  73565. * @param cameras the cameras that the effect should be enabled on
  73566. */
  73567. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73568. /**
  73569. * Disables an effect by name on a pipeline
  73570. * @param renderPipelineName the name of the pipeline to disable the effect in
  73571. * @param renderEffectName the name of the effect to disable
  73572. * @param cameras the cameras that the effect should be disabled on
  73573. */
  73574. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  73575. /**
  73576. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  73577. */
  73578. update(): void;
  73579. /** @hidden */
  73580. _rebuild(): void;
  73581. /**
  73582. * Disposes of the manager and pipelines
  73583. */
  73584. dispose(): void;
  73585. }
  73586. }
  73587. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  73588. import { ISceneComponent } from "babylonjs/sceneComponent";
  73589. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73590. import { Scene } from "babylonjs/scene";
  73591. module "babylonjs/scene" {
  73592. interface Scene {
  73593. /** @hidden (Backing field) */
  73594. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73595. /**
  73596. * Gets the postprocess render pipeline manager
  73597. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73598. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73599. */
  73600. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  73601. }
  73602. }
  73603. /**
  73604. * Defines the Render Pipeline scene component responsible to rendering pipelines
  73605. */
  73606. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  73607. /**
  73608. * The component name helpfull to identify the component in the list of scene components.
  73609. */
  73610. readonly name: string;
  73611. /**
  73612. * The scene the component belongs to.
  73613. */
  73614. scene: Scene;
  73615. /**
  73616. * Creates a new instance of the component for the given scene
  73617. * @param scene Defines the scene to register the component in
  73618. */
  73619. constructor(scene: Scene);
  73620. /**
  73621. * Registers the component in a given scene
  73622. */
  73623. register(): void;
  73624. /**
  73625. * Rebuilds the elements related to this component in case of
  73626. * context lost for instance.
  73627. */
  73628. rebuild(): void;
  73629. /**
  73630. * Disposes the component and the associated ressources
  73631. */
  73632. dispose(): void;
  73633. private _gatherRenderTargets;
  73634. }
  73635. }
  73636. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  73637. import { Nullable } from "babylonjs/types";
  73638. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73639. import { Camera } from "babylonjs/Cameras/camera";
  73640. import { IDisposable } from "babylonjs/scene";
  73641. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  73642. import { Scene } from "babylonjs/scene";
  73643. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  73644. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73645. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  73646. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  73647. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73648. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73649. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  73650. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73651. import { Animation } from "babylonjs/Animations/animation";
  73652. /**
  73653. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73654. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73655. */
  73656. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73657. private _scene;
  73658. private _camerasToBeAttached;
  73659. /**
  73660. * ID of the sharpen post process,
  73661. */
  73662. private readonly SharpenPostProcessId;
  73663. /**
  73664. * @ignore
  73665. * ID of the image processing post process;
  73666. */
  73667. readonly ImageProcessingPostProcessId: string;
  73668. /**
  73669. * @ignore
  73670. * ID of the Fast Approximate Anti-Aliasing post process;
  73671. */
  73672. readonly FxaaPostProcessId: string;
  73673. /**
  73674. * ID of the chromatic aberration post process,
  73675. */
  73676. private readonly ChromaticAberrationPostProcessId;
  73677. /**
  73678. * ID of the grain post process
  73679. */
  73680. private readonly GrainPostProcessId;
  73681. /**
  73682. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73683. */
  73684. sharpen: SharpenPostProcess;
  73685. private _sharpenEffect;
  73686. private bloom;
  73687. /**
  73688. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73689. */
  73690. depthOfField: DepthOfFieldEffect;
  73691. /**
  73692. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73693. */
  73694. fxaa: FxaaPostProcess;
  73695. /**
  73696. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73697. */
  73698. imageProcessing: ImageProcessingPostProcess;
  73699. /**
  73700. * Chromatic aberration post process which will shift rgb colors in the image
  73701. */
  73702. chromaticAberration: ChromaticAberrationPostProcess;
  73703. private _chromaticAberrationEffect;
  73704. /**
  73705. * Grain post process which add noise to the image
  73706. */
  73707. grain: GrainPostProcess;
  73708. private _grainEffect;
  73709. /**
  73710. * Glow post process which adds a glow to emissive areas of the image
  73711. */
  73712. private _glowLayer;
  73713. /**
  73714. * Animations which can be used to tweak settings over a period of time
  73715. */
  73716. animations: Animation[];
  73717. private _imageProcessingConfigurationObserver;
  73718. private _sharpenEnabled;
  73719. private _bloomEnabled;
  73720. private _depthOfFieldEnabled;
  73721. private _depthOfFieldBlurLevel;
  73722. private _fxaaEnabled;
  73723. private _imageProcessingEnabled;
  73724. private _defaultPipelineTextureType;
  73725. private _bloomScale;
  73726. private _chromaticAberrationEnabled;
  73727. private _grainEnabled;
  73728. private _buildAllowed;
  73729. /**
  73730. * Gets active scene
  73731. */
  73732. get scene(): Scene;
  73733. /**
  73734. * Enable or disable the sharpen process from the pipeline
  73735. */
  73736. set sharpenEnabled(enabled: boolean);
  73737. get sharpenEnabled(): boolean;
  73738. private _resizeObserver;
  73739. private _hardwareScaleLevel;
  73740. private _bloomKernel;
  73741. /**
  73742. * Specifies the size of the bloom blur kernel, relative to the final output size
  73743. */
  73744. get bloomKernel(): number;
  73745. set bloomKernel(value: number);
  73746. /**
  73747. * Specifies the weight of the bloom in the final rendering
  73748. */
  73749. private _bloomWeight;
  73750. /**
  73751. * Specifies the luma threshold for the area that will be blurred by the bloom
  73752. */
  73753. private _bloomThreshold;
  73754. private _hdr;
  73755. /**
  73756. * The strength of the bloom.
  73757. */
  73758. set bloomWeight(value: number);
  73759. get bloomWeight(): number;
  73760. /**
  73761. * The strength of the bloom.
  73762. */
  73763. set bloomThreshold(value: number);
  73764. get bloomThreshold(): number;
  73765. /**
  73766. * The scale of the bloom, lower value will provide better performance.
  73767. */
  73768. set bloomScale(value: number);
  73769. get bloomScale(): number;
  73770. /**
  73771. * Enable or disable the bloom from the pipeline
  73772. */
  73773. set bloomEnabled(enabled: boolean);
  73774. get bloomEnabled(): boolean;
  73775. private _rebuildBloom;
  73776. /**
  73777. * If the depth of field is enabled.
  73778. */
  73779. get depthOfFieldEnabled(): boolean;
  73780. set depthOfFieldEnabled(enabled: boolean);
  73781. /**
  73782. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73783. */
  73784. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73785. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73786. /**
  73787. * If the anti aliasing is enabled.
  73788. */
  73789. set fxaaEnabled(enabled: boolean);
  73790. get fxaaEnabled(): boolean;
  73791. private _samples;
  73792. /**
  73793. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73794. */
  73795. set samples(sampleCount: number);
  73796. get samples(): number;
  73797. /**
  73798. * If image processing is enabled.
  73799. */
  73800. set imageProcessingEnabled(enabled: boolean);
  73801. get imageProcessingEnabled(): boolean;
  73802. /**
  73803. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73804. */
  73805. set glowLayerEnabled(enabled: boolean);
  73806. get glowLayerEnabled(): boolean;
  73807. /**
  73808. * Gets the glow layer (or null if not defined)
  73809. */
  73810. get glowLayer(): Nullable<GlowLayer>;
  73811. /**
  73812. * Enable or disable the chromaticAberration process from the pipeline
  73813. */
  73814. set chromaticAberrationEnabled(enabled: boolean);
  73815. get chromaticAberrationEnabled(): boolean;
  73816. /**
  73817. * Enable or disable the grain process from the pipeline
  73818. */
  73819. set grainEnabled(enabled: boolean);
  73820. get grainEnabled(): boolean;
  73821. /**
  73822. * @constructor
  73823. * @param name - The rendering pipeline name (default: "")
  73824. * @param hdr - If high dynamic range textures should be used (default: true)
  73825. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73826. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73827. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73828. */
  73829. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73830. /**
  73831. * Get the class name
  73832. * @returns "DefaultRenderingPipeline"
  73833. */
  73834. getClassName(): string;
  73835. /**
  73836. * Force the compilation of the entire pipeline.
  73837. */
  73838. prepare(): void;
  73839. private _hasCleared;
  73840. private _prevPostProcess;
  73841. private _prevPrevPostProcess;
  73842. private _setAutoClearAndTextureSharing;
  73843. private _depthOfFieldSceneObserver;
  73844. private _buildPipeline;
  73845. private _disposePostProcesses;
  73846. /**
  73847. * Adds a camera to the pipeline
  73848. * @param camera the camera to be added
  73849. */
  73850. addCamera(camera: Camera): void;
  73851. /**
  73852. * Removes a camera from the pipeline
  73853. * @param camera the camera to remove
  73854. */
  73855. removeCamera(camera: Camera): void;
  73856. /**
  73857. * Dispose of the pipeline and stop all post processes
  73858. */
  73859. dispose(): void;
  73860. /**
  73861. * Serialize the rendering pipeline (Used when exporting)
  73862. * @returns the serialized object
  73863. */
  73864. serialize(): any;
  73865. /**
  73866. * Parse the serialized pipeline
  73867. * @param source Source pipeline.
  73868. * @param scene The scene to load the pipeline to.
  73869. * @param rootUrl The URL of the serialized pipeline.
  73870. * @returns An instantiated pipeline from the serialized object.
  73871. */
  73872. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73873. }
  73874. }
  73875. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73876. /** @hidden */
  73877. export var lensHighlightsPixelShader: {
  73878. name: string;
  73879. shader: string;
  73880. };
  73881. }
  73882. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73883. /** @hidden */
  73884. export var depthOfFieldPixelShader: {
  73885. name: string;
  73886. shader: string;
  73887. };
  73888. }
  73889. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73890. import { Camera } from "babylonjs/Cameras/camera";
  73891. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73892. import { Scene } from "babylonjs/scene";
  73893. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73894. import "babylonjs/Shaders/chromaticAberration.fragment";
  73895. import "babylonjs/Shaders/lensHighlights.fragment";
  73896. import "babylonjs/Shaders/depthOfField.fragment";
  73897. /**
  73898. * BABYLON.JS Chromatic Aberration GLSL Shader
  73899. * Author: Olivier Guyot
  73900. * Separates very slightly R, G and B colors on the edges of the screen
  73901. * Inspired by Francois Tarlier & Martins Upitis
  73902. */
  73903. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73904. /**
  73905. * @ignore
  73906. * The chromatic aberration PostProcess id in the pipeline
  73907. */
  73908. LensChromaticAberrationEffect: string;
  73909. /**
  73910. * @ignore
  73911. * The highlights enhancing PostProcess id in the pipeline
  73912. */
  73913. HighlightsEnhancingEffect: string;
  73914. /**
  73915. * @ignore
  73916. * The depth-of-field PostProcess id in the pipeline
  73917. */
  73918. LensDepthOfFieldEffect: string;
  73919. private _scene;
  73920. private _depthTexture;
  73921. private _grainTexture;
  73922. private _chromaticAberrationPostProcess;
  73923. private _highlightsPostProcess;
  73924. private _depthOfFieldPostProcess;
  73925. private _edgeBlur;
  73926. private _grainAmount;
  73927. private _chromaticAberration;
  73928. private _distortion;
  73929. private _highlightsGain;
  73930. private _highlightsThreshold;
  73931. private _dofDistance;
  73932. private _dofAperture;
  73933. private _dofDarken;
  73934. private _dofPentagon;
  73935. private _blurNoise;
  73936. /**
  73937. * @constructor
  73938. *
  73939. * Effect parameters are as follow:
  73940. * {
  73941. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73942. * edge_blur: number; // from 0 to x (1 for realism)
  73943. * distortion: number; // from 0 to x (1 for realism)
  73944. * grain_amount: number; // from 0 to 1
  73945. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73946. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73947. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73948. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73949. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73950. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73951. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73952. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73953. * }
  73954. * Note: if an effect parameter is unset, effect is disabled
  73955. *
  73956. * @param name The rendering pipeline name
  73957. * @param parameters - An object containing all parameters (see above)
  73958. * @param scene The scene linked to this pipeline
  73959. * @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)
  73960. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73961. */
  73962. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73963. /**
  73964. * Get the class name
  73965. * @returns "LensRenderingPipeline"
  73966. */
  73967. getClassName(): string;
  73968. /**
  73969. * Gets associated scene
  73970. */
  73971. get scene(): Scene;
  73972. /**
  73973. * Gets or sets the edge blur
  73974. */
  73975. get edgeBlur(): number;
  73976. set edgeBlur(value: number);
  73977. /**
  73978. * Gets or sets the grain amount
  73979. */
  73980. get grainAmount(): number;
  73981. set grainAmount(value: number);
  73982. /**
  73983. * Gets or sets the chromatic aberration amount
  73984. */
  73985. get chromaticAberration(): number;
  73986. set chromaticAberration(value: number);
  73987. /**
  73988. * Gets or sets the depth of field aperture
  73989. */
  73990. get dofAperture(): number;
  73991. set dofAperture(value: number);
  73992. /**
  73993. * Gets or sets the edge distortion
  73994. */
  73995. get edgeDistortion(): number;
  73996. set edgeDistortion(value: number);
  73997. /**
  73998. * Gets or sets the depth of field distortion
  73999. */
  74000. get dofDistortion(): number;
  74001. set dofDistortion(value: number);
  74002. /**
  74003. * Gets or sets the darken out of focus amount
  74004. */
  74005. get darkenOutOfFocus(): number;
  74006. set darkenOutOfFocus(value: number);
  74007. /**
  74008. * Gets or sets a boolean indicating if blur noise is enabled
  74009. */
  74010. get blurNoise(): boolean;
  74011. set blurNoise(value: boolean);
  74012. /**
  74013. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74014. */
  74015. get pentagonBokeh(): boolean;
  74016. set pentagonBokeh(value: boolean);
  74017. /**
  74018. * Gets or sets the highlight grain amount
  74019. */
  74020. get highlightsGain(): number;
  74021. set highlightsGain(value: number);
  74022. /**
  74023. * Gets or sets the highlight threshold
  74024. */
  74025. get highlightsThreshold(): number;
  74026. set highlightsThreshold(value: number);
  74027. /**
  74028. * Sets the amount of blur at the edges
  74029. * @param amount blur amount
  74030. */
  74031. setEdgeBlur(amount: number): void;
  74032. /**
  74033. * Sets edge blur to 0
  74034. */
  74035. disableEdgeBlur(): void;
  74036. /**
  74037. * Sets the amout of grain
  74038. * @param amount Amount of grain
  74039. */
  74040. setGrainAmount(amount: number): void;
  74041. /**
  74042. * Set grain amount to 0
  74043. */
  74044. disableGrain(): void;
  74045. /**
  74046. * Sets the chromatic aberration amount
  74047. * @param amount amount of chromatic aberration
  74048. */
  74049. setChromaticAberration(amount: number): void;
  74050. /**
  74051. * Sets chromatic aberration amount to 0
  74052. */
  74053. disableChromaticAberration(): void;
  74054. /**
  74055. * Sets the EdgeDistortion amount
  74056. * @param amount amount of EdgeDistortion
  74057. */
  74058. setEdgeDistortion(amount: number): void;
  74059. /**
  74060. * Sets edge distortion to 0
  74061. */
  74062. disableEdgeDistortion(): void;
  74063. /**
  74064. * Sets the FocusDistance amount
  74065. * @param amount amount of FocusDistance
  74066. */
  74067. setFocusDistance(amount: number): void;
  74068. /**
  74069. * Disables depth of field
  74070. */
  74071. disableDepthOfField(): void;
  74072. /**
  74073. * Sets the Aperture amount
  74074. * @param amount amount of Aperture
  74075. */
  74076. setAperture(amount: number): void;
  74077. /**
  74078. * Sets the DarkenOutOfFocus amount
  74079. * @param amount amount of DarkenOutOfFocus
  74080. */
  74081. setDarkenOutOfFocus(amount: number): void;
  74082. private _pentagonBokehIsEnabled;
  74083. /**
  74084. * Creates a pentagon bokeh effect
  74085. */
  74086. enablePentagonBokeh(): void;
  74087. /**
  74088. * Disables the pentagon bokeh effect
  74089. */
  74090. disablePentagonBokeh(): void;
  74091. /**
  74092. * Enables noise blur
  74093. */
  74094. enableNoiseBlur(): void;
  74095. /**
  74096. * Disables noise blur
  74097. */
  74098. disableNoiseBlur(): void;
  74099. /**
  74100. * Sets the HighlightsGain amount
  74101. * @param amount amount of HighlightsGain
  74102. */
  74103. setHighlightsGain(amount: number): void;
  74104. /**
  74105. * Sets the HighlightsThreshold amount
  74106. * @param amount amount of HighlightsThreshold
  74107. */
  74108. setHighlightsThreshold(amount: number): void;
  74109. /**
  74110. * Disables highlights
  74111. */
  74112. disableHighlights(): void;
  74113. /**
  74114. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74115. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74116. */
  74117. dispose(disableDepthRender?: boolean): void;
  74118. private _createChromaticAberrationPostProcess;
  74119. private _createHighlightsPostProcess;
  74120. private _createDepthOfFieldPostProcess;
  74121. private _createGrainTexture;
  74122. }
  74123. }
  74124. declare module "babylonjs/Shaders/ssao2.fragment" {
  74125. /** @hidden */
  74126. export var ssao2PixelShader: {
  74127. name: string;
  74128. shader: string;
  74129. };
  74130. }
  74131. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74132. /** @hidden */
  74133. export var ssaoCombinePixelShader: {
  74134. name: string;
  74135. shader: string;
  74136. };
  74137. }
  74138. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74139. import { Camera } from "babylonjs/Cameras/camera";
  74140. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74141. import { Scene } from "babylonjs/scene";
  74142. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74143. import "babylonjs/Shaders/ssao2.fragment";
  74144. import "babylonjs/Shaders/ssaoCombine.fragment";
  74145. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74146. /**
  74147. * Render pipeline to produce ssao effect
  74148. */
  74149. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74150. /**
  74151. * @ignore
  74152. * The PassPostProcess id in the pipeline that contains the original scene color
  74153. */
  74154. SSAOOriginalSceneColorEffect: string;
  74155. /**
  74156. * @ignore
  74157. * The SSAO PostProcess id in the pipeline
  74158. */
  74159. SSAORenderEffect: string;
  74160. /**
  74161. * @ignore
  74162. * The horizontal blur PostProcess id in the pipeline
  74163. */
  74164. SSAOBlurHRenderEffect: string;
  74165. /**
  74166. * @ignore
  74167. * The vertical blur PostProcess id in the pipeline
  74168. */
  74169. SSAOBlurVRenderEffect: string;
  74170. /**
  74171. * @ignore
  74172. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74173. */
  74174. SSAOCombineRenderEffect: string;
  74175. /**
  74176. * The output strength of the SSAO post-process. Default value is 1.0.
  74177. */
  74178. totalStrength: number;
  74179. /**
  74180. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74181. */
  74182. maxZ: number;
  74183. /**
  74184. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74185. */
  74186. minZAspect: number;
  74187. private _samples;
  74188. /**
  74189. * Number of samples used for the SSAO calculations. Default value is 8
  74190. */
  74191. set samples(n: number);
  74192. get samples(): number;
  74193. private _textureSamples;
  74194. /**
  74195. * Number of samples to use for antialiasing
  74196. */
  74197. set textureSamples(n: number);
  74198. get textureSamples(): number;
  74199. /**
  74200. * Force rendering the geometry through geometry buffer
  74201. */
  74202. private _forceGeometryBuffer;
  74203. /**
  74204. * Ratio object used for SSAO ratio and blur ratio
  74205. */
  74206. private _ratio;
  74207. /**
  74208. * Dynamically generated sphere sampler.
  74209. */
  74210. private _sampleSphere;
  74211. /**
  74212. * Blur filter offsets
  74213. */
  74214. private _samplerOffsets;
  74215. private _expensiveBlur;
  74216. /**
  74217. * If bilateral blur should be used
  74218. */
  74219. set expensiveBlur(b: boolean);
  74220. get expensiveBlur(): boolean;
  74221. /**
  74222. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74223. */
  74224. radius: number;
  74225. /**
  74226. * The base color of the SSAO post-process
  74227. * The final result is "base + ssao" between [0, 1]
  74228. */
  74229. base: number;
  74230. /**
  74231. * Support test.
  74232. */
  74233. static get IsSupported(): boolean;
  74234. private _scene;
  74235. private _randomTexture;
  74236. private _originalColorPostProcess;
  74237. private _ssaoPostProcess;
  74238. private _blurHPostProcess;
  74239. private _blurVPostProcess;
  74240. private _ssaoCombinePostProcess;
  74241. private _prePassRenderer;
  74242. /**
  74243. * Gets active scene
  74244. */
  74245. get scene(): Scene;
  74246. /**
  74247. * @constructor
  74248. * @param name The rendering pipeline name
  74249. * @param scene The scene linked to this pipeline
  74250. * @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 }
  74251. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74252. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74253. */
  74254. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74255. /**
  74256. * Get the class name
  74257. * @returns "SSAO2RenderingPipeline"
  74258. */
  74259. getClassName(): string;
  74260. /**
  74261. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74262. */
  74263. dispose(disableGeometryBufferRenderer?: boolean): void;
  74264. private _createBlurPostProcess;
  74265. /** @hidden */
  74266. _rebuild(): void;
  74267. private _bits;
  74268. private _radicalInverse_VdC;
  74269. private _hammersley;
  74270. private _hemisphereSample_uniform;
  74271. private _generateHemisphere;
  74272. private _getDefinesForSSAO;
  74273. private _createSSAOPostProcess;
  74274. private _createSSAOCombinePostProcess;
  74275. private _createRandomTexture;
  74276. /**
  74277. * Serialize the rendering pipeline (Used when exporting)
  74278. * @returns the serialized object
  74279. */
  74280. serialize(): any;
  74281. /**
  74282. * Parse the serialized pipeline
  74283. * @param source Source pipeline.
  74284. * @param scene The scene to load the pipeline to.
  74285. * @param rootUrl The URL of the serialized pipeline.
  74286. * @returns An instantiated pipeline from the serialized object.
  74287. */
  74288. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74289. /**
  74290. * Sets the required values to the prepass renderer.
  74291. * @param prePassRenderer defines the prepass renderer to setup
  74292. * @returns true if the pre pass is needed.
  74293. */
  74294. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74295. }
  74296. }
  74297. declare module "babylonjs/Shaders/ssao.fragment" {
  74298. /** @hidden */
  74299. export var ssaoPixelShader: {
  74300. name: string;
  74301. shader: string;
  74302. };
  74303. }
  74304. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74305. import { Camera } from "babylonjs/Cameras/camera";
  74306. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74307. import { Scene } from "babylonjs/scene";
  74308. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74309. import "babylonjs/Shaders/ssao.fragment";
  74310. import "babylonjs/Shaders/ssaoCombine.fragment";
  74311. /**
  74312. * Render pipeline to produce ssao effect
  74313. */
  74314. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74315. /**
  74316. * @ignore
  74317. * The PassPostProcess id in the pipeline that contains the original scene color
  74318. */
  74319. SSAOOriginalSceneColorEffect: string;
  74320. /**
  74321. * @ignore
  74322. * The SSAO PostProcess id in the pipeline
  74323. */
  74324. SSAORenderEffect: string;
  74325. /**
  74326. * @ignore
  74327. * The horizontal blur PostProcess id in the pipeline
  74328. */
  74329. SSAOBlurHRenderEffect: string;
  74330. /**
  74331. * @ignore
  74332. * The vertical blur PostProcess id in the pipeline
  74333. */
  74334. SSAOBlurVRenderEffect: string;
  74335. /**
  74336. * @ignore
  74337. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74338. */
  74339. SSAOCombineRenderEffect: string;
  74340. /**
  74341. * The output strength of the SSAO post-process. Default value is 1.0.
  74342. */
  74343. totalStrength: number;
  74344. /**
  74345. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74346. */
  74347. radius: number;
  74348. /**
  74349. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74350. * Must not be equal to fallOff and superior to fallOff.
  74351. * Default value is 0.0075
  74352. */
  74353. area: number;
  74354. /**
  74355. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74356. * Must not be equal to area and inferior to area.
  74357. * Default value is 0.000001
  74358. */
  74359. fallOff: number;
  74360. /**
  74361. * The base color of the SSAO post-process
  74362. * The final result is "base + ssao" between [0, 1]
  74363. */
  74364. base: number;
  74365. private _scene;
  74366. private _depthTexture;
  74367. private _randomTexture;
  74368. private _originalColorPostProcess;
  74369. private _ssaoPostProcess;
  74370. private _blurHPostProcess;
  74371. private _blurVPostProcess;
  74372. private _ssaoCombinePostProcess;
  74373. private _firstUpdate;
  74374. /**
  74375. * Gets active scene
  74376. */
  74377. get scene(): Scene;
  74378. /**
  74379. * @constructor
  74380. * @param name - The rendering pipeline name
  74381. * @param scene - The scene linked to this pipeline
  74382. * @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 }
  74383. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74384. */
  74385. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74386. /**
  74387. * Get the class name
  74388. * @returns "SSAORenderingPipeline"
  74389. */
  74390. getClassName(): string;
  74391. /**
  74392. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74393. */
  74394. dispose(disableDepthRender?: boolean): void;
  74395. private _createBlurPostProcess;
  74396. /** @hidden */
  74397. _rebuild(): void;
  74398. private _createSSAOPostProcess;
  74399. private _createSSAOCombinePostProcess;
  74400. private _createRandomTexture;
  74401. }
  74402. }
  74403. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74404. /** @hidden */
  74405. export var screenSpaceReflectionPixelShader: {
  74406. name: string;
  74407. shader: string;
  74408. };
  74409. }
  74410. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74411. import { Nullable } from "babylonjs/types";
  74412. import { Camera } from "babylonjs/Cameras/camera";
  74413. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74414. import { Scene } from "babylonjs/scene";
  74415. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74416. import { Engine } from "babylonjs/Engines/engine";
  74417. /**
  74418. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74419. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74420. */
  74421. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74422. /**
  74423. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74424. */
  74425. threshold: number;
  74426. /**
  74427. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74428. */
  74429. strength: number;
  74430. /**
  74431. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74432. */
  74433. reflectionSpecularFalloffExponent: number;
  74434. /**
  74435. * 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]
  74436. */
  74437. step: number;
  74438. /**
  74439. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74440. */
  74441. roughnessFactor: number;
  74442. private _geometryBufferRenderer;
  74443. private _enableSmoothReflections;
  74444. private _reflectionSamples;
  74445. private _smoothSteps;
  74446. /**
  74447. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74448. * @param name The name of the effect.
  74449. * @param scene The scene containing the objects to calculate reflections.
  74450. * @param options The required width/height ratio to downsize to before computing the render pass.
  74451. * @param camera The camera to apply the render pass to.
  74452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74453. * @param engine The engine which the post process will be applied. (default: current engine)
  74454. * @param reusable If the post process can be reused on the same frame. (default: false)
  74455. * @param textureType Type of textures used when performing the post process. (default: 0)
  74456. * @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)
  74457. */
  74458. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74459. /**
  74460. * Gets wether or not smoothing reflections is enabled.
  74461. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74462. */
  74463. get enableSmoothReflections(): boolean;
  74464. /**
  74465. * Sets wether or not smoothing reflections is enabled.
  74466. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74467. */
  74468. set enableSmoothReflections(enabled: boolean);
  74469. /**
  74470. * Gets the number of samples taken while computing reflections. More samples count is high,
  74471. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74472. */
  74473. get reflectionSamples(): number;
  74474. /**
  74475. * Sets the number of samples taken while computing reflections. More samples count is high,
  74476. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74477. */
  74478. set reflectionSamples(samples: number);
  74479. /**
  74480. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74481. * more the post-process will require GPU power and can generate a drop in FPS.
  74482. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74483. */
  74484. get smoothSteps(): number;
  74485. set smoothSteps(steps: number);
  74486. private _updateEffectDefines;
  74487. }
  74488. }
  74489. declare module "babylonjs/Shaders/standard.fragment" {
  74490. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74491. /** @hidden */
  74492. export var standardPixelShader: {
  74493. name: string;
  74494. shader: string;
  74495. };
  74496. }
  74497. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74498. import { Nullable } from "babylonjs/types";
  74499. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74500. import { Camera } from "babylonjs/Cameras/camera";
  74501. import { Texture } from "babylonjs/Materials/Textures/texture";
  74502. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74503. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74504. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74505. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74506. import { IDisposable } from "babylonjs/scene";
  74507. import { SpotLight } from "babylonjs/Lights/spotLight";
  74508. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74509. import { Scene } from "babylonjs/scene";
  74510. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74511. import { Animation } from "babylonjs/Animations/animation";
  74512. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74513. import "babylonjs/Shaders/standard.fragment";
  74514. /**
  74515. * Standard rendering pipeline
  74516. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74517. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74518. */
  74519. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74520. /**
  74521. * Public members
  74522. */
  74523. /**
  74524. * Post-process which contains the original scene color before the pipeline applies all the effects
  74525. */
  74526. originalPostProcess: Nullable<PostProcess>;
  74527. /**
  74528. * Post-process used to down scale an image x4
  74529. */
  74530. downSampleX4PostProcess: Nullable<PostProcess>;
  74531. /**
  74532. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74533. */
  74534. brightPassPostProcess: Nullable<PostProcess>;
  74535. /**
  74536. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74537. */
  74538. blurHPostProcesses: PostProcess[];
  74539. /**
  74540. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74541. */
  74542. blurVPostProcesses: PostProcess[];
  74543. /**
  74544. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74545. */
  74546. textureAdderPostProcess: Nullable<PostProcess>;
  74547. /**
  74548. * Post-process used to create volumetric lighting effect
  74549. */
  74550. volumetricLightPostProcess: Nullable<PostProcess>;
  74551. /**
  74552. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74553. */
  74554. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74555. /**
  74556. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74557. */
  74558. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74559. /**
  74560. * Post-process used to merge the volumetric light effect and the real scene color
  74561. */
  74562. volumetricLightMergePostProces: Nullable<PostProcess>;
  74563. /**
  74564. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74565. */
  74566. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74567. /**
  74568. * Base post-process used to calculate the average luminance of the final image for HDR
  74569. */
  74570. luminancePostProcess: Nullable<PostProcess>;
  74571. /**
  74572. * Post-processes used to create down sample post-processes in order to get
  74573. * the average luminance of the final image for HDR
  74574. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74575. */
  74576. luminanceDownSamplePostProcesses: PostProcess[];
  74577. /**
  74578. * Post-process used to create a HDR effect (light adaptation)
  74579. */
  74580. hdrPostProcess: Nullable<PostProcess>;
  74581. /**
  74582. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74583. */
  74584. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74585. /**
  74586. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74587. */
  74588. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74589. /**
  74590. * Post-process used to merge the final HDR post-process and the real scene color
  74591. */
  74592. hdrFinalPostProcess: Nullable<PostProcess>;
  74593. /**
  74594. * Post-process used to create a lens flare effect
  74595. */
  74596. lensFlarePostProcess: Nullable<PostProcess>;
  74597. /**
  74598. * Post-process that merges the result of the lens flare post-process and the real scene color
  74599. */
  74600. lensFlareComposePostProcess: Nullable<PostProcess>;
  74601. /**
  74602. * Post-process used to create a motion blur effect
  74603. */
  74604. motionBlurPostProcess: Nullable<PostProcess>;
  74605. /**
  74606. * Post-process used to create a depth of field effect
  74607. */
  74608. depthOfFieldPostProcess: Nullable<PostProcess>;
  74609. /**
  74610. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74611. */
  74612. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74613. /**
  74614. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74615. */
  74616. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74617. /**
  74618. * Represents the brightness threshold in order to configure the illuminated surfaces
  74619. */
  74620. brightThreshold: number;
  74621. /**
  74622. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74623. */
  74624. blurWidth: number;
  74625. /**
  74626. * Sets if the blur for highlighted surfaces must be only horizontal
  74627. */
  74628. horizontalBlur: boolean;
  74629. /**
  74630. * Gets the overall exposure used by the pipeline
  74631. */
  74632. get exposure(): number;
  74633. /**
  74634. * Sets the overall exposure used by the pipeline
  74635. */
  74636. set exposure(value: number);
  74637. /**
  74638. * Texture used typically to simulate "dirty" on camera lens
  74639. */
  74640. lensTexture: Nullable<Texture>;
  74641. /**
  74642. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74643. */
  74644. volumetricLightCoefficient: number;
  74645. /**
  74646. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74647. */
  74648. volumetricLightPower: number;
  74649. /**
  74650. * Used the set the blur intensity to smooth the volumetric lights
  74651. */
  74652. volumetricLightBlurScale: number;
  74653. /**
  74654. * Light (spot or directional) used to generate the volumetric lights rays
  74655. * The source light must have a shadow generate so the pipeline can get its
  74656. * depth map
  74657. */
  74658. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74659. /**
  74660. * For eye adaptation, represents the minimum luminance the eye can see
  74661. */
  74662. hdrMinimumLuminance: number;
  74663. /**
  74664. * For eye adaptation, represents the decrease luminance speed
  74665. */
  74666. hdrDecreaseRate: number;
  74667. /**
  74668. * For eye adaptation, represents the increase luminance speed
  74669. */
  74670. hdrIncreaseRate: number;
  74671. /**
  74672. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74673. */
  74674. get hdrAutoExposure(): boolean;
  74675. /**
  74676. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74677. */
  74678. set hdrAutoExposure(value: boolean);
  74679. /**
  74680. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74681. */
  74682. lensColorTexture: Nullable<Texture>;
  74683. /**
  74684. * The overall strengh for the lens flare effect
  74685. */
  74686. lensFlareStrength: number;
  74687. /**
  74688. * Dispersion coefficient for lens flare ghosts
  74689. */
  74690. lensFlareGhostDispersal: number;
  74691. /**
  74692. * Main lens flare halo width
  74693. */
  74694. lensFlareHaloWidth: number;
  74695. /**
  74696. * Based on the lens distortion effect, defines how much the lens flare result
  74697. * is distorted
  74698. */
  74699. lensFlareDistortionStrength: number;
  74700. /**
  74701. * Configures the blur intensity used for for lens flare (halo)
  74702. */
  74703. lensFlareBlurWidth: number;
  74704. /**
  74705. * Lens star texture must be used to simulate rays on the flares and is available
  74706. * in the documentation
  74707. */
  74708. lensStarTexture: Nullable<Texture>;
  74709. /**
  74710. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74711. * flare effect by taking account of the dirt texture
  74712. */
  74713. lensFlareDirtTexture: Nullable<Texture>;
  74714. /**
  74715. * Represents the focal length for the depth of field effect
  74716. */
  74717. depthOfFieldDistance: number;
  74718. /**
  74719. * Represents the blur intensity for the blurred part of the depth of field effect
  74720. */
  74721. depthOfFieldBlurWidth: number;
  74722. /**
  74723. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74724. */
  74725. get motionStrength(): number;
  74726. /**
  74727. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74728. */
  74729. set motionStrength(strength: number);
  74730. /**
  74731. * Gets wether or not the motion blur post-process is object based or screen based.
  74732. */
  74733. get objectBasedMotionBlur(): boolean;
  74734. /**
  74735. * Sets wether or not the motion blur post-process should be object based or screen based
  74736. */
  74737. set objectBasedMotionBlur(value: boolean);
  74738. /**
  74739. * List of animations for the pipeline (IAnimatable implementation)
  74740. */
  74741. animations: Animation[];
  74742. /**
  74743. * Private members
  74744. */
  74745. private _scene;
  74746. private _currentDepthOfFieldSource;
  74747. private _basePostProcess;
  74748. private _fixedExposure;
  74749. private _currentExposure;
  74750. private _hdrAutoExposure;
  74751. private _hdrCurrentLuminance;
  74752. private _motionStrength;
  74753. private _isObjectBasedMotionBlur;
  74754. private _floatTextureType;
  74755. private _camerasToBeAttached;
  74756. private _ratio;
  74757. private _bloomEnabled;
  74758. private _depthOfFieldEnabled;
  74759. private _vlsEnabled;
  74760. private _lensFlareEnabled;
  74761. private _hdrEnabled;
  74762. private _motionBlurEnabled;
  74763. private _fxaaEnabled;
  74764. private _screenSpaceReflectionsEnabled;
  74765. private _motionBlurSamples;
  74766. private _volumetricLightStepsCount;
  74767. private _samples;
  74768. /**
  74769. * @ignore
  74770. * Specifies if the bloom pipeline is enabled
  74771. */
  74772. get BloomEnabled(): boolean;
  74773. set BloomEnabled(enabled: boolean);
  74774. /**
  74775. * @ignore
  74776. * Specifies if the depth of field pipeline is enabed
  74777. */
  74778. get DepthOfFieldEnabled(): boolean;
  74779. set DepthOfFieldEnabled(enabled: boolean);
  74780. /**
  74781. * @ignore
  74782. * Specifies if the lens flare pipeline is enabed
  74783. */
  74784. get LensFlareEnabled(): boolean;
  74785. set LensFlareEnabled(enabled: boolean);
  74786. /**
  74787. * @ignore
  74788. * Specifies if the HDR pipeline is enabled
  74789. */
  74790. get HDREnabled(): boolean;
  74791. set HDREnabled(enabled: boolean);
  74792. /**
  74793. * @ignore
  74794. * Specifies if the volumetric lights scattering effect is enabled
  74795. */
  74796. get VLSEnabled(): boolean;
  74797. set VLSEnabled(enabled: boolean);
  74798. /**
  74799. * @ignore
  74800. * Specifies if the motion blur effect is enabled
  74801. */
  74802. get MotionBlurEnabled(): boolean;
  74803. set MotionBlurEnabled(enabled: boolean);
  74804. /**
  74805. * Specifies if anti-aliasing is enabled
  74806. */
  74807. get fxaaEnabled(): boolean;
  74808. set fxaaEnabled(enabled: boolean);
  74809. /**
  74810. * Specifies if screen space reflections are enabled.
  74811. */
  74812. get screenSpaceReflectionsEnabled(): boolean;
  74813. set screenSpaceReflectionsEnabled(enabled: boolean);
  74814. /**
  74815. * Specifies the number of steps used to calculate the volumetric lights
  74816. * Typically in interval [50, 200]
  74817. */
  74818. get volumetricLightStepsCount(): number;
  74819. set volumetricLightStepsCount(count: number);
  74820. /**
  74821. * Specifies the number of samples used for the motion blur effect
  74822. * Typically in interval [16, 64]
  74823. */
  74824. get motionBlurSamples(): number;
  74825. set motionBlurSamples(samples: number);
  74826. /**
  74827. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74828. */
  74829. get samples(): number;
  74830. set samples(sampleCount: number);
  74831. /**
  74832. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74833. * @constructor
  74834. * @param name The rendering pipeline name
  74835. * @param scene The scene linked to this pipeline
  74836. * @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)
  74837. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74838. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74839. */
  74840. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74841. private _buildPipeline;
  74842. private _createDownSampleX4PostProcess;
  74843. private _createBrightPassPostProcess;
  74844. private _createBlurPostProcesses;
  74845. private _createTextureAdderPostProcess;
  74846. private _createVolumetricLightPostProcess;
  74847. private _createLuminancePostProcesses;
  74848. private _createHdrPostProcess;
  74849. private _createLensFlarePostProcess;
  74850. private _createDepthOfFieldPostProcess;
  74851. private _createMotionBlurPostProcess;
  74852. private _getDepthTexture;
  74853. private _disposePostProcesses;
  74854. /**
  74855. * Dispose of the pipeline and stop all post processes
  74856. */
  74857. dispose(): void;
  74858. /**
  74859. * Serialize the rendering pipeline (Used when exporting)
  74860. * @returns the serialized object
  74861. */
  74862. serialize(): any;
  74863. /**
  74864. * Parse the serialized pipeline
  74865. * @param source Source pipeline.
  74866. * @param scene The scene to load the pipeline to.
  74867. * @param rootUrl The URL of the serialized pipeline.
  74868. * @returns An instantiated pipeline from the serialized object.
  74869. */
  74870. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74871. /**
  74872. * Luminance steps
  74873. */
  74874. static LuminanceSteps: number;
  74875. }
  74876. }
  74877. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74878. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74879. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74880. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74881. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74882. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74883. }
  74884. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74885. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74886. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74887. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74888. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74889. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74890. }
  74891. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74892. /** @hidden */
  74893. export var stereoscopicInterlacePixelShader: {
  74894. name: string;
  74895. shader: string;
  74896. };
  74897. }
  74898. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74899. import { Camera } from "babylonjs/Cameras/camera";
  74900. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74901. import { Engine } from "babylonjs/Engines/engine";
  74902. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74903. /**
  74904. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74905. */
  74906. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74907. private _stepSize;
  74908. private _passedProcess;
  74909. /**
  74910. * Initializes a StereoscopicInterlacePostProcessI
  74911. * @param name The name of the effect.
  74912. * @param rigCameras The rig cameras to be appled to the post process
  74913. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74914. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74916. * @param engine The engine which the post process will be applied. (default: current engine)
  74917. * @param reusable If the post process can be reused on the same frame. (default: false)
  74918. */
  74919. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74920. }
  74921. /**
  74922. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74923. */
  74924. export class StereoscopicInterlacePostProcess extends PostProcess {
  74925. private _stepSize;
  74926. private _passedProcess;
  74927. /**
  74928. * Initializes a StereoscopicInterlacePostProcess
  74929. * @param name The name of the effect.
  74930. * @param rigCameras The rig cameras to be appled to the post process
  74931. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74933. * @param engine The engine which the post process will be applied. (default: current engine)
  74934. * @param reusable If the post process can be reused on the same frame. (default: false)
  74935. */
  74936. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74937. }
  74938. }
  74939. declare module "babylonjs/Shaders/tonemap.fragment" {
  74940. /** @hidden */
  74941. export var tonemapPixelShader: {
  74942. name: string;
  74943. shader: string;
  74944. };
  74945. }
  74946. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74947. import { Camera } from "babylonjs/Cameras/camera";
  74948. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74949. import "babylonjs/Shaders/tonemap.fragment";
  74950. import { Engine } from "babylonjs/Engines/engine";
  74951. /** Defines operator used for tonemapping */
  74952. export enum TonemappingOperator {
  74953. /** Hable */
  74954. Hable = 0,
  74955. /** Reinhard */
  74956. Reinhard = 1,
  74957. /** HejiDawson */
  74958. HejiDawson = 2,
  74959. /** Photographic */
  74960. Photographic = 3
  74961. }
  74962. /**
  74963. * Defines a post process to apply tone mapping
  74964. */
  74965. export class TonemapPostProcess extends PostProcess {
  74966. private _operator;
  74967. /** Defines the required exposure adjustement */
  74968. exposureAdjustment: number;
  74969. /**
  74970. * Creates a new TonemapPostProcess
  74971. * @param name defines the name of the postprocess
  74972. * @param _operator defines the operator to use
  74973. * @param exposureAdjustment defines the required exposure adjustement
  74974. * @param camera defines the camera to use (can be null)
  74975. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74976. * @param engine defines the hosting engine (can be ignore if camera is set)
  74977. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74978. */
  74979. constructor(name: string, _operator: TonemappingOperator,
  74980. /** Defines the required exposure adjustement */
  74981. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74982. }
  74983. }
  74984. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74985. /** @hidden */
  74986. export var volumetricLightScatteringPixelShader: {
  74987. name: string;
  74988. shader: string;
  74989. };
  74990. }
  74991. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74992. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74993. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74994. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74995. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74996. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74997. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74998. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74999. /** @hidden */
  75000. export var volumetricLightScatteringPassVertexShader: {
  75001. name: string;
  75002. shader: string;
  75003. };
  75004. }
  75005. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75006. /** @hidden */
  75007. export var volumetricLightScatteringPassPixelShader: {
  75008. name: string;
  75009. shader: string;
  75010. };
  75011. }
  75012. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75013. import { Vector3 } from "babylonjs/Maths/math.vector";
  75014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75015. import { Mesh } from "babylonjs/Meshes/mesh";
  75016. import { Camera } from "babylonjs/Cameras/camera";
  75017. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75018. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75019. import { Scene } from "babylonjs/scene";
  75020. import "babylonjs/Meshes/Builders/planeBuilder";
  75021. import "babylonjs/Shaders/depth.vertex";
  75022. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75023. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75024. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75025. import { Engine } from "babylonjs/Engines/engine";
  75026. /**
  75027. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75028. */
  75029. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75030. private _volumetricLightScatteringPass;
  75031. private _volumetricLightScatteringRTT;
  75032. private _viewPort;
  75033. private _screenCoordinates;
  75034. private _cachedDefines;
  75035. /**
  75036. * If not undefined, the mesh position is computed from the attached node position
  75037. */
  75038. attachedNode: {
  75039. position: Vector3;
  75040. };
  75041. /**
  75042. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75043. */
  75044. customMeshPosition: Vector3;
  75045. /**
  75046. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75047. */
  75048. useCustomMeshPosition: boolean;
  75049. /**
  75050. * If the post-process should inverse the light scattering direction
  75051. */
  75052. invert: boolean;
  75053. /**
  75054. * The internal mesh used by the post-process
  75055. */
  75056. mesh: Mesh;
  75057. /**
  75058. * @hidden
  75059. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75060. */
  75061. get useDiffuseColor(): boolean;
  75062. set useDiffuseColor(useDiffuseColor: boolean);
  75063. /**
  75064. * Array containing the excluded meshes not rendered in the internal pass
  75065. */
  75066. excludedMeshes: AbstractMesh[];
  75067. /**
  75068. * Controls the overall intensity of the post-process
  75069. */
  75070. exposure: number;
  75071. /**
  75072. * Dissipates each sample's contribution in range [0, 1]
  75073. */
  75074. decay: number;
  75075. /**
  75076. * Controls the overall intensity of each sample
  75077. */
  75078. weight: number;
  75079. /**
  75080. * Controls the density of each sample
  75081. */
  75082. density: number;
  75083. /**
  75084. * @constructor
  75085. * @param name The post-process name
  75086. * @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)
  75087. * @param camera The camera that the post-process will be attached to
  75088. * @param mesh The mesh used to create the light scattering
  75089. * @param samples The post-process quality, default 100
  75090. * @param samplingModeThe post-process filtering mode
  75091. * @param engine The babylon engine
  75092. * @param reusable If the post-process is reusable
  75093. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75094. */
  75095. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75096. /**
  75097. * Returns the string "VolumetricLightScatteringPostProcess"
  75098. * @returns "VolumetricLightScatteringPostProcess"
  75099. */
  75100. getClassName(): string;
  75101. private _isReady;
  75102. /**
  75103. * Sets the new light position for light scattering effect
  75104. * @param position The new custom light position
  75105. */
  75106. setCustomMeshPosition(position: Vector3): void;
  75107. /**
  75108. * Returns the light position for light scattering effect
  75109. * @return Vector3 The custom light position
  75110. */
  75111. getCustomMeshPosition(): Vector3;
  75112. /**
  75113. * Disposes the internal assets and detaches the post-process from the camera
  75114. */
  75115. dispose(camera: Camera): void;
  75116. /**
  75117. * Returns the render target texture used by the post-process
  75118. * @return the render target texture used by the post-process
  75119. */
  75120. getPass(): RenderTargetTexture;
  75121. private _meshExcluded;
  75122. private _createPass;
  75123. private _updateMeshScreenCoordinates;
  75124. /**
  75125. * Creates a default mesh for the Volumeric Light Scattering post-process
  75126. * @param name The mesh name
  75127. * @param scene The scene where to create the mesh
  75128. * @return the default mesh
  75129. */
  75130. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75131. }
  75132. }
  75133. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75134. /** @hidden */
  75135. export var screenSpaceCurvaturePixelShader: {
  75136. name: string;
  75137. shader: string;
  75138. };
  75139. }
  75140. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75141. import { Nullable } from "babylonjs/types";
  75142. import { Camera } from "babylonjs/Cameras/camera";
  75143. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75144. import { Scene } from "babylonjs/scene";
  75145. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75146. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75147. import { Engine } from "babylonjs/Engines/engine";
  75148. /**
  75149. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75150. */
  75151. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75152. /**
  75153. * Defines how much ridge the curvature effect displays.
  75154. */
  75155. ridge: number;
  75156. /**
  75157. * Defines how much valley the curvature effect displays.
  75158. */
  75159. valley: number;
  75160. private _geometryBufferRenderer;
  75161. /**
  75162. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75163. * @param name The name of the effect.
  75164. * @param scene The scene containing the objects to blur according to their velocity.
  75165. * @param options The required width/height ratio to downsize to before computing the render pass.
  75166. * @param camera The camera to apply the render pass to.
  75167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75168. * @param engine The engine which the post process will be applied. (default: current engine)
  75169. * @param reusable If the post process can be reused on the same frame. (default: false)
  75170. * @param textureType Type of textures used when performing the post process. (default: 0)
  75171. * @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)
  75172. */
  75173. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75174. /**
  75175. * Support test.
  75176. */
  75177. static get IsSupported(): boolean;
  75178. }
  75179. }
  75180. declare module "babylonjs/PostProcesses/index" {
  75181. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75182. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75183. export * from "babylonjs/PostProcesses/bloomEffect";
  75184. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75185. export * from "babylonjs/PostProcesses/blurPostProcess";
  75186. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75187. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75188. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75189. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75190. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75191. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75192. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75193. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75194. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75195. export * from "babylonjs/PostProcesses/filterPostProcess";
  75196. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75197. export * from "babylonjs/PostProcesses/grainPostProcess";
  75198. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75199. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75200. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75201. export * from "babylonjs/PostProcesses/passPostProcess";
  75202. export * from "babylonjs/PostProcesses/postProcess";
  75203. export * from "babylonjs/PostProcesses/postProcessManager";
  75204. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75205. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75206. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75207. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75208. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75209. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75210. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75211. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75212. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75213. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75214. }
  75215. declare module "babylonjs/Probes/index" {
  75216. export * from "babylonjs/Probes/reflectionProbe";
  75217. }
  75218. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75219. import { Scene } from "babylonjs/scene";
  75220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75221. import { SmartArray } from "babylonjs/Misc/smartArray";
  75222. import { ISceneComponent } from "babylonjs/sceneComponent";
  75223. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75224. import "babylonjs/Meshes/Builders/boxBuilder";
  75225. import "babylonjs/Shaders/color.fragment";
  75226. import "babylonjs/Shaders/color.vertex";
  75227. import { Color3 } from "babylonjs/Maths/math.color";
  75228. import { Observable } from "babylonjs/Misc/observable";
  75229. module "babylonjs/scene" {
  75230. interface Scene {
  75231. /** @hidden (Backing field) */
  75232. _boundingBoxRenderer: BoundingBoxRenderer;
  75233. /** @hidden (Backing field) */
  75234. _forceShowBoundingBoxes: boolean;
  75235. /**
  75236. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75237. */
  75238. forceShowBoundingBoxes: boolean;
  75239. /**
  75240. * Gets the bounding box renderer associated with the scene
  75241. * @returns a BoundingBoxRenderer
  75242. */
  75243. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75244. }
  75245. }
  75246. module "babylonjs/Meshes/abstractMesh" {
  75247. interface AbstractMesh {
  75248. /** @hidden (Backing field) */
  75249. _showBoundingBox: boolean;
  75250. /**
  75251. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75252. */
  75253. showBoundingBox: boolean;
  75254. }
  75255. }
  75256. /**
  75257. * Component responsible of rendering the bounding box of the meshes in a scene.
  75258. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75259. */
  75260. export class BoundingBoxRenderer implements ISceneComponent {
  75261. /**
  75262. * The component name helpfull to identify the component in the list of scene components.
  75263. */
  75264. readonly name: string;
  75265. /**
  75266. * The scene the component belongs to.
  75267. */
  75268. scene: Scene;
  75269. /**
  75270. * Color of the bounding box lines placed in front of an object
  75271. */
  75272. frontColor: Color3;
  75273. /**
  75274. * Color of the bounding box lines placed behind an object
  75275. */
  75276. backColor: Color3;
  75277. /**
  75278. * Defines if the renderer should show the back lines or not
  75279. */
  75280. showBackLines: boolean;
  75281. /**
  75282. * Observable raised before rendering a bounding box
  75283. */
  75284. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75285. /**
  75286. * Observable raised after rendering a bounding box
  75287. */
  75288. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75289. /**
  75290. * @hidden
  75291. */
  75292. renderList: SmartArray<BoundingBox>;
  75293. private _colorShader;
  75294. private _vertexBuffers;
  75295. private _indexBuffer;
  75296. private _fillIndexBuffer;
  75297. private _fillIndexData;
  75298. /**
  75299. * Instantiates a new bounding box renderer in a scene.
  75300. * @param scene the scene the renderer renders in
  75301. */
  75302. constructor(scene: Scene);
  75303. /**
  75304. * Registers the component in a given scene
  75305. */
  75306. register(): void;
  75307. private _evaluateSubMesh;
  75308. private _activeMesh;
  75309. private _prepareRessources;
  75310. private _createIndexBuffer;
  75311. /**
  75312. * Rebuilds the elements related to this component in case of
  75313. * context lost for instance.
  75314. */
  75315. rebuild(): void;
  75316. /**
  75317. * @hidden
  75318. */
  75319. reset(): void;
  75320. /**
  75321. * Render the bounding boxes of a specific rendering group
  75322. * @param renderingGroupId defines the rendering group to render
  75323. */
  75324. render(renderingGroupId: number): void;
  75325. /**
  75326. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75327. * @param mesh Define the mesh to render the occlusion bounding box for
  75328. */
  75329. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75330. /**
  75331. * Dispose and release the resources attached to this renderer.
  75332. */
  75333. dispose(): void;
  75334. }
  75335. }
  75336. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75337. import { Nullable } from "babylonjs/types";
  75338. import { Scene } from "babylonjs/scene";
  75339. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75340. import { Camera } from "babylonjs/Cameras/camera";
  75341. import { ISceneComponent } from "babylonjs/sceneComponent";
  75342. module "babylonjs/scene" {
  75343. interface Scene {
  75344. /** @hidden (Backing field) */
  75345. _depthRenderer: {
  75346. [id: string]: DepthRenderer;
  75347. };
  75348. /**
  75349. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75350. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75351. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75352. * @returns the created depth renderer
  75353. */
  75354. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75355. /**
  75356. * Disables a depth renderer for a given camera
  75357. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75358. */
  75359. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75360. }
  75361. }
  75362. /**
  75363. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75364. * in several rendering techniques.
  75365. */
  75366. export class DepthRendererSceneComponent implements ISceneComponent {
  75367. /**
  75368. * The component name helpfull to identify the component in the list of scene components.
  75369. */
  75370. readonly name: string;
  75371. /**
  75372. * The scene the component belongs to.
  75373. */
  75374. scene: Scene;
  75375. /**
  75376. * Creates a new instance of the component for the given scene
  75377. * @param scene Defines the scene to register the component in
  75378. */
  75379. constructor(scene: Scene);
  75380. /**
  75381. * Registers the component in a given scene
  75382. */
  75383. register(): void;
  75384. /**
  75385. * Rebuilds the elements related to this component in case of
  75386. * context lost for instance.
  75387. */
  75388. rebuild(): void;
  75389. /**
  75390. * Disposes the component and the associated ressources
  75391. */
  75392. dispose(): void;
  75393. private _gatherRenderTargets;
  75394. private _gatherActiveCameraRenderTargets;
  75395. }
  75396. }
  75397. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75398. import { Nullable } from "babylonjs/types";
  75399. import { Scene } from "babylonjs/scene";
  75400. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75401. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75402. import { AbstractScene } from "babylonjs/abstractScene";
  75403. module "babylonjs/abstractScene" {
  75404. interface AbstractScene {
  75405. /** @hidden (Backing field) */
  75406. _prePassRenderer: Nullable<PrePassRenderer>;
  75407. /**
  75408. * Gets or Sets the current prepass renderer associated to the scene.
  75409. */
  75410. prePassRenderer: Nullable<PrePassRenderer>;
  75411. /**
  75412. * Enables the prepass and associates it with the scene
  75413. * @returns the PrePassRenderer
  75414. */
  75415. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75416. /**
  75417. * Disables the prepass associated with the scene
  75418. */
  75419. disablePrePassRenderer(): void;
  75420. }
  75421. }
  75422. /**
  75423. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75424. * in several rendering techniques.
  75425. */
  75426. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75427. /**
  75428. * The component name helpful to identify the component in the list of scene components.
  75429. */
  75430. readonly name: string;
  75431. /**
  75432. * The scene the component belongs to.
  75433. */
  75434. scene: Scene;
  75435. /**
  75436. * Creates a new instance of the component for the given scene
  75437. * @param scene Defines the scene to register the component in
  75438. */
  75439. constructor(scene: Scene);
  75440. /**
  75441. * Registers the component in a given scene
  75442. */
  75443. register(): void;
  75444. private _beforeCameraDraw;
  75445. private _afterCameraDraw;
  75446. private _beforeClearStage;
  75447. /**
  75448. * Serializes the component data to the specified json object
  75449. * @param serializationObject The object to serialize to
  75450. */
  75451. serialize(serializationObject: any): void;
  75452. /**
  75453. * Adds all the elements from the container to the scene
  75454. * @param container the container holding the elements
  75455. */
  75456. addFromContainer(container: AbstractScene): void;
  75457. /**
  75458. * Removes all the elements in the container from the scene
  75459. * @param container contains the elements to remove
  75460. * @param dispose if the removed element should be disposed (default: false)
  75461. */
  75462. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75463. /**
  75464. * Rebuilds the elements related to this component in case of
  75465. * context lost for instance.
  75466. */
  75467. rebuild(): void;
  75468. /**
  75469. * Disposes the component and the associated ressources
  75470. */
  75471. dispose(): void;
  75472. }
  75473. }
  75474. declare module "babylonjs/Shaders/outline.fragment" {
  75475. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75476. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75477. /** @hidden */
  75478. export var outlinePixelShader: {
  75479. name: string;
  75480. shader: string;
  75481. };
  75482. }
  75483. declare module "babylonjs/Shaders/outline.vertex" {
  75484. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75485. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75486. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75487. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75488. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75490. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75491. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75492. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75493. /** @hidden */
  75494. export var outlineVertexShader: {
  75495. name: string;
  75496. shader: string;
  75497. };
  75498. }
  75499. declare module "babylonjs/Rendering/outlineRenderer" {
  75500. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75501. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75502. import { Scene } from "babylonjs/scene";
  75503. import { ISceneComponent } from "babylonjs/sceneComponent";
  75504. import "babylonjs/Shaders/outline.fragment";
  75505. import "babylonjs/Shaders/outline.vertex";
  75506. module "babylonjs/scene" {
  75507. interface Scene {
  75508. /** @hidden */
  75509. _outlineRenderer: OutlineRenderer;
  75510. /**
  75511. * Gets the outline renderer associated with the scene
  75512. * @returns a OutlineRenderer
  75513. */
  75514. getOutlineRenderer(): OutlineRenderer;
  75515. }
  75516. }
  75517. module "babylonjs/Meshes/abstractMesh" {
  75518. interface AbstractMesh {
  75519. /** @hidden (Backing field) */
  75520. _renderOutline: boolean;
  75521. /**
  75522. * Gets or sets a boolean indicating if the outline must be rendered as well
  75523. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75524. */
  75525. renderOutline: boolean;
  75526. /** @hidden (Backing field) */
  75527. _renderOverlay: boolean;
  75528. /**
  75529. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75530. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75531. */
  75532. renderOverlay: boolean;
  75533. }
  75534. }
  75535. /**
  75536. * This class is responsible to draw bothe outline/overlay of meshes.
  75537. * It should not be used directly but through the available method on mesh.
  75538. */
  75539. export class OutlineRenderer implements ISceneComponent {
  75540. /**
  75541. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75542. */
  75543. private static _StencilReference;
  75544. /**
  75545. * The name of the component. Each component must have a unique name.
  75546. */
  75547. name: string;
  75548. /**
  75549. * The scene the component belongs to.
  75550. */
  75551. scene: Scene;
  75552. /**
  75553. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75554. */
  75555. zOffset: number;
  75556. private _engine;
  75557. private _effect;
  75558. private _cachedDefines;
  75559. private _savedDepthWrite;
  75560. /**
  75561. * Instantiates a new outline renderer. (There could be only one per scene).
  75562. * @param scene Defines the scene it belongs to
  75563. */
  75564. constructor(scene: Scene);
  75565. /**
  75566. * Register the component to one instance of a scene.
  75567. */
  75568. register(): void;
  75569. /**
  75570. * Rebuilds the elements related to this component in case of
  75571. * context lost for instance.
  75572. */
  75573. rebuild(): void;
  75574. /**
  75575. * Disposes the component and the associated ressources.
  75576. */
  75577. dispose(): void;
  75578. /**
  75579. * Renders the outline in the canvas.
  75580. * @param subMesh Defines the sumesh to render
  75581. * @param batch Defines the batch of meshes in case of instances
  75582. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75583. */
  75584. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75585. /**
  75586. * Returns whether or not the outline renderer is ready for a given submesh.
  75587. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75588. * @param subMesh Defines the submesh to check readyness for
  75589. * @param useInstances Defines wheter wee are trying to render instances or not
  75590. * @returns true if ready otherwise false
  75591. */
  75592. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75593. private _beforeRenderingMesh;
  75594. private _afterRenderingMesh;
  75595. }
  75596. }
  75597. declare module "babylonjs/Rendering/index" {
  75598. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75599. export * from "babylonjs/Rendering/depthRenderer";
  75600. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75601. export * from "babylonjs/Rendering/edgesRenderer";
  75602. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75603. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75604. export * from "babylonjs/Rendering/prePassRenderer";
  75605. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75606. export * from "babylonjs/Rendering/outlineRenderer";
  75607. export * from "babylonjs/Rendering/renderingGroup";
  75608. export * from "babylonjs/Rendering/renderingManager";
  75609. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75610. }
  75611. declare module "babylonjs/Sprites/ISprites" {
  75612. /**
  75613. * Defines the basic options interface of a Sprite Frame Source Size.
  75614. */
  75615. export interface ISpriteJSONSpriteSourceSize {
  75616. /**
  75617. * number of the original width of the Frame
  75618. */
  75619. w: number;
  75620. /**
  75621. * number of the original height of the Frame
  75622. */
  75623. h: number;
  75624. }
  75625. /**
  75626. * Defines the basic options interface of a Sprite Frame Data.
  75627. */
  75628. export interface ISpriteJSONSpriteFrameData {
  75629. /**
  75630. * number of the x offset of the Frame
  75631. */
  75632. x: number;
  75633. /**
  75634. * number of the y offset of the Frame
  75635. */
  75636. y: number;
  75637. /**
  75638. * number of the width of the Frame
  75639. */
  75640. w: number;
  75641. /**
  75642. * number of the height of the Frame
  75643. */
  75644. h: number;
  75645. }
  75646. /**
  75647. * Defines the basic options interface of a JSON Sprite.
  75648. */
  75649. export interface ISpriteJSONSprite {
  75650. /**
  75651. * string name of the Frame
  75652. */
  75653. filename: string;
  75654. /**
  75655. * ISpriteJSONSpriteFrame basic object of the frame data
  75656. */
  75657. frame: ISpriteJSONSpriteFrameData;
  75658. /**
  75659. * boolean to flag is the frame was rotated.
  75660. */
  75661. rotated: boolean;
  75662. /**
  75663. * boolean to flag is the frame was trimmed.
  75664. */
  75665. trimmed: boolean;
  75666. /**
  75667. * ISpriteJSONSpriteFrame basic object of the source data
  75668. */
  75669. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75670. /**
  75671. * ISpriteJSONSpriteFrame basic object of the source data
  75672. */
  75673. sourceSize: ISpriteJSONSpriteSourceSize;
  75674. }
  75675. /**
  75676. * Defines the basic options interface of a JSON atlas.
  75677. */
  75678. export interface ISpriteJSONAtlas {
  75679. /**
  75680. * Array of objects that contain the frame data.
  75681. */
  75682. frames: Array<ISpriteJSONSprite>;
  75683. /**
  75684. * object basic object containing the sprite meta data.
  75685. */
  75686. meta?: object;
  75687. }
  75688. }
  75689. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75690. /** @hidden */
  75691. export var spriteMapPixelShader: {
  75692. name: string;
  75693. shader: string;
  75694. };
  75695. }
  75696. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75697. /** @hidden */
  75698. export var spriteMapVertexShader: {
  75699. name: string;
  75700. shader: string;
  75701. };
  75702. }
  75703. declare module "babylonjs/Sprites/spriteMap" {
  75704. import { IDisposable, Scene } from "babylonjs/scene";
  75705. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75706. import { Texture } from "babylonjs/Materials/Textures/texture";
  75707. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75708. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75709. import "babylonjs/Meshes/Builders/planeBuilder";
  75710. import "babylonjs/Shaders/spriteMap.fragment";
  75711. import "babylonjs/Shaders/spriteMap.vertex";
  75712. /**
  75713. * Defines the basic options interface of a SpriteMap
  75714. */
  75715. export interface ISpriteMapOptions {
  75716. /**
  75717. * Vector2 of the number of cells in the grid.
  75718. */
  75719. stageSize?: Vector2;
  75720. /**
  75721. * Vector2 of the size of the output plane in World Units.
  75722. */
  75723. outputSize?: Vector2;
  75724. /**
  75725. * Vector3 of the position of the output plane in World Units.
  75726. */
  75727. outputPosition?: Vector3;
  75728. /**
  75729. * Vector3 of the rotation of the output plane.
  75730. */
  75731. outputRotation?: Vector3;
  75732. /**
  75733. * number of layers that the system will reserve in resources.
  75734. */
  75735. layerCount?: number;
  75736. /**
  75737. * number of max animation frames a single cell will reserve in resources.
  75738. */
  75739. maxAnimationFrames?: number;
  75740. /**
  75741. * number cell index of the base tile when the system compiles.
  75742. */
  75743. baseTile?: number;
  75744. /**
  75745. * boolean flip the sprite after its been repositioned by the framing data.
  75746. */
  75747. flipU?: boolean;
  75748. /**
  75749. * Vector3 scalar of the global RGB values of the SpriteMap.
  75750. */
  75751. colorMultiply?: Vector3;
  75752. }
  75753. /**
  75754. * Defines the IDisposable interface in order to be cleanable from resources.
  75755. */
  75756. export interface ISpriteMap extends IDisposable {
  75757. /**
  75758. * String name of the SpriteMap.
  75759. */
  75760. name: string;
  75761. /**
  75762. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75763. */
  75764. atlasJSON: ISpriteJSONAtlas;
  75765. /**
  75766. * Texture of the SpriteMap.
  75767. */
  75768. spriteSheet: Texture;
  75769. /**
  75770. * The parameters to initialize the SpriteMap with.
  75771. */
  75772. options: ISpriteMapOptions;
  75773. }
  75774. /**
  75775. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75776. */
  75777. export class SpriteMap implements ISpriteMap {
  75778. /** The Name of the spriteMap */
  75779. name: string;
  75780. /** The JSON file with the frame and meta data */
  75781. atlasJSON: ISpriteJSONAtlas;
  75782. /** The systems Sprite Sheet Texture */
  75783. spriteSheet: Texture;
  75784. /** Arguments passed with the Constructor */
  75785. options: ISpriteMapOptions;
  75786. /** Public Sprite Storage array, parsed from atlasJSON */
  75787. sprites: Array<ISpriteJSONSprite>;
  75788. /** Returns the Number of Sprites in the System */
  75789. get spriteCount(): number;
  75790. /** Returns the Position of Output Plane*/
  75791. get position(): Vector3;
  75792. /** Returns the Position of Output Plane*/
  75793. set position(v: Vector3);
  75794. /** Returns the Rotation of Output Plane*/
  75795. get rotation(): Vector3;
  75796. /** Returns the Rotation of Output Plane*/
  75797. set rotation(v: Vector3);
  75798. /** Sets the AnimationMap*/
  75799. get animationMap(): RawTexture;
  75800. /** Sets the AnimationMap*/
  75801. set animationMap(v: RawTexture);
  75802. /** Scene that the SpriteMap was created in */
  75803. private _scene;
  75804. /** Texture Buffer of Float32 that holds tile frame data*/
  75805. private _frameMap;
  75806. /** Texture Buffers of Float32 that holds tileMap data*/
  75807. private _tileMaps;
  75808. /** Texture Buffer of Float32 that holds Animation Data*/
  75809. private _animationMap;
  75810. /** Custom ShaderMaterial Central to the System*/
  75811. private _material;
  75812. /** Custom ShaderMaterial Central to the System*/
  75813. private _output;
  75814. /** Systems Time Ticker*/
  75815. private _time;
  75816. /**
  75817. * Creates a new SpriteMap
  75818. * @param name defines the SpriteMaps Name
  75819. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75820. * @param spriteSheet is the Texture that the Sprites are on.
  75821. * @param options a basic deployment configuration
  75822. * @param scene The Scene that the map is deployed on
  75823. */
  75824. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75825. /**
  75826. * Returns tileID location
  75827. * @returns Vector2 the cell position ID
  75828. */
  75829. getTileID(): Vector2;
  75830. /**
  75831. * Gets the UV location of the mouse over the SpriteMap.
  75832. * @returns Vector2 the UV position of the mouse interaction
  75833. */
  75834. getMousePosition(): Vector2;
  75835. /**
  75836. * Creates the "frame" texture Buffer
  75837. * -------------------------------------
  75838. * Structure of frames
  75839. * "filename": "Falling-Water-2.png",
  75840. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75841. * "rotated": true,
  75842. * "trimmed": true,
  75843. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75844. * "sourceSize": {"w":32,"h":32}
  75845. * @returns RawTexture of the frameMap
  75846. */
  75847. private _createFrameBuffer;
  75848. /**
  75849. * Creates the tileMap texture Buffer
  75850. * @param buffer normally and array of numbers, or a false to generate from scratch
  75851. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75852. * @returns RawTexture of the tileMap
  75853. */
  75854. private _createTileBuffer;
  75855. /**
  75856. * Modifies the data of the tileMaps
  75857. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75858. * @param pos is the iVector2 Coordinates of the Tile
  75859. * @param tile The SpriteIndex of the new Tile
  75860. */
  75861. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75862. /**
  75863. * Creates the animationMap texture Buffer
  75864. * @param buffer normally and array of numbers, or a false to generate from scratch
  75865. * @returns RawTexture of the animationMap
  75866. */
  75867. private _createTileAnimationBuffer;
  75868. /**
  75869. * Modifies the data of the animationMap
  75870. * @param cellID is the Index of the Sprite
  75871. * @param _frame is the target Animation frame
  75872. * @param toCell is the Target Index of the next frame of the animation
  75873. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75874. * @param speed is a global scalar of the time variable on the map.
  75875. */
  75876. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75877. /**
  75878. * Exports the .tilemaps file
  75879. */
  75880. saveTileMaps(): void;
  75881. /**
  75882. * Imports the .tilemaps file
  75883. * @param url of the .tilemaps file
  75884. */
  75885. loadTileMaps(url: string): void;
  75886. /**
  75887. * Release associated resources
  75888. */
  75889. dispose(): void;
  75890. }
  75891. }
  75892. declare module "babylonjs/Sprites/spritePackedManager" {
  75893. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75894. import { Scene } from "babylonjs/scene";
  75895. /**
  75896. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75897. * @see https://doc.babylonjs.com/babylon101/sprites
  75898. */
  75899. export class SpritePackedManager extends SpriteManager {
  75900. /** defines the packed manager's name */
  75901. name: string;
  75902. /**
  75903. * Creates a new sprite manager from a packed sprite sheet
  75904. * @param name defines the manager's name
  75905. * @param imgUrl defines the sprite sheet url
  75906. * @param capacity defines the maximum allowed number of sprites
  75907. * @param scene defines the hosting scene
  75908. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75909. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75910. * @param samplingMode defines the smapling mode to use with spritesheet
  75911. * @param fromPacked set to true; do not alter
  75912. */
  75913. constructor(
  75914. /** defines the packed manager's name */
  75915. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75916. }
  75917. }
  75918. declare module "babylonjs/Sprites/index" {
  75919. export * from "babylonjs/Sprites/sprite";
  75920. export * from "babylonjs/Sprites/ISprites";
  75921. export * from "babylonjs/Sprites/spriteManager";
  75922. export * from "babylonjs/Sprites/spriteMap";
  75923. export * from "babylonjs/Sprites/spritePackedManager";
  75924. export * from "babylonjs/Sprites/spriteSceneComponent";
  75925. }
  75926. declare module "babylonjs/States/index" {
  75927. export * from "babylonjs/States/alphaCullingState";
  75928. export * from "babylonjs/States/depthCullingState";
  75929. export * from "babylonjs/States/stencilState";
  75930. }
  75931. declare module "babylonjs/Misc/assetsManager" {
  75932. import { Scene } from "babylonjs/scene";
  75933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75934. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75935. import { Skeleton } from "babylonjs/Bones/skeleton";
  75936. import { Observable } from "babylonjs/Misc/observable";
  75937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75938. import { Texture } from "babylonjs/Materials/Textures/texture";
  75939. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75940. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75941. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75942. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75943. import { AssetContainer } from "babylonjs/assetContainer";
  75944. /**
  75945. * Defines the list of states available for a task inside a AssetsManager
  75946. */
  75947. export enum AssetTaskState {
  75948. /**
  75949. * Initialization
  75950. */
  75951. INIT = 0,
  75952. /**
  75953. * Running
  75954. */
  75955. RUNNING = 1,
  75956. /**
  75957. * Done
  75958. */
  75959. DONE = 2,
  75960. /**
  75961. * Error
  75962. */
  75963. ERROR = 3
  75964. }
  75965. /**
  75966. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75967. */
  75968. export abstract class AbstractAssetTask {
  75969. /**
  75970. * Task name
  75971. */ name: string;
  75972. /**
  75973. * Callback called when the task is successful
  75974. */
  75975. onSuccess: (task: any) => void;
  75976. /**
  75977. * Callback called when the task is not successful
  75978. */
  75979. onError: (task: any, message?: string, exception?: any) => void;
  75980. /**
  75981. * Creates a new AssetsManager
  75982. * @param name defines the name of the task
  75983. */
  75984. constructor(
  75985. /**
  75986. * Task name
  75987. */ name: string);
  75988. private _isCompleted;
  75989. private _taskState;
  75990. private _errorObject;
  75991. /**
  75992. * Get if the task is completed
  75993. */
  75994. get isCompleted(): boolean;
  75995. /**
  75996. * Gets the current state of the task
  75997. */
  75998. get taskState(): AssetTaskState;
  75999. /**
  76000. * Gets the current error object (if task is in error)
  76001. */
  76002. get errorObject(): {
  76003. message?: string;
  76004. exception?: any;
  76005. };
  76006. /**
  76007. * Internal only
  76008. * @hidden
  76009. */
  76010. _setErrorObject(message?: string, exception?: any): void;
  76011. /**
  76012. * Execute the current task
  76013. * @param scene defines the scene where you want your assets to be loaded
  76014. * @param onSuccess is a callback called when the task is successfully executed
  76015. * @param onError is a callback called if an error occurs
  76016. */
  76017. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76018. /**
  76019. * Execute the current task
  76020. * @param scene defines the scene where you want your assets to be loaded
  76021. * @param onSuccess is a callback called when the task is successfully executed
  76022. * @param onError is a callback called if an error occurs
  76023. */
  76024. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76025. /**
  76026. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76027. * This can be used with failed tasks that have the reason for failure fixed.
  76028. */
  76029. reset(): void;
  76030. private onErrorCallback;
  76031. private onDoneCallback;
  76032. }
  76033. /**
  76034. * Define the interface used by progress events raised during assets loading
  76035. */
  76036. export interface IAssetsProgressEvent {
  76037. /**
  76038. * Defines the number of remaining tasks to process
  76039. */
  76040. remainingCount: number;
  76041. /**
  76042. * Defines the total number of tasks
  76043. */
  76044. totalCount: number;
  76045. /**
  76046. * Defines the task that was just processed
  76047. */
  76048. task: AbstractAssetTask;
  76049. }
  76050. /**
  76051. * Class used to share progress information about assets loading
  76052. */
  76053. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76054. /**
  76055. * Defines the number of remaining tasks to process
  76056. */
  76057. remainingCount: number;
  76058. /**
  76059. * Defines the total number of tasks
  76060. */
  76061. totalCount: number;
  76062. /**
  76063. * Defines the task that was just processed
  76064. */
  76065. task: AbstractAssetTask;
  76066. /**
  76067. * Creates a AssetsProgressEvent
  76068. * @param remainingCount defines the number of remaining tasks to process
  76069. * @param totalCount defines the total number of tasks
  76070. * @param task defines the task that was just processed
  76071. */
  76072. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76073. }
  76074. /**
  76075. * Define a task used by AssetsManager to load assets into a container
  76076. */
  76077. export class ContainerAssetTask extends AbstractAssetTask {
  76078. /**
  76079. * Defines the name of the task
  76080. */
  76081. name: string;
  76082. /**
  76083. * Defines the list of mesh's names you want to load
  76084. */
  76085. meshesNames: any;
  76086. /**
  76087. * Defines the root url to use as a base to load your meshes and associated resources
  76088. */
  76089. rootUrl: string;
  76090. /**
  76091. * Defines the filename or File of the scene to load from
  76092. */
  76093. sceneFilename: string | File;
  76094. /**
  76095. * Get the loaded asset container
  76096. */
  76097. loadedContainer: AssetContainer;
  76098. /**
  76099. * Gets the list of loaded meshes
  76100. */
  76101. loadedMeshes: Array<AbstractMesh>;
  76102. /**
  76103. * Gets the list of loaded particle systems
  76104. */
  76105. loadedParticleSystems: Array<IParticleSystem>;
  76106. /**
  76107. * Gets the list of loaded skeletons
  76108. */
  76109. loadedSkeletons: Array<Skeleton>;
  76110. /**
  76111. * Gets the list of loaded animation groups
  76112. */
  76113. loadedAnimationGroups: Array<AnimationGroup>;
  76114. /**
  76115. * Callback called when the task is successful
  76116. */
  76117. onSuccess: (task: ContainerAssetTask) => void;
  76118. /**
  76119. * Callback called when the task is successful
  76120. */
  76121. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76122. /**
  76123. * Creates a new ContainerAssetTask
  76124. * @param name defines the name of the task
  76125. * @param meshesNames defines the list of mesh's names you want to load
  76126. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76127. * @param sceneFilename defines the filename or File of the scene to load from
  76128. */
  76129. constructor(
  76130. /**
  76131. * Defines the name of the task
  76132. */
  76133. name: string,
  76134. /**
  76135. * Defines the list of mesh's names you want to load
  76136. */
  76137. meshesNames: any,
  76138. /**
  76139. * Defines the root url to use as a base to load your meshes and associated resources
  76140. */
  76141. rootUrl: string,
  76142. /**
  76143. * Defines the filename or File of the scene to load from
  76144. */
  76145. sceneFilename: string | File);
  76146. /**
  76147. * Execute the current task
  76148. * @param scene defines the scene where you want your assets to be loaded
  76149. * @param onSuccess is a callback called when the task is successfully executed
  76150. * @param onError is a callback called if an error occurs
  76151. */
  76152. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76153. }
  76154. /**
  76155. * Define a task used by AssetsManager to load meshes
  76156. */
  76157. export class MeshAssetTask extends AbstractAssetTask {
  76158. /**
  76159. * Defines the name of the task
  76160. */
  76161. name: string;
  76162. /**
  76163. * Defines the list of mesh's names you want to load
  76164. */
  76165. meshesNames: any;
  76166. /**
  76167. * Defines the root url to use as a base to load your meshes and associated resources
  76168. */
  76169. rootUrl: string;
  76170. /**
  76171. * Defines the filename or File of the scene to load from
  76172. */
  76173. sceneFilename: string | File;
  76174. /**
  76175. * Gets the list of loaded meshes
  76176. */
  76177. loadedMeshes: Array<AbstractMesh>;
  76178. /**
  76179. * Gets the list of loaded particle systems
  76180. */
  76181. loadedParticleSystems: Array<IParticleSystem>;
  76182. /**
  76183. * Gets the list of loaded skeletons
  76184. */
  76185. loadedSkeletons: Array<Skeleton>;
  76186. /**
  76187. * Gets the list of loaded animation groups
  76188. */
  76189. loadedAnimationGroups: Array<AnimationGroup>;
  76190. /**
  76191. * Callback called when the task is successful
  76192. */
  76193. onSuccess: (task: MeshAssetTask) => void;
  76194. /**
  76195. * Callback called when the task is successful
  76196. */
  76197. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76198. /**
  76199. * Creates a new MeshAssetTask
  76200. * @param name defines the name of the task
  76201. * @param meshesNames defines the list of mesh's names you want to load
  76202. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76203. * @param sceneFilename defines the filename or File of the scene to load from
  76204. */
  76205. constructor(
  76206. /**
  76207. * Defines the name of the task
  76208. */
  76209. name: string,
  76210. /**
  76211. * Defines the list of mesh's names you want to load
  76212. */
  76213. meshesNames: any,
  76214. /**
  76215. * Defines the root url to use as a base to load your meshes and associated resources
  76216. */
  76217. rootUrl: string,
  76218. /**
  76219. * Defines the filename or File of the scene to load from
  76220. */
  76221. sceneFilename: string | File);
  76222. /**
  76223. * Execute the current task
  76224. * @param scene defines the scene where you want your assets to be loaded
  76225. * @param onSuccess is a callback called when the task is successfully executed
  76226. * @param onError is a callback called if an error occurs
  76227. */
  76228. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76229. }
  76230. /**
  76231. * Define a task used by AssetsManager to load text content
  76232. */
  76233. export class TextFileAssetTask extends AbstractAssetTask {
  76234. /**
  76235. * Defines the name of the task
  76236. */
  76237. name: string;
  76238. /**
  76239. * Defines the location of the file to load
  76240. */
  76241. url: string;
  76242. /**
  76243. * Gets the loaded text string
  76244. */
  76245. text: string;
  76246. /**
  76247. * Callback called when the task is successful
  76248. */
  76249. onSuccess: (task: TextFileAssetTask) => void;
  76250. /**
  76251. * Callback called when the task is successful
  76252. */
  76253. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76254. /**
  76255. * Creates a new TextFileAssetTask object
  76256. * @param name defines the name of the task
  76257. * @param url defines the location of the file to load
  76258. */
  76259. constructor(
  76260. /**
  76261. * Defines the name of the task
  76262. */
  76263. name: string,
  76264. /**
  76265. * Defines the location of the file to load
  76266. */
  76267. url: string);
  76268. /**
  76269. * Execute the current task
  76270. * @param scene defines the scene where you want your assets to be loaded
  76271. * @param onSuccess is a callback called when the task is successfully executed
  76272. * @param onError is a callback called if an error occurs
  76273. */
  76274. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76275. }
  76276. /**
  76277. * Define a task used by AssetsManager to load binary data
  76278. */
  76279. export class BinaryFileAssetTask extends AbstractAssetTask {
  76280. /**
  76281. * Defines the name of the task
  76282. */
  76283. name: string;
  76284. /**
  76285. * Defines the location of the file to load
  76286. */
  76287. url: string;
  76288. /**
  76289. * Gets the lodaded data (as an array buffer)
  76290. */
  76291. data: ArrayBuffer;
  76292. /**
  76293. * Callback called when the task is successful
  76294. */
  76295. onSuccess: (task: BinaryFileAssetTask) => void;
  76296. /**
  76297. * Callback called when the task is successful
  76298. */
  76299. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76300. /**
  76301. * Creates a new BinaryFileAssetTask object
  76302. * @param name defines the name of the new task
  76303. * @param url defines the location of the file to load
  76304. */
  76305. constructor(
  76306. /**
  76307. * Defines the name of the task
  76308. */
  76309. name: string,
  76310. /**
  76311. * Defines the location of the file to load
  76312. */
  76313. url: string);
  76314. /**
  76315. * Execute the current task
  76316. * @param scene defines the scene where you want your assets to be loaded
  76317. * @param onSuccess is a callback called when the task is successfully executed
  76318. * @param onError is a callback called if an error occurs
  76319. */
  76320. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76321. }
  76322. /**
  76323. * Define a task used by AssetsManager to load images
  76324. */
  76325. export class ImageAssetTask extends AbstractAssetTask {
  76326. /**
  76327. * Defines the name of the task
  76328. */
  76329. name: string;
  76330. /**
  76331. * Defines the location of the image to load
  76332. */
  76333. url: string;
  76334. /**
  76335. * Gets the loaded images
  76336. */
  76337. image: HTMLImageElement;
  76338. /**
  76339. * Callback called when the task is successful
  76340. */
  76341. onSuccess: (task: ImageAssetTask) => void;
  76342. /**
  76343. * Callback called when the task is successful
  76344. */
  76345. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76346. /**
  76347. * Creates a new ImageAssetTask
  76348. * @param name defines the name of the task
  76349. * @param url defines the location of the image to load
  76350. */
  76351. constructor(
  76352. /**
  76353. * Defines the name of the task
  76354. */
  76355. name: string,
  76356. /**
  76357. * Defines the location of the image to load
  76358. */
  76359. url: string);
  76360. /**
  76361. * Execute the current task
  76362. * @param scene defines the scene where you want your assets to be loaded
  76363. * @param onSuccess is a callback called when the task is successfully executed
  76364. * @param onError is a callback called if an error occurs
  76365. */
  76366. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76367. }
  76368. /**
  76369. * Defines the interface used by texture loading tasks
  76370. */
  76371. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76372. /**
  76373. * Gets the loaded texture
  76374. */
  76375. texture: TEX;
  76376. }
  76377. /**
  76378. * Define a task used by AssetsManager to load 2D textures
  76379. */
  76380. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76381. /**
  76382. * Defines the name of the task
  76383. */
  76384. name: string;
  76385. /**
  76386. * Defines the location of the file to load
  76387. */
  76388. url: string;
  76389. /**
  76390. * Defines if mipmap should not be generated (default is false)
  76391. */
  76392. noMipmap?: boolean | undefined;
  76393. /**
  76394. * Defines if texture must be inverted on Y axis (default is true)
  76395. */
  76396. invertY: boolean;
  76397. /**
  76398. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76399. */
  76400. samplingMode: number;
  76401. /**
  76402. * Gets the loaded texture
  76403. */
  76404. texture: Texture;
  76405. /**
  76406. * Callback called when the task is successful
  76407. */
  76408. onSuccess: (task: TextureAssetTask) => void;
  76409. /**
  76410. * Callback called when the task is successful
  76411. */
  76412. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76413. /**
  76414. * Creates a new TextureAssetTask object
  76415. * @param name defines the name of the task
  76416. * @param url defines the location of the file to load
  76417. * @param noMipmap defines if mipmap should not be generated (default is false)
  76418. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76419. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76420. */
  76421. constructor(
  76422. /**
  76423. * Defines the name of the task
  76424. */
  76425. name: string,
  76426. /**
  76427. * Defines the location of the file to load
  76428. */
  76429. url: string,
  76430. /**
  76431. * Defines if mipmap should not be generated (default is false)
  76432. */
  76433. noMipmap?: boolean | undefined,
  76434. /**
  76435. * Defines if texture must be inverted on Y axis (default is true)
  76436. */
  76437. invertY?: boolean,
  76438. /**
  76439. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76440. */
  76441. samplingMode?: number);
  76442. /**
  76443. * Execute the current task
  76444. * @param scene defines the scene where you want your assets to be loaded
  76445. * @param onSuccess is a callback called when the task is successfully executed
  76446. * @param onError is a callback called if an error occurs
  76447. */
  76448. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76449. }
  76450. /**
  76451. * Define a task used by AssetsManager to load cube textures
  76452. */
  76453. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  76454. /**
  76455. * Defines the name of the task
  76456. */
  76457. name: string;
  76458. /**
  76459. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76460. */
  76461. url: string;
  76462. /**
  76463. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76464. */
  76465. extensions?: string[] | undefined;
  76466. /**
  76467. * Defines if mipmaps should not be generated (default is false)
  76468. */
  76469. noMipmap?: boolean | undefined;
  76470. /**
  76471. * Defines the explicit list of files (undefined by default)
  76472. */
  76473. files?: string[] | undefined;
  76474. /**
  76475. * Gets the loaded texture
  76476. */
  76477. texture: CubeTexture;
  76478. /**
  76479. * Callback called when the task is successful
  76480. */
  76481. onSuccess: (task: CubeTextureAssetTask) => void;
  76482. /**
  76483. * Callback called when the task is successful
  76484. */
  76485. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  76486. /**
  76487. * Creates a new CubeTextureAssetTask
  76488. * @param name defines the name of the task
  76489. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76490. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76491. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76492. * @param files defines the explicit list of files (undefined by default)
  76493. */
  76494. constructor(
  76495. /**
  76496. * Defines the name of the task
  76497. */
  76498. name: string,
  76499. /**
  76500. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  76501. */
  76502. url: string,
  76503. /**
  76504. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  76505. */
  76506. extensions?: string[] | undefined,
  76507. /**
  76508. * Defines if mipmaps should not be generated (default is false)
  76509. */
  76510. noMipmap?: boolean | undefined,
  76511. /**
  76512. * Defines the explicit list of files (undefined by default)
  76513. */
  76514. files?: string[] | undefined);
  76515. /**
  76516. * Execute the current task
  76517. * @param scene defines the scene where you want your assets to be loaded
  76518. * @param onSuccess is a callback called when the task is successfully executed
  76519. * @param onError is a callback called if an error occurs
  76520. */
  76521. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76522. }
  76523. /**
  76524. * Define a task used by AssetsManager to load HDR cube textures
  76525. */
  76526. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76527. /**
  76528. * Defines the name of the task
  76529. */
  76530. name: string;
  76531. /**
  76532. * Defines the location of the file to load
  76533. */
  76534. url: string;
  76535. /**
  76536. * Defines the desired size (the more it increases the longer the generation will be)
  76537. */
  76538. size: number;
  76539. /**
  76540. * Defines if mipmaps should not be generated (default is false)
  76541. */
  76542. noMipmap: boolean;
  76543. /**
  76544. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76545. */
  76546. generateHarmonics: boolean;
  76547. /**
  76548. * 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)
  76549. */
  76550. gammaSpace: boolean;
  76551. /**
  76552. * Internal Use Only
  76553. */
  76554. reserved: boolean;
  76555. /**
  76556. * Gets the loaded texture
  76557. */
  76558. texture: HDRCubeTexture;
  76559. /**
  76560. * Callback called when the task is successful
  76561. */
  76562. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76563. /**
  76564. * Callback called when the task is successful
  76565. */
  76566. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76567. /**
  76568. * Creates a new HDRCubeTextureAssetTask object
  76569. * @param name defines the name of the task
  76570. * @param url defines the location of the file to load
  76571. * @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.
  76572. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76573. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76574. * @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)
  76575. * @param reserved Internal use only
  76576. */
  76577. constructor(
  76578. /**
  76579. * Defines the name of the task
  76580. */
  76581. name: string,
  76582. /**
  76583. * Defines the location of the file to load
  76584. */
  76585. url: string,
  76586. /**
  76587. * Defines the desired size (the more it increases the longer the generation will be)
  76588. */
  76589. size: number,
  76590. /**
  76591. * Defines if mipmaps should not be generated (default is false)
  76592. */
  76593. noMipmap?: boolean,
  76594. /**
  76595. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76596. */
  76597. generateHarmonics?: boolean,
  76598. /**
  76599. * 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)
  76600. */
  76601. gammaSpace?: boolean,
  76602. /**
  76603. * Internal Use Only
  76604. */
  76605. reserved?: boolean);
  76606. /**
  76607. * Execute the current task
  76608. * @param scene defines the scene where you want your assets to be loaded
  76609. * @param onSuccess is a callback called when the task is successfully executed
  76610. * @param onError is a callback called if an error occurs
  76611. */
  76612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76613. }
  76614. /**
  76615. * Define a task used by AssetsManager to load Equirectangular cube textures
  76616. */
  76617. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76618. /**
  76619. * Defines the name of the task
  76620. */
  76621. name: string;
  76622. /**
  76623. * Defines the location of the file to load
  76624. */
  76625. url: string;
  76626. /**
  76627. * Defines the desired size (the more it increases the longer the generation will be)
  76628. */
  76629. size: number;
  76630. /**
  76631. * Defines if mipmaps should not be generated (default is false)
  76632. */
  76633. noMipmap: boolean;
  76634. /**
  76635. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76636. * but the standard material would require them in Gamma space) (default is true)
  76637. */
  76638. gammaSpace: boolean;
  76639. /**
  76640. * Gets the loaded texture
  76641. */
  76642. texture: EquiRectangularCubeTexture;
  76643. /**
  76644. * Callback called when the task is successful
  76645. */
  76646. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76647. /**
  76648. * Callback called when the task is successful
  76649. */
  76650. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76651. /**
  76652. * Creates a new EquiRectangularCubeTextureAssetTask object
  76653. * @param name defines the name of the task
  76654. * @param url defines the location of the file to load
  76655. * @param size defines the desired size (the more it increases the longer the generation will be)
  76656. * If the size is omitted this implies you are using a preprocessed cubemap.
  76657. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76658. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76659. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76660. * (default is true)
  76661. */
  76662. constructor(
  76663. /**
  76664. * Defines the name of the task
  76665. */
  76666. name: string,
  76667. /**
  76668. * Defines the location of the file to load
  76669. */
  76670. url: string,
  76671. /**
  76672. * Defines the desired size (the more it increases the longer the generation will be)
  76673. */
  76674. size: number,
  76675. /**
  76676. * Defines if mipmaps should not be generated (default is false)
  76677. */
  76678. noMipmap?: boolean,
  76679. /**
  76680. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76681. * but the standard material would require them in Gamma space) (default is true)
  76682. */
  76683. gammaSpace?: boolean);
  76684. /**
  76685. * Execute the current task
  76686. * @param scene defines the scene where you want your assets to be loaded
  76687. * @param onSuccess is a callback called when the task is successfully executed
  76688. * @param onError is a callback called if an error occurs
  76689. */
  76690. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76691. }
  76692. /**
  76693. * This class can be used to easily import assets into a scene
  76694. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76695. */
  76696. export class AssetsManager {
  76697. private _scene;
  76698. private _isLoading;
  76699. protected _tasks: AbstractAssetTask[];
  76700. protected _waitingTasksCount: number;
  76701. protected _totalTasksCount: number;
  76702. /**
  76703. * Callback called when all tasks are processed
  76704. */
  76705. onFinish: (tasks: AbstractAssetTask[]) => void;
  76706. /**
  76707. * Callback called when a task is successful
  76708. */
  76709. onTaskSuccess: (task: AbstractAssetTask) => void;
  76710. /**
  76711. * Callback called when a task had an error
  76712. */
  76713. onTaskError: (task: AbstractAssetTask) => void;
  76714. /**
  76715. * Callback called when a task is done (whatever the result is)
  76716. */
  76717. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76718. /**
  76719. * Observable called when all tasks are processed
  76720. */
  76721. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76722. /**
  76723. * Observable called when a task had an error
  76724. */
  76725. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76726. /**
  76727. * Observable called when all tasks were executed
  76728. */
  76729. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76730. /**
  76731. * Observable called when a task is done (whatever the result is)
  76732. */
  76733. onProgressObservable: Observable<IAssetsProgressEvent>;
  76734. /**
  76735. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76736. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76737. */
  76738. useDefaultLoadingScreen: boolean;
  76739. /**
  76740. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76741. * when all assets have been downloaded.
  76742. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76743. */
  76744. autoHideLoadingUI: boolean;
  76745. /**
  76746. * Creates a new AssetsManager
  76747. * @param scene defines the scene to work on
  76748. */
  76749. constructor(scene: Scene);
  76750. /**
  76751. * Add a ContainerAssetTask to the list of active tasks
  76752. * @param taskName defines the name of the new task
  76753. * @param meshesNames defines the name of meshes to load
  76754. * @param rootUrl defines the root url to use to locate files
  76755. * @param sceneFilename defines the filename of the scene file
  76756. * @returns a new ContainerAssetTask object
  76757. */
  76758. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  76759. /**
  76760. * Add a MeshAssetTask to the list of active tasks
  76761. * @param taskName defines the name of the new task
  76762. * @param meshesNames defines the name of meshes to load
  76763. * @param rootUrl defines the root url to use to locate files
  76764. * @param sceneFilename defines the filename of the scene file
  76765. * @returns a new MeshAssetTask object
  76766. */
  76767. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76768. /**
  76769. * Add a TextFileAssetTask to the list of active tasks
  76770. * @param taskName defines the name of the new task
  76771. * @param url defines the url of the file to load
  76772. * @returns a new TextFileAssetTask object
  76773. */
  76774. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76775. /**
  76776. * Add a BinaryFileAssetTask to the list of active tasks
  76777. * @param taskName defines the name of the new task
  76778. * @param url defines the url of the file to load
  76779. * @returns a new BinaryFileAssetTask object
  76780. */
  76781. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76782. /**
  76783. * Add a ImageAssetTask to the list of active tasks
  76784. * @param taskName defines the name of the new task
  76785. * @param url defines the url of the file to load
  76786. * @returns a new ImageAssetTask object
  76787. */
  76788. addImageTask(taskName: string, url: string): ImageAssetTask;
  76789. /**
  76790. * Add a TextureAssetTask to the list of active tasks
  76791. * @param taskName defines the name of the new task
  76792. * @param url defines the url of the file to load
  76793. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76794. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76795. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76796. * @returns a new TextureAssetTask object
  76797. */
  76798. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76799. /**
  76800. * Add a CubeTextureAssetTask to the list of active tasks
  76801. * @param taskName defines the name of the new task
  76802. * @param url defines the url of the file to load
  76803. * @param extensions defines the extension to use to load the cube map (can be null)
  76804. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76805. * @param files defines the list of files to load (can be null)
  76806. * @returns a new CubeTextureAssetTask object
  76807. */
  76808. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76809. /**
  76810. *
  76811. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76812. * @param taskName defines the name of the new task
  76813. * @param url defines the url of the file to load
  76814. * @param size defines the size you want for the cubemap (can be null)
  76815. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76816. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76817. * @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)
  76818. * @param reserved Internal use only
  76819. * @returns a new HDRCubeTextureAssetTask object
  76820. */
  76821. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76822. /**
  76823. *
  76824. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76825. * @param taskName defines the name of the new task
  76826. * @param url defines the url of the file to load
  76827. * @param size defines the size you want for the cubemap (can be null)
  76828. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76829. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76830. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76831. * @returns a new EquiRectangularCubeTextureAssetTask object
  76832. */
  76833. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76834. /**
  76835. * Remove a task from the assets manager.
  76836. * @param task the task to remove
  76837. */
  76838. removeTask(task: AbstractAssetTask): void;
  76839. private _decreaseWaitingTasksCount;
  76840. private _runTask;
  76841. /**
  76842. * Reset the AssetsManager and remove all tasks
  76843. * @return the current instance of the AssetsManager
  76844. */
  76845. reset(): AssetsManager;
  76846. /**
  76847. * Start the loading process
  76848. * @return the current instance of the AssetsManager
  76849. */
  76850. load(): AssetsManager;
  76851. /**
  76852. * Start the loading process as an async operation
  76853. * @return a promise returning the list of failed tasks
  76854. */
  76855. loadAsync(): Promise<void>;
  76856. }
  76857. }
  76858. declare module "babylonjs/Misc/deferred" {
  76859. /**
  76860. * Wrapper class for promise with external resolve and reject.
  76861. */
  76862. export class Deferred<T> {
  76863. /**
  76864. * The promise associated with this deferred object.
  76865. */
  76866. readonly promise: Promise<T>;
  76867. private _resolve;
  76868. private _reject;
  76869. /**
  76870. * The resolve method of the promise associated with this deferred object.
  76871. */
  76872. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76873. /**
  76874. * The reject method of the promise associated with this deferred object.
  76875. */
  76876. get reject(): (reason?: any) => void;
  76877. /**
  76878. * Constructor for this deferred object.
  76879. */
  76880. constructor();
  76881. }
  76882. }
  76883. declare module "babylonjs/Misc/meshExploder" {
  76884. import { Mesh } from "babylonjs/Meshes/mesh";
  76885. /**
  76886. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76887. */
  76888. export class MeshExploder {
  76889. private _centerMesh;
  76890. private _meshes;
  76891. private _meshesOrigins;
  76892. private _toCenterVectors;
  76893. private _scaledDirection;
  76894. private _newPosition;
  76895. private _centerPosition;
  76896. /**
  76897. * Explodes meshes from a center mesh.
  76898. * @param meshes The meshes to explode.
  76899. * @param centerMesh The mesh to be center of explosion.
  76900. */
  76901. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76902. private _setCenterMesh;
  76903. /**
  76904. * Get class name
  76905. * @returns "MeshExploder"
  76906. */
  76907. getClassName(): string;
  76908. /**
  76909. * "Exploded meshes"
  76910. * @returns Array of meshes with the centerMesh at index 0.
  76911. */
  76912. getMeshes(): Array<Mesh>;
  76913. /**
  76914. * Explodes meshes giving a specific direction
  76915. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76916. */
  76917. explode(direction?: number): void;
  76918. }
  76919. }
  76920. declare module "babylonjs/Misc/filesInput" {
  76921. import { Engine } from "babylonjs/Engines/engine";
  76922. import { Scene } from "babylonjs/scene";
  76923. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76924. import { Nullable } from "babylonjs/types";
  76925. /**
  76926. * Class used to help managing file picking and drag'n'drop
  76927. */
  76928. export class FilesInput {
  76929. /**
  76930. * List of files ready to be loaded
  76931. */
  76932. static get FilesToLoad(): {
  76933. [key: string]: File;
  76934. };
  76935. /**
  76936. * Callback called when a file is processed
  76937. */
  76938. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76939. private _engine;
  76940. private _currentScene;
  76941. private _sceneLoadedCallback;
  76942. private _progressCallback;
  76943. private _additionalRenderLoopLogicCallback;
  76944. private _textureLoadingCallback;
  76945. private _startingProcessingFilesCallback;
  76946. private _onReloadCallback;
  76947. private _errorCallback;
  76948. private _elementToMonitor;
  76949. private _sceneFileToLoad;
  76950. private _filesToLoad;
  76951. /**
  76952. * Creates a new FilesInput
  76953. * @param engine defines the rendering engine
  76954. * @param scene defines the hosting scene
  76955. * @param sceneLoadedCallback callback called when scene is loaded
  76956. * @param progressCallback callback called to track progress
  76957. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76958. * @param textureLoadingCallback callback called when a texture is loading
  76959. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76960. * @param onReloadCallback callback called when a reload is requested
  76961. * @param errorCallback callback call if an error occurs
  76962. */
  76963. 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>);
  76964. private _dragEnterHandler;
  76965. private _dragOverHandler;
  76966. private _dropHandler;
  76967. /**
  76968. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76969. * @param elementToMonitor defines the DOM element to track
  76970. */
  76971. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76972. /** Gets the current list of files to load */
  76973. get filesToLoad(): File[];
  76974. /**
  76975. * Release all associated resources
  76976. */
  76977. dispose(): void;
  76978. private renderFunction;
  76979. private drag;
  76980. private drop;
  76981. private _traverseFolder;
  76982. private _processFiles;
  76983. /**
  76984. * Load files from a drop event
  76985. * @param event defines the drop event to use as source
  76986. */
  76987. loadFiles(event: any): void;
  76988. private _processReload;
  76989. /**
  76990. * Reload the current scene from the loaded files
  76991. */
  76992. reload(): void;
  76993. }
  76994. }
  76995. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76996. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76997. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76998. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76999. }
  77000. declare module "babylonjs/Misc/sceneOptimizer" {
  77001. import { Scene, IDisposable } from "babylonjs/scene";
  77002. import { Observable } from "babylonjs/Misc/observable";
  77003. /**
  77004. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77005. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77006. */
  77007. export class SceneOptimization {
  77008. /**
  77009. * Defines the priority of this optimization (0 by default which means first in the list)
  77010. */
  77011. priority: number;
  77012. /**
  77013. * Gets a string describing the action executed by the current optimization
  77014. * @returns description string
  77015. */
  77016. getDescription(): string;
  77017. /**
  77018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77019. * @param scene defines the current scene where to apply this optimization
  77020. * @param optimizer defines the current optimizer
  77021. * @returns true if everything that can be done was applied
  77022. */
  77023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77024. /**
  77025. * Creates the SceneOptimization object
  77026. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77027. * @param desc defines the description associated with the optimization
  77028. */
  77029. constructor(
  77030. /**
  77031. * Defines the priority of this optimization (0 by default which means first in the list)
  77032. */
  77033. priority?: number);
  77034. }
  77035. /**
  77036. * Defines an optimization used to reduce the size of render target textures
  77037. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77038. */
  77039. export class TextureOptimization extends SceneOptimization {
  77040. /**
  77041. * Defines the priority of this optimization (0 by default which means first in the list)
  77042. */
  77043. priority: number;
  77044. /**
  77045. * 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
  77046. */
  77047. maximumSize: number;
  77048. /**
  77049. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77050. */
  77051. step: number;
  77052. /**
  77053. * Gets a string describing the action executed by the current optimization
  77054. * @returns description string
  77055. */
  77056. getDescription(): string;
  77057. /**
  77058. * Creates the TextureOptimization object
  77059. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77060. * @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
  77061. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77062. */
  77063. constructor(
  77064. /**
  77065. * Defines the priority of this optimization (0 by default which means first in the list)
  77066. */
  77067. priority?: number,
  77068. /**
  77069. * 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
  77070. */
  77071. maximumSize?: number,
  77072. /**
  77073. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77074. */
  77075. step?: number);
  77076. /**
  77077. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77078. * @param scene defines the current scene where to apply this optimization
  77079. * @param optimizer defines the current optimizer
  77080. * @returns true if everything that can be done was applied
  77081. */
  77082. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77083. }
  77084. /**
  77085. * Defines an optimization used to increase or decrease the rendering resolution
  77086. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77087. */
  77088. export class HardwareScalingOptimization extends SceneOptimization {
  77089. /**
  77090. * Defines the priority of this optimization (0 by default which means first in the list)
  77091. */
  77092. priority: number;
  77093. /**
  77094. * Defines the maximum scale to use (2 by default)
  77095. */
  77096. maximumScale: number;
  77097. /**
  77098. * Defines the step to use between two passes (0.5 by default)
  77099. */
  77100. step: number;
  77101. private _currentScale;
  77102. private _directionOffset;
  77103. /**
  77104. * Gets a string describing the action executed by the current optimization
  77105. * @return description string
  77106. */
  77107. getDescription(): string;
  77108. /**
  77109. * Creates the HardwareScalingOptimization object
  77110. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77111. * @param maximumScale defines the maximum scale to use (2 by default)
  77112. * @param step defines the step to use between two passes (0.5 by default)
  77113. */
  77114. constructor(
  77115. /**
  77116. * Defines the priority of this optimization (0 by default which means first in the list)
  77117. */
  77118. priority?: number,
  77119. /**
  77120. * Defines the maximum scale to use (2 by default)
  77121. */
  77122. maximumScale?: number,
  77123. /**
  77124. * Defines the step to use between two passes (0.5 by default)
  77125. */
  77126. step?: number);
  77127. /**
  77128. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77129. * @param scene defines the current scene where to apply this optimization
  77130. * @param optimizer defines the current optimizer
  77131. * @returns true if everything that can be done was applied
  77132. */
  77133. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77134. }
  77135. /**
  77136. * Defines an optimization used to remove shadows
  77137. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77138. */
  77139. export class ShadowsOptimization extends SceneOptimization {
  77140. /**
  77141. * Gets a string describing the action executed by the current optimization
  77142. * @return description string
  77143. */
  77144. getDescription(): string;
  77145. /**
  77146. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77147. * @param scene defines the current scene where to apply this optimization
  77148. * @param optimizer defines the current optimizer
  77149. * @returns true if everything that can be done was applied
  77150. */
  77151. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77152. }
  77153. /**
  77154. * Defines an optimization used to turn post-processes off
  77155. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77156. */
  77157. export class PostProcessesOptimization extends SceneOptimization {
  77158. /**
  77159. * Gets a string describing the action executed by the current optimization
  77160. * @return description string
  77161. */
  77162. getDescription(): string;
  77163. /**
  77164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77165. * @param scene defines the current scene where to apply this optimization
  77166. * @param optimizer defines the current optimizer
  77167. * @returns true if everything that can be done was applied
  77168. */
  77169. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77170. }
  77171. /**
  77172. * Defines an optimization used to turn lens flares off
  77173. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77174. */
  77175. export class LensFlaresOptimization extends SceneOptimization {
  77176. /**
  77177. * Gets a string describing the action executed by the current optimization
  77178. * @return description string
  77179. */
  77180. getDescription(): string;
  77181. /**
  77182. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77183. * @param scene defines the current scene where to apply this optimization
  77184. * @param optimizer defines the current optimizer
  77185. * @returns true if everything that can be done was applied
  77186. */
  77187. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77188. }
  77189. /**
  77190. * Defines an optimization based on user defined callback.
  77191. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77192. */
  77193. export class CustomOptimization extends SceneOptimization {
  77194. /**
  77195. * Callback called to apply the custom optimization.
  77196. */
  77197. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77198. /**
  77199. * Callback called to get custom description
  77200. */
  77201. onGetDescription: () => string;
  77202. /**
  77203. * Gets a string describing the action executed by the current optimization
  77204. * @returns description string
  77205. */
  77206. getDescription(): string;
  77207. /**
  77208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77209. * @param scene defines the current scene where to apply this optimization
  77210. * @param optimizer defines the current optimizer
  77211. * @returns true if everything that can be done was applied
  77212. */
  77213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77214. }
  77215. /**
  77216. * Defines an optimization used to turn particles off
  77217. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77218. */
  77219. export class ParticlesOptimization extends SceneOptimization {
  77220. /**
  77221. * Gets a string describing the action executed by the current optimization
  77222. * @return description string
  77223. */
  77224. getDescription(): string;
  77225. /**
  77226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77227. * @param scene defines the current scene where to apply this optimization
  77228. * @param optimizer defines the current optimizer
  77229. * @returns true if everything that can be done was applied
  77230. */
  77231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77232. }
  77233. /**
  77234. * Defines an optimization used to turn render targets off
  77235. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77236. */
  77237. export class RenderTargetsOptimization extends SceneOptimization {
  77238. /**
  77239. * Gets a string describing the action executed by the current optimization
  77240. * @return description string
  77241. */
  77242. getDescription(): string;
  77243. /**
  77244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77245. * @param scene defines the current scene where to apply this optimization
  77246. * @param optimizer defines the current optimizer
  77247. * @returns true if everything that can be done was applied
  77248. */
  77249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77250. }
  77251. /**
  77252. * Defines an optimization used to merge meshes with compatible materials
  77253. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77254. */
  77255. export class MergeMeshesOptimization extends SceneOptimization {
  77256. private static _UpdateSelectionTree;
  77257. /**
  77258. * Gets or sets a boolean which defines if optimization octree has to be updated
  77259. */
  77260. static get UpdateSelectionTree(): boolean;
  77261. /**
  77262. * Gets or sets a boolean which defines if optimization octree has to be updated
  77263. */
  77264. static set UpdateSelectionTree(value: boolean);
  77265. /**
  77266. * Gets a string describing the action executed by the current optimization
  77267. * @return description string
  77268. */
  77269. getDescription(): string;
  77270. private _canBeMerged;
  77271. /**
  77272. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77273. * @param scene defines the current scene where to apply this optimization
  77274. * @param optimizer defines the current optimizer
  77275. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77276. * @returns true if everything that can be done was applied
  77277. */
  77278. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77279. }
  77280. /**
  77281. * Defines a list of options used by SceneOptimizer
  77282. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77283. */
  77284. export class SceneOptimizerOptions {
  77285. /**
  77286. * Defines the target frame rate to reach (60 by default)
  77287. */
  77288. targetFrameRate: number;
  77289. /**
  77290. * Defines the interval between two checkes (2000ms by default)
  77291. */
  77292. trackerDuration: number;
  77293. /**
  77294. * Gets the list of optimizations to apply
  77295. */
  77296. optimizations: SceneOptimization[];
  77297. /**
  77298. * Creates a new list of options used by SceneOptimizer
  77299. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77300. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77301. */
  77302. constructor(
  77303. /**
  77304. * Defines the target frame rate to reach (60 by default)
  77305. */
  77306. targetFrameRate?: number,
  77307. /**
  77308. * Defines the interval between two checkes (2000ms by default)
  77309. */
  77310. trackerDuration?: number);
  77311. /**
  77312. * Add a new optimization
  77313. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77314. * @returns the current SceneOptimizerOptions
  77315. */
  77316. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77317. /**
  77318. * Add a new custom optimization
  77319. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77320. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77321. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77322. * @returns the current SceneOptimizerOptions
  77323. */
  77324. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77325. /**
  77326. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77327. * @param targetFrameRate defines the target frame rate (60 by default)
  77328. * @returns a SceneOptimizerOptions object
  77329. */
  77330. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77331. /**
  77332. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77333. * @param targetFrameRate defines the target frame rate (60 by default)
  77334. * @returns a SceneOptimizerOptions object
  77335. */
  77336. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77337. /**
  77338. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77339. * @param targetFrameRate defines the target frame rate (60 by default)
  77340. * @returns a SceneOptimizerOptions object
  77341. */
  77342. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77343. }
  77344. /**
  77345. * Class used to run optimizations in order to reach a target frame rate
  77346. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77347. */
  77348. export class SceneOptimizer implements IDisposable {
  77349. private _isRunning;
  77350. private _options;
  77351. private _scene;
  77352. private _currentPriorityLevel;
  77353. private _targetFrameRate;
  77354. private _trackerDuration;
  77355. private _currentFrameRate;
  77356. private _sceneDisposeObserver;
  77357. private _improvementMode;
  77358. /**
  77359. * Defines an observable called when the optimizer reaches the target frame rate
  77360. */
  77361. onSuccessObservable: Observable<SceneOptimizer>;
  77362. /**
  77363. * Defines an observable called when the optimizer enables an optimization
  77364. */
  77365. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77366. /**
  77367. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77368. */
  77369. onFailureObservable: Observable<SceneOptimizer>;
  77370. /**
  77371. * Gets a boolean indicating if the optimizer is in improvement mode
  77372. */
  77373. get isInImprovementMode(): boolean;
  77374. /**
  77375. * Gets the current priority level (0 at start)
  77376. */
  77377. get currentPriorityLevel(): number;
  77378. /**
  77379. * Gets the current frame rate checked by the SceneOptimizer
  77380. */
  77381. get currentFrameRate(): number;
  77382. /**
  77383. * Gets or sets the current target frame rate (60 by default)
  77384. */
  77385. get targetFrameRate(): number;
  77386. /**
  77387. * Gets or sets the current target frame rate (60 by default)
  77388. */
  77389. set targetFrameRate(value: number);
  77390. /**
  77391. * Gets or sets the current interval between two checks (every 2000ms by default)
  77392. */
  77393. get trackerDuration(): number;
  77394. /**
  77395. * Gets or sets the current interval between two checks (every 2000ms by default)
  77396. */
  77397. set trackerDuration(value: number);
  77398. /**
  77399. * Gets the list of active optimizations
  77400. */
  77401. get optimizations(): SceneOptimization[];
  77402. /**
  77403. * Creates a new SceneOptimizer
  77404. * @param scene defines the scene to work on
  77405. * @param options defines the options to use with the SceneOptimizer
  77406. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77407. * @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)
  77408. */
  77409. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77410. /**
  77411. * Stops the current optimizer
  77412. */
  77413. stop(): void;
  77414. /**
  77415. * Reset the optimizer to initial step (current priority level = 0)
  77416. */
  77417. reset(): void;
  77418. /**
  77419. * Start the optimizer. By default it will try to reach a specific framerate
  77420. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77421. */
  77422. start(): void;
  77423. private _checkCurrentState;
  77424. /**
  77425. * Release all resources
  77426. */
  77427. dispose(): void;
  77428. /**
  77429. * Helper function to create a SceneOptimizer with one single line of code
  77430. * @param scene defines the scene to work on
  77431. * @param options defines the options to use with the SceneOptimizer
  77432. * @param onSuccess defines a callback to call on success
  77433. * @param onFailure defines a callback to call on failure
  77434. * @returns the new SceneOptimizer object
  77435. */
  77436. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  77437. }
  77438. }
  77439. declare module "babylonjs/Misc/sceneSerializer" {
  77440. import { Scene } from "babylonjs/scene";
  77441. /**
  77442. * Class used to serialize a scene into a string
  77443. */
  77444. export class SceneSerializer {
  77445. /**
  77446. * Clear cache used by a previous serialization
  77447. */
  77448. static ClearCache(): void;
  77449. /**
  77450. * Serialize a scene into a JSON compatible object
  77451. * @param scene defines the scene to serialize
  77452. * @returns a JSON compatible object
  77453. */
  77454. static Serialize(scene: Scene): any;
  77455. /**
  77456. * Serialize a mesh into a JSON compatible object
  77457. * @param toSerialize defines the mesh to serialize
  77458. * @param withParents defines if parents must be serialized as well
  77459. * @param withChildren defines if children must be serialized as well
  77460. * @returns a JSON compatible object
  77461. */
  77462. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  77463. }
  77464. }
  77465. declare module "babylonjs/Misc/textureTools" {
  77466. import { Texture } from "babylonjs/Materials/Textures/texture";
  77467. /**
  77468. * Class used to host texture specific utilities
  77469. */
  77470. export class TextureTools {
  77471. /**
  77472. * Uses the GPU to create a copy texture rescaled at a given size
  77473. * @param texture Texture to copy from
  77474. * @param width defines the desired width
  77475. * @param height defines the desired height
  77476. * @param useBilinearMode defines if bilinear mode has to be used
  77477. * @return the generated texture
  77478. */
  77479. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  77480. }
  77481. }
  77482. declare module "babylonjs/Misc/videoRecorder" {
  77483. import { Nullable } from "babylonjs/types";
  77484. import { Engine } from "babylonjs/Engines/engine";
  77485. /**
  77486. * This represents the different options available for the video capture.
  77487. */
  77488. export interface VideoRecorderOptions {
  77489. /** Defines the mime type of the video. */
  77490. mimeType: string;
  77491. /** Defines the FPS the video should be recorded at. */
  77492. fps: number;
  77493. /** Defines the chunk size for the recording data. */
  77494. recordChunckSize: number;
  77495. /** The audio tracks to attach to the recording. */
  77496. audioTracks?: MediaStreamTrack[];
  77497. }
  77498. /**
  77499. * This can help with recording videos from BabylonJS.
  77500. * This is based on the available WebRTC functionalities of the browser.
  77501. *
  77502. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  77503. */
  77504. export class VideoRecorder {
  77505. private static readonly _defaultOptions;
  77506. /**
  77507. * Returns whether or not the VideoRecorder is available in your browser.
  77508. * @param engine Defines the Babylon Engine.
  77509. * @returns true if supported otherwise false.
  77510. */
  77511. static IsSupported(engine: Engine): boolean;
  77512. private readonly _options;
  77513. private _canvas;
  77514. private _mediaRecorder;
  77515. private _recordedChunks;
  77516. private _fileName;
  77517. private _resolve;
  77518. private _reject;
  77519. /**
  77520. * True when a recording is already in progress.
  77521. */
  77522. get isRecording(): boolean;
  77523. /**
  77524. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  77525. * @param engine Defines the BabylonJS Engine you wish to record.
  77526. * @param options Defines options that can be used to customize the capture.
  77527. */
  77528. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  77529. /**
  77530. * Stops the current recording before the default capture timeout passed in the startRecording function.
  77531. */
  77532. stopRecording(): void;
  77533. /**
  77534. * Starts recording the canvas for a max duration specified in parameters.
  77535. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77536. * If null no automatic download will start and you can rely on the promise to get the data back.
  77537. * @param maxDuration Defines the maximum recording time in seconds.
  77538. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77539. * @return A promise callback at the end of the recording with the video data in Blob.
  77540. */
  77541. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77542. /**
  77543. * Releases internal resources used during the recording.
  77544. */
  77545. dispose(): void;
  77546. private _handleDataAvailable;
  77547. private _handleError;
  77548. private _handleStop;
  77549. }
  77550. }
  77551. declare module "babylonjs/Misc/screenshotTools" {
  77552. import { Camera } from "babylonjs/Cameras/camera";
  77553. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77554. import { Engine } from "babylonjs/Engines/engine";
  77555. /**
  77556. * Class containing a set of static utilities functions for screenshots
  77557. */
  77558. export class ScreenshotTools {
  77559. /**
  77560. * Captures a screenshot of the current rendering
  77561. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77562. * @param engine defines the rendering engine
  77563. * @param camera defines the source camera
  77564. * @param size This parameter can be set to a single number or to an object with the
  77565. * following (optional) properties: precision, width, height. If a single number is passed,
  77566. * it will be used for both width and height. If an object is passed, the screenshot size
  77567. * will be derived from the parameters. The precision property is a multiplier allowing
  77568. * rendering at a higher or lower resolution
  77569. * @param successCallback defines the callback receives a single parameter which contains the
  77570. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77571. * src parameter of an <img> to display it
  77572. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77573. * Check your browser for supported MIME types
  77574. */
  77575. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77576. /**
  77577. * Captures a screenshot of the current rendering
  77578. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77579. * @param engine defines the rendering engine
  77580. * @param camera defines the source camera
  77581. * @param size This parameter can be set to a single number or to an object with the
  77582. * following (optional) properties: precision, width, height. If a single number is passed,
  77583. * it will be used for both width and height. If an object is passed, the screenshot size
  77584. * will be derived from the parameters. The precision property is a multiplier allowing
  77585. * rendering at a higher or lower resolution
  77586. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77587. * Check your browser for supported MIME types
  77588. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77589. * to the src parameter of an <img> to display it
  77590. */
  77591. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77592. /**
  77593. * Generates an image screenshot from the specified camera.
  77594. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77595. * @param engine The engine to use for rendering
  77596. * @param camera The camera to use for rendering
  77597. * @param size This parameter can be set to a single number or to an object with the
  77598. * following (optional) properties: precision, width, height. If a single number is passed,
  77599. * it will be used for both width and height. If an object is passed, the screenshot size
  77600. * will be derived from the parameters. The precision property is a multiplier allowing
  77601. * rendering at a higher or lower resolution
  77602. * @param successCallback The callback receives a single parameter which contains the
  77603. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77604. * src parameter of an <img> to display it
  77605. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77606. * Check your browser for supported MIME types
  77607. * @param samples Texture samples (default: 1)
  77608. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77609. * @param fileName A name for for the downloaded file.
  77610. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77611. */
  77612. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77613. /**
  77614. * Generates an image screenshot from the specified camera.
  77615. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77616. * @param engine The engine to use for rendering
  77617. * @param camera The camera to use for rendering
  77618. * @param size This parameter can be set to a single number or to an object with the
  77619. * following (optional) properties: precision, width, height. If a single number is passed,
  77620. * it will be used for both width and height. If an object is passed, the screenshot size
  77621. * will be derived from the parameters. The precision property is a multiplier allowing
  77622. * rendering at a higher or lower resolution
  77623. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77624. * Check your browser for supported MIME types
  77625. * @param samples Texture samples (default: 1)
  77626. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77627. * @param fileName A name for for the downloaded file.
  77628. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77629. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77630. * to the src parameter of an <img> to display it
  77631. */
  77632. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77633. /**
  77634. * Gets height and width for screenshot size
  77635. * @private
  77636. */
  77637. private static _getScreenshotSize;
  77638. }
  77639. }
  77640. declare module "babylonjs/Misc/dataReader" {
  77641. /**
  77642. * Interface for a data buffer
  77643. */
  77644. export interface IDataBuffer {
  77645. /**
  77646. * Reads bytes from the data buffer.
  77647. * @param byteOffset The byte offset to read
  77648. * @param byteLength The byte length to read
  77649. * @returns A promise that resolves when the bytes are read
  77650. */
  77651. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77652. /**
  77653. * The byte length of the buffer.
  77654. */
  77655. readonly byteLength: number;
  77656. }
  77657. /**
  77658. * Utility class for reading from a data buffer
  77659. */
  77660. export class DataReader {
  77661. /**
  77662. * The data buffer associated with this data reader.
  77663. */
  77664. readonly buffer: IDataBuffer;
  77665. /**
  77666. * The current byte offset from the beginning of the data buffer.
  77667. */
  77668. byteOffset: number;
  77669. private _dataView;
  77670. private _dataByteOffset;
  77671. /**
  77672. * Constructor
  77673. * @param buffer The buffer to read
  77674. */
  77675. constructor(buffer: IDataBuffer);
  77676. /**
  77677. * Loads the given byte length.
  77678. * @param byteLength The byte length to load
  77679. * @returns A promise that resolves when the load is complete
  77680. */
  77681. loadAsync(byteLength: number): Promise<void>;
  77682. /**
  77683. * Read a unsigned 32-bit integer from the currently loaded data range.
  77684. * @returns The 32-bit integer read
  77685. */
  77686. readUint32(): number;
  77687. /**
  77688. * Read a byte array from the currently loaded data range.
  77689. * @param byteLength The byte length to read
  77690. * @returns The byte array read
  77691. */
  77692. readUint8Array(byteLength: number): Uint8Array;
  77693. /**
  77694. * Read a string from the currently loaded data range.
  77695. * @param byteLength The byte length to read
  77696. * @returns The string read
  77697. */
  77698. readString(byteLength: number): string;
  77699. /**
  77700. * Skips the given byte length the currently loaded data range.
  77701. * @param byteLength The byte length to skip
  77702. */
  77703. skipBytes(byteLength: number): void;
  77704. }
  77705. }
  77706. declare module "babylonjs/Misc/dataStorage" {
  77707. /**
  77708. * Class for storing data to local storage if available or in-memory storage otherwise
  77709. */
  77710. export class DataStorage {
  77711. private static _Storage;
  77712. private static _GetStorage;
  77713. /**
  77714. * Reads a string from the data storage
  77715. * @param key The key to read
  77716. * @param defaultValue The value if the key doesn't exist
  77717. * @returns The string value
  77718. */
  77719. static ReadString(key: string, defaultValue: string): string;
  77720. /**
  77721. * Writes a string to the data storage
  77722. * @param key The key to write
  77723. * @param value The value to write
  77724. */
  77725. static WriteString(key: string, value: string): void;
  77726. /**
  77727. * Reads a boolean from the data storage
  77728. * @param key The key to read
  77729. * @param defaultValue The value if the key doesn't exist
  77730. * @returns The boolean value
  77731. */
  77732. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77733. /**
  77734. * Writes a boolean to the data storage
  77735. * @param key The key to write
  77736. * @param value The value to write
  77737. */
  77738. static WriteBoolean(key: string, value: boolean): void;
  77739. /**
  77740. * Reads a number from the data storage
  77741. * @param key The key to read
  77742. * @param defaultValue The value if the key doesn't exist
  77743. * @returns The number value
  77744. */
  77745. static ReadNumber(key: string, defaultValue: number): number;
  77746. /**
  77747. * Writes a number to the data storage
  77748. * @param key The key to write
  77749. * @param value The value to write
  77750. */
  77751. static WriteNumber(key: string, value: number): void;
  77752. }
  77753. }
  77754. declare module "babylonjs/Misc/sceneRecorder" {
  77755. import { Scene } from "babylonjs/scene";
  77756. /**
  77757. * Class used to record delta files between 2 scene states
  77758. */
  77759. export class SceneRecorder {
  77760. private _trackedScene;
  77761. private _savedJSON;
  77762. /**
  77763. * Track a given scene. This means the current scene state will be considered the original state
  77764. * @param scene defines the scene to track
  77765. */
  77766. track(scene: Scene): void;
  77767. /**
  77768. * Get the delta between current state and original state
  77769. * @returns a string containing the delta
  77770. */
  77771. getDelta(): any;
  77772. private _compareArray;
  77773. private _compareObjects;
  77774. private _compareCollections;
  77775. private static GetShadowGeneratorById;
  77776. /**
  77777. * Apply a given delta to a given scene
  77778. * @param deltaJSON defines the JSON containing the delta
  77779. * @param scene defines the scene to apply the delta to
  77780. */
  77781. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  77782. private static _ApplyPropertiesToEntity;
  77783. private static _ApplyDeltaForEntity;
  77784. }
  77785. }
  77786. declare module "babylonjs/Misc/index" {
  77787. export * from "babylonjs/Misc/andOrNotEvaluator";
  77788. export * from "babylonjs/Misc/assetsManager";
  77789. export * from "babylonjs/Misc/basis";
  77790. export * from "babylonjs/Misc/dds";
  77791. export * from "babylonjs/Misc/decorators";
  77792. export * from "babylonjs/Misc/deferred";
  77793. export * from "babylonjs/Misc/environmentTextureTools";
  77794. export * from "babylonjs/Misc/meshExploder";
  77795. export * from "babylonjs/Misc/filesInput";
  77796. export * from "babylonjs/Misc/HighDynamicRange/index";
  77797. export * from "babylonjs/Misc/khronosTextureContainer";
  77798. export * from "babylonjs/Misc/observable";
  77799. export * from "babylonjs/Misc/performanceMonitor";
  77800. export * from "babylonjs/Misc/promise";
  77801. export * from "babylonjs/Misc/sceneOptimizer";
  77802. export * from "babylonjs/Misc/sceneSerializer";
  77803. export * from "babylonjs/Misc/smartArray";
  77804. export * from "babylonjs/Misc/stringDictionary";
  77805. export * from "babylonjs/Misc/tags";
  77806. export * from "babylonjs/Misc/textureTools";
  77807. export * from "babylonjs/Misc/tga";
  77808. export * from "babylonjs/Misc/tools";
  77809. export * from "babylonjs/Misc/videoRecorder";
  77810. export * from "babylonjs/Misc/virtualJoystick";
  77811. export * from "babylonjs/Misc/workerPool";
  77812. export * from "babylonjs/Misc/logger";
  77813. export * from "babylonjs/Misc/typeStore";
  77814. export * from "babylonjs/Misc/filesInputStore";
  77815. export * from "babylonjs/Misc/deepCopier";
  77816. export * from "babylonjs/Misc/pivotTools";
  77817. export * from "babylonjs/Misc/precisionDate";
  77818. export * from "babylonjs/Misc/screenshotTools";
  77819. export * from "babylonjs/Misc/typeStore";
  77820. export * from "babylonjs/Misc/webRequest";
  77821. export * from "babylonjs/Misc/iInspectable";
  77822. export * from "babylonjs/Misc/brdfTextureTools";
  77823. export * from "babylonjs/Misc/rgbdTextureTools";
  77824. export * from "babylonjs/Misc/gradients";
  77825. export * from "babylonjs/Misc/perfCounter";
  77826. export * from "babylonjs/Misc/fileRequest";
  77827. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77828. export * from "babylonjs/Misc/retryStrategy";
  77829. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77830. export * from "babylonjs/Misc/canvasGenerator";
  77831. export * from "babylonjs/Misc/fileTools";
  77832. export * from "babylonjs/Misc/stringTools";
  77833. export * from "babylonjs/Misc/dataReader";
  77834. export * from "babylonjs/Misc/minMaxReducer";
  77835. export * from "babylonjs/Misc/depthReducer";
  77836. export * from "babylonjs/Misc/dataStorage";
  77837. export * from "babylonjs/Misc/sceneRecorder";
  77838. }
  77839. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77840. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77841. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77842. import { Observable } from "babylonjs/Misc/observable";
  77843. import { Matrix } from "babylonjs/Maths/math.vector";
  77844. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77845. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77846. /**
  77847. * An interface for all Hit test features
  77848. */
  77849. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77850. /**
  77851. * Triggered when new babylon (transformed) hit test results are available
  77852. */
  77853. onHitTestResultObservable: Observable<T[]>;
  77854. }
  77855. /**
  77856. * Options used for hit testing
  77857. */
  77858. export interface IWebXRLegacyHitTestOptions {
  77859. /**
  77860. * Only test when user interacted with the scene. Default - hit test every frame
  77861. */
  77862. testOnPointerDownOnly?: boolean;
  77863. /**
  77864. * The node to use to transform the local results to world coordinates
  77865. */
  77866. worldParentNode?: TransformNode;
  77867. }
  77868. /**
  77869. * Interface defining the babylon result of raycasting/hit-test
  77870. */
  77871. export interface IWebXRLegacyHitResult {
  77872. /**
  77873. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77874. */
  77875. transformationMatrix: Matrix;
  77876. /**
  77877. * The native hit test result
  77878. */
  77879. xrHitResult: XRHitResult | XRHitTestResult;
  77880. }
  77881. /**
  77882. * The currently-working hit-test module.
  77883. * Hit test (or Ray-casting) is used to interact with the real world.
  77884. * For further information read here - https://github.com/immersive-web/hit-test
  77885. */
  77886. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77887. /**
  77888. * options to use when constructing this feature
  77889. */
  77890. readonly options: IWebXRLegacyHitTestOptions;
  77891. private _direction;
  77892. private _mat;
  77893. private _onSelectEnabled;
  77894. private _origin;
  77895. /**
  77896. * The module's name
  77897. */
  77898. static readonly Name: string;
  77899. /**
  77900. * The (Babylon) version of this module.
  77901. * This is an integer representing the implementation version.
  77902. * This number does not correspond to the WebXR specs version
  77903. */
  77904. static readonly Version: number;
  77905. /**
  77906. * Populated with the last native XR Hit Results
  77907. */
  77908. lastNativeXRHitResults: XRHitResult[];
  77909. /**
  77910. * Triggered when new babylon (transformed) hit test results are available
  77911. */
  77912. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77913. /**
  77914. * Creates a new instance of the (legacy version) hit test feature
  77915. * @param _xrSessionManager an instance of WebXRSessionManager
  77916. * @param options options to use when constructing this feature
  77917. */
  77918. constructor(_xrSessionManager: WebXRSessionManager,
  77919. /**
  77920. * options to use when constructing this feature
  77921. */
  77922. options?: IWebXRLegacyHitTestOptions);
  77923. /**
  77924. * execute a hit test with an XR Ray
  77925. *
  77926. * @param xrSession a native xrSession that will execute this hit test
  77927. * @param xrRay the ray (position and direction) to use for ray-casting
  77928. * @param referenceSpace native XR reference space to use for the hit-test
  77929. * @param filter filter function that will filter the results
  77930. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77931. */
  77932. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77933. /**
  77934. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77935. * @param event the (select) event to use to select with
  77936. * @param referenceSpace the reference space to use for this hit test
  77937. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77938. */
  77939. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77940. /**
  77941. * attach this feature
  77942. * Will usually be called by the features manager
  77943. *
  77944. * @returns true if successful.
  77945. */
  77946. attach(): boolean;
  77947. /**
  77948. * detach this feature.
  77949. * Will usually be called by the features manager
  77950. *
  77951. * @returns true if successful.
  77952. */
  77953. detach(): boolean;
  77954. /**
  77955. * Dispose this feature and all of the resources attached
  77956. */
  77957. dispose(): void;
  77958. protected _onXRFrame(frame: XRFrame): void;
  77959. private _onHitTestResults;
  77960. private _onSelect;
  77961. }
  77962. }
  77963. declare module "babylonjs/XR/features/WebXRHitTest" {
  77964. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77965. import { Observable } from "babylonjs/Misc/observable";
  77966. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77967. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77968. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77969. /**
  77970. * Options used for hit testing (version 2)
  77971. */
  77972. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77973. /**
  77974. * Do not create a permanent hit test. Will usually be used when only
  77975. * transient inputs are needed.
  77976. */
  77977. disablePermanentHitTest?: boolean;
  77978. /**
  77979. * Enable transient (for example touch-based) hit test inspections
  77980. */
  77981. enableTransientHitTest?: boolean;
  77982. /**
  77983. * Offset ray for the permanent hit test
  77984. */
  77985. offsetRay?: Vector3;
  77986. /**
  77987. * Offset ray for the transient hit test
  77988. */
  77989. transientOffsetRay?: Vector3;
  77990. /**
  77991. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77992. */
  77993. useReferenceSpace?: boolean;
  77994. }
  77995. /**
  77996. * Interface defining the babylon result of hit-test
  77997. */
  77998. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77999. /**
  78000. * The input source that generated this hit test (if transient)
  78001. */
  78002. inputSource?: XRInputSource;
  78003. /**
  78004. * Is this a transient hit test
  78005. */
  78006. isTransient?: boolean;
  78007. /**
  78008. * Position of the hit test result
  78009. */
  78010. position: Vector3;
  78011. /**
  78012. * Rotation of the hit test result
  78013. */
  78014. rotationQuaternion: Quaternion;
  78015. /**
  78016. * The native hit test result
  78017. */
  78018. xrHitResult: XRHitTestResult;
  78019. }
  78020. /**
  78021. * The currently-working hit-test module.
  78022. * Hit test (or Ray-casting) is used to interact with the real world.
  78023. * For further information read here - https://github.com/immersive-web/hit-test
  78024. *
  78025. * Tested on chrome (mobile) 80.
  78026. */
  78027. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78028. /**
  78029. * options to use when constructing this feature
  78030. */
  78031. readonly options: IWebXRHitTestOptions;
  78032. private _tmpMat;
  78033. private _tmpPos;
  78034. private _tmpQuat;
  78035. private _transientXrHitTestSource;
  78036. private _xrHitTestSource;
  78037. private initHitTestSource;
  78038. /**
  78039. * The module's name
  78040. */
  78041. static readonly Name: string;
  78042. /**
  78043. * The (Babylon) version of this module.
  78044. * This is an integer representing the implementation version.
  78045. * This number does not correspond to the WebXR specs version
  78046. */
  78047. static readonly Version: number;
  78048. /**
  78049. * When set to true, each hit test will have its own position/rotation objects
  78050. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78051. * the developers will clone them or copy them as they see fit.
  78052. */
  78053. autoCloneTransformation: boolean;
  78054. /**
  78055. * Triggered when new babylon (transformed) hit test results are available
  78056. */
  78057. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78058. /**
  78059. * Use this to temporarily pause hit test checks.
  78060. */
  78061. paused: boolean;
  78062. /**
  78063. * Creates a new instance of the hit test feature
  78064. * @param _xrSessionManager an instance of WebXRSessionManager
  78065. * @param options options to use when constructing this feature
  78066. */
  78067. constructor(_xrSessionManager: WebXRSessionManager,
  78068. /**
  78069. * options to use when constructing this feature
  78070. */
  78071. options?: IWebXRHitTestOptions);
  78072. /**
  78073. * attach this feature
  78074. * Will usually be called by the features manager
  78075. *
  78076. * @returns true if successful.
  78077. */
  78078. attach(): boolean;
  78079. /**
  78080. * detach this feature.
  78081. * Will usually be called by the features manager
  78082. *
  78083. * @returns true if successful.
  78084. */
  78085. detach(): boolean;
  78086. /**
  78087. * Dispose this feature and all of the resources attached
  78088. */
  78089. dispose(): void;
  78090. protected _onXRFrame(frame: XRFrame): void;
  78091. private _processWebXRHitTestResult;
  78092. }
  78093. }
  78094. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78095. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78096. import { Observable } from "babylonjs/Misc/observable";
  78097. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78098. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78099. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78100. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78101. /**
  78102. * Configuration options of the anchor system
  78103. */
  78104. export interface IWebXRAnchorSystemOptions {
  78105. /**
  78106. * a node that will be used to convert local to world coordinates
  78107. */
  78108. worldParentNode?: TransformNode;
  78109. /**
  78110. * If set to true a reference of the created anchors will be kept until the next session starts
  78111. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78112. */
  78113. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78114. }
  78115. /**
  78116. * A babylon container for an XR Anchor
  78117. */
  78118. export interface IWebXRAnchor {
  78119. /**
  78120. * A babylon-assigned ID for this anchor
  78121. */
  78122. id: number;
  78123. /**
  78124. * Transformation matrix to apply to an object attached to this anchor
  78125. */
  78126. transformationMatrix: Matrix;
  78127. /**
  78128. * The native anchor object
  78129. */
  78130. xrAnchor: XRAnchor;
  78131. /**
  78132. * if defined, this object will be constantly updated by the anchor's position and rotation
  78133. */
  78134. attachedNode?: TransformNode;
  78135. }
  78136. /**
  78137. * An implementation of the anchor system for WebXR.
  78138. * For further information see https://github.com/immersive-web/anchors/
  78139. */
  78140. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78141. private _options;
  78142. private _lastFrameDetected;
  78143. private _trackedAnchors;
  78144. private _referenceSpaceForFrameAnchors;
  78145. private _futureAnchors;
  78146. /**
  78147. * The module's name
  78148. */
  78149. static readonly Name: string;
  78150. /**
  78151. * The (Babylon) version of this module.
  78152. * This is an integer representing the implementation version.
  78153. * This number does not correspond to the WebXR specs version
  78154. */
  78155. static readonly Version: number;
  78156. /**
  78157. * Observers registered here will be executed when a new anchor was added to the session
  78158. */
  78159. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78160. /**
  78161. * Observers registered here will be executed when an anchor was removed from the session
  78162. */
  78163. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78164. /**
  78165. * Observers registered here will be executed when an existing anchor updates
  78166. * This can execute N times every frame
  78167. */
  78168. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78169. /**
  78170. * Set the reference space to use for anchor creation, when not using a hit test.
  78171. * Will default to the session's reference space if not defined
  78172. */
  78173. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78174. /**
  78175. * constructs a new anchor system
  78176. * @param _xrSessionManager an instance of WebXRSessionManager
  78177. * @param _options configuration object for this feature
  78178. */
  78179. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78180. private _tmpVector;
  78181. private _tmpQuaternion;
  78182. private _populateTmpTransformation;
  78183. /**
  78184. * Create a new anchor point using a hit test result at a specific point in the scene
  78185. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78186. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78187. *
  78188. * @param hitTestResult The hit test result to use for this anchor creation
  78189. * @param position an optional position offset for this anchor
  78190. * @param rotationQuaternion an optional rotation offset for this anchor
  78191. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78192. */
  78193. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78194. /**
  78195. * Add a new anchor at a specific position and rotation
  78196. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78197. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78198. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78199. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78200. *
  78201. * @param position the position in which to add an anchor
  78202. * @param rotationQuaternion an optional rotation for the anchor transformation
  78203. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78204. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78205. */
  78206. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78207. /**
  78208. * detach this feature.
  78209. * Will usually be called by the features manager
  78210. *
  78211. * @returns true if successful.
  78212. */
  78213. detach(): boolean;
  78214. /**
  78215. * Dispose this feature and all of the resources attached
  78216. */
  78217. dispose(): void;
  78218. protected _onXRFrame(frame: XRFrame): void;
  78219. /**
  78220. * avoiding using Array.find for global support.
  78221. * @param xrAnchor the plane to find in the array
  78222. */
  78223. private _findIndexInAnchorArray;
  78224. private _updateAnchorWithXRFrame;
  78225. private _createAnchorAtTransformation;
  78226. }
  78227. }
  78228. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78229. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78230. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78231. import { Observable } from "babylonjs/Misc/observable";
  78232. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78233. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78234. /**
  78235. * Options used in the plane detector module
  78236. */
  78237. export interface IWebXRPlaneDetectorOptions {
  78238. /**
  78239. * The node to use to transform the local results to world coordinates
  78240. */
  78241. worldParentNode?: TransformNode;
  78242. /**
  78243. * If set to true a reference of the created planes will be kept until the next session starts
  78244. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78245. */
  78246. doNotRemovePlanesOnSessionEnded?: boolean;
  78247. }
  78248. /**
  78249. * A babylon interface for a WebXR plane.
  78250. * A Plane is actually a polygon, built from N points in space
  78251. *
  78252. * Supported in chrome 79, not supported in canary 81 ATM
  78253. */
  78254. export interface IWebXRPlane {
  78255. /**
  78256. * a babylon-assigned ID for this polygon
  78257. */
  78258. id: number;
  78259. /**
  78260. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78261. */
  78262. polygonDefinition: Array<Vector3>;
  78263. /**
  78264. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78265. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78266. */
  78267. transformationMatrix: Matrix;
  78268. /**
  78269. * the native xr-plane object
  78270. */
  78271. xrPlane: XRPlane;
  78272. }
  78273. /**
  78274. * The plane detector is used to detect planes in the real world when in AR
  78275. * For more information see https://github.com/immersive-web/real-world-geometry/
  78276. */
  78277. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78278. private _options;
  78279. private _detectedPlanes;
  78280. private _enabled;
  78281. private _lastFrameDetected;
  78282. /**
  78283. * The module's name
  78284. */
  78285. static readonly Name: string;
  78286. /**
  78287. * The (Babylon) version of this module.
  78288. * This is an integer representing the implementation version.
  78289. * This number does not correspond to the WebXR specs version
  78290. */
  78291. static readonly Version: number;
  78292. /**
  78293. * Observers registered here will be executed when a new plane was added to the session
  78294. */
  78295. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78296. /**
  78297. * Observers registered here will be executed when a plane is no longer detected in the session
  78298. */
  78299. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78300. /**
  78301. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78302. * This can execute N times every frame
  78303. */
  78304. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78305. /**
  78306. * construct a new Plane Detector
  78307. * @param _xrSessionManager an instance of xr Session manager
  78308. * @param _options configuration to use when constructing this feature
  78309. */
  78310. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78311. /**
  78312. * detach this feature.
  78313. * Will usually be called by the features manager
  78314. *
  78315. * @returns true if successful.
  78316. */
  78317. detach(): boolean;
  78318. /**
  78319. * Dispose this feature and all of the resources attached
  78320. */
  78321. dispose(): void;
  78322. protected _onXRFrame(frame: XRFrame): void;
  78323. private _init;
  78324. private _updatePlaneWithXRPlane;
  78325. /**
  78326. * avoiding using Array.find for global support.
  78327. * @param xrPlane the plane to find in the array
  78328. */
  78329. private findIndexInPlaneArray;
  78330. }
  78331. }
  78332. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78333. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78335. import { Observable } from "babylonjs/Misc/observable";
  78336. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78337. /**
  78338. * Options interface for the background remover plugin
  78339. */
  78340. export interface IWebXRBackgroundRemoverOptions {
  78341. /**
  78342. * Further background meshes to disable when entering AR
  78343. */
  78344. backgroundMeshes?: AbstractMesh[];
  78345. /**
  78346. * flags to configure the removal of the environment helper.
  78347. * If not set, the entire background will be removed. If set, flags should be set as well.
  78348. */
  78349. environmentHelperRemovalFlags?: {
  78350. /**
  78351. * Should the skybox be removed (default false)
  78352. */
  78353. skyBox?: boolean;
  78354. /**
  78355. * Should the ground be removed (default false)
  78356. */
  78357. ground?: boolean;
  78358. };
  78359. /**
  78360. * don't disable the environment helper
  78361. */
  78362. ignoreEnvironmentHelper?: boolean;
  78363. }
  78364. /**
  78365. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78366. */
  78367. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78368. /**
  78369. * read-only options to be used in this module
  78370. */
  78371. readonly options: IWebXRBackgroundRemoverOptions;
  78372. /**
  78373. * The module's name
  78374. */
  78375. static readonly Name: string;
  78376. /**
  78377. * The (Babylon) version of this module.
  78378. * This is an integer representing the implementation version.
  78379. * This number does not correspond to the WebXR specs version
  78380. */
  78381. static readonly Version: number;
  78382. /**
  78383. * registered observers will be triggered when the background state changes
  78384. */
  78385. onBackgroundStateChangedObservable: Observable<boolean>;
  78386. /**
  78387. * constructs a new background remover module
  78388. * @param _xrSessionManager the session manager for this module
  78389. * @param options read-only options to be used in this module
  78390. */
  78391. constructor(_xrSessionManager: WebXRSessionManager,
  78392. /**
  78393. * read-only options to be used in this module
  78394. */
  78395. options?: IWebXRBackgroundRemoverOptions);
  78396. /**
  78397. * attach this feature
  78398. * Will usually be called by the features manager
  78399. *
  78400. * @returns true if successful.
  78401. */
  78402. attach(): boolean;
  78403. /**
  78404. * detach this feature.
  78405. * Will usually be called by the features manager
  78406. *
  78407. * @returns true if successful.
  78408. */
  78409. detach(): boolean;
  78410. /**
  78411. * Dispose this feature and all of the resources attached
  78412. */
  78413. dispose(): void;
  78414. protected _onXRFrame(_xrFrame: XRFrame): void;
  78415. private _setBackgroundState;
  78416. }
  78417. }
  78418. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78419. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78420. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78421. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78422. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78423. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78424. import { Nullable } from "babylonjs/types";
  78425. /**
  78426. * Options for the controller physics feature
  78427. */
  78428. export class IWebXRControllerPhysicsOptions {
  78429. /**
  78430. * Should the headset get its own impostor
  78431. */
  78432. enableHeadsetImpostor?: boolean;
  78433. /**
  78434. * Optional parameters for the headset impostor
  78435. */
  78436. headsetImpostorParams?: {
  78437. /**
  78438. * The type of impostor to create. Default is sphere
  78439. */
  78440. impostorType: number;
  78441. /**
  78442. * the size of the impostor. Defaults to 10cm
  78443. */
  78444. impostorSize?: number | {
  78445. width: number;
  78446. height: number;
  78447. depth: number;
  78448. };
  78449. /**
  78450. * Friction definitions
  78451. */
  78452. friction?: number;
  78453. /**
  78454. * Restitution
  78455. */
  78456. restitution?: number;
  78457. };
  78458. /**
  78459. * The physics properties of the future impostors
  78460. */
  78461. physicsProperties?: {
  78462. /**
  78463. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  78464. * Note that this requires a physics engine that supports mesh impostors!
  78465. */
  78466. useControllerMesh?: boolean;
  78467. /**
  78468. * The type of impostor to create. Default is sphere
  78469. */
  78470. impostorType?: number;
  78471. /**
  78472. * the size of the impostor. Defaults to 10cm
  78473. */
  78474. impostorSize?: number | {
  78475. width: number;
  78476. height: number;
  78477. depth: number;
  78478. };
  78479. /**
  78480. * Friction definitions
  78481. */
  78482. friction?: number;
  78483. /**
  78484. * Restitution
  78485. */
  78486. restitution?: number;
  78487. };
  78488. /**
  78489. * the xr input to use with this pointer selection
  78490. */
  78491. xrInput: WebXRInput;
  78492. }
  78493. /**
  78494. * Add physics impostor to your webxr controllers,
  78495. * including naive calculation of their linear and angular velocity
  78496. */
  78497. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  78498. private readonly _options;
  78499. private _attachController;
  78500. private _controllers;
  78501. private _debugMode;
  78502. private _delta;
  78503. private _headsetImpostor?;
  78504. private _headsetMesh?;
  78505. private _lastTimestamp;
  78506. private _tmpQuaternion;
  78507. private _tmpVector;
  78508. /**
  78509. * The module's name
  78510. */
  78511. static readonly Name: string;
  78512. /**
  78513. * The (Babylon) version of this module.
  78514. * This is an integer representing the implementation version.
  78515. * This number does not correspond to the webxr specs version
  78516. */
  78517. static readonly Version: number;
  78518. /**
  78519. * Construct a new Controller Physics Feature
  78520. * @param _xrSessionManager the corresponding xr session manager
  78521. * @param _options options to create this feature with
  78522. */
  78523. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  78524. /**
  78525. * @hidden
  78526. * enable debugging - will show console outputs and the impostor mesh
  78527. */
  78528. _enablePhysicsDebug(): void;
  78529. /**
  78530. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  78531. * @param xrController the controller to add
  78532. */
  78533. addController(xrController: WebXRInputSource): void;
  78534. /**
  78535. * attach this feature
  78536. * Will usually be called by the features manager
  78537. *
  78538. * @returns true if successful.
  78539. */
  78540. attach(): boolean;
  78541. /**
  78542. * detach this feature.
  78543. * Will usually be called by the features manager
  78544. *
  78545. * @returns true if successful.
  78546. */
  78547. detach(): boolean;
  78548. /**
  78549. * Get the headset impostor, if enabled
  78550. * @returns the impostor
  78551. */
  78552. getHeadsetImpostor(): PhysicsImpostor | undefined;
  78553. /**
  78554. * Get the physics impostor of a specific controller.
  78555. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  78556. * @param controller the controller or the controller id of which to get the impostor
  78557. * @returns the impostor or null
  78558. */
  78559. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  78560. /**
  78561. * Update the physics properties provided in the constructor
  78562. * @param newProperties the new properties object
  78563. */
  78564. setPhysicsProperties(newProperties: {
  78565. impostorType?: number;
  78566. impostorSize?: number | {
  78567. width: number;
  78568. height: number;
  78569. depth: number;
  78570. };
  78571. friction?: number;
  78572. restitution?: number;
  78573. }): void;
  78574. protected _onXRFrame(_xrFrame: any): void;
  78575. private _detachController;
  78576. }
  78577. }
  78578. declare module "babylonjs/XR/features/index" {
  78579. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78580. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78581. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78582. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78583. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78584. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78585. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78586. export * from "babylonjs/XR/features/WebXRHitTest";
  78587. }
  78588. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78589. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78591. import { Scene } from "babylonjs/scene";
  78592. /**
  78593. * The motion controller class for all microsoft mixed reality controllers
  78594. */
  78595. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78596. protected readonly _mapping: {
  78597. defaultButton: {
  78598. valueNodeName: string;
  78599. unpressedNodeName: string;
  78600. pressedNodeName: string;
  78601. };
  78602. defaultAxis: {
  78603. valueNodeName: string;
  78604. minNodeName: string;
  78605. maxNodeName: string;
  78606. };
  78607. buttons: {
  78608. "xr-standard-trigger": {
  78609. rootNodeName: string;
  78610. componentProperty: string;
  78611. states: string[];
  78612. };
  78613. "xr-standard-squeeze": {
  78614. rootNodeName: string;
  78615. componentProperty: string;
  78616. states: string[];
  78617. };
  78618. "xr-standard-touchpad": {
  78619. rootNodeName: string;
  78620. labelAnchorNodeName: string;
  78621. touchPointNodeName: string;
  78622. };
  78623. "xr-standard-thumbstick": {
  78624. rootNodeName: string;
  78625. componentProperty: string;
  78626. states: string[];
  78627. };
  78628. };
  78629. axes: {
  78630. "xr-standard-touchpad": {
  78631. "x-axis": {
  78632. rootNodeName: string;
  78633. };
  78634. "y-axis": {
  78635. rootNodeName: string;
  78636. };
  78637. };
  78638. "xr-standard-thumbstick": {
  78639. "x-axis": {
  78640. rootNodeName: string;
  78641. };
  78642. "y-axis": {
  78643. rootNodeName: string;
  78644. };
  78645. };
  78646. };
  78647. };
  78648. /**
  78649. * The base url used to load the left and right controller models
  78650. */
  78651. static MODEL_BASE_URL: string;
  78652. /**
  78653. * The name of the left controller model file
  78654. */
  78655. static MODEL_LEFT_FILENAME: string;
  78656. /**
  78657. * The name of the right controller model file
  78658. */
  78659. static MODEL_RIGHT_FILENAME: string;
  78660. profileId: string;
  78661. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78662. protected _getFilenameAndPath(): {
  78663. filename: string;
  78664. path: string;
  78665. };
  78666. protected _getModelLoadingConstraints(): boolean;
  78667. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78668. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78669. protected _updateModel(): void;
  78670. }
  78671. }
  78672. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78673. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78675. import { Scene } from "babylonjs/scene";
  78676. /**
  78677. * The motion controller class for oculus touch (quest, rift).
  78678. * This class supports legacy mapping as well the standard xr mapping
  78679. */
  78680. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78681. private _forceLegacyControllers;
  78682. private _modelRootNode;
  78683. /**
  78684. * The base url used to load the left and right controller models
  78685. */
  78686. static MODEL_BASE_URL: string;
  78687. /**
  78688. * The name of the left controller model file
  78689. */
  78690. static MODEL_LEFT_FILENAME: string;
  78691. /**
  78692. * The name of the right controller model file
  78693. */
  78694. static MODEL_RIGHT_FILENAME: string;
  78695. /**
  78696. * Base Url for the Quest controller model.
  78697. */
  78698. static QUEST_MODEL_BASE_URL: string;
  78699. profileId: string;
  78700. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78701. protected _getFilenameAndPath(): {
  78702. filename: string;
  78703. path: string;
  78704. };
  78705. protected _getModelLoadingConstraints(): boolean;
  78706. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78707. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78708. protected _updateModel(): void;
  78709. /**
  78710. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78711. * between the touch and touch 2.
  78712. */
  78713. private _isQuest;
  78714. }
  78715. }
  78716. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78717. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78718. import { Scene } from "babylonjs/scene";
  78719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78720. /**
  78721. * The motion controller class for the standard HTC-Vive controllers
  78722. */
  78723. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78724. private _modelRootNode;
  78725. /**
  78726. * The base url used to load the left and right controller models
  78727. */
  78728. static MODEL_BASE_URL: string;
  78729. /**
  78730. * File name for the controller model.
  78731. */
  78732. static MODEL_FILENAME: string;
  78733. profileId: string;
  78734. /**
  78735. * Create a new Vive motion controller object
  78736. * @param scene the scene to use to create this controller
  78737. * @param gamepadObject the corresponding gamepad object
  78738. * @param handedness the handedness of the controller
  78739. */
  78740. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78741. protected _getFilenameAndPath(): {
  78742. filename: string;
  78743. path: string;
  78744. };
  78745. protected _getModelLoadingConstraints(): boolean;
  78746. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78747. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78748. protected _updateModel(): void;
  78749. }
  78750. }
  78751. declare module "babylonjs/XR/motionController/index" {
  78752. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78753. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78754. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78755. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78756. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78757. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78758. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78759. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78760. }
  78761. declare module "babylonjs/XR/index" {
  78762. export * from "babylonjs/XR/webXRCamera";
  78763. export * from "babylonjs/XR/webXREnterExitUI";
  78764. export * from "babylonjs/XR/webXRExperienceHelper";
  78765. export * from "babylonjs/XR/webXRInput";
  78766. export * from "babylonjs/XR/webXRInputSource";
  78767. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78768. export * from "babylonjs/XR/webXRTypes";
  78769. export * from "babylonjs/XR/webXRSessionManager";
  78770. export * from "babylonjs/XR/webXRDefaultExperience";
  78771. export * from "babylonjs/XR/webXRFeaturesManager";
  78772. export * from "babylonjs/XR/features/index";
  78773. export * from "babylonjs/XR/motionController/index";
  78774. }
  78775. declare module "babylonjs/index" {
  78776. export * from "babylonjs/abstractScene";
  78777. export * from "babylonjs/Actions/index";
  78778. export * from "babylonjs/Animations/index";
  78779. export * from "babylonjs/assetContainer";
  78780. export * from "babylonjs/Audio/index";
  78781. export * from "babylonjs/Behaviors/index";
  78782. export * from "babylonjs/Bones/index";
  78783. export * from "babylonjs/Cameras/index";
  78784. export * from "babylonjs/Collisions/index";
  78785. export * from "babylonjs/Culling/index";
  78786. export * from "babylonjs/Debug/index";
  78787. export * from "babylonjs/DeviceInput/index";
  78788. export * from "babylonjs/Engines/index";
  78789. export * from "babylonjs/Events/index";
  78790. export * from "babylonjs/Gamepads/index";
  78791. export * from "babylonjs/Gizmos/index";
  78792. export * from "babylonjs/Helpers/index";
  78793. export * from "babylonjs/Instrumentation/index";
  78794. export * from "babylonjs/Layers/index";
  78795. export * from "babylonjs/LensFlares/index";
  78796. export * from "babylonjs/Lights/index";
  78797. export * from "babylonjs/Loading/index";
  78798. export * from "babylonjs/Materials/index";
  78799. export * from "babylonjs/Maths/index";
  78800. export * from "babylonjs/Meshes/index";
  78801. export * from "babylonjs/Morph/index";
  78802. export * from "babylonjs/Navigation/index";
  78803. export * from "babylonjs/node";
  78804. export * from "babylonjs/Offline/index";
  78805. export * from "babylonjs/Particles/index";
  78806. export * from "babylonjs/Physics/index";
  78807. export * from "babylonjs/PostProcesses/index";
  78808. export * from "babylonjs/Probes/index";
  78809. export * from "babylonjs/Rendering/index";
  78810. export * from "babylonjs/scene";
  78811. export * from "babylonjs/sceneComponent";
  78812. export * from "babylonjs/Sprites/index";
  78813. export * from "babylonjs/States/index";
  78814. export * from "babylonjs/Misc/index";
  78815. export * from "babylonjs/XR/index";
  78816. export * from "babylonjs/types";
  78817. }
  78818. declare module "babylonjs/Animations/pathCursor" {
  78819. import { Vector3 } from "babylonjs/Maths/math.vector";
  78820. import { Path2 } from "babylonjs/Maths/math.path";
  78821. /**
  78822. * A cursor which tracks a point on a path
  78823. */
  78824. export class PathCursor {
  78825. private path;
  78826. /**
  78827. * Stores path cursor callbacks for when an onchange event is triggered
  78828. */
  78829. private _onchange;
  78830. /**
  78831. * The value of the path cursor
  78832. */
  78833. value: number;
  78834. /**
  78835. * The animation array of the path cursor
  78836. */
  78837. animations: Animation[];
  78838. /**
  78839. * Initializes the path cursor
  78840. * @param path The path to track
  78841. */
  78842. constructor(path: Path2);
  78843. /**
  78844. * Gets the cursor point on the path
  78845. * @returns A point on the path cursor at the cursor location
  78846. */
  78847. getPoint(): Vector3;
  78848. /**
  78849. * Moves the cursor ahead by the step amount
  78850. * @param step The amount to move the cursor forward
  78851. * @returns This path cursor
  78852. */
  78853. moveAhead(step?: number): PathCursor;
  78854. /**
  78855. * Moves the cursor behind by the step amount
  78856. * @param step The amount to move the cursor back
  78857. * @returns This path cursor
  78858. */
  78859. moveBack(step?: number): PathCursor;
  78860. /**
  78861. * Moves the cursor by the step amount
  78862. * If the step amount is greater than one, an exception is thrown
  78863. * @param step The amount to move the cursor
  78864. * @returns This path cursor
  78865. */
  78866. move(step: number): PathCursor;
  78867. /**
  78868. * Ensures that the value is limited between zero and one
  78869. * @returns This path cursor
  78870. */
  78871. private ensureLimits;
  78872. /**
  78873. * Runs onchange callbacks on change (used by the animation engine)
  78874. * @returns This path cursor
  78875. */
  78876. private raiseOnChange;
  78877. /**
  78878. * Executes a function on change
  78879. * @param f A path cursor onchange callback
  78880. * @returns This path cursor
  78881. */
  78882. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78883. }
  78884. }
  78885. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78886. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78887. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78888. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78889. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78890. }
  78891. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78892. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78893. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78894. }
  78895. declare module "babylonjs/Engines/Processors/index" {
  78896. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78897. export * from "babylonjs/Engines/Processors/Expressions/index";
  78898. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78899. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78900. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78901. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78902. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78903. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78904. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78905. }
  78906. declare module "babylonjs/Legacy/legacy" {
  78907. import * as Babylon from "babylonjs/index";
  78908. export * from "babylonjs/index";
  78909. }
  78910. declare module "babylonjs/Shaders/blur.fragment" {
  78911. /** @hidden */
  78912. export var blurPixelShader: {
  78913. name: string;
  78914. shader: string;
  78915. };
  78916. }
  78917. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78918. /** @hidden */
  78919. export var pointCloudVertexDeclaration: {
  78920. name: string;
  78921. shader: string;
  78922. };
  78923. }
  78924. declare module "babylonjs" {
  78925. export * from "babylonjs/Legacy/legacy";
  78926. }
  78927. declare module BABYLON {
  78928. /** Alias type for value that can be null */
  78929. export type Nullable<T> = T | null;
  78930. /**
  78931. * Alias type for number that are floats
  78932. * @ignorenaming
  78933. */
  78934. export type float = number;
  78935. /**
  78936. * Alias type for number that are doubles.
  78937. * @ignorenaming
  78938. */
  78939. export type double = number;
  78940. /**
  78941. * Alias type for number that are integer
  78942. * @ignorenaming
  78943. */
  78944. export type int = number;
  78945. /** Alias type for number array or Float32Array */
  78946. export type FloatArray = number[] | Float32Array;
  78947. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78948. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78949. /**
  78950. * Alias for types that can be used by a Buffer or VertexBuffer.
  78951. */
  78952. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78953. /**
  78954. * Alias type for primitive types
  78955. * @ignorenaming
  78956. */
  78957. type Primitive = undefined | null | boolean | string | number | Function;
  78958. /**
  78959. * Type modifier to make all the properties of an object Readonly
  78960. */
  78961. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78962. /**
  78963. * Type modifier to make all the properties of an object Readonly recursively
  78964. */
  78965. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78966. /**
  78967. * Type modifier to make object properties readonly.
  78968. */
  78969. export type DeepImmutableObject<T> = {
  78970. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78971. };
  78972. /** @hidden */
  78973. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78974. }
  78975. }
  78976. declare module BABYLON {
  78977. /**
  78978. * A class serves as a medium between the observable and its observers
  78979. */
  78980. export class EventState {
  78981. /**
  78982. * Create a new EventState
  78983. * @param mask defines the mask associated with this state
  78984. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78985. * @param target defines the original target of the state
  78986. * @param currentTarget defines the current target of the state
  78987. */
  78988. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78989. /**
  78990. * Initialize the current event state
  78991. * @param mask defines the mask associated with this state
  78992. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78993. * @param target defines the original target of the state
  78994. * @param currentTarget defines the current target of the state
  78995. * @returns the current event state
  78996. */
  78997. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78998. /**
  78999. * An Observer can set this property to true to prevent subsequent observers of being notified
  79000. */
  79001. skipNextObservers: boolean;
  79002. /**
  79003. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79004. */
  79005. mask: number;
  79006. /**
  79007. * The object that originally notified the event
  79008. */
  79009. target?: any;
  79010. /**
  79011. * The current object in the bubbling phase
  79012. */
  79013. currentTarget?: any;
  79014. /**
  79015. * This will be populated with the return value of the last function that was executed.
  79016. * If it is the first function in the callback chain it will be the event data.
  79017. */
  79018. lastReturnValue?: any;
  79019. }
  79020. /**
  79021. * Represent an Observer registered to a given Observable object.
  79022. */
  79023. export class Observer<T> {
  79024. /**
  79025. * Defines the callback to call when the observer is notified
  79026. */
  79027. callback: (eventData: T, eventState: EventState) => void;
  79028. /**
  79029. * Defines the mask of the observer (used to filter notifications)
  79030. */
  79031. mask: number;
  79032. /**
  79033. * Defines the current scope used to restore the JS context
  79034. */
  79035. scope: any;
  79036. /** @hidden */
  79037. _willBeUnregistered: boolean;
  79038. /**
  79039. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79040. */
  79041. unregisterOnNextCall: boolean;
  79042. /**
  79043. * Creates a new observer
  79044. * @param callback defines the callback to call when the observer is notified
  79045. * @param mask defines the mask of the observer (used to filter notifications)
  79046. * @param scope defines the current scope used to restore the JS context
  79047. */
  79048. constructor(
  79049. /**
  79050. * Defines the callback to call when the observer is notified
  79051. */
  79052. callback: (eventData: T, eventState: EventState) => void,
  79053. /**
  79054. * Defines the mask of the observer (used to filter notifications)
  79055. */
  79056. mask: number,
  79057. /**
  79058. * Defines the current scope used to restore the JS context
  79059. */
  79060. scope?: any);
  79061. }
  79062. /**
  79063. * Represent a list of observers registered to multiple Observables object.
  79064. */
  79065. export class MultiObserver<T> {
  79066. private _observers;
  79067. private _observables;
  79068. /**
  79069. * Release associated resources
  79070. */
  79071. dispose(): void;
  79072. /**
  79073. * Raise a callback when one of the observable will notify
  79074. * @param observables defines a list of observables to watch
  79075. * @param callback defines the callback to call on notification
  79076. * @param mask defines the mask used to filter notifications
  79077. * @param scope defines the current scope used to restore the JS context
  79078. * @returns the new MultiObserver
  79079. */
  79080. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79081. }
  79082. /**
  79083. * The Observable class is a simple implementation of the Observable pattern.
  79084. *
  79085. * 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.
  79086. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79087. * 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).
  79088. * 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.
  79089. */
  79090. export class Observable<T> {
  79091. private _observers;
  79092. private _eventState;
  79093. private _onObserverAdded;
  79094. /**
  79095. * Gets the list of observers
  79096. */
  79097. get observers(): Array<Observer<T>>;
  79098. /**
  79099. * Creates a new observable
  79100. * @param onObserverAdded defines a callback to call when a new observer is added
  79101. */
  79102. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79103. /**
  79104. * Create a new Observer with the specified callback
  79105. * @param callback the callback that will be executed for that Observer
  79106. * @param mask the mask used to filter observers
  79107. * @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.
  79108. * @param scope optional scope for the callback to be called from
  79109. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79110. * @returns the new observer created for the callback
  79111. */
  79112. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79113. /**
  79114. * Create a new Observer with the specified callback and unregisters after the next notification
  79115. * @param callback the callback that will be executed for that Observer
  79116. * @returns the new observer created for the callback
  79117. */
  79118. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79119. /**
  79120. * Remove an Observer from the Observable object
  79121. * @param observer the instance of the Observer to remove
  79122. * @returns false if it doesn't belong to this Observable
  79123. */
  79124. remove(observer: Nullable<Observer<T>>): boolean;
  79125. /**
  79126. * Remove a callback from the Observable object
  79127. * @param callback the callback to remove
  79128. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79129. * @returns false if it doesn't belong to this Observable
  79130. */
  79131. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79132. private _deferUnregister;
  79133. private _remove;
  79134. /**
  79135. * Moves the observable to the top of the observer list making it get called first when notified
  79136. * @param observer the observer to move
  79137. */
  79138. makeObserverTopPriority(observer: Observer<T>): void;
  79139. /**
  79140. * Moves the observable to the bottom of the observer list making it get called last when notified
  79141. * @param observer the observer to move
  79142. */
  79143. makeObserverBottomPriority(observer: Observer<T>): void;
  79144. /**
  79145. * Notify all Observers by calling their respective callback with the given data
  79146. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  79147. * @param eventData defines the data to send to all observers
  79148. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  79149. * @param target defines the original target of the state
  79150. * @param currentTarget defines the current target of the state
  79151. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  79152. */
  79153. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  79154. /**
  79155. * Calling this will execute each callback, expecting it to be a promise or return a value.
  79156. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  79157. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  79158. * and it is crucial that all callbacks will be executed.
  79159. * The order of the callbacks is kept, callbacks are not executed parallel.
  79160. *
  79161. * @param eventData The data to be sent to each callback
  79162. * @param mask is used to filter observers defaults to -1
  79163. * @param target defines the callback target (see EventState)
  79164. * @param currentTarget defines he current object in the bubbling phase
  79165. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  79166. */
  79167. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  79168. /**
  79169. * Notify a specific observer
  79170. * @param observer defines the observer to notify
  79171. * @param eventData defines the data to be sent to each callback
  79172. * @param mask is used to filter observers defaults to -1
  79173. */
  79174. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  79175. /**
  79176. * Gets a boolean indicating if the observable has at least one observer
  79177. * @returns true is the Observable has at least one Observer registered
  79178. */
  79179. hasObservers(): boolean;
  79180. /**
  79181. * Clear the list of observers
  79182. */
  79183. clear(): void;
  79184. /**
  79185. * Clone the current observable
  79186. * @returns a new observable
  79187. */
  79188. clone(): Observable<T>;
  79189. /**
  79190. * Does this observable handles observer registered with a given mask
  79191. * @param mask defines the mask to be tested
  79192. * @return whether or not one observer registered with the given mask is handeled
  79193. **/
  79194. hasSpecificMask(mask?: number): boolean;
  79195. }
  79196. }
  79197. declare module BABYLON {
  79198. /**
  79199. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  79200. * Babylon.js
  79201. */
  79202. export class DomManagement {
  79203. /**
  79204. * Checks if the window object exists
  79205. * @returns true if the window object exists
  79206. */
  79207. static IsWindowObjectExist(): boolean;
  79208. /**
  79209. * Checks if the navigator object exists
  79210. * @returns true if the navigator object exists
  79211. */
  79212. static IsNavigatorAvailable(): boolean;
  79213. /**
  79214. * Check if the document object exists
  79215. * @returns true if the document object exists
  79216. */
  79217. static IsDocumentAvailable(): boolean;
  79218. /**
  79219. * Extracts text content from a DOM element hierarchy
  79220. * @param element defines the root element
  79221. * @returns a string
  79222. */
  79223. static GetDOMTextContent(element: HTMLElement): string;
  79224. }
  79225. }
  79226. declare module BABYLON {
  79227. /**
  79228. * Logger used througouht the application to allow configuration of
  79229. * the log level required for the messages.
  79230. */
  79231. export class Logger {
  79232. /**
  79233. * No log
  79234. */
  79235. static readonly NoneLogLevel: number;
  79236. /**
  79237. * Only message logs
  79238. */
  79239. static readonly MessageLogLevel: number;
  79240. /**
  79241. * Only warning logs
  79242. */
  79243. static readonly WarningLogLevel: number;
  79244. /**
  79245. * Only error logs
  79246. */
  79247. static readonly ErrorLogLevel: number;
  79248. /**
  79249. * All logs
  79250. */
  79251. static readonly AllLogLevel: number;
  79252. private static _LogCache;
  79253. /**
  79254. * Gets a value indicating the number of loading errors
  79255. * @ignorenaming
  79256. */
  79257. static errorsCount: number;
  79258. /**
  79259. * Callback called when a new log is added
  79260. */
  79261. static OnNewCacheEntry: (entry: string) => void;
  79262. private static _AddLogEntry;
  79263. private static _FormatMessage;
  79264. private static _LogDisabled;
  79265. private static _LogEnabled;
  79266. private static _WarnDisabled;
  79267. private static _WarnEnabled;
  79268. private static _ErrorDisabled;
  79269. private static _ErrorEnabled;
  79270. /**
  79271. * Log a message to the console
  79272. */
  79273. static Log: (message: string) => void;
  79274. /**
  79275. * Write a warning message to the console
  79276. */
  79277. static Warn: (message: string) => void;
  79278. /**
  79279. * Write an error message to the console
  79280. */
  79281. static Error: (message: string) => void;
  79282. /**
  79283. * Gets current log cache (list of logs)
  79284. */
  79285. static get LogCache(): string;
  79286. /**
  79287. * Clears the log cache
  79288. */
  79289. static ClearLogCache(): void;
  79290. /**
  79291. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  79292. */
  79293. static set LogLevels(level: number);
  79294. }
  79295. }
  79296. declare module BABYLON {
  79297. /** @hidden */
  79298. export class _TypeStore {
  79299. /** @hidden */
  79300. static RegisteredTypes: {
  79301. [key: string]: Object;
  79302. };
  79303. /** @hidden */
  79304. static GetClass(fqdn: string): any;
  79305. }
  79306. }
  79307. declare module BABYLON {
  79308. /**
  79309. * Helper to manipulate strings
  79310. */
  79311. export class StringTools {
  79312. /**
  79313. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  79314. * @param str Source string
  79315. * @param suffix Suffix to search for in the source string
  79316. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79317. */
  79318. static EndsWith(str: string, suffix: string): boolean;
  79319. /**
  79320. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  79321. * @param str Source string
  79322. * @param suffix Suffix to search for in the source string
  79323. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  79324. */
  79325. static StartsWith(str: string, suffix: string): boolean;
  79326. /**
  79327. * Decodes a buffer into a string
  79328. * @param buffer The buffer to decode
  79329. * @returns The decoded string
  79330. */
  79331. static Decode(buffer: Uint8Array | Uint16Array): string;
  79332. /**
  79333. * Encode a buffer to a base64 string
  79334. * @param buffer defines the buffer to encode
  79335. * @returns the encoded string
  79336. */
  79337. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  79338. /**
  79339. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  79340. * @param num the number to convert and pad
  79341. * @param length the expected length of the string
  79342. * @returns the padded string
  79343. */
  79344. static PadNumber(num: number, length: number): string;
  79345. }
  79346. }
  79347. declare module BABYLON {
  79348. /**
  79349. * Class containing a set of static utilities functions for deep copy.
  79350. */
  79351. export class DeepCopier {
  79352. /**
  79353. * Tries to copy an object by duplicating every property
  79354. * @param source defines the source object
  79355. * @param destination defines the target object
  79356. * @param doNotCopyList defines a list of properties to avoid
  79357. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  79358. */
  79359. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  79360. }
  79361. }
  79362. declare module BABYLON {
  79363. /**
  79364. * Class containing a set of static utilities functions for precision date
  79365. */
  79366. export class PrecisionDate {
  79367. /**
  79368. * Gets either window.performance.now() if supported or Date.now() else
  79369. */
  79370. static get Now(): number;
  79371. }
  79372. }
  79373. declare module BABYLON {
  79374. /** @hidden */
  79375. export class _DevTools {
  79376. static WarnImport(name: string): string;
  79377. }
  79378. }
  79379. declare module BABYLON {
  79380. /**
  79381. * Interface used to define the mechanism to get data from the network
  79382. */
  79383. export interface IWebRequest {
  79384. /**
  79385. * Returns client's response url
  79386. */
  79387. responseURL: string;
  79388. /**
  79389. * Returns client's status
  79390. */
  79391. status: number;
  79392. /**
  79393. * Returns client's status as a text
  79394. */
  79395. statusText: string;
  79396. }
  79397. }
  79398. declare module BABYLON {
  79399. /**
  79400. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  79401. */
  79402. export class WebRequest implements IWebRequest {
  79403. private _xhr;
  79404. /**
  79405. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  79406. * i.e. when loading files, where the server/service expects an Authorization header
  79407. */
  79408. static CustomRequestHeaders: {
  79409. [key: string]: string;
  79410. };
  79411. /**
  79412. * Add callback functions in this array to update all the requests before they get sent to the network
  79413. */
  79414. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  79415. private _injectCustomRequestHeaders;
  79416. /**
  79417. * Gets or sets a function to be called when loading progress changes
  79418. */
  79419. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  79420. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  79421. /**
  79422. * Returns client's state
  79423. */
  79424. get readyState(): number;
  79425. /**
  79426. * Returns client's status
  79427. */
  79428. get status(): number;
  79429. /**
  79430. * Returns client's status as a text
  79431. */
  79432. get statusText(): string;
  79433. /**
  79434. * Returns client's response
  79435. */
  79436. get response(): any;
  79437. /**
  79438. * Returns client's response url
  79439. */
  79440. get responseURL(): string;
  79441. /**
  79442. * Returns client's response as text
  79443. */
  79444. get responseText(): string;
  79445. /**
  79446. * Gets or sets the expected response type
  79447. */
  79448. get responseType(): XMLHttpRequestResponseType;
  79449. set responseType(value: XMLHttpRequestResponseType);
  79450. /** @hidden */
  79451. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  79452. /** @hidden */
  79453. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  79454. /**
  79455. * Cancels any network activity
  79456. */
  79457. abort(): void;
  79458. /**
  79459. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  79460. * @param body defines an optional request body
  79461. */
  79462. send(body?: Document | BodyInit | null): void;
  79463. /**
  79464. * Sets the request method, request URL
  79465. * @param method defines the method to use (GET, POST, etc..)
  79466. * @param url defines the url to connect with
  79467. */
  79468. open(method: string, url: string): void;
  79469. /**
  79470. * Sets the value of a request header.
  79471. * @param name The name of the header whose value is to be set
  79472. * @param value The value to set as the body of the header
  79473. */
  79474. setRequestHeader(name: string, value: string): void;
  79475. /**
  79476. * Get the string containing the text of a particular header's value.
  79477. * @param name The name of the header
  79478. * @returns The string containing the text of the given header name
  79479. */
  79480. getResponseHeader(name: string): Nullable<string>;
  79481. }
  79482. }
  79483. declare module BABYLON {
  79484. /**
  79485. * File request interface
  79486. */
  79487. export interface IFileRequest {
  79488. /**
  79489. * Raised when the request is complete (success or error).
  79490. */
  79491. onCompleteObservable: Observable<IFileRequest>;
  79492. /**
  79493. * Aborts the request for a file.
  79494. */
  79495. abort: () => void;
  79496. }
  79497. }
  79498. declare module BABYLON {
  79499. /**
  79500. * Define options used to create a render target texture
  79501. */
  79502. export class RenderTargetCreationOptions {
  79503. /**
  79504. * Specifies is mipmaps must be generated
  79505. */
  79506. generateMipMaps?: boolean;
  79507. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  79508. generateDepthBuffer?: boolean;
  79509. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  79510. generateStencilBuffer?: boolean;
  79511. /** Defines texture type (int by default) */
  79512. type?: number;
  79513. /** Defines sampling mode (trilinear by default) */
  79514. samplingMode?: number;
  79515. /** Defines format (RGBA by default) */
  79516. format?: number;
  79517. }
  79518. }
  79519. declare module BABYLON {
  79520. /** Defines the cross module used constants to avoid circular dependncies */
  79521. export class Constants {
  79522. /** Defines that alpha blending is disabled */
  79523. static readonly ALPHA_DISABLE: number;
  79524. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  79525. static readonly ALPHA_ADD: number;
  79526. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  79527. static readonly ALPHA_COMBINE: number;
  79528. /** Defines that alpha blending is DEST - SRC * DEST */
  79529. static readonly ALPHA_SUBTRACT: number;
  79530. /** Defines that alpha blending is SRC * DEST */
  79531. static readonly ALPHA_MULTIPLY: number;
  79532. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  79533. static readonly ALPHA_MAXIMIZED: number;
  79534. /** Defines that alpha blending is SRC + DEST */
  79535. static readonly ALPHA_ONEONE: number;
  79536. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  79537. static readonly ALPHA_PREMULTIPLIED: number;
  79538. /**
  79539. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  79540. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  79541. */
  79542. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  79543. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  79544. static readonly ALPHA_INTERPOLATE: number;
  79545. /**
  79546. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  79547. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  79548. */
  79549. static readonly ALPHA_SCREENMODE: number;
  79550. /**
  79551. * Defines that alpha blending is SRC + DST
  79552. * Alpha will be set to SRC ALPHA + DST ALPHA
  79553. */
  79554. static readonly ALPHA_ONEONE_ONEONE: number;
  79555. /**
  79556. * Defines that alpha blending is SRC * DST ALPHA + DST
  79557. * Alpha will be set to 0
  79558. */
  79559. static readonly ALPHA_ALPHATOCOLOR: number;
  79560. /**
  79561. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79562. */
  79563. static readonly ALPHA_REVERSEONEMINUS: number;
  79564. /**
  79565. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79566. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79567. */
  79568. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79569. /**
  79570. * Defines that alpha blending is SRC + DST
  79571. * Alpha will be set to SRC ALPHA
  79572. */
  79573. static readonly ALPHA_ONEONE_ONEZERO: number;
  79574. /**
  79575. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79576. * Alpha will be set to DST ALPHA
  79577. */
  79578. static readonly ALPHA_EXCLUSION: number;
  79579. /** Defines that alpha blending equation a SUM */
  79580. static readonly ALPHA_EQUATION_ADD: number;
  79581. /** Defines that alpha blending equation a SUBSTRACTION */
  79582. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79583. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79584. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79585. /** Defines that alpha blending equation a MAX operation */
  79586. static readonly ALPHA_EQUATION_MAX: number;
  79587. /** Defines that alpha blending equation a MIN operation */
  79588. static readonly ALPHA_EQUATION_MIN: number;
  79589. /**
  79590. * Defines that alpha blending equation a DARKEN operation:
  79591. * It takes the min of the src and sums the alpha channels.
  79592. */
  79593. static readonly ALPHA_EQUATION_DARKEN: number;
  79594. /** Defines that the ressource is not delayed*/
  79595. static readonly DELAYLOADSTATE_NONE: number;
  79596. /** Defines that the ressource was successfully delay loaded */
  79597. static readonly DELAYLOADSTATE_LOADED: number;
  79598. /** Defines that the ressource is currently delay loading */
  79599. static readonly DELAYLOADSTATE_LOADING: number;
  79600. /** Defines that the ressource is delayed and has not started loading */
  79601. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79602. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79603. static readonly NEVER: number;
  79604. /** 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 */
  79605. static readonly ALWAYS: number;
  79606. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79607. static readonly LESS: number;
  79608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79609. static readonly EQUAL: number;
  79610. /** 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 */
  79611. static readonly LEQUAL: number;
  79612. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79613. static readonly GREATER: number;
  79614. /** 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 */
  79615. static readonly GEQUAL: number;
  79616. /** 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 */
  79617. static readonly NOTEQUAL: number;
  79618. /** Passed to stencilOperation to specify that stencil value must be kept */
  79619. static readonly KEEP: number;
  79620. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79621. static readonly REPLACE: number;
  79622. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79623. static readonly INCR: number;
  79624. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79625. static readonly DECR: number;
  79626. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79627. static readonly INVERT: number;
  79628. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79629. static readonly INCR_WRAP: number;
  79630. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79631. static readonly DECR_WRAP: number;
  79632. /** Texture is not repeating outside of 0..1 UVs */
  79633. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79634. /** Texture is repeating outside of 0..1 UVs */
  79635. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79636. /** Texture is repeating and mirrored */
  79637. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79638. /** ALPHA */
  79639. static readonly TEXTUREFORMAT_ALPHA: number;
  79640. /** LUMINANCE */
  79641. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79642. /** LUMINANCE_ALPHA */
  79643. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79644. /** RGB */
  79645. static readonly TEXTUREFORMAT_RGB: number;
  79646. /** RGBA */
  79647. static readonly TEXTUREFORMAT_RGBA: number;
  79648. /** RED */
  79649. static readonly TEXTUREFORMAT_RED: number;
  79650. /** RED (2nd reference) */
  79651. static readonly TEXTUREFORMAT_R: number;
  79652. /** RG */
  79653. static readonly TEXTUREFORMAT_RG: number;
  79654. /** RED_INTEGER */
  79655. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79656. /** RED_INTEGER (2nd reference) */
  79657. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79658. /** RG_INTEGER */
  79659. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79660. /** RGB_INTEGER */
  79661. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79662. /** RGBA_INTEGER */
  79663. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79664. /** UNSIGNED_BYTE */
  79665. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79666. /** UNSIGNED_BYTE (2nd reference) */
  79667. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79668. /** FLOAT */
  79669. static readonly TEXTURETYPE_FLOAT: number;
  79670. /** HALF_FLOAT */
  79671. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79672. /** BYTE */
  79673. static readonly TEXTURETYPE_BYTE: number;
  79674. /** SHORT */
  79675. static readonly TEXTURETYPE_SHORT: number;
  79676. /** UNSIGNED_SHORT */
  79677. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79678. /** INT */
  79679. static readonly TEXTURETYPE_INT: number;
  79680. /** UNSIGNED_INT */
  79681. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79682. /** UNSIGNED_SHORT_4_4_4_4 */
  79683. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79684. /** UNSIGNED_SHORT_5_5_5_1 */
  79685. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79686. /** UNSIGNED_SHORT_5_6_5 */
  79687. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79688. /** UNSIGNED_INT_2_10_10_10_REV */
  79689. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79690. /** UNSIGNED_INT_24_8 */
  79691. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79692. /** UNSIGNED_INT_10F_11F_11F_REV */
  79693. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79694. /** UNSIGNED_INT_5_9_9_9_REV */
  79695. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79696. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79697. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79698. /** nearest is mag = nearest and min = nearest and no mip */
  79699. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79700. /** mag = nearest and min = nearest and mip = none */
  79701. static readonly TEXTURE_NEAREST_NEAREST: number;
  79702. /** Bilinear is mag = linear and min = linear and no mip */
  79703. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79704. /** mag = linear and min = linear and mip = none */
  79705. static readonly TEXTURE_LINEAR_LINEAR: number;
  79706. /** Trilinear is mag = linear and min = linear and mip = linear */
  79707. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79708. /** Trilinear is mag = linear and min = linear and mip = linear */
  79709. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79710. /** mag = nearest and min = nearest and mip = nearest */
  79711. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79712. /** mag = nearest and min = linear and mip = nearest */
  79713. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79714. /** mag = nearest and min = linear and mip = linear */
  79715. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79716. /** mag = nearest and min = linear and mip = none */
  79717. static readonly TEXTURE_NEAREST_LINEAR: number;
  79718. /** nearest is mag = nearest and min = nearest and mip = linear */
  79719. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79720. /** mag = linear and min = nearest and mip = nearest */
  79721. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79722. /** mag = linear and min = nearest and mip = linear */
  79723. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79724. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79725. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79726. /** mag = linear and min = nearest and mip = none */
  79727. static readonly TEXTURE_LINEAR_NEAREST: number;
  79728. /** Explicit coordinates mode */
  79729. static readonly TEXTURE_EXPLICIT_MODE: number;
  79730. /** Spherical coordinates mode */
  79731. static readonly TEXTURE_SPHERICAL_MODE: number;
  79732. /** Planar coordinates mode */
  79733. static readonly TEXTURE_PLANAR_MODE: number;
  79734. /** Cubic coordinates mode */
  79735. static readonly TEXTURE_CUBIC_MODE: number;
  79736. /** Projection coordinates mode */
  79737. static readonly TEXTURE_PROJECTION_MODE: number;
  79738. /** Skybox coordinates mode */
  79739. static readonly TEXTURE_SKYBOX_MODE: number;
  79740. /** Inverse Cubic coordinates mode */
  79741. static readonly TEXTURE_INVCUBIC_MODE: number;
  79742. /** Equirectangular coordinates mode */
  79743. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79744. /** Equirectangular Fixed coordinates mode */
  79745. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79746. /** Equirectangular Fixed Mirrored coordinates mode */
  79747. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79748. /** Offline (baking) quality for texture filtering */
  79749. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79750. /** High quality for texture filtering */
  79751. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79752. /** Medium quality for texture filtering */
  79753. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79754. /** Low quality for texture filtering */
  79755. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79756. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79757. static readonly SCALEMODE_FLOOR: number;
  79758. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79759. static readonly SCALEMODE_NEAREST: number;
  79760. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79761. static readonly SCALEMODE_CEILING: number;
  79762. /**
  79763. * The dirty texture flag value
  79764. */
  79765. static readonly MATERIAL_TextureDirtyFlag: number;
  79766. /**
  79767. * The dirty light flag value
  79768. */
  79769. static readonly MATERIAL_LightDirtyFlag: number;
  79770. /**
  79771. * The dirty fresnel flag value
  79772. */
  79773. static readonly MATERIAL_FresnelDirtyFlag: number;
  79774. /**
  79775. * The dirty attribute flag value
  79776. */
  79777. static readonly MATERIAL_AttributesDirtyFlag: number;
  79778. /**
  79779. * The dirty misc flag value
  79780. */
  79781. static readonly MATERIAL_MiscDirtyFlag: number;
  79782. /**
  79783. * The all dirty flag value
  79784. */
  79785. static readonly MATERIAL_AllDirtyFlag: number;
  79786. /**
  79787. * Returns the triangle fill mode
  79788. */
  79789. static readonly MATERIAL_TriangleFillMode: number;
  79790. /**
  79791. * Returns the wireframe mode
  79792. */
  79793. static readonly MATERIAL_WireFrameFillMode: number;
  79794. /**
  79795. * Returns the point fill mode
  79796. */
  79797. static readonly MATERIAL_PointFillMode: number;
  79798. /**
  79799. * Returns the point list draw mode
  79800. */
  79801. static readonly MATERIAL_PointListDrawMode: number;
  79802. /**
  79803. * Returns the line list draw mode
  79804. */
  79805. static readonly MATERIAL_LineListDrawMode: number;
  79806. /**
  79807. * Returns the line loop draw mode
  79808. */
  79809. static readonly MATERIAL_LineLoopDrawMode: number;
  79810. /**
  79811. * Returns the line strip draw mode
  79812. */
  79813. static readonly MATERIAL_LineStripDrawMode: number;
  79814. /**
  79815. * Returns the triangle strip draw mode
  79816. */
  79817. static readonly MATERIAL_TriangleStripDrawMode: number;
  79818. /**
  79819. * Returns the triangle fan draw mode
  79820. */
  79821. static readonly MATERIAL_TriangleFanDrawMode: number;
  79822. /**
  79823. * Stores the clock-wise side orientation
  79824. */
  79825. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79826. /**
  79827. * Stores the counter clock-wise side orientation
  79828. */
  79829. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79830. /**
  79831. * Nothing
  79832. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79833. */
  79834. static readonly ACTION_NothingTrigger: number;
  79835. /**
  79836. * On pick
  79837. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79838. */
  79839. static readonly ACTION_OnPickTrigger: number;
  79840. /**
  79841. * On left pick
  79842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79843. */
  79844. static readonly ACTION_OnLeftPickTrigger: number;
  79845. /**
  79846. * On right pick
  79847. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79848. */
  79849. static readonly ACTION_OnRightPickTrigger: number;
  79850. /**
  79851. * On center pick
  79852. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79853. */
  79854. static readonly ACTION_OnCenterPickTrigger: number;
  79855. /**
  79856. * On pick down
  79857. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79858. */
  79859. static readonly ACTION_OnPickDownTrigger: number;
  79860. /**
  79861. * On double pick
  79862. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79863. */
  79864. static readonly ACTION_OnDoublePickTrigger: number;
  79865. /**
  79866. * On pick up
  79867. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79868. */
  79869. static readonly ACTION_OnPickUpTrigger: number;
  79870. /**
  79871. * On pick out.
  79872. * This trigger will only be raised if you also declared a OnPickDown
  79873. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79874. */
  79875. static readonly ACTION_OnPickOutTrigger: number;
  79876. /**
  79877. * On long press
  79878. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79879. */
  79880. static readonly ACTION_OnLongPressTrigger: number;
  79881. /**
  79882. * On pointer over
  79883. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79884. */
  79885. static readonly ACTION_OnPointerOverTrigger: number;
  79886. /**
  79887. * On pointer out
  79888. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79889. */
  79890. static readonly ACTION_OnPointerOutTrigger: number;
  79891. /**
  79892. * On every frame
  79893. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79894. */
  79895. static readonly ACTION_OnEveryFrameTrigger: number;
  79896. /**
  79897. * On intersection enter
  79898. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79899. */
  79900. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79901. /**
  79902. * On intersection exit
  79903. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79904. */
  79905. static readonly ACTION_OnIntersectionExitTrigger: number;
  79906. /**
  79907. * On key down
  79908. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79909. */
  79910. static readonly ACTION_OnKeyDownTrigger: number;
  79911. /**
  79912. * On key up
  79913. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79914. */
  79915. static readonly ACTION_OnKeyUpTrigger: number;
  79916. /**
  79917. * Billboard mode will only apply to Y axis
  79918. */
  79919. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79920. /**
  79921. * Billboard mode will apply to all axes
  79922. */
  79923. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79924. /**
  79925. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79926. */
  79927. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79928. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79929. * Test order :
  79930. * Is the bounding sphere outside the frustum ?
  79931. * If not, are the bounding box vertices outside the frustum ?
  79932. * It not, then the cullable object is in the frustum.
  79933. */
  79934. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79935. /** Culling strategy : Bounding Sphere Only.
  79936. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79937. * It's also less accurate than the standard because some not visible objects can still be selected.
  79938. * Test : is the bounding sphere outside the frustum ?
  79939. * If not, then the cullable object is in the frustum.
  79940. */
  79941. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79942. /** Culling strategy : Optimistic Inclusion.
  79943. * This in an inclusion test first, then the standard exclusion test.
  79944. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79945. * 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.
  79946. * Anyway, it's as accurate as the standard strategy.
  79947. * Test :
  79948. * Is the cullable object bounding sphere center in the frustum ?
  79949. * If not, apply the default culling strategy.
  79950. */
  79951. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79952. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79953. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79954. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79955. * 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.
  79956. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79957. * Test :
  79958. * Is the cullable object bounding sphere center in the frustum ?
  79959. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79960. */
  79961. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79962. /**
  79963. * No logging while loading
  79964. */
  79965. static readonly SCENELOADER_NO_LOGGING: number;
  79966. /**
  79967. * Minimal logging while loading
  79968. */
  79969. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79970. /**
  79971. * Summary logging while loading
  79972. */
  79973. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79974. /**
  79975. * Detailled logging while loading
  79976. */
  79977. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79978. /**
  79979. * Prepass texture index for color
  79980. */
  79981. static readonly PREPASS_COLOR_INDEX: number;
  79982. /**
  79983. * Prepass texture index for irradiance
  79984. */
  79985. static readonly PREPASS_IRRADIANCE_INDEX: number;
  79986. /**
  79987. * Prepass texture index for depth + normal
  79988. */
  79989. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  79990. /**
  79991. * Prepass texture index for albedo
  79992. */
  79993. static readonly PREPASS_ALBEDO_INDEX: number;
  79994. }
  79995. }
  79996. declare module BABYLON {
  79997. /**
  79998. * This represents the required contract to create a new type of texture loader.
  79999. */
  80000. export interface IInternalTextureLoader {
  80001. /**
  80002. * Defines wether the loader supports cascade loading the different faces.
  80003. */
  80004. supportCascades: boolean;
  80005. /**
  80006. * This returns if the loader support the current file information.
  80007. * @param extension defines the file extension of the file being loaded
  80008. * @param mimeType defines the optional mime type of the file being loaded
  80009. * @returns true if the loader can load the specified file
  80010. */
  80011. canLoad(extension: string, mimeType?: string): boolean;
  80012. /**
  80013. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80014. * @param data contains the texture data
  80015. * @param texture defines the BabylonJS internal texture
  80016. * @param createPolynomials will be true if polynomials have been requested
  80017. * @param onLoad defines the callback to trigger once the texture is ready
  80018. * @param onError defines the callback to trigger in case of error
  80019. */
  80020. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80021. /**
  80022. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80023. * @param data contains the texture data
  80024. * @param texture defines the BabylonJS internal texture
  80025. * @param callback defines the method to call once ready to upload
  80026. */
  80027. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80028. }
  80029. }
  80030. declare module BABYLON {
  80031. /**
  80032. * Class used to store and describe the pipeline context associated with an effect
  80033. */
  80034. export interface IPipelineContext {
  80035. /**
  80036. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80037. */
  80038. isAsync: boolean;
  80039. /**
  80040. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80041. */
  80042. isReady: boolean;
  80043. /** @hidden */
  80044. _getVertexShaderCode(): string | null;
  80045. /** @hidden */
  80046. _getFragmentShaderCode(): string | null;
  80047. /** @hidden */
  80048. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80049. }
  80050. }
  80051. declare module BABYLON {
  80052. /**
  80053. * Class used to store gfx data (like WebGLBuffer)
  80054. */
  80055. export class DataBuffer {
  80056. /**
  80057. * Gets or sets the number of objects referencing this buffer
  80058. */
  80059. references: number;
  80060. /** Gets or sets the size of the underlying buffer */
  80061. capacity: number;
  80062. /**
  80063. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80064. */
  80065. is32Bits: boolean;
  80066. /**
  80067. * Gets the underlying buffer
  80068. */
  80069. get underlyingResource(): any;
  80070. }
  80071. }
  80072. declare module BABYLON {
  80073. /** @hidden */
  80074. export interface IShaderProcessor {
  80075. attributeProcessor?: (attribute: string) => string;
  80076. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80077. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80078. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80079. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80080. lineProcessor?: (line: string, isFragment: boolean) => string;
  80081. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80082. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80083. }
  80084. }
  80085. declare module BABYLON {
  80086. /** @hidden */
  80087. export interface ProcessingOptions {
  80088. defines: string[];
  80089. indexParameters: any;
  80090. isFragment: boolean;
  80091. shouldUseHighPrecisionShader: boolean;
  80092. supportsUniformBuffers: boolean;
  80093. shadersRepository: string;
  80094. includesShadersStore: {
  80095. [key: string]: string;
  80096. };
  80097. processor?: IShaderProcessor;
  80098. version: string;
  80099. platformName: string;
  80100. lookForClosingBracketForUniformBuffer?: boolean;
  80101. }
  80102. }
  80103. declare module BABYLON {
  80104. /** @hidden */
  80105. export class ShaderCodeNode {
  80106. line: string;
  80107. children: ShaderCodeNode[];
  80108. additionalDefineKey?: string;
  80109. additionalDefineValue?: string;
  80110. isValid(preprocessors: {
  80111. [key: string]: string;
  80112. }): boolean;
  80113. process(preprocessors: {
  80114. [key: string]: string;
  80115. }, options: ProcessingOptions): string;
  80116. }
  80117. }
  80118. declare module BABYLON {
  80119. /** @hidden */
  80120. export class ShaderCodeCursor {
  80121. private _lines;
  80122. lineIndex: number;
  80123. get currentLine(): string;
  80124. get canRead(): boolean;
  80125. set lines(value: string[]);
  80126. }
  80127. }
  80128. declare module BABYLON {
  80129. /** @hidden */
  80130. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80131. process(preprocessors: {
  80132. [key: string]: string;
  80133. }, options: ProcessingOptions): string;
  80134. }
  80135. }
  80136. declare module BABYLON {
  80137. /** @hidden */
  80138. export class ShaderDefineExpression {
  80139. isTrue(preprocessors: {
  80140. [key: string]: string;
  80141. }): boolean;
  80142. private static _OperatorPriority;
  80143. private static _Stack;
  80144. static postfixToInfix(postfix: string[]): string;
  80145. static infixToPostfix(infix: string): string[];
  80146. }
  80147. }
  80148. declare module BABYLON {
  80149. /** @hidden */
  80150. export class ShaderCodeTestNode extends ShaderCodeNode {
  80151. testExpression: ShaderDefineExpression;
  80152. isValid(preprocessors: {
  80153. [key: string]: string;
  80154. }): boolean;
  80155. }
  80156. }
  80157. declare module BABYLON {
  80158. /** @hidden */
  80159. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  80160. define: string;
  80161. not: boolean;
  80162. constructor(define: string, not?: boolean);
  80163. isTrue(preprocessors: {
  80164. [key: string]: string;
  80165. }): boolean;
  80166. }
  80167. }
  80168. declare module BABYLON {
  80169. /** @hidden */
  80170. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  80171. leftOperand: ShaderDefineExpression;
  80172. rightOperand: ShaderDefineExpression;
  80173. isTrue(preprocessors: {
  80174. [key: string]: string;
  80175. }): boolean;
  80176. }
  80177. }
  80178. declare module BABYLON {
  80179. /** @hidden */
  80180. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  80181. leftOperand: ShaderDefineExpression;
  80182. rightOperand: ShaderDefineExpression;
  80183. isTrue(preprocessors: {
  80184. [key: string]: string;
  80185. }): boolean;
  80186. }
  80187. }
  80188. declare module BABYLON {
  80189. /** @hidden */
  80190. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  80191. define: string;
  80192. operand: string;
  80193. testValue: string;
  80194. constructor(define: string, operand: string, testValue: string);
  80195. isTrue(preprocessors: {
  80196. [key: string]: string;
  80197. }): boolean;
  80198. }
  80199. }
  80200. declare module BABYLON {
  80201. /**
  80202. * Class used to enable access to offline support
  80203. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  80204. */
  80205. export interface IOfflineProvider {
  80206. /**
  80207. * Gets a boolean indicating if scene must be saved in the database
  80208. */
  80209. enableSceneOffline: boolean;
  80210. /**
  80211. * Gets a boolean indicating if textures must be saved in the database
  80212. */
  80213. enableTexturesOffline: boolean;
  80214. /**
  80215. * Open the offline support and make it available
  80216. * @param successCallback defines the callback to call on success
  80217. * @param errorCallback defines the callback to call on error
  80218. */
  80219. open(successCallback: () => void, errorCallback: () => void): void;
  80220. /**
  80221. * Loads an image from the offline support
  80222. * @param url defines the url to load from
  80223. * @param image defines the target DOM image
  80224. */
  80225. loadImage(url: string, image: HTMLImageElement): void;
  80226. /**
  80227. * Loads a file from offline support
  80228. * @param url defines the URL to load from
  80229. * @param sceneLoaded defines a callback to call on success
  80230. * @param progressCallBack defines a callback to call when progress changed
  80231. * @param errorCallback defines a callback to call on error
  80232. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  80233. */
  80234. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  80235. }
  80236. }
  80237. declare module BABYLON {
  80238. /**
  80239. * Class used to help managing file picking and drag'n'drop
  80240. * File Storage
  80241. */
  80242. export class FilesInputStore {
  80243. /**
  80244. * List of files ready to be loaded
  80245. */
  80246. static FilesToLoad: {
  80247. [key: string]: File;
  80248. };
  80249. }
  80250. }
  80251. declare module BABYLON {
  80252. /**
  80253. * Class used to define a retry strategy when error happens while loading assets
  80254. */
  80255. export class RetryStrategy {
  80256. /**
  80257. * Function used to defines an exponential back off strategy
  80258. * @param maxRetries defines the maximum number of retries (3 by default)
  80259. * @param baseInterval defines the interval between retries
  80260. * @returns the strategy function to use
  80261. */
  80262. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  80263. }
  80264. }
  80265. declare module BABYLON {
  80266. /**
  80267. * @ignore
  80268. * Application error to support additional information when loading a file
  80269. */
  80270. export abstract class BaseError extends Error {
  80271. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  80272. }
  80273. }
  80274. declare module BABYLON {
  80275. /** @ignore */
  80276. export class LoadFileError extends BaseError {
  80277. request?: WebRequest;
  80278. file?: File;
  80279. /**
  80280. * Creates a new LoadFileError
  80281. * @param message defines the message of the error
  80282. * @param request defines the optional web request
  80283. * @param file defines the optional file
  80284. */
  80285. constructor(message: string, object?: WebRequest | File);
  80286. }
  80287. /** @ignore */
  80288. export class RequestFileError extends BaseError {
  80289. request: WebRequest;
  80290. /**
  80291. * Creates a new LoadFileError
  80292. * @param message defines the message of the error
  80293. * @param request defines the optional web request
  80294. */
  80295. constructor(message: string, request: WebRequest);
  80296. }
  80297. /** @ignore */
  80298. export class ReadFileError extends BaseError {
  80299. file: File;
  80300. /**
  80301. * Creates a new ReadFileError
  80302. * @param message defines the message of the error
  80303. * @param file defines the optional file
  80304. */
  80305. constructor(message: string, file: File);
  80306. }
  80307. /**
  80308. * @hidden
  80309. */
  80310. export class FileTools {
  80311. /**
  80312. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  80313. */
  80314. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  80315. /**
  80316. * Gets or sets the base URL to use to load assets
  80317. */
  80318. static BaseUrl: string;
  80319. /**
  80320. * Default behaviour for cors in the application.
  80321. * It can be a string if the expected behavior is identical in the entire app.
  80322. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  80323. */
  80324. static CorsBehavior: string | ((url: string | string[]) => string);
  80325. /**
  80326. * Gets or sets a function used to pre-process url before using them to load assets
  80327. */
  80328. static PreprocessUrl: (url: string) => string;
  80329. /**
  80330. * Removes unwanted characters from an url
  80331. * @param url defines the url to clean
  80332. * @returns the cleaned url
  80333. */
  80334. private static _CleanUrl;
  80335. /**
  80336. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  80337. * @param url define the url we are trying
  80338. * @param element define the dom element where to configure the cors policy
  80339. */
  80340. static SetCorsBehavior(url: string | string[], element: {
  80341. crossOrigin: string | null;
  80342. }): void;
  80343. /**
  80344. * Loads an image as an HTMLImageElement.
  80345. * @param input url string, ArrayBuffer, or Blob to load
  80346. * @param onLoad callback called when the image successfully loads
  80347. * @param onError callback called when the image fails to load
  80348. * @param offlineProvider offline provider for caching
  80349. * @param mimeType optional mime type
  80350. * @returns the HTMLImageElement of the loaded image
  80351. */
  80352. 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>;
  80353. /**
  80354. * Reads a file from a File object
  80355. * @param file defines the file to load
  80356. * @param onSuccess defines the callback to call when data is loaded
  80357. * @param onProgress defines the callback to call during loading process
  80358. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  80359. * @param onError defines the callback to call when an error occurs
  80360. * @returns a file request object
  80361. */
  80362. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  80363. /**
  80364. * Loads a file from a url
  80365. * @param url url to load
  80366. * @param onSuccess callback called when the file successfully loads
  80367. * @param onProgress callback called while file is loading (if the server supports this mode)
  80368. * @param offlineProvider defines the offline provider for caching
  80369. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80370. * @param onError callback called when the file fails to load
  80371. * @returns a file request object
  80372. */
  80373. 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;
  80374. /**
  80375. * Loads a file
  80376. * @param url url to load
  80377. * @param onSuccess callback called when the file successfully loads
  80378. * @param onProgress callback called while file is loading (if the server supports this mode)
  80379. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80380. * @param onError callback called when the file fails to load
  80381. * @param onOpened callback called when the web request is opened
  80382. * @returns a file request object
  80383. */
  80384. 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;
  80385. /**
  80386. * Checks if the loaded document was accessed via `file:`-Protocol.
  80387. * @returns boolean
  80388. */
  80389. static IsFileURL(): boolean;
  80390. }
  80391. }
  80392. declare module BABYLON {
  80393. /** @hidden */
  80394. export class ShaderProcessor {
  80395. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  80396. private static _ProcessPrecision;
  80397. private static _ExtractOperation;
  80398. private static _BuildSubExpression;
  80399. private static _BuildExpression;
  80400. private static _MoveCursorWithinIf;
  80401. private static _MoveCursor;
  80402. private static _EvaluatePreProcessors;
  80403. private static _PreparePreProcessors;
  80404. private static _ProcessShaderConversion;
  80405. private static _ProcessIncludes;
  80406. /**
  80407. * Loads a file from a url
  80408. * @param url url to load
  80409. * @param onSuccess callback called when the file successfully loads
  80410. * @param onProgress callback called while file is loading (if the server supports this mode)
  80411. * @param offlineProvider defines the offline provider for caching
  80412. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  80413. * @param onError callback called when the file fails to load
  80414. * @returns a file request object
  80415. * @hidden
  80416. */
  80417. 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;
  80418. }
  80419. }
  80420. declare module BABYLON {
  80421. /**
  80422. * @hidden
  80423. */
  80424. export interface IColor4Like {
  80425. r: float;
  80426. g: float;
  80427. b: float;
  80428. a: float;
  80429. }
  80430. /**
  80431. * @hidden
  80432. */
  80433. export interface IColor3Like {
  80434. r: float;
  80435. g: float;
  80436. b: float;
  80437. }
  80438. /**
  80439. * @hidden
  80440. */
  80441. export interface IVector4Like {
  80442. x: float;
  80443. y: float;
  80444. z: float;
  80445. w: float;
  80446. }
  80447. /**
  80448. * @hidden
  80449. */
  80450. export interface IVector3Like {
  80451. x: float;
  80452. y: float;
  80453. z: float;
  80454. }
  80455. /**
  80456. * @hidden
  80457. */
  80458. export interface IVector2Like {
  80459. x: float;
  80460. y: float;
  80461. }
  80462. /**
  80463. * @hidden
  80464. */
  80465. export interface IMatrixLike {
  80466. toArray(): DeepImmutable<Float32Array | Array<number>>;
  80467. updateFlag: int;
  80468. }
  80469. /**
  80470. * @hidden
  80471. */
  80472. export interface IViewportLike {
  80473. x: float;
  80474. y: float;
  80475. width: float;
  80476. height: float;
  80477. }
  80478. /**
  80479. * @hidden
  80480. */
  80481. export interface IPlaneLike {
  80482. normal: IVector3Like;
  80483. d: float;
  80484. normalize(): void;
  80485. }
  80486. }
  80487. declare module BABYLON {
  80488. /**
  80489. * Interface used to define common properties for effect fallbacks
  80490. */
  80491. export interface IEffectFallbacks {
  80492. /**
  80493. * Removes the defines that should be removed when falling back.
  80494. * @param currentDefines defines the current define statements for the shader.
  80495. * @param effect defines the current effect we try to compile
  80496. * @returns The resulting defines with defines of the current rank removed.
  80497. */
  80498. reduce(currentDefines: string, effect: Effect): string;
  80499. /**
  80500. * Removes the fallback from the bound mesh.
  80501. */
  80502. unBindMesh(): void;
  80503. /**
  80504. * Checks to see if more fallbacks are still availible.
  80505. */
  80506. hasMoreFallbacks: boolean;
  80507. }
  80508. }
  80509. declare module BABYLON {
  80510. /**
  80511. * Class used to evalaute queries containing `and` and `or` operators
  80512. */
  80513. export class AndOrNotEvaluator {
  80514. /**
  80515. * Evaluate a query
  80516. * @param query defines the query to evaluate
  80517. * @param evaluateCallback defines the callback used to filter result
  80518. * @returns true if the query matches
  80519. */
  80520. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  80521. private static _HandleParenthesisContent;
  80522. private static _SimplifyNegation;
  80523. }
  80524. }
  80525. declare module BABYLON {
  80526. /**
  80527. * Class used to store custom tags
  80528. */
  80529. export class Tags {
  80530. /**
  80531. * Adds support for tags on the given object
  80532. * @param obj defines the object to use
  80533. */
  80534. static EnableFor(obj: any): void;
  80535. /**
  80536. * Removes tags support
  80537. * @param obj defines the object to use
  80538. */
  80539. static DisableFor(obj: any): void;
  80540. /**
  80541. * Gets a boolean indicating if the given object has tags
  80542. * @param obj defines the object to use
  80543. * @returns a boolean
  80544. */
  80545. static HasTags(obj: any): boolean;
  80546. /**
  80547. * Gets the tags available on a given object
  80548. * @param obj defines the object to use
  80549. * @param asString defines if the tags must be returned as a string instead of an array of strings
  80550. * @returns the tags
  80551. */
  80552. static GetTags(obj: any, asString?: boolean): any;
  80553. /**
  80554. * Adds tags to an object
  80555. * @param obj defines the object to use
  80556. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  80557. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  80558. */
  80559. static AddTagsTo(obj: any, tagsString: string): void;
  80560. /**
  80561. * @hidden
  80562. */
  80563. static _AddTagTo(obj: any, tag: string): void;
  80564. /**
  80565. * Removes specific tags from a specific object
  80566. * @param obj defines the object to use
  80567. * @param tagsString defines the tags to remove
  80568. */
  80569. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80570. /**
  80571. * @hidden
  80572. */
  80573. static _RemoveTagFrom(obj: any, tag: string): void;
  80574. /**
  80575. * Defines if tags hosted on an object match a given query
  80576. * @param obj defines the object to use
  80577. * @param tagsQuery defines the tag query
  80578. * @returns a boolean
  80579. */
  80580. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80581. }
  80582. }
  80583. declare module BABYLON {
  80584. /**
  80585. * Scalar computation library
  80586. */
  80587. export class Scalar {
  80588. /**
  80589. * Two pi constants convenient for computation.
  80590. */
  80591. static TwoPi: number;
  80592. /**
  80593. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80594. * @param a number
  80595. * @param b number
  80596. * @param epsilon (default = 1.401298E-45)
  80597. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80598. */
  80599. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80600. /**
  80601. * Returns a string : the upper case translation of the number i to hexadecimal.
  80602. * @param i number
  80603. * @returns the upper case translation of the number i to hexadecimal.
  80604. */
  80605. static ToHex(i: number): string;
  80606. /**
  80607. * Returns -1 if value is negative and +1 is value is positive.
  80608. * @param value the value
  80609. * @returns the value itself if it's equal to zero.
  80610. */
  80611. static Sign(value: number): number;
  80612. /**
  80613. * Returns the value itself if it's between min and max.
  80614. * Returns min if the value is lower than min.
  80615. * Returns max if the value is greater than max.
  80616. * @param value the value to clmap
  80617. * @param min the min value to clamp to (default: 0)
  80618. * @param max the max value to clamp to (default: 1)
  80619. * @returns the clamped value
  80620. */
  80621. static Clamp(value: number, min?: number, max?: number): number;
  80622. /**
  80623. * the log2 of value.
  80624. * @param value the value to compute log2 of
  80625. * @returns the log2 of value.
  80626. */
  80627. static Log2(value: number): number;
  80628. /**
  80629. * Loops the value, so that it is never larger than length and never smaller than 0.
  80630. *
  80631. * This is similar to the modulo operator but it works with floating point numbers.
  80632. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80633. * With t = 5 and length = 2.5, the result would be 0.0.
  80634. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80635. * @param value the value
  80636. * @param length the length
  80637. * @returns the looped value
  80638. */
  80639. static Repeat(value: number, length: number): number;
  80640. /**
  80641. * Normalize the value between 0.0 and 1.0 using min and max values
  80642. * @param value value to normalize
  80643. * @param min max to normalize between
  80644. * @param max min to normalize between
  80645. * @returns the normalized value
  80646. */
  80647. static Normalize(value: number, min: number, max: number): number;
  80648. /**
  80649. * Denormalize the value from 0.0 and 1.0 using min and max values
  80650. * @param normalized value to denormalize
  80651. * @param min max to denormalize between
  80652. * @param max min to denormalize between
  80653. * @returns the denormalized value
  80654. */
  80655. static Denormalize(normalized: number, min: number, max: number): number;
  80656. /**
  80657. * Calculates the shortest difference between two given angles given in degrees.
  80658. * @param current current angle in degrees
  80659. * @param target target angle in degrees
  80660. * @returns the delta
  80661. */
  80662. static DeltaAngle(current: number, target: number): number;
  80663. /**
  80664. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80665. * @param tx value
  80666. * @param length length
  80667. * @returns The returned value will move back and forth between 0 and length
  80668. */
  80669. static PingPong(tx: number, length: number): number;
  80670. /**
  80671. * Interpolates between min and max with smoothing at the limits.
  80672. *
  80673. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80674. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80675. * @param from from
  80676. * @param to to
  80677. * @param tx value
  80678. * @returns the smooth stepped value
  80679. */
  80680. static SmoothStep(from: number, to: number, tx: number): number;
  80681. /**
  80682. * Moves a value current towards target.
  80683. *
  80684. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80685. * Negative values of maxDelta pushes the value away from target.
  80686. * @param current current value
  80687. * @param target target value
  80688. * @param maxDelta max distance to move
  80689. * @returns resulting value
  80690. */
  80691. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80692. /**
  80693. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80694. *
  80695. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80696. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80697. * @param current current value
  80698. * @param target target value
  80699. * @param maxDelta max distance to move
  80700. * @returns resulting angle
  80701. */
  80702. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80703. /**
  80704. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80705. * @param start start value
  80706. * @param end target value
  80707. * @param amount amount to lerp between
  80708. * @returns the lerped value
  80709. */
  80710. static Lerp(start: number, end: number, amount: number): number;
  80711. /**
  80712. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80713. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80714. * @param start start value
  80715. * @param end target value
  80716. * @param amount amount to lerp between
  80717. * @returns the lerped value
  80718. */
  80719. static LerpAngle(start: number, end: number, amount: number): number;
  80720. /**
  80721. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80722. * @param a start value
  80723. * @param b target value
  80724. * @param value value between a and b
  80725. * @returns the inverseLerp value
  80726. */
  80727. static InverseLerp(a: number, b: number, value: number): number;
  80728. /**
  80729. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80730. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80731. * @param value1 spline value
  80732. * @param tangent1 spline value
  80733. * @param value2 spline value
  80734. * @param tangent2 spline value
  80735. * @param amount input value
  80736. * @returns hermite result
  80737. */
  80738. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80739. /**
  80740. * Returns a random float number between and min and max values
  80741. * @param min min value of random
  80742. * @param max max value of random
  80743. * @returns random value
  80744. */
  80745. static RandomRange(min: number, max: number): number;
  80746. /**
  80747. * This function returns percentage of a number in a given range.
  80748. *
  80749. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80750. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80751. * @param number to convert to percentage
  80752. * @param min min range
  80753. * @param max max range
  80754. * @returns the percentage
  80755. */
  80756. static RangeToPercent(number: number, min: number, max: number): number;
  80757. /**
  80758. * This function returns number that corresponds to the percentage in a given range.
  80759. *
  80760. * PercentToRange(0.34,0,100) will return 34.
  80761. * @param percent to convert to number
  80762. * @param min min range
  80763. * @param max max range
  80764. * @returns the number
  80765. */
  80766. static PercentToRange(percent: number, min: number, max: number): number;
  80767. /**
  80768. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80769. * @param angle The angle to normalize in radian.
  80770. * @return The converted angle.
  80771. */
  80772. static NormalizeRadians(angle: number): number;
  80773. }
  80774. }
  80775. declare module BABYLON {
  80776. /**
  80777. * Constant used to convert a value to gamma space
  80778. * @ignorenaming
  80779. */
  80780. export const ToGammaSpace: number;
  80781. /**
  80782. * Constant used to convert a value to linear space
  80783. * @ignorenaming
  80784. */
  80785. export const ToLinearSpace = 2.2;
  80786. /**
  80787. * Constant used to define the minimal number value in Babylon.js
  80788. * @ignorenaming
  80789. */
  80790. let Epsilon: number;
  80791. }
  80792. declare module BABYLON {
  80793. /**
  80794. * Class used to represent a viewport on screen
  80795. */
  80796. export class Viewport {
  80797. /** viewport left coordinate */
  80798. x: number;
  80799. /** viewport top coordinate */
  80800. y: number;
  80801. /**viewport width */
  80802. width: number;
  80803. /** viewport height */
  80804. height: number;
  80805. /**
  80806. * Creates a Viewport object located at (x, y) and sized (width, height)
  80807. * @param x defines viewport left coordinate
  80808. * @param y defines viewport top coordinate
  80809. * @param width defines the viewport width
  80810. * @param height defines the viewport height
  80811. */
  80812. constructor(
  80813. /** viewport left coordinate */
  80814. x: number,
  80815. /** viewport top coordinate */
  80816. y: number,
  80817. /**viewport width */
  80818. width: number,
  80819. /** viewport height */
  80820. height: number);
  80821. /**
  80822. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80823. * @param renderWidth defines the rendering width
  80824. * @param renderHeight defines the rendering height
  80825. * @returns a new Viewport
  80826. */
  80827. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80828. /**
  80829. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80830. * @param renderWidth defines the rendering width
  80831. * @param renderHeight defines the rendering height
  80832. * @param ref defines the target viewport
  80833. * @returns the current viewport
  80834. */
  80835. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80836. /**
  80837. * Returns a new Viewport copied from the current one
  80838. * @returns a new Viewport
  80839. */
  80840. clone(): Viewport;
  80841. }
  80842. }
  80843. declare module BABYLON {
  80844. /**
  80845. * Class containing a set of static utilities functions for arrays.
  80846. */
  80847. export class ArrayTools {
  80848. /**
  80849. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80850. * @param size the number of element to construct and put in the array
  80851. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80852. * @returns a new array filled with new objects
  80853. */
  80854. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80855. }
  80856. }
  80857. declare module BABYLON {
  80858. /**
  80859. * Represents a plane by the equation ax + by + cz + d = 0
  80860. */
  80861. export class Plane {
  80862. private static _TmpMatrix;
  80863. /**
  80864. * Normal of the plane (a,b,c)
  80865. */
  80866. normal: Vector3;
  80867. /**
  80868. * d component of the plane
  80869. */
  80870. d: number;
  80871. /**
  80872. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80873. * @param a a component of the plane
  80874. * @param b b component of the plane
  80875. * @param c c component of the plane
  80876. * @param d d component of the plane
  80877. */
  80878. constructor(a: number, b: number, c: number, d: number);
  80879. /**
  80880. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80881. */
  80882. asArray(): number[];
  80883. /**
  80884. * @returns a new plane copied from the current Plane.
  80885. */
  80886. clone(): Plane;
  80887. /**
  80888. * @returns the string "Plane".
  80889. */
  80890. getClassName(): string;
  80891. /**
  80892. * @returns the Plane hash code.
  80893. */
  80894. getHashCode(): number;
  80895. /**
  80896. * Normalize the current Plane in place.
  80897. * @returns the updated Plane.
  80898. */
  80899. normalize(): Plane;
  80900. /**
  80901. * Applies a transformation the plane and returns the result
  80902. * @param transformation the transformation matrix to be applied to the plane
  80903. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80904. */
  80905. transform(transformation: DeepImmutable<Matrix>): Plane;
  80906. /**
  80907. * Compute the dot product between the point and the plane normal
  80908. * @param point point to calculate the dot product with
  80909. * @returns the dot product (float) of the point coordinates and the plane normal.
  80910. */
  80911. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80912. /**
  80913. * Updates the current Plane from the plane defined by the three given points.
  80914. * @param point1 one of the points used to contruct the plane
  80915. * @param point2 one of the points used to contruct the plane
  80916. * @param point3 one of the points used to contruct the plane
  80917. * @returns the updated Plane.
  80918. */
  80919. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80920. /**
  80921. * Checks if the plane is facing a given direction
  80922. * @param direction the direction to check if the plane is facing
  80923. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80924. * @returns True is the vector "direction" is the same side than the plane normal.
  80925. */
  80926. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80927. /**
  80928. * Calculates the distance to a point
  80929. * @param point point to calculate distance to
  80930. * @returns the signed distance (float) from the given point to the Plane.
  80931. */
  80932. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80933. /**
  80934. * Creates a plane from an array
  80935. * @param array the array to create a plane from
  80936. * @returns a new Plane from the given array.
  80937. */
  80938. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80939. /**
  80940. * Creates a plane from three points
  80941. * @param point1 point used to create the plane
  80942. * @param point2 point used to create the plane
  80943. * @param point3 point used to create the plane
  80944. * @returns a new Plane defined by the three given points.
  80945. */
  80946. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80947. /**
  80948. * Creates a plane from an origin point and a normal
  80949. * @param origin origin of the plane to be constructed
  80950. * @param normal normal of the plane to be constructed
  80951. * @returns a new Plane the normal vector to this plane at the given origin point.
  80952. * Note : the vector "normal" is updated because normalized.
  80953. */
  80954. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80955. /**
  80956. * Calculates the distance from a plane and a point
  80957. * @param origin origin of the plane to be constructed
  80958. * @param normal normal of the plane to be constructed
  80959. * @param point point to calculate distance to
  80960. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80961. */
  80962. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80963. }
  80964. }
  80965. declare module BABYLON {
  80966. /** @hidden */
  80967. export class PerformanceConfigurator {
  80968. /** @hidden */
  80969. static MatrixUse64Bits: boolean;
  80970. /** @hidden */
  80971. static MatrixTrackPrecisionChange: boolean;
  80972. /** @hidden */
  80973. static MatrixCurrentType: any;
  80974. /** @hidden */
  80975. static MatrixTrackedMatrices: Array<any> | null;
  80976. /** @hidden */
  80977. static SetMatrixPrecision(use64bits: boolean): void;
  80978. }
  80979. }
  80980. declare module BABYLON {
  80981. /**
  80982. * Class representing a vector containing 2 coordinates
  80983. */
  80984. export class Vector2 {
  80985. /** defines the first coordinate */
  80986. x: number;
  80987. /** defines the second coordinate */
  80988. y: number;
  80989. /**
  80990. * Creates a new Vector2 from the given x and y coordinates
  80991. * @param x defines the first coordinate
  80992. * @param y defines the second coordinate
  80993. */
  80994. constructor(
  80995. /** defines the first coordinate */
  80996. x?: number,
  80997. /** defines the second coordinate */
  80998. y?: number);
  80999. /**
  81000. * Gets a string with the Vector2 coordinates
  81001. * @returns a string with the Vector2 coordinates
  81002. */
  81003. toString(): string;
  81004. /**
  81005. * Gets class name
  81006. * @returns the string "Vector2"
  81007. */
  81008. getClassName(): string;
  81009. /**
  81010. * Gets current vector hash code
  81011. * @returns the Vector2 hash code as a number
  81012. */
  81013. getHashCode(): number;
  81014. /**
  81015. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81016. * @param array defines the source array
  81017. * @param index defines the offset in source array
  81018. * @returns the current Vector2
  81019. */
  81020. toArray(array: FloatArray, index?: number): Vector2;
  81021. /**
  81022. * Update the current vector from an array
  81023. * @param array defines the destination array
  81024. * @param index defines the offset in the destination array
  81025. * @returns the current Vector3
  81026. */
  81027. fromArray(array: FloatArray, index?: number): Vector2;
  81028. /**
  81029. * Copy the current vector to an array
  81030. * @returns a new array with 2 elements: the Vector2 coordinates.
  81031. */
  81032. asArray(): number[];
  81033. /**
  81034. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81035. * @param source defines the source Vector2
  81036. * @returns the current updated Vector2
  81037. */
  81038. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81039. /**
  81040. * Sets the Vector2 coordinates with the given floats
  81041. * @param x defines the first coordinate
  81042. * @param y defines the second coordinate
  81043. * @returns the current updated Vector2
  81044. */
  81045. copyFromFloats(x: number, y: number): Vector2;
  81046. /**
  81047. * Sets the Vector2 coordinates with the given floats
  81048. * @param x defines the first coordinate
  81049. * @param y defines the second coordinate
  81050. * @returns the current updated Vector2
  81051. */
  81052. set(x: number, y: number): Vector2;
  81053. /**
  81054. * Add another vector with the current one
  81055. * @param otherVector defines the other vector
  81056. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81057. */
  81058. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81059. /**
  81060. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81061. * @param otherVector defines the other vector
  81062. * @param result defines the target vector
  81063. * @returns the unmodified current Vector2
  81064. */
  81065. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81066. /**
  81067. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81068. * @param otherVector defines the other vector
  81069. * @returns the current updated Vector2
  81070. */
  81071. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81072. /**
  81073. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81074. * @param otherVector defines the other vector
  81075. * @returns a new Vector2
  81076. */
  81077. addVector3(otherVector: Vector3): Vector2;
  81078. /**
  81079. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81080. * @param otherVector defines the other vector
  81081. * @returns a new Vector2
  81082. */
  81083. subtract(otherVector: Vector2): Vector2;
  81084. /**
  81085. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81086. * @param otherVector defines the other vector
  81087. * @param result defines the target vector
  81088. * @returns the unmodified current Vector2
  81089. */
  81090. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81091. /**
  81092. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81093. * @param otherVector defines the other vector
  81094. * @returns the current updated Vector2
  81095. */
  81096. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81097. /**
  81098. * Multiplies in place the current Vector2 coordinates by the given ones
  81099. * @param otherVector defines the other vector
  81100. * @returns the current updated Vector2
  81101. */
  81102. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81103. /**
  81104. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81105. * @param otherVector defines the other vector
  81106. * @returns a new Vector2
  81107. */
  81108. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81109. /**
  81110. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81111. * @param otherVector defines the other vector
  81112. * @param result defines the target vector
  81113. * @returns the unmodified current Vector2
  81114. */
  81115. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81116. /**
  81117. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81118. * @param x defines the first coordinate
  81119. * @param y defines the second coordinate
  81120. * @returns a new Vector2
  81121. */
  81122. multiplyByFloats(x: number, y: number): Vector2;
  81123. /**
  81124. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81125. * @param otherVector defines the other vector
  81126. * @returns a new Vector2
  81127. */
  81128. divide(otherVector: Vector2): Vector2;
  81129. /**
  81130. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81131. * @param otherVector defines the other vector
  81132. * @param result defines the target vector
  81133. * @returns the unmodified current Vector2
  81134. */
  81135. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81136. /**
  81137. * Divides the current Vector2 coordinates by the given ones
  81138. * @param otherVector defines the other vector
  81139. * @returns the current updated Vector2
  81140. */
  81141. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81142. /**
  81143. * Gets a new Vector2 with current Vector2 negated coordinates
  81144. * @returns a new Vector2
  81145. */
  81146. negate(): Vector2;
  81147. /**
  81148. * Negate this vector in place
  81149. * @returns this
  81150. */
  81151. negateInPlace(): Vector2;
  81152. /**
  81153. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  81154. * @param result defines the Vector3 object where to store the result
  81155. * @returns the current Vector2
  81156. */
  81157. negateToRef(result: Vector2): Vector2;
  81158. /**
  81159. * Multiply the Vector2 coordinates by scale
  81160. * @param scale defines the scaling factor
  81161. * @returns the current updated Vector2
  81162. */
  81163. scaleInPlace(scale: number): Vector2;
  81164. /**
  81165. * Returns a new Vector2 scaled by "scale" from the current Vector2
  81166. * @param scale defines the scaling factor
  81167. * @returns a new Vector2
  81168. */
  81169. scale(scale: number): Vector2;
  81170. /**
  81171. * Scale the current Vector2 values by a factor to a given Vector2
  81172. * @param scale defines the scale factor
  81173. * @param result defines the Vector2 object where to store the result
  81174. * @returns the unmodified current Vector2
  81175. */
  81176. scaleToRef(scale: number, result: Vector2): Vector2;
  81177. /**
  81178. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  81179. * @param scale defines the scale factor
  81180. * @param result defines the Vector2 object where to store the result
  81181. * @returns the unmodified current Vector2
  81182. */
  81183. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  81184. /**
  81185. * Gets a boolean if two vectors are equals
  81186. * @param otherVector defines the other vector
  81187. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  81188. */
  81189. equals(otherVector: DeepImmutable<Vector2>): boolean;
  81190. /**
  81191. * Gets a boolean if two vectors are equals (using an epsilon value)
  81192. * @param otherVector defines the other vector
  81193. * @param epsilon defines the minimal distance to consider equality
  81194. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  81195. */
  81196. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  81197. /**
  81198. * Gets a new Vector2 from current Vector2 floored values
  81199. * @returns a new Vector2
  81200. */
  81201. floor(): Vector2;
  81202. /**
  81203. * Gets a new Vector2 from current Vector2 floored values
  81204. * @returns a new Vector2
  81205. */
  81206. fract(): Vector2;
  81207. /**
  81208. * Gets the length of the vector
  81209. * @returns the vector length (float)
  81210. */
  81211. length(): number;
  81212. /**
  81213. * Gets the vector squared length
  81214. * @returns the vector squared length (float)
  81215. */
  81216. lengthSquared(): number;
  81217. /**
  81218. * Normalize the vector
  81219. * @returns the current updated Vector2
  81220. */
  81221. normalize(): Vector2;
  81222. /**
  81223. * Gets a new Vector2 copied from the Vector2
  81224. * @returns a new Vector2
  81225. */
  81226. clone(): Vector2;
  81227. /**
  81228. * Gets a new Vector2(0, 0)
  81229. * @returns a new Vector2
  81230. */
  81231. static Zero(): Vector2;
  81232. /**
  81233. * Gets a new Vector2(1, 1)
  81234. * @returns a new Vector2
  81235. */
  81236. static One(): Vector2;
  81237. /**
  81238. * Gets a new Vector2 set from the given index element of the given array
  81239. * @param array defines the data source
  81240. * @param offset defines the offset in the data source
  81241. * @returns a new Vector2
  81242. */
  81243. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  81244. /**
  81245. * Sets "result" from the given index element of the given array
  81246. * @param array defines the data source
  81247. * @param offset defines the offset in the data source
  81248. * @param result defines the target vector
  81249. */
  81250. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  81251. /**
  81252. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  81253. * @param value1 defines 1st point of control
  81254. * @param value2 defines 2nd point of control
  81255. * @param value3 defines 3rd point of control
  81256. * @param value4 defines 4th point of control
  81257. * @param amount defines the interpolation factor
  81258. * @returns a new Vector2
  81259. */
  81260. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  81261. /**
  81262. * 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".
  81263. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  81264. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  81265. * @param value defines the value to clamp
  81266. * @param min defines the lower limit
  81267. * @param max defines the upper limit
  81268. * @returns a new Vector2
  81269. */
  81270. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  81271. /**
  81272. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  81273. * @param value1 defines the 1st control point
  81274. * @param tangent1 defines the outgoing tangent
  81275. * @param value2 defines the 2nd control point
  81276. * @param tangent2 defines the incoming tangent
  81277. * @param amount defines the interpolation factor
  81278. * @returns a new Vector2
  81279. */
  81280. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  81281. /**
  81282. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  81283. * @param start defines the start vector
  81284. * @param end defines the end vector
  81285. * @param amount defines the interpolation factor
  81286. * @returns a new Vector2
  81287. */
  81288. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  81289. /**
  81290. * Gets the dot product of the vector "left" and the vector "right"
  81291. * @param left defines first vector
  81292. * @param right defines second vector
  81293. * @returns the dot product (float)
  81294. */
  81295. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  81296. /**
  81297. * Returns a new Vector2 equal to the normalized given vector
  81298. * @param vector defines the vector to normalize
  81299. * @returns a new Vector2
  81300. */
  81301. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  81302. /**
  81303. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  81304. * @param left defines 1st vector
  81305. * @param right defines 2nd vector
  81306. * @returns a new Vector2
  81307. */
  81308. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81309. /**
  81310. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  81311. * @param left defines 1st vector
  81312. * @param right defines 2nd vector
  81313. * @returns a new Vector2
  81314. */
  81315. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  81316. /**
  81317. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  81318. * @param vector defines the vector to transform
  81319. * @param transformation defines the matrix to apply
  81320. * @returns a new Vector2
  81321. */
  81322. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  81323. /**
  81324. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  81325. * @param vector defines the vector to transform
  81326. * @param transformation defines the matrix to apply
  81327. * @param result defines the target vector
  81328. */
  81329. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  81330. /**
  81331. * Determines if a given vector is included in a triangle
  81332. * @param p defines the vector to test
  81333. * @param p0 defines 1st triangle point
  81334. * @param p1 defines 2nd triangle point
  81335. * @param p2 defines 3rd triangle point
  81336. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  81337. */
  81338. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  81339. /**
  81340. * Gets the distance between the vectors "value1" and "value2"
  81341. * @param value1 defines first vector
  81342. * @param value2 defines second vector
  81343. * @returns the distance between vectors
  81344. */
  81345. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81346. /**
  81347. * Returns the squared distance between the vectors "value1" and "value2"
  81348. * @param value1 defines first vector
  81349. * @param value2 defines second vector
  81350. * @returns the squared distance between vectors
  81351. */
  81352. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  81353. /**
  81354. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  81355. * @param value1 defines first vector
  81356. * @param value2 defines second vector
  81357. * @returns a new Vector2
  81358. */
  81359. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  81360. /**
  81361. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  81362. * @param p defines the middle point
  81363. * @param segA defines one point of the segment
  81364. * @param segB defines the other point of the segment
  81365. * @returns the shortest distance
  81366. */
  81367. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  81368. }
  81369. /**
  81370. * Class used to store (x,y,z) vector representation
  81371. * A Vector3 is the main object used in 3D geometry
  81372. * It can represent etiher the coordinates of a point the space, either a direction
  81373. * Reminder: js uses a left handed forward facing system
  81374. */
  81375. export class Vector3 {
  81376. private static _UpReadOnly;
  81377. private static _ZeroReadOnly;
  81378. /** @hidden */
  81379. _x: number;
  81380. /** @hidden */
  81381. _y: number;
  81382. /** @hidden */
  81383. _z: number;
  81384. /** @hidden */
  81385. _isDirty: boolean;
  81386. /** Gets or sets the x coordinate */
  81387. get x(): number;
  81388. set x(value: number);
  81389. /** Gets or sets the y coordinate */
  81390. get y(): number;
  81391. set y(value: number);
  81392. /** Gets or sets the z coordinate */
  81393. get z(): number;
  81394. set z(value: number);
  81395. /**
  81396. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  81397. * @param x defines the first coordinates (on X axis)
  81398. * @param y defines the second coordinates (on Y axis)
  81399. * @param z defines the third coordinates (on Z axis)
  81400. */
  81401. constructor(x?: number, y?: number, z?: number);
  81402. /**
  81403. * Creates a string representation of the Vector3
  81404. * @returns a string with the Vector3 coordinates.
  81405. */
  81406. toString(): string;
  81407. /**
  81408. * Gets the class name
  81409. * @returns the string "Vector3"
  81410. */
  81411. getClassName(): string;
  81412. /**
  81413. * Creates the Vector3 hash code
  81414. * @returns a number which tends to be unique between Vector3 instances
  81415. */
  81416. getHashCode(): number;
  81417. /**
  81418. * Creates an array containing three elements : the coordinates of the Vector3
  81419. * @returns a new array of numbers
  81420. */
  81421. asArray(): number[];
  81422. /**
  81423. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  81424. * @param array defines the destination array
  81425. * @param index defines the offset in the destination array
  81426. * @returns the current Vector3
  81427. */
  81428. toArray(array: FloatArray, index?: number): Vector3;
  81429. /**
  81430. * Update the current vector from an array
  81431. * @param array defines the destination array
  81432. * @param index defines the offset in the destination array
  81433. * @returns the current Vector3
  81434. */
  81435. fromArray(array: FloatArray, index?: number): Vector3;
  81436. /**
  81437. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  81438. * @returns a new Quaternion object, computed from the Vector3 coordinates
  81439. */
  81440. toQuaternion(): Quaternion;
  81441. /**
  81442. * Adds the given vector to the current Vector3
  81443. * @param otherVector defines the second operand
  81444. * @returns the current updated Vector3
  81445. */
  81446. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81447. /**
  81448. * Adds the given coordinates to the current Vector3
  81449. * @param x defines the x coordinate of the operand
  81450. * @param y defines the y coordinate of the operand
  81451. * @param z defines the z coordinate of the operand
  81452. * @returns the current updated Vector3
  81453. */
  81454. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81455. /**
  81456. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  81457. * @param otherVector defines the second operand
  81458. * @returns the resulting Vector3
  81459. */
  81460. add(otherVector: DeepImmutable<Vector3>): Vector3;
  81461. /**
  81462. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  81463. * @param otherVector defines the second operand
  81464. * @param result defines the Vector3 object where to store the result
  81465. * @returns the current Vector3
  81466. */
  81467. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81468. /**
  81469. * Subtract the given vector from the current Vector3
  81470. * @param otherVector defines the second operand
  81471. * @returns the current updated Vector3
  81472. */
  81473. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81474. /**
  81475. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  81476. * @param otherVector defines the second operand
  81477. * @returns the resulting Vector3
  81478. */
  81479. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  81480. /**
  81481. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  81482. * @param otherVector defines the second operand
  81483. * @param result defines the Vector3 object where to store the result
  81484. * @returns the current Vector3
  81485. */
  81486. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81487. /**
  81488. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  81489. * @param x defines the x coordinate of the operand
  81490. * @param y defines the y coordinate of the operand
  81491. * @param z defines the z coordinate of the operand
  81492. * @returns the resulting Vector3
  81493. */
  81494. subtractFromFloats(x: number, y: number, z: number): Vector3;
  81495. /**
  81496. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  81497. * @param x defines the x coordinate of the operand
  81498. * @param y defines the y coordinate of the operand
  81499. * @param z defines the z coordinate of the operand
  81500. * @param result defines the Vector3 object where to store the result
  81501. * @returns the current Vector3
  81502. */
  81503. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  81504. /**
  81505. * Gets a new Vector3 set with the current Vector3 negated coordinates
  81506. * @returns a new Vector3
  81507. */
  81508. negate(): Vector3;
  81509. /**
  81510. * Negate this vector in place
  81511. * @returns this
  81512. */
  81513. negateInPlace(): Vector3;
  81514. /**
  81515. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  81516. * @param result defines the Vector3 object where to store the result
  81517. * @returns the current Vector3
  81518. */
  81519. negateToRef(result: Vector3): Vector3;
  81520. /**
  81521. * Multiplies the Vector3 coordinates by the float "scale"
  81522. * @param scale defines the multiplier factor
  81523. * @returns the current updated Vector3
  81524. */
  81525. scaleInPlace(scale: number): Vector3;
  81526. /**
  81527. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  81528. * @param scale defines the multiplier factor
  81529. * @returns a new Vector3
  81530. */
  81531. scale(scale: number): Vector3;
  81532. /**
  81533. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  81534. * @param scale defines the multiplier factor
  81535. * @param result defines the Vector3 object where to store the result
  81536. * @returns the current Vector3
  81537. */
  81538. scaleToRef(scale: number, result: Vector3): Vector3;
  81539. /**
  81540. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  81541. * @param scale defines the scale factor
  81542. * @param result defines the Vector3 object where to store the result
  81543. * @returns the unmodified current Vector3
  81544. */
  81545. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  81546. /**
  81547. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81548. * @param origin defines the origin of the projection ray
  81549. * @param plane defines the plane to project to
  81550. * @returns the projected vector3
  81551. */
  81552. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  81553. /**
  81554. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  81555. * @param origin defines the origin of the projection ray
  81556. * @param plane defines the plane to project to
  81557. * @param result defines the Vector3 where to store the result
  81558. */
  81559. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  81560. /**
  81561. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  81562. * @param otherVector defines the second operand
  81563. * @returns true if both vectors are equals
  81564. */
  81565. equals(otherVector: DeepImmutable<Vector3>): boolean;
  81566. /**
  81567. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  81568. * @param otherVector defines the second operand
  81569. * @param epsilon defines the minimal distance to define values as equals
  81570. * @returns true if both vectors are distant less than epsilon
  81571. */
  81572. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  81573. /**
  81574. * Returns true if the current Vector3 coordinates equals the given floats
  81575. * @param x defines the x coordinate of the operand
  81576. * @param y defines the y coordinate of the operand
  81577. * @param z defines the z coordinate of the operand
  81578. * @returns true if both vectors are equals
  81579. */
  81580. equalsToFloats(x: number, y: number, z: number): boolean;
  81581. /**
  81582. * Multiplies the current Vector3 coordinates by the given ones
  81583. * @param otherVector defines the second operand
  81584. * @returns the current updated Vector3
  81585. */
  81586. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  81587. /**
  81588. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  81589. * @param otherVector defines the second operand
  81590. * @returns the new Vector3
  81591. */
  81592. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  81593. /**
  81594. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81595. * @param otherVector defines the second operand
  81596. * @param result defines the Vector3 object where to store the result
  81597. * @returns the current Vector3
  81598. */
  81599. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81600. /**
  81601. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81602. * @param x defines the x coordinate of the operand
  81603. * @param y defines the y coordinate of the operand
  81604. * @param z defines the z coordinate of the operand
  81605. * @returns the new Vector3
  81606. */
  81607. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81608. /**
  81609. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81610. * @param otherVector defines the second operand
  81611. * @returns the new Vector3
  81612. */
  81613. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81614. /**
  81615. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81616. * @param otherVector defines the second operand
  81617. * @param result defines the Vector3 object where to store the result
  81618. * @returns the current Vector3
  81619. */
  81620. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81621. /**
  81622. * Divides the current Vector3 coordinates by the given ones.
  81623. * @param otherVector defines the second operand
  81624. * @returns the current updated Vector3
  81625. */
  81626. divideInPlace(otherVector: Vector3): Vector3;
  81627. /**
  81628. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81629. * @param other defines the second operand
  81630. * @returns the current updated Vector3
  81631. */
  81632. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81633. /**
  81634. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81635. * @param other defines the second operand
  81636. * @returns the current updated Vector3
  81637. */
  81638. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81639. /**
  81640. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81641. * @param x defines the x coordinate of the operand
  81642. * @param y defines the y coordinate of the operand
  81643. * @param z defines the z coordinate of the operand
  81644. * @returns the current updated Vector3
  81645. */
  81646. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81647. /**
  81648. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81649. * @param x defines the x coordinate of the operand
  81650. * @param y defines the y coordinate of the operand
  81651. * @param z defines the z coordinate of the operand
  81652. * @returns the current updated Vector3
  81653. */
  81654. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81655. /**
  81656. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81657. * Check if is non uniform within a certain amount of decimal places to account for this
  81658. * @param epsilon the amount the values can differ
  81659. * @returns if the the vector is non uniform to a certain number of decimal places
  81660. */
  81661. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81662. /**
  81663. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81664. */
  81665. get isNonUniform(): boolean;
  81666. /**
  81667. * Gets a new Vector3 from current Vector3 floored values
  81668. * @returns a new Vector3
  81669. */
  81670. floor(): Vector3;
  81671. /**
  81672. * Gets a new Vector3 from current Vector3 floored values
  81673. * @returns a new Vector3
  81674. */
  81675. fract(): Vector3;
  81676. /**
  81677. * Gets the length of the Vector3
  81678. * @returns the length of the Vector3
  81679. */
  81680. length(): number;
  81681. /**
  81682. * Gets the squared length of the Vector3
  81683. * @returns squared length of the Vector3
  81684. */
  81685. lengthSquared(): number;
  81686. /**
  81687. * Normalize the current Vector3.
  81688. * Please note that this is an in place operation.
  81689. * @returns the current updated Vector3
  81690. */
  81691. normalize(): Vector3;
  81692. /**
  81693. * Reorders the x y z properties of the vector in place
  81694. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81695. * @returns the current updated vector
  81696. */
  81697. reorderInPlace(order: string): this;
  81698. /**
  81699. * Rotates the vector around 0,0,0 by a quaternion
  81700. * @param quaternion the rotation quaternion
  81701. * @param result vector to store the result
  81702. * @returns the resulting vector
  81703. */
  81704. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81705. /**
  81706. * Rotates a vector around a given point
  81707. * @param quaternion the rotation quaternion
  81708. * @param point the point to rotate around
  81709. * @param result vector to store the result
  81710. * @returns the resulting vector
  81711. */
  81712. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81713. /**
  81714. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81715. * The cross product is then orthogonal to both current and "other"
  81716. * @param other defines the right operand
  81717. * @returns the cross product
  81718. */
  81719. cross(other: Vector3): Vector3;
  81720. /**
  81721. * Normalize the current Vector3 with the given input length.
  81722. * Please note that this is an in place operation.
  81723. * @param len the length of the vector
  81724. * @returns the current updated Vector3
  81725. */
  81726. normalizeFromLength(len: number): Vector3;
  81727. /**
  81728. * Normalize the current Vector3 to a new vector
  81729. * @returns the new Vector3
  81730. */
  81731. normalizeToNew(): Vector3;
  81732. /**
  81733. * Normalize the current Vector3 to the reference
  81734. * @param reference define the Vector3 to update
  81735. * @returns the updated Vector3
  81736. */
  81737. normalizeToRef(reference: Vector3): Vector3;
  81738. /**
  81739. * Creates a new Vector3 copied from the current Vector3
  81740. * @returns the new Vector3
  81741. */
  81742. clone(): Vector3;
  81743. /**
  81744. * Copies the given vector coordinates to the current Vector3 ones
  81745. * @param source defines the source Vector3
  81746. * @returns the current updated Vector3
  81747. */
  81748. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81749. /**
  81750. * Copies the given floats to the current Vector3 coordinates
  81751. * @param x defines the x coordinate of the operand
  81752. * @param y defines the y coordinate of the operand
  81753. * @param z defines the z coordinate of the operand
  81754. * @returns the current updated Vector3
  81755. */
  81756. copyFromFloats(x: number, y: number, z: number): Vector3;
  81757. /**
  81758. * Copies the given floats to the current Vector3 coordinates
  81759. * @param x defines the x coordinate of the operand
  81760. * @param y defines the y coordinate of the operand
  81761. * @param z defines the z coordinate of the operand
  81762. * @returns the current updated Vector3
  81763. */
  81764. set(x: number, y: number, z: number): Vector3;
  81765. /**
  81766. * Copies the given float to the current Vector3 coordinates
  81767. * @param v defines the x, y and z coordinates of the operand
  81768. * @returns the current updated Vector3
  81769. */
  81770. setAll(v: number): Vector3;
  81771. /**
  81772. * Get the clip factor between two vectors
  81773. * @param vector0 defines the first operand
  81774. * @param vector1 defines the second operand
  81775. * @param axis defines the axis to use
  81776. * @param size defines the size along the axis
  81777. * @returns the clip factor
  81778. */
  81779. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81780. /**
  81781. * Get angle between two vectors
  81782. * @param vector0 angle between vector0 and vector1
  81783. * @param vector1 angle between vector0 and vector1
  81784. * @param normal direction of the normal
  81785. * @return the angle between vector0 and vector1
  81786. */
  81787. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81788. /**
  81789. * Returns a new Vector3 set from the index "offset" of the given array
  81790. * @param array defines the source array
  81791. * @param offset defines the offset in the source array
  81792. * @returns the new Vector3
  81793. */
  81794. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81795. /**
  81796. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81797. * @param array defines the source array
  81798. * @param offset defines the offset in the source array
  81799. * @returns the new Vector3
  81800. * @deprecated Please use FromArray instead.
  81801. */
  81802. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81803. /**
  81804. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81805. * @param array defines the source array
  81806. * @param offset defines the offset in the source array
  81807. * @param result defines the Vector3 where to store the result
  81808. */
  81809. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81810. /**
  81811. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81812. * @param array defines the source array
  81813. * @param offset defines the offset in the source array
  81814. * @param result defines the Vector3 where to store the result
  81815. * @deprecated Please use FromArrayToRef instead.
  81816. */
  81817. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81818. /**
  81819. * Sets the given vector "result" with the given floats.
  81820. * @param x defines the x coordinate of the source
  81821. * @param y defines the y coordinate of the source
  81822. * @param z defines the z coordinate of the source
  81823. * @param result defines the Vector3 where to store the result
  81824. */
  81825. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81826. /**
  81827. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81828. * @returns a new empty Vector3
  81829. */
  81830. static Zero(): Vector3;
  81831. /**
  81832. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81833. * @returns a new unit Vector3
  81834. */
  81835. static One(): Vector3;
  81836. /**
  81837. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81838. * @returns a new up Vector3
  81839. */
  81840. static Up(): Vector3;
  81841. /**
  81842. * Gets a up Vector3 that must not be updated
  81843. */
  81844. static get UpReadOnly(): DeepImmutable<Vector3>;
  81845. /**
  81846. * Gets a zero Vector3 that must not be updated
  81847. */
  81848. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81849. /**
  81850. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81851. * @returns a new down Vector3
  81852. */
  81853. static Down(): Vector3;
  81854. /**
  81855. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81856. * @param rightHandedSystem is the scene right-handed (negative z)
  81857. * @returns a new forward Vector3
  81858. */
  81859. static Forward(rightHandedSystem?: boolean): Vector3;
  81860. /**
  81861. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81862. * @param rightHandedSystem is the scene right-handed (negative-z)
  81863. * @returns a new forward Vector3
  81864. */
  81865. static Backward(rightHandedSystem?: boolean): Vector3;
  81866. /**
  81867. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81868. * @returns a new right Vector3
  81869. */
  81870. static Right(): Vector3;
  81871. /**
  81872. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81873. * @returns a new left Vector3
  81874. */
  81875. static Left(): Vector3;
  81876. /**
  81877. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81878. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81879. * @param vector defines the Vector3 to transform
  81880. * @param transformation defines the transformation matrix
  81881. * @returns the transformed Vector3
  81882. */
  81883. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81884. /**
  81885. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81886. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81887. * @param vector defines the Vector3 to transform
  81888. * @param transformation defines the transformation matrix
  81889. * @param result defines the Vector3 where to store the result
  81890. */
  81891. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81892. /**
  81893. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81894. * This method computes tranformed coordinates only, not transformed direction vectors
  81895. * @param x define the x coordinate of the source vector
  81896. * @param y define the y coordinate of the source vector
  81897. * @param z define the z coordinate of the source vector
  81898. * @param transformation defines the transformation matrix
  81899. * @param result defines the Vector3 where to store the result
  81900. */
  81901. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81902. /**
  81903. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81904. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81905. * @param vector defines the Vector3 to transform
  81906. * @param transformation defines the transformation matrix
  81907. * @returns the new Vector3
  81908. */
  81909. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81910. /**
  81911. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81912. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81913. * @param vector defines the Vector3 to transform
  81914. * @param transformation defines the transformation matrix
  81915. * @param result defines the Vector3 where to store the result
  81916. */
  81917. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81918. /**
  81919. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81920. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81921. * @param x define the x coordinate of the source vector
  81922. * @param y define the y coordinate of the source vector
  81923. * @param z define the z coordinate of the source vector
  81924. * @param transformation defines the transformation matrix
  81925. * @param result defines the Vector3 where to store the result
  81926. */
  81927. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81928. /**
  81929. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81930. * @param value1 defines the first control point
  81931. * @param value2 defines the second control point
  81932. * @param value3 defines the third control point
  81933. * @param value4 defines the fourth control point
  81934. * @param amount defines the amount on the spline to use
  81935. * @returns the new Vector3
  81936. */
  81937. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81938. /**
  81939. * 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"
  81940. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81941. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81942. * @param value defines the current value
  81943. * @param min defines the lower range value
  81944. * @param max defines the upper range value
  81945. * @returns the new Vector3
  81946. */
  81947. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81948. /**
  81949. * 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"
  81950. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81951. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81952. * @param value defines the current value
  81953. * @param min defines the lower range value
  81954. * @param max defines the upper range value
  81955. * @param result defines the Vector3 where to store the result
  81956. */
  81957. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81958. /**
  81959. * Checks if a given vector is inside a specific range
  81960. * @param v defines the vector to test
  81961. * @param min defines the minimum range
  81962. * @param max defines the maximum range
  81963. */
  81964. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81965. /**
  81966. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81967. * @param value1 defines the first control point
  81968. * @param tangent1 defines the first tangent vector
  81969. * @param value2 defines the second control point
  81970. * @param tangent2 defines the second tangent vector
  81971. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81972. * @returns the new Vector3
  81973. */
  81974. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81975. /**
  81976. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81977. * @param start defines the start value
  81978. * @param end defines the end value
  81979. * @param amount max defines amount between both (between 0 and 1)
  81980. * @returns the new Vector3
  81981. */
  81982. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81983. /**
  81984. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81985. * @param start defines the start value
  81986. * @param end defines the end value
  81987. * @param amount max defines amount between both (between 0 and 1)
  81988. * @param result defines the Vector3 where to store the result
  81989. */
  81990. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81991. /**
  81992. * Returns the dot product (float) between the vectors "left" and "right"
  81993. * @param left defines the left operand
  81994. * @param right defines the right operand
  81995. * @returns the dot product
  81996. */
  81997. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81998. /**
  81999. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82000. * The cross product is then orthogonal to both "left" and "right"
  82001. * @param left defines the left operand
  82002. * @param right defines the right operand
  82003. * @returns the cross product
  82004. */
  82005. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82006. /**
  82007. * Sets the given vector "result" with the cross product of "left" and "right"
  82008. * The cross product is then orthogonal to both "left" and "right"
  82009. * @param left defines the left operand
  82010. * @param right defines the right operand
  82011. * @param result defines the Vector3 where to store the result
  82012. */
  82013. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82014. /**
  82015. * Returns a new Vector3 as the normalization of the given vector
  82016. * @param vector defines the Vector3 to normalize
  82017. * @returns the new Vector3
  82018. */
  82019. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82020. /**
  82021. * Sets the given vector "result" with the normalization of the given first vector
  82022. * @param vector defines the Vector3 to normalize
  82023. * @param result defines the Vector3 where to store the result
  82024. */
  82025. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82026. /**
  82027. * Project a Vector3 onto screen space
  82028. * @param vector defines the Vector3 to project
  82029. * @param world defines the world matrix to use
  82030. * @param transform defines the transform (view x projection) matrix to use
  82031. * @param viewport defines the screen viewport to use
  82032. * @returns the new Vector3
  82033. */
  82034. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82035. /** @hidden */
  82036. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82037. /**
  82038. * Unproject from screen space to object space
  82039. * @param source defines the screen space Vector3 to use
  82040. * @param viewportWidth defines the current width of the viewport
  82041. * @param viewportHeight defines the current height of the viewport
  82042. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82043. * @param transform defines the transform (view x projection) matrix to use
  82044. * @returns the new Vector3
  82045. */
  82046. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82047. /**
  82048. * Unproject from screen space to object space
  82049. * @param source defines the screen space Vector3 to use
  82050. * @param viewportWidth defines the current width of the viewport
  82051. * @param viewportHeight defines the current height of the viewport
  82052. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82053. * @param view defines the view matrix to use
  82054. * @param projection defines the projection matrix to use
  82055. * @returns the new Vector3
  82056. */
  82057. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82058. /**
  82059. * Unproject from screen space to object space
  82060. * @param source defines the screen space Vector3 to use
  82061. * @param viewportWidth defines the current width of the viewport
  82062. * @param viewportHeight defines the current height of the viewport
  82063. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82064. * @param view defines the view matrix to use
  82065. * @param projection defines the projection matrix to use
  82066. * @param result defines the Vector3 where to store the result
  82067. */
  82068. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82069. /**
  82070. * Unproject from screen space to object space
  82071. * @param sourceX defines the screen space x coordinate to use
  82072. * @param sourceY defines the screen space y coordinate to use
  82073. * @param sourceZ defines the screen space z coordinate to use
  82074. * @param viewportWidth defines the current width of the viewport
  82075. * @param viewportHeight defines the current height of the viewport
  82076. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82077. * @param view defines the view matrix to use
  82078. * @param projection defines the projection matrix to use
  82079. * @param result defines the Vector3 where to store the result
  82080. */
  82081. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82082. /**
  82083. * Gets the minimal coordinate values between two Vector3
  82084. * @param left defines the first operand
  82085. * @param right defines the second operand
  82086. * @returns the new Vector3
  82087. */
  82088. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82089. /**
  82090. * Gets the maximal coordinate values between two Vector3
  82091. * @param left defines the first operand
  82092. * @param right defines the second operand
  82093. * @returns the new Vector3
  82094. */
  82095. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82096. /**
  82097. * Returns the distance between the vectors "value1" and "value2"
  82098. * @param value1 defines the first operand
  82099. * @param value2 defines the second operand
  82100. * @returns the distance
  82101. */
  82102. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82103. /**
  82104. * Returns the squared distance between the vectors "value1" and "value2"
  82105. * @param value1 defines the first operand
  82106. * @param value2 defines the second operand
  82107. * @returns the squared distance
  82108. */
  82109. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82110. /**
  82111. * Returns a new Vector3 located at the center between "value1" and "value2"
  82112. * @param value1 defines the first operand
  82113. * @param value2 defines the second operand
  82114. * @returns the new Vector3
  82115. */
  82116. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82117. /**
  82118. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82119. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82120. * to something in order to rotate it from its local system to the given target system
  82121. * Note: axis1, axis2 and axis3 are normalized during this operation
  82122. * @param axis1 defines the first axis
  82123. * @param axis2 defines the second axis
  82124. * @param axis3 defines the third axis
  82125. * @returns a new Vector3
  82126. */
  82127. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82128. /**
  82129. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82130. * @param axis1 defines the first axis
  82131. * @param axis2 defines the second axis
  82132. * @param axis3 defines the third axis
  82133. * @param ref defines the Vector3 where to store the result
  82134. */
  82135. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  82136. }
  82137. /**
  82138. * Vector4 class created for EulerAngle class conversion to Quaternion
  82139. */
  82140. export class Vector4 {
  82141. /** x value of the vector */
  82142. x: number;
  82143. /** y value of the vector */
  82144. y: number;
  82145. /** z value of the vector */
  82146. z: number;
  82147. /** w value of the vector */
  82148. w: number;
  82149. /**
  82150. * Creates a Vector4 object from the given floats.
  82151. * @param x x value of the vector
  82152. * @param y y value of the vector
  82153. * @param z z value of the vector
  82154. * @param w w value of the vector
  82155. */
  82156. constructor(
  82157. /** x value of the vector */
  82158. x: number,
  82159. /** y value of the vector */
  82160. y: number,
  82161. /** z value of the vector */
  82162. z: number,
  82163. /** w value of the vector */
  82164. w: number);
  82165. /**
  82166. * Returns the string with the Vector4 coordinates.
  82167. * @returns a string containing all the vector values
  82168. */
  82169. toString(): string;
  82170. /**
  82171. * Returns the string "Vector4".
  82172. * @returns "Vector4"
  82173. */
  82174. getClassName(): string;
  82175. /**
  82176. * Returns the Vector4 hash code.
  82177. * @returns a unique hash code
  82178. */
  82179. getHashCode(): number;
  82180. /**
  82181. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  82182. * @returns the resulting array
  82183. */
  82184. asArray(): number[];
  82185. /**
  82186. * Populates the given array from the given index with the Vector4 coordinates.
  82187. * @param array array to populate
  82188. * @param index index of the array to start at (default: 0)
  82189. * @returns the Vector4.
  82190. */
  82191. toArray(array: FloatArray, index?: number): Vector4;
  82192. /**
  82193. * Update the current vector from an array
  82194. * @param array defines the destination array
  82195. * @param index defines the offset in the destination array
  82196. * @returns the current Vector3
  82197. */
  82198. fromArray(array: FloatArray, index?: number): Vector4;
  82199. /**
  82200. * Adds the given vector to the current Vector4.
  82201. * @param otherVector the vector to add
  82202. * @returns the updated Vector4.
  82203. */
  82204. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82205. /**
  82206. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  82207. * @param otherVector the vector to add
  82208. * @returns the resulting vector
  82209. */
  82210. add(otherVector: DeepImmutable<Vector4>): Vector4;
  82211. /**
  82212. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  82213. * @param otherVector the vector to add
  82214. * @param result the vector to store the result
  82215. * @returns the current Vector4.
  82216. */
  82217. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82218. /**
  82219. * Subtract in place the given vector from the current Vector4.
  82220. * @param otherVector the vector to subtract
  82221. * @returns the updated Vector4.
  82222. */
  82223. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82224. /**
  82225. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  82226. * @param otherVector the vector to add
  82227. * @returns the new vector with the result
  82228. */
  82229. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  82230. /**
  82231. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  82232. * @param otherVector the vector to subtract
  82233. * @param result the vector to store the result
  82234. * @returns the current Vector4.
  82235. */
  82236. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82237. /**
  82238. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82239. */
  82240. /**
  82241. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82242. * @param x value to subtract
  82243. * @param y value to subtract
  82244. * @param z value to subtract
  82245. * @param w value to subtract
  82246. * @returns new vector containing the result
  82247. */
  82248. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82249. /**
  82250. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  82251. * @param x value to subtract
  82252. * @param y value to subtract
  82253. * @param z value to subtract
  82254. * @param w value to subtract
  82255. * @param result the vector to store the result in
  82256. * @returns the current Vector4.
  82257. */
  82258. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  82259. /**
  82260. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  82261. * @returns a new vector with the negated values
  82262. */
  82263. negate(): Vector4;
  82264. /**
  82265. * Negate this vector in place
  82266. * @returns this
  82267. */
  82268. negateInPlace(): Vector4;
  82269. /**
  82270. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  82271. * @param result defines the Vector3 object where to store the result
  82272. * @returns the current Vector4
  82273. */
  82274. negateToRef(result: Vector4): Vector4;
  82275. /**
  82276. * Multiplies the current Vector4 coordinates by scale (float).
  82277. * @param scale the number to scale with
  82278. * @returns the updated Vector4.
  82279. */
  82280. scaleInPlace(scale: number): Vector4;
  82281. /**
  82282. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  82283. * @param scale the number to scale with
  82284. * @returns a new vector with the result
  82285. */
  82286. scale(scale: number): Vector4;
  82287. /**
  82288. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  82289. * @param scale the number to scale with
  82290. * @param result a vector to store the result in
  82291. * @returns the current Vector4.
  82292. */
  82293. scaleToRef(scale: number, result: Vector4): Vector4;
  82294. /**
  82295. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  82296. * @param scale defines the scale factor
  82297. * @param result defines the Vector4 object where to store the result
  82298. * @returns the unmodified current Vector4
  82299. */
  82300. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  82301. /**
  82302. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  82303. * @param otherVector the vector to compare against
  82304. * @returns true if they are equal
  82305. */
  82306. equals(otherVector: DeepImmutable<Vector4>): boolean;
  82307. /**
  82308. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  82309. * @param otherVector vector to compare against
  82310. * @param epsilon (Default: very small number)
  82311. * @returns true if they are equal
  82312. */
  82313. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  82314. /**
  82315. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  82316. * @param x x value to compare against
  82317. * @param y y value to compare against
  82318. * @param z z value to compare against
  82319. * @param w w value to compare against
  82320. * @returns true if equal
  82321. */
  82322. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  82323. /**
  82324. * Multiplies in place the current Vector4 by the given one.
  82325. * @param otherVector vector to multiple with
  82326. * @returns the updated Vector4.
  82327. */
  82328. multiplyInPlace(otherVector: Vector4): Vector4;
  82329. /**
  82330. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  82331. * @param otherVector vector to multiple with
  82332. * @returns resulting new vector
  82333. */
  82334. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  82335. /**
  82336. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  82337. * @param otherVector vector to multiple with
  82338. * @param result vector to store the result
  82339. * @returns the current Vector4.
  82340. */
  82341. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82342. /**
  82343. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  82344. * @param x x value multiply with
  82345. * @param y y value multiply with
  82346. * @param z z value multiply with
  82347. * @param w w value multiply with
  82348. * @returns resulting new vector
  82349. */
  82350. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  82351. /**
  82352. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  82353. * @param otherVector vector to devide with
  82354. * @returns resulting new vector
  82355. */
  82356. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  82357. /**
  82358. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  82359. * @param otherVector vector to devide with
  82360. * @param result vector to store the result
  82361. * @returns the current Vector4.
  82362. */
  82363. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  82364. /**
  82365. * Divides the current Vector3 coordinates by the given ones.
  82366. * @param otherVector vector to devide with
  82367. * @returns the updated Vector3.
  82368. */
  82369. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  82370. /**
  82371. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  82372. * @param other defines the second operand
  82373. * @returns the current updated Vector4
  82374. */
  82375. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82376. /**
  82377. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  82378. * @param other defines the second operand
  82379. * @returns the current updated Vector4
  82380. */
  82381. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  82382. /**
  82383. * Gets a new Vector4 from current Vector4 floored values
  82384. * @returns a new Vector4
  82385. */
  82386. floor(): Vector4;
  82387. /**
  82388. * Gets a new Vector4 from current Vector3 floored values
  82389. * @returns a new Vector4
  82390. */
  82391. fract(): Vector4;
  82392. /**
  82393. * Returns the Vector4 length (float).
  82394. * @returns the length
  82395. */
  82396. length(): number;
  82397. /**
  82398. * Returns the Vector4 squared length (float).
  82399. * @returns the length squared
  82400. */
  82401. lengthSquared(): number;
  82402. /**
  82403. * Normalizes in place the Vector4.
  82404. * @returns the updated Vector4.
  82405. */
  82406. normalize(): Vector4;
  82407. /**
  82408. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  82409. * @returns this converted to a new vector3
  82410. */
  82411. toVector3(): Vector3;
  82412. /**
  82413. * Returns a new Vector4 copied from the current one.
  82414. * @returns the new cloned vector
  82415. */
  82416. clone(): Vector4;
  82417. /**
  82418. * Updates the current Vector4 with the given one coordinates.
  82419. * @param source the source vector to copy from
  82420. * @returns the updated Vector4.
  82421. */
  82422. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  82423. /**
  82424. * Updates the current Vector4 coordinates with the given floats.
  82425. * @param x float to copy from
  82426. * @param y float to copy from
  82427. * @param z float to copy from
  82428. * @param w float to copy from
  82429. * @returns the updated Vector4.
  82430. */
  82431. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  82432. /**
  82433. * Updates the current Vector4 coordinates with the given floats.
  82434. * @param x float to set from
  82435. * @param y float to set from
  82436. * @param z float to set from
  82437. * @param w float to set from
  82438. * @returns the updated Vector4.
  82439. */
  82440. set(x: number, y: number, z: number, w: number): Vector4;
  82441. /**
  82442. * Copies the given float to the current Vector3 coordinates
  82443. * @param v defines the x, y, z and w coordinates of the operand
  82444. * @returns the current updated Vector3
  82445. */
  82446. setAll(v: number): Vector4;
  82447. /**
  82448. * Returns a new Vector4 set from the starting index of the given array.
  82449. * @param array the array to pull values from
  82450. * @param offset the offset into the array to start at
  82451. * @returns the new vector
  82452. */
  82453. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  82454. /**
  82455. * Updates the given vector "result" from the starting index of the given array.
  82456. * @param array the array to pull values from
  82457. * @param offset the offset into the array to start at
  82458. * @param result the vector to store the result in
  82459. */
  82460. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  82461. /**
  82462. * Updates the given vector "result" from the starting index of the given Float32Array.
  82463. * @param array the array to pull values from
  82464. * @param offset the offset into the array to start at
  82465. * @param result the vector to store the result in
  82466. */
  82467. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  82468. /**
  82469. * Updates the given vector "result" coordinates from the given floats.
  82470. * @param x float to set from
  82471. * @param y float to set from
  82472. * @param z float to set from
  82473. * @param w float to set from
  82474. * @param result the vector to the floats in
  82475. */
  82476. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  82477. /**
  82478. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  82479. * @returns the new vector
  82480. */
  82481. static Zero(): Vector4;
  82482. /**
  82483. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  82484. * @returns the new vector
  82485. */
  82486. static One(): Vector4;
  82487. /**
  82488. * Returns a new normalized Vector4 from the given one.
  82489. * @param vector the vector to normalize
  82490. * @returns the vector
  82491. */
  82492. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  82493. /**
  82494. * Updates the given vector "result" from the normalization of the given one.
  82495. * @param vector the vector to normalize
  82496. * @param result the vector to store the result in
  82497. */
  82498. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  82499. /**
  82500. * Returns a vector with the minimum values from the left and right vectors
  82501. * @param left left vector to minimize
  82502. * @param right right vector to minimize
  82503. * @returns a new vector with the minimum of the left and right vector values
  82504. */
  82505. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82506. /**
  82507. * Returns a vector with the maximum values from the left and right vectors
  82508. * @param left left vector to maximize
  82509. * @param right right vector to maximize
  82510. * @returns a new vector with the maximum of the left and right vector values
  82511. */
  82512. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  82513. /**
  82514. * Returns the distance (float) between the vectors "value1" and "value2".
  82515. * @param value1 value to calulate the distance between
  82516. * @param value2 value to calulate the distance between
  82517. * @return the distance between the two vectors
  82518. */
  82519. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82520. /**
  82521. * Returns the squared distance (float) between the vectors "value1" and "value2".
  82522. * @param value1 value to calulate the distance between
  82523. * @param value2 value to calulate the distance between
  82524. * @return the distance between the two vectors squared
  82525. */
  82526. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  82527. /**
  82528. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  82529. * @param value1 value to calulate the center between
  82530. * @param value2 value to calulate the center between
  82531. * @return the center between the two vectors
  82532. */
  82533. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  82534. /**
  82535. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  82536. * This methods computes transformed normalized direction vectors only.
  82537. * @param vector the vector to transform
  82538. * @param transformation the transformation matrix to apply
  82539. * @returns the new vector
  82540. */
  82541. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  82542. /**
  82543. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  82544. * This methods computes transformed normalized direction vectors only.
  82545. * @param vector the vector to transform
  82546. * @param transformation the transformation matrix to apply
  82547. * @param result the vector to store the result in
  82548. */
  82549. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82550. /**
  82551. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  82552. * This methods computes transformed normalized direction vectors only.
  82553. * @param x value to transform
  82554. * @param y value to transform
  82555. * @param z value to transform
  82556. * @param w value to transform
  82557. * @param transformation the transformation matrix to apply
  82558. * @param result the vector to store the results in
  82559. */
  82560. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  82561. /**
  82562. * Creates a new Vector4 from a Vector3
  82563. * @param source defines the source data
  82564. * @param w defines the 4th component (default is 0)
  82565. * @returns a new Vector4
  82566. */
  82567. static FromVector3(source: Vector3, w?: number): Vector4;
  82568. }
  82569. /**
  82570. * Class used to store quaternion data
  82571. * @see https://en.wikipedia.org/wiki/Quaternion
  82572. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  82573. */
  82574. export class Quaternion {
  82575. /** @hidden */
  82576. _x: number;
  82577. /** @hidden */
  82578. _y: number;
  82579. /** @hidden */
  82580. _z: number;
  82581. /** @hidden */
  82582. _w: number;
  82583. /** @hidden */
  82584. _isDirty: boolean;
  82585. /** Gets or sets the x coordinate */
  82586. get x(): number;
  82587. set x(value: number);
  82588. /** Gets or sets the y coordinate */
  82589. get y(): number;
  82590. set y(value: number);
  82591. /** Gets or sets the z coordinate */
  82592. get z(): number;
  82593. set z(value: number);
  82594. /** Gets or sets the w coordinate */
  82595. get w(): number;
  82596. set w(value: number);
  82597. /**
  82598. * Creates a new Quaternion from the given floats
  82599. * @param x defines the first component (0 by default)
  82600. * @param y defines the second component (0 by default)
  82601. * @param z defines the third component (0 by default)
  82602. * @param w defines the fourth component (1.0 by default)
  82603. */
  82604. constructor(x?: number, y?: number, z?: number, w?: number);
  82605. /**
  82606. * Gets a string representation for the current quaternion
  82607. * @returns a string with the Quaternion coordinates
  82608. */
  82609. toString(): string;
  82610. /**
  82611. * Gets the class name of the quaternion
  82612. * @returns the string "Quaternion"
  82613. */
  82614. getClassName(): string;
  82615. /**
  82616. * Gets a hash code for this quaternion
  82617. * @returns the quaternion hash code
  82618. */
  82619. getHashCode(): number;
  82620. /**
  82621. * Copy the quaternion to an array
  82622. * @returns a new array populated with 4 elements from the quaternion coordinates
  82623. */
  82624. asArray(): number[];
  82625. /**
  82626. * Check if two quaternions are equals
  82627. * @param otherQuaternion defines the second operand
  82628. * @return true if the current quaternion and the given one coordinates are strictly equals
  82629. */
  82630. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82631. /**
  82632. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82633. * @param otherQuaternion defines the other quaternion
  82634. * @param epsilon defines the minimal distance to consider equality
  82635. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82636. */
  82637. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82638. /**
  82639. * Clone the current quaternion
  82640. * @returns a new quaternion copied from the current one
  82641. */
  82642. clone(): Quaternion;
  82643. /**
  82644. * Copy a quaternion to the current one
  82645. * @param other defines the other quaternion
  82646. * @returns the updated current quaternion
  82647. */
  82648. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82649. /**
  82650. * Updates the current quaternion with the given float coordinates
  82651. * @param x defines the x coordinate
  82652. * @param y defines the y coordinate
  82653. * @param z defines the z coordinate
  82654. * @param w defines the w coordinate
  82655. * @returns the updated current quaternion
  82656. */
  82657. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82658. /**
  82659. * Updates the current quaternion from the given float coordinates
  82660. * @param x defines the x coordinate
  82661. * @param y defines the y coordinate
  82662. * @param z defines the z coordinate
  82663. * @param w defines the w coordinate
  82664. * @returns the updated current quaternion
  82665. */
  82666. set(x: number, y: number, z: number, w: number): Quaternion;
  82667. /**
  82668. * Adds two quaternions
  82669. * @param other defines the second operand
  82670. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82671. */
  82672. add(other: DeepImmutable<Quaternion>): Quaternion;
  82673. /**
  82674. * Add a quaternion to the current one
  82675. * @param other defines the quaternion to add
  82676. * @returns the current quaternion
  82677. */
  82678. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82679. /**
  82680. * Subtract two quaternions
  82681. * @param other defines the second operand
  82682. * @returns a new quaternion as the subtraction result of the given one from the current one
  82683. */
  82684. subtract(other: Quaternion): Quaternion;
  82685. /**
  82686. * Multiplies the current quaternion by a scale factor
  82687. * @param value defines the scale factor
  82688. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82689. */
  82690. scale(value: number): Quaternion;
  82691. /**
  82692. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82693. * @param scale defines the scale factor
  82694. * @param result defines the Quaternion object where to store the result
  82695. * @returns the unmodified current quaternion
  82696. */
  82697. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82698. /**
  82699. * Multiplies in place the current quaternion by a scale factor
  82700. * @param value defines the scale factor
  82701. * @returns the current modified quaternion
  82702. */
  82703. scaleInPlace(value: number): Quaternion;
  82704. /**
  82705. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82706. * @param scale defines the scale factor
  82707. * @param result defines the Quaternion object where to store the result
  82708. * @returns the unmodified current quaternion
  82709. */
  82710. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82711. /**
  82712. * Multiplies two quaternions
  82713. * @param q1 defines the second operand
  82714. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82715. */
  82716. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82717. /**
  82718. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82719. * @param q1 defines the second operand
  82720. * @param result defines the target quaternion
  82721. * @returns the current quaternion
  82722. */
  82723. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82724. /**
  82725. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82726. * @param q1 defines the second operand
  82727. * @returns the currentupdated quaternion
  82728. */
  82729. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82730. /**
  82731. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82732. * @param ref defines the target quaternion
  82733. * @returns the current quaternion
  82734. */
  82735. conjugateToRef(ref: Quaternion): Quaternion;
  82736. /**
  82737. * Conjugates in place (1-q) the current quaternion
  82738. * @returns the current updated quaternion
  82739. */
  82740. conjugateInPlace(): Quaternion;
  82741. /**
  82742. * Conjugates in place (1-q) the current quaternion
  82743. * @returns a new quaternion
  82744. */
  82745. conjugate(): Quaternion;
  82746. /**
  82747. * Gets length of current quaternion
  82748. * @returns the quaternion length (float)
  82749. */
  82750. length(): number;
  82751. /**
  82752. * Normalize in place the current quaternion
  82753. * @returns the current updated quaternion
  82754. */
  82755. normalize(): Quaternion;
  82756. /**
  82757. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82758. * @param order is a reserved parameter and is ignore for now
  82759. * @returns a new Vector3 containing the Euler angles
  82760. */
  82761. toEulerAngles(order?: string): Vector3;
  82762. /**
  82763. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82764. * @param result defines the vector which will be filled with the Euler angles
  82765. * @param order is a reserved parameter and is ignore for now
  82766. * @returns the current unchanged quaternion
  82767. */
  82768. toEulerAnglesToRef(result: Vector3): Quaternion;
  82769. /**
  82770. * Updates the given rotation matrix with the current quaternion values
  82771. * @param result defines the target matrix
  82772. * @returns the current unchanged quaternion
  82773. */
  82774. toRotationMatrix(result: Matrix): Quaternion;
  82775. /**
  82776. * Updates the current quaternion from the given rotation matrix values
  82777. * @param matrix defines the source matrix
  82778. * @returns the current updated quaternion
  82779. */
  82780. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82781. /**
  82782. * Creates a new quaternion from a rotation matrix
  82783. * @param matrix defines the source matrix
  82784. * @returns a new quaternion created from the given rotation matrix values
  82785. */
  82786. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82787. /**
  82788. * Updates the given quaternion with the given rotation matrix values
  82789. * @param matrix defines the source matrix
  82790. * @param result defines the target quaternion
  82791. */
  82792. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82793. /**
  82794. * Returns the dot product (float) between the quaternions "left" and "right"
  82795. * @param left defines the left operand
  82796. * @param right defines the right operand
  82797. * @returns the dot product
  82798. */
  82799. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82800. /**
  82801. * Checks if the two quaternions are close to each other
  82802. * @param quat0 defines the first quaternion to check
  82803. * @param quat1 defines the second quaternion to check
  82804. * @returns true if the two quaternions are close to each other
  82805. */
  82806. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82807. /**
  82808. * Creates an empty quaternion
  82809. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82810. */
  82811. static Zero(): Quaternion;
  82812. /**
  82813. * Inverse a given quaternion
  82814. * @param q defines the source quaternion
  82815. * @returns a new quaternion as the inverted current quaternion
  82816. */
  82817. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82818. /**
  82819. * Inverse a given quaternion
  82820. * @param q defines the source quaternion
  82821. * @param result the quaternion the result will be stored in
  82822. * @returns the result quaternion
  82823. */
  82824. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82825. /**
  82826. * Creates an identity quaternion
  82827. * @returns the identity quaternion
  82828. */
  82829. static Identity(): Quaternion;
  82830. /**
  82831. * Gets a boolean indicating if the given quaternion is identity
  82832. * @param quaternion defines the quaternion to check
  82833. * @returns true if the quaternion is identity
  82834. */
  82835. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82836. /**
  82837. * Creates a quaternion from a rotation around an axis
  82838. * @param axis defines the axis to use
  82839. * @param angle defines the angle to use
  82840. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82841. */
  82842. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82843. /**
  82844. * Creates a rotation around an axis and stores it into the given quaternion
  82845. * @param axis defines the axis to use
  82846. * @param angle defines the angle to use
  82847. * @param result defines the target quaternion
  82848. * @returns the target quaternion
  82849. */
  82850. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82851. /**
  82852. * Creates a new quaternion from data stored into an array
  82853. * @param array defines the data source
  82854. * @param offset defines the offset in the source array where the data starts
  82855. * @returns a new quaternion
  82856. */
  82857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82858. /**
  82859. * Updates the given quaternion "result" from the starting index of the given array.
  82860. * @param array the array to pull values from
  82861. * @param offset the offset into the array to start at
  82862. * @param result the quaternion to store the result in
  82863. */
  82864. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82865. /**
  82866. * Create a quaternion from Euler rotation angles
  82867. * @param x Pitch
  82868. * @param y Yaw
  82869. * @param z Roll
  82870. * @returns the new Quaternion
  82871. */
  82872. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82873. /**
  82874. * Updates a quaternion from Euler rotation angles
  82875. * @param x Pitch
  82876. * @param y Yaw
  82877. * @param z Roll
  82878. * @param result the quaternion to store the result
  82879. * @returns the updated quaternion
  82880. */
  82881. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82882. /**
  82883. * Create a quaternion from Euler rotation vector
  82884. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82885. * @returns the new Quaternion
  82886. */
  82887. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82888. /**
  82889. * Updates a quaternion from Euler rotation vector
  82890. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82891. * @param result the quaternion to store the result
  82892. * @returns the updated quaternion
  82893. */
  82894. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82895. /**
  82896. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82897. * @param yaw defines the rotation around Y axis
  82898. * @param pitch defines the rotation around X axis
  82899. * @param roll defines the rotation around Z axis
  82900. * @returns the new quaternion
  82901. */
  82902. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82903. /**
  82904. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82905. * @param yaw defines the rotation around Y axis
  82906. * @param pitch defines the rotation around X axis
  82907. * @param roll defines the rotation around Z axis
  82908. * @param result defines the target quaternion
  82909. */
  82910. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82911. /**
  82912. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82913. * @param alpha defines the rotation around first axis
  82914. * @param beta defines the rotation around second axis
  82915. * @param gamma defines the rotation around third axis
  82916. * @returns the new quaternion
  82917. */
  82918. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82919. /**
  82920. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82921. * @param alpha defines the rotation around first axis
  82922. * @param beta defines the rotation around second axis
  82923. * @param gamma defines the rotation around third axis
  82924. * @param result defines the target quaternion
  82925. */
  82926. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82927. /**
  82928. * 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)
  82929. * @param axis1 defines the first axis
  82930. * @param axis2 defines the second axis
  82931. * @param axis3 defines the third axis
  82932. * @returns the new quaternion
  82933. */
  82934. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82935. /**
  82936. * 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
  82937. * @param axis1 defines the first axis
  82938. * @param axis2 defines the second axis
  82939. * @param axis3 defines the third axis
  82940. * @param ref defines the target quaternion
  82941. */
  82942. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82943. /**
  82944. * Interpolates between two quaternions
  82945. * @param left defines first quaternion
  82946. * @param right defines second quaternion
  82947. * @param amount defines the gradient to use
  82948. * @returns the new interpolated quaternion
  82949. */
  82950. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82951. /**
  82952. * Interpolates between two quaternions and stores it into a target quaternion
  82953. * @param left defines first quaternion
  82954. * @param right defines second quaternion
  82955. * @param amount defines the gradient to use
  82956. * @param result defines the target quaternion
  82957. */
  82958. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82959. /**
  82960. * Interpolate between two quaternions using Hermite interpolation
  82961. * @param value1 defines first quaternion
  82962. * @param tangent1 defines the incoming tangent
  82963. * @param value2 defines second quaternion
  82964. * @param tangent2 defines the outgoing tangent
  82965. * @param amount defines the target quaternion
  82966. * @returns the new interpolated quaternion
  82967. */
  82968. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82969. }
  82970. /**
  82971. * Class used to store matrix data (4x4)
  82972. */
  82973. export class Matrix {
  82974. /**
  82975. * Gets the precision of matrix computations
  82976. */
  82977. static get Use64Bits(): boolean;
  82978. private static _updateFlagSeed;
  82979. private static _identityReadOnly;
  82980. private _isIdentity;
  82981. private _isIdentityDirty;
  82982. private _isIdentity3x2;
  82983. private _isIdentity3x2Dirty;
  82984. /**
  82985. * Gets the update flag of the matrix which is an unique number for the matrix.
  82986. * It will be incremented every time the matrix data change.
  82987. * You can use it to speed the comparison between two versions of the same matrix.
  82988. */
  82989. updateFlag: number;
  82990. private readonly _m;
  82991. /**
  82992. * Gets the internal data of the matrix
  82993. */
  82994. get m(): DeepImmutable<Float32Array | Array<number>>;
  82995. /** @hidden */
  82996. _markAsUpdated(): void;
  82997. /** @hidden */
  82998. private _updateIdentityStatus;
  82999. /**
  83000. * Creates an empty matrix (filled with zeros)
  83001. */
  83002. constructor();
  83003. /**
  83004. * Check if the current matrix is identity
  83005. * @returns true is the matrix is the identity matrix
  83006. */
  83007. isIdentity(): boolean;
  83008. /**
  83009. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83010. * @returns true is the matrix is the identity matrix
  83011. */
  83012. isIdentityAs3x2(): boolean;
  83013. /**
  83014. * Gets the determinant of the matrix
  83015. * @returns the matrix determinant
  83016. */
  83017. determinant(): number;
  83018. /**
  83019. * Returns the matrix as a Float32Array or Array<number>
  83020. * @returns the matrix underlying array
  83021. */
  83022. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83023. /**
  83024. * Returns the matrix as a Float32Array or Array<number>
  83025. * @returns the matrix underlying array.
  83026. */
  83027. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83028. /**
  83029. * Inverts the current matrix in place
  83030. * @returns the current inverted matrix
  83031. */
  83032. invert(): Matrix;
  83033. /**
  83034. * Sets all the matrix elements to zero
  83035. * @returns the current matrix
  83036. */
  83037. reset(): Matrix;
  83038. /**
  83039. * Adds the current matrix with a second one
  83040. * @param other defines the matrix to add
  83041. * @returns a new matrix as the addition of the current matrix and the given one
  83042. */
  83043. add(other: DeepImmutable<Matrix>): Matrix;
  83044. /**
  83045. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83046. * @param other defines the matrix to add
  83047. * @param result defines the target matrix
  83048. * @returns the current matrix
  83049. */
  83050. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83051. /**
  83052. * Adds in place the given matrix to the current matrix
  83053. * @param other defines the second operand
  83054. * @returns the current updated matrix
  83055. */
  83056. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83057. /**
  83058. * Sets the given matrix to the current inverted Matrix
  83059. * @param other defines the target matrix
  83060. * @returns the unmodified current matrix
  83061. */
  83062. invertToRef(other: Matrix): Matrix;
  83063. /**
  83064. * add a value at the specified position in the current Matrix
  83065. * @param index the index of the value within the matrix. between 0 and 15.
  83066. * @param value the value to be added
  83067. * @returns the current updated matrix
  83068. */
  83069. addAtIndex(index: number, value: number): Matrix;
  83070. /**
  83071. * mutiply the specified position in the current Matrix by a value
  83072. * @param index the index of the value within the matrix. between 0 and 15.
  83073. * @param value the value to be added
  83074. * @returns the current updated matrix
  83075. */
  83076. multiplyAtIndex(index: number, value: number): Matrix;
  83077. /**
  83078. * Inserts the translation vector (using 3 floats) in the current matrix
  83079. * @param x defines the 1st component of the translation
  83080. * @param y defines the 2nd component of the translation
  83081. * @param z defines the 3rd component of the translation
  83082. * @returns the current updated matrix
  83083. */
  83084. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83085. /**
  83086. * Adds the translation vector (using 3 floats) in the current matrix
  83087. * @param x defines the 1st component of the translation
  83088. * @param y defines the 2nd component of the translation
  83089. * @param z defines the 3rd component of the translation
  83090. * @returns the current updated matrix
  83091. */
  83092. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83093. /**
  83094. * Inserts the translation vector in the current matrix
  83095. * @param vector3 defines the translation to insert
  83096. * @returns the current updated matrix
  83097. */
  83098. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83099. /**
  83100. * Gets the translation value of the current matrix
  83101. * @returns a new Vector3 as the extracted translation from the matrix
  83102. */
  83103. getTranslation(): Vector3;
  83104. /**
  83105. * Fill a Vector3 with the extracted translation from the matrix
  83106. * @param result defines the Vector3 where to store the translation
  83107. * @returns the current matrix
  83108. */
  83109. getTranslationToRef(result: Vector3): Matrix;
  83110. /**
  83111. * Remove rotation and scaling part from the matrix
  83112. * @returns the updated matrix
  83113. */
  83114. removeRotationAndScaling(): Matrix;
  83115. /**
  83116. * Multiply two matrices
  83117. * @param other defines the second operand
  83118. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83119. */
  83120. multiply(other: DeepImmutable<Matrix>): Matrix;
  83121. /**
  83122. * Copy the current matrix from the given one
  83123. * @param other defines the source matrix
  83124. * @returns the current updated matrix
  83125. */
  83126. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83127. /**
  83128. * Populates the given array from the starting index with the current matrix values
  83129. * @param array defines the target array
  83130. * @param offset defines the offset in the target array where to start storing values
  83131. * @returns the current matrix
  83132. */
  83133. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  83134. /**
  83135. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  83136. * @param other defines the second operand
  83137. * @param result defines the matrix where to store the multiplication
  83138. * @returns the current matrix
  83139. */
  83140. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83141. /**
  83142. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  83143. * @param other defines the second operand
  83144. * @param result defines the array where to store the multiplication
  83145. * @param offset defines the offset in the target array where to start storing values
  83146. * @returns the current matrix
  83147. */
  83148. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  83149. /**
  83150. * Check equality between this matrix and a second one
  83151. * @param value defines the second matrix to compare
  83152. * @returns true is the current matrix and the given one values are strictly equal
  83153. */
  83154. equals(value: DeepImmutable<Matrix>): boolean;
  83155. /**
  83156. * Clone the current matrix
  83157. * @returns a new matrix from the current matrix
  83158. */
  83159. clone(): Matrix;
  83160. /**
  83161. * Returns the name of the current matrix class
  83162. * @returns the string "Matrix"
  83163. */
  83164. getClassName(): string;
  83165. /**
  83166. * Gets the hash code of the current matrix
  83167. * @returns the hash code
  83168. */
  83169. getHashCode(): number;
  83170. /**
  83171. * Decomposes the current Matrix into a translation, rotation and scaling components
  83172. * @param scale defines the scale vector3 given as a reference to update
  83173. * @param rotation defines the rotation quaternion given as a reference to update
  83174. * @param translation defines the translation vector3 given as a reference to update
  83175. * @returns true if operation was successful
  83176. */
  83177. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  83178. /**
  83179. * Gets specific row of the matrix
  83180. * @param index defines the number of the row to get
  83181. * @returns the index-th row of the current matrix as a new Vector4
  83182. */
  83183. getRow(index: number): Nullable<Vector4>;
  83184. /**
  83185. * Sets the index-th row of the current matrix to the vector4 values
  83186. * @param index defines the number of the row to set
  83187. * @param row defines the target vector4
  83188. * @returns the updated current matrix
  83189. */
  83190. setRow(index: number, row: Vector4): Matrix;
  83191. /**
  83192. * Compute the transpose of the matrix
  83193. * @returns the new transposed matrix
  83194. */
  83195. transpose(): Matrix;
  83196. /**
  83197. * Compute the transpose of the matrix and store it in a given matrix
  83198. * @param result defines the target matrix
  83199. * @returns the current matrix
  83200. */
  83201. transposeToRef(result: Matrix): Matrix;
  83202. /**
  83203. * Sets the index-th row of the current matrix with the given 4 x float values
  83204. * @param index defines the row index
  83205. * @param x defines the x component to set
  83206. * @param y defines the y component to set
  83207. * @param z defines the z component to set
  83208. * @param w defines the w component to set
  83209. * @returns the updated current matrix
  83210. */
  83211. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  83212. /**
  83213. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  83214. * @param scale defines the scale factor
  83215. * @returns a new matrix
  83216. */
  83217. scale(scale: number): Matrix;
  83218. /**
  83219. * Scale the current matrix values by a factor to a given result matrix
  83220. * @param scale defines the scale factor
  83221. * @param result defines the matrix to store the result
  83222. * @returns the current matrix
  83223. */
  83224. scaleToRef(scale: number, result: Matrix): Matrix;
  83225. /**
  83226. * Scale the current matrix values by a factor and add the result to a given matrix
  83227. * @param scale defines the scale factor
  83228. * @param result defines the Matrix to store the result
  83229. * @returns the current matrix
  83230. */
  83231. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  83232. /**
  83233. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  83234. * @param ref matrix to store the result
  83235. */
  83236. toNormalMatrix(ref: Matrix): void;
  83237. /**
  83238. * Gets only rotation part of the current matrix
  83239. * @returns a new matrix sets to the extracted rotation matrix from the current one
  83240. */
  83241. getRotationMatrix(): Matrix;
  83242. /**
  83243. * Extracts the rotation matrix from the current one and sets it as the given "result"
  83244. * @param result defines the target matrix to store data to
  83245. * @returns the current matrix
  83246. */
  83247. getRotationMatrixToRef(result: Matrix): Matrix;
  83248. /**
  83249. * Toggles model matrix from being right handed to left handed in place and vice versa
  83250. */
  83251. toggleModelMatrixHandInPlace(): void;
  83252. /**
  83253. * Toggles projection matrix from being right handed to left handed in place and vice versa
  83254. */
  83255. toggleProjectionMatrixHandInPlace(): void;
  83256. /**
  83257. * Creates a matrix from an array
  83258. * @param array defines the source array
  83259. * @param offset defines an offset in the source array
  83260. * @returns a new Matrix set from the starting index of the given array
  83261. */
  83262. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  83263. /**
  83264. * Copy the content of an array into a given matrix
  83265. * @param array defines the source array
  83266. * @param offset defines an offset in the source array
  83267. * @param result defines the target matrix
  83268. */
  83269. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  83270. /**
  83271. * Stores an array into a matrix after having multiplied each component by a given factor
  83272. * @param array defines the source array
  83273. * @param offset defines the offset in the source array
  83274. * @param scale defines the scaling factor
  83275. * @param result defines the target matrix
  83276. */
  83277. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  83278. /**
  83279. * Gets an identity matrix that must not be updated
  83280. */
  83281. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  83282. /**
  83283. * Stores a list of values (16) inside a given matrix
  83284. * @param initialM11 defines 1st value of 1st row
  83285. * @param initialM12 defines 2nd value of 1st row
  83286. * @param initialM13 defines 3rd value of 1st row
  83287. * @param initialM14 defines 4th value of 1st row
  83288. * @param initialM21 defines 1st value of 2nd row
  83289. * @param initialM22 defines 2nd value of 2nd row
  83290. * @param initialM23 defines 3rd value of 2nd row
  83291. * @param initialM24 defines 4th value of 2nd row
  83292. * @param initialM31 defines 1st value of 3rd row
  83293. * @param initialM32 defines 2nd value of 3rd row
  83294. * @param initialM33 defines 3rd value of 3rd row
  83295. * @param initialM34 defines 4th value of 3rd row
  83296. * @param initialM41 defines 1st value of 4th row
  83297. * @param initialM42 defines 2nd value of 4th row
  83298. * @param initialM43 defines 3rd value of 4th row
  83299. * @param initialM44 defines 4th value of 4th row
  83300. * @param result defines the target matrix
  83301. */
  83302. 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;
  83303. /**
  83304. * Creates new matrix from a list of values (16)
  83305. * @param initialM11 defines 1st value of 1st row
  83306. * @param initialM12 defines 2nd value of 1st row
  83307. * @param initialM13 defines 3rd value of 1st row
  83308. * @param initialM14 defines 4th value of 1st row
  83309. * @param initialM21 defines 1st value of 2nd row
  83310. * @param initialM22 defines 2nd value of 2nd row
  83311. * @param initialM23 defines 3rd value of 2nd row
  83312. * @param initialM24 defines 4th value of 2nd row
  83313. * @param initialM31 defines 1st value of 3rd row
  83314. * @param initialM32 defines 2nd value of 3rd row
  83315. * @param initialM33 defines 3rd value of 3rd row
  83316. * @param initialM34 defines 4th value of 3rd row
  83317. * @param initialM41 defines 1st value of 4th row
  83318. * @param initialM42 defines 2nd value of 4th row
  83319. * @param initialM43 defines 3rd value of 4th row
  83320. * @param initialM44 defines 4th value of 4th row
  83321. * @returns the new matrix
  83322. */
  83323. 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;
  83324. /**
  83325. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83326. * @param scale defines the scale vector3
  83327. * @param rotation defines the rotation quaternion
  83328. * @param translation defines the translation vector3
  83329. * @returns a new matrix
  83330. */
  83331. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  83332. /**
  83333. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  83334. * @param scale defines the scale vector3
  83335. * @param rotation defines the rotation quaternion
  83336. * @param translation defines the translation vector3
  83337. * @param result defines the target matrix
  83338. */
  83339. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  83340. /**
  83341. * Creates a new identity matrix
  83342. * @returns a new identity matrix
  83343. */
  83344. static Identity(): Matrix;
  83345. /**
  83346. * Creates a new identity matrix and stores the result in a given matrix
  83347. * @param result defines the target matrix
  83348. */
  83349. static IdentityToRef(result: Matrix): void;
  83350. /**
  83351. * Creates a new zero matrix
  83352. * @returns a new zero matrix
  83353. */
  83354. static Zero(): Matrix;
  83355. /**
  83356. * Creates a new rotation matrix for "angle" radians around the X axis
  83357. * @param angle defines the angle (in radians) to use
  83358. * @return the new matrix
  83359. */
  83360. static RotationX(angle: number): Matrix;
  83361. /**
  83362. * Creates a new matrix as the invert of a given matrix
  83363. * @param source defines the source matrix
  83364. * @returns the new matrix
  83365. */
  83366. static Invert(source: DeepImmutable<Matrix>): Matrix;
  83367. /**
  83368. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  83369. * @param angle defines the angle (in radians) to use
  83370. * @param result defines the target matrix
  83371. */
  83372. static RotationXToRef(angle: number, result: Matrix): void;
  83373. /**
  83374. * Creates a new rotation matrix for "angle" radians around the Y axis
  83375. * @param angle defines the angle (in radians) to use
  83376. * @return the new matrix
  83377. */
  83378. static RotationY(angle: number): Matrix;
  83379. /**
  83380. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  83381. * @param angle defines the angle (in radians) to use
  83382. * @param result defines the target matrix
  83383. */
  83384. static RotationYToRef(angle: number, result: Matrix): void;
  83385. /**
  83386. * Creates a new rotation matrix for "angle" radians around the Z axis
  83387. * @param angle defines the angle (in radians) to use
  83388. * @return the new matrix
  83389. */
  83390. static RotationZ(angle: number): Matrix;
  83391. /**
  83392. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  83393. * @param angle defines the angle (in radians) to use
  83394. * @param result defines the target matrix
  83395. */
  83396. static RotationZToRef(angle: number, result: Matrix): void;
  83397. /**
  83398. * Creates a new rotation matrix for "angle" radians around the given axis
  83399. * @param axis defines the axis to use
  83400. * @param angle defines the angle (in radians) to use
  83401. * @return the new matrix
  83402. */
  83403. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  83404. /**
  83405. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  83406. * @param axis defines the axis to use
  83407. * @param angle defines the angle (in radians) to use
  83408. * @param result defines the target matrix
  83409. */
  83410. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  83411. /**
  83412. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  83413. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  83414. * @param from defines the vector to align
  83415. * @param to defines the vector to align to
  83416. * @param result defines the target matrix
  83417. */
  83418. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  83419. /**
  83420. * Creates a rotation matrix
  83421. * @param yaw defines the yaw angle in radians (Y axis)
  83422. * @param pitch defines the pitch angle in radians (X axis)
  83423. * @param roll defines the roll angle in radians (Z axis)
  83424. * @returns the new rotation matrix
  83425. */
  83426. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  83427. /**
  83428. * Creates a rotation matrix and stores it in a given matrix
  83429. * @param yaw defines the yaw angle in radians (Y axis)
  83430. * @param pitch defines the pitch angle in radians (X axis)
  83431. * @param roll defines the roll angle in radians (Z axis)
  83432. * @param result defines the target matrix
  83433. */
  83434. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  83435. /**
  83436. * Creates a scaling matrix
  83437. * @param x defines the scale factor on X axis
  83438. * @param y defines the scale factor on Y axis
  83439. * @param z defines the scale factor on Z axis
  83440. * @returns the new matrix
  83441. */
  83442. static Scaling(x: number, y: number, z: number): Matrix;
  83443. /**
  83444. * Creates a scaling matrix and stores it in a given matrix
  83445. * @param x defines the scale factor on X axis
  83446. * @param y defines the scale factor on Y axis
  83447. * @param z defines the scale factor on Z axis
  83448. * @param result defines the target matrix
  83449. */
  83450. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  83451. /**
  83452. * Creates a translation matrix
  83453. * @param x defines the translation on X axis
  83454. * @param y defines the translation on Y axis
  83455. * @param z defines the translationon Z axis
  83456. * @returns the new matrix
  83457. */
  83458. static Translation(x: number, y: number, z: number): Matrix;
  83459. /**
  83460. * Creates a translation matrix and stores it in a given matrix
  83461. * @param x defines the translation on X axis
  83462. * @param y defines the translation on Y axis
  83463. * @param z defines the translationon Z axis
  83464. * @param result defines the target matrix
  83465. */
  83466. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  83467. /**
  83468. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83469. * @param startValue defines the start value
  83470. * @param endValue defines the end value
  83471. * @param gradient defines the gradient factor
  83472. * @returns the new matrix
  83473. */
  83474. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83475. /**
  83476. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  83477. * @param startValue defines the start value
  83478. * @param endValue defines the end value
  83479. * @param gradient defines the gradient factor
  83480. * @param result defines the Matrix object where to store data
  83481. */
  83482. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83483. /**
  83484. * Builds a new matrix whose values are computed by:
  83485. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83486. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83487. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83488. * @param startValue defines the first matrix
  83489. * @param endValue defines the second matrix
  83490. * @param gradient defines the gradient between the two matrices
  83491. * @returns the new matrix
  83492. */
  83493. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  83494. /**
  83495. * Update a matrix to values which are computed by:
  83496. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  83497. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  83498. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  83499. * @param startValue defines the first matrix
  83500. * @param endValue defines the second matrix
  83501. * @param gradient defines the gradient between the two matrices
  83502. * @param result defines the target matrix
  83503. */
  83504. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  83505. /**
  83506. * 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"
  83507. * This function works in left handed mode
  83508. * @param eye defines the final position of the entity
  83509. * @param target defines where the entity should look at
  83510. * @param up defines the up vector for the entity
  83511. * @returns the new matrix
  83512. */
  83513. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83514. /**
  83515. * 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".
  83516. * This function works in left handed mode
  83517. * @param eye defines the final position of the entity
  83518. * @param target defines where the entity should look at
  83519. * @param up defines the up vector for the entity
  83520. * @param result defines the target matrix
  83521. */
  83522. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83523. /**
  83524. * 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"
  83525. * This function works in right handed mode
  83526. * @param eye defines the final position of the entity
  83527. * @param target defines where the entity should look at
  83528. * @param up defines the up vector for the entity
  83529. * @returns the new matrix
  83530. */
  83531. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  83532. /**
  83533. * 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".
  83534. * This function works in right handed mode
  83535. * @param eye defines the final position of the entity
  83536. * @param target defines where the entity should look at
  83537. * @param up defines the up vector for the entity
  83538. * @param result defines the target matrix
  83539. */
  83540. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  83541. /**
  83542. * Create a left-handed orthographic projection matrix
  83543. * @param width defines the viewport width
  83544. * @param height defines the viewport height
  83545. * @param znear defines the near clip plane
  83546. * @param zfar defines the far clip plane
  83547. * @returns a new matrix as a left-handed orthographic projection matrix
  83548. */
  83549. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83550. /**
  83551. * Store a left-handed orthographic projection to a given matrix
  83552. * @param width defines the viewport width
  83553. * @param height defines the viewport height
  83554. * @param znear defines the near clip plane
  83555. * @param zfar defines the far clip plane
  83556. * @param result defines the target matrix
  83557. */
  83558. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  83559. /**
  83560. * Create a left-handed orthographic projection matrix
  83561. * @param left defines the viewport left coordinate
  83562. * @param right defines the viewport right coordinate
  83563. * @param bottom defines the viewport bottom coordinate
  83564. * @param top defines the viewport top coordinate
  83565. * @param znear defines the near clip plane
  83566. * @param zfar defines the far clip plane
  83567. * @returns a new matrix as a left-handed orthographic projection matrix
  83568. */
  83569. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83570. /**
  83571. * Stores a left-handed orthographic projection into a given matrix
  83572. * @param left defines the viewport left coordinate
  83573. * @param right defines the viewport right coordinate
  83574. * @param bottom defines the viewport bottom coordinate
  83575. * @param top defines the viewport top coordinate
  83576. * @param znear defines the near clip plane
  83577. * @param zfar defines the far clip plane
  83578. * @param result defines the target matrix
  83579. */
  83580. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83581. /**
  83582. * Creates a right-handed orthographic projection matrix
  83583. * @param left defines the viewport left coordinate
  83584. * @param right defines the viewport right coordinate
  83585. * @param bottom defines the viewport bottom coordinate
  83586. * @param top defines the viewport top coordinate
  83587. * @param znear defines the near clip plane
  83588. * @param zfar defines the far clip plane
  83589. * @returns a new matrix as a right-handed orthographic projection matrix
  83590. */
  83591. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  83592. /**
  83593. * Stores a right-handed orthographic projection into a given matrix
  83594. * @param left defines the viewport left coordinate
  83595. * @param right defines the viewport right coordinate
  83596. * @param bottom defines the viewport bottom coordinate
  83597. * @param top defines the viewport top coordinate
  83598. * @param znear defines the near clip plane
  83599. * @param zfar defines the far clip plane
  83600. * @param result defines the target matrix
  83601. */
  83602. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  83603. /**
  83604. * Creates a left-handed perspective projection matrix
  83605. * @param width defines the viewport width
  83606. * @param height defines the viewport height
  83607. * @param znear defines the near clip plane
  83608. * @param zfar defines the far clip plane
  83609. * @returns a new matrix as a left-handed perspective projection matrix
  83610. */
  83611. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83612. /**
  83613. * Creates a left-handed perspective projection matrix
  83614. * @param fov defines the horizontal field of view
  83615. * @param aspect defines the aspect ratio
  83616. * @param znear defines the near clip plane
  83617. * @param zfar defines the far clip plane
  83618. * @returns a new matrix as a left-handed perspective projection matrix
  83619. */
  83620. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83621. /**
  83622. * Stores a left-handed perspective projection into a given matrix
  83623. * @param fov defines the horizontal field of view
  83624. * @param aspect defines the aspect ratio
  83625. * @param znear defines the near clip plane
  83626. * @param zfar defines the far clip plane
  83627. * @param result defines the target matrix
  83628. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83629. */
  83630. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83631. /**
  83632. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83633. * @param fov defines the horizontal field of view
  83634. * @param aspect defines the aspect ratio
  83635. * @param znear defines the near clip plane
  83636. * @param zfar not used as infinity is used as far clip
  83637. * @param result defines the target matrix
  83638. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83639. */
  83640. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83641. /**
  83642. * Creates a right-handed perspective projection matrix
  83643. * @param fov defines the horizontal field of view
  83644. * @param aspect defines the aspect ratio
  83645. * @param znear defines the near clip plane
  83646. * @param zfar defines the far clip plane
  83647. * @returns a new matrix as a right-handed perspective projection matrix
  83648. */
  83649. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83650. /**
  83651. * Stores a right-handed perspective projection into a given matrix
  83652. * @param fov defines the horizontal field of view
  83653. * @param aspect defines the aspect ratio
  83654. * @param znear defines the near clip plane
  83655. * @param zfar defines the far clip plane
  83656. * @param result defines the target matrix
  83657. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83658. */
  83659. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83660. /**
  83661. * Stores a right-handed perspective projection into a given matrix
  83662. * @param fov defines the horizontal field of view
  83663. * @param aspect defines the aspect ratio
  83664. * @param znear defines the near clip plane
  83665. * @param zfar not used as infinity is used as far clip
  83666. * @param result defines the target matrix
  83667. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83668. */
  83669. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83670. /**
  83671. * Stores a perspective projection for WebVR info a given matrix
  83672. * @param fov defines the field of view
  83673. * @param znear defines the near clip plane
  83674. * @param zfar defines the far clip plane
  83675. * @param result defines the target matrix
  83676. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83677. */
  83678. static PerspectiveFovWebVRToRef(fov: {
  83679. upDegrees: number;
  83680. downDegrees: number;
  83681. leftDegrees: number;
  83682. rightDegrees: number;
  83683. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83684. /**
  83685. * Computes a complete transformation matrix
  83686. * @param viewport defines the viewport to use
  83687. * @param world defines the world matrix
  83688. * @param view defines the view matrix
  83689. * @param projection defines the projection matrix
  83690. * @param zmin defines the near clip plane
  83691. * @param zmax defines the far clip plane
  83692. * @returns the transformation matrix
  83693. */
  83694. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83695. /**
  83696. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83697. * @param matrix defines the matrix to use
  83698. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83699. */
  83700. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83701. /**
  83702. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83703. * @param matrix defines the matrix to use
  83704. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83705. */
  83706. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  83707. /**
  83708. * Compute the transpose of a given matrix
  83709. * @param matrix defines the matrix to transpose
  83710. * @returns the new matrix
  83711. */
  83712. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83713. /**
  83714. * Compute the transpose of a matrix and store it in a target matrix
  83715. * @param matrix defines the matrix to transpose
  83716. * @param result defines the target matrix
  83717. */
  83718. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83719. /**
  83720. * Computes a reflection matrix from a plane
  83721. * @param plane defines the reflection plane
  83722. * @returns a new matrix
  83723. */
  83724. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83725. /**
  83726. * Computes a reflection matrix from a plane
  83727. * @param plane defines the reflection plane
  83728. * @param result defines the target matrix
  83729. */
  83730. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83731. /**
  83732. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83733. * @param xaxis defines the value of the 1st axis
  83734. * @param yaxis defines the value of the 2nd axis
  83735. * @param zaxis defines the value of the 3rd axis
  83736. * @param result defines the target matrix
  83737. */
  83738. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83739. /**
  83740. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83741. * @param quat defines the quaternion to use
  83742. * @param result defines the target matrix
  83743. */
  83744. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83745. }
  83746. /**
  83747. * @hidden
  83748. */
  83749. export class TmpVectors {
  83750. static Vector2: Vector2[];
  83751. static Vector3: Vector3[];
  83752. static Vector4: Vector4[];
  83753. static Quaternion: Quaternion[];
  83754. static Matrix: Matrix[];
  83755. }
  83756. }
  83757. declare module BABYLON {
  83758. /**
  83759. * Defines potential orientation for back face culling
  83760. */
  83761. export enum Orientation {
  83762. /**
  83763. * Clockwise
  83764. */
  83765. CW = 0,
  83766. /** Counter clockwise */
  83767. CCW = 1
  83768. }
  83769. /** Class used to represent a Bezier curve */
  83770. export class BezierCurve {
  83771. /**
  83772. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83773. * @param t defines the time
  83774. * @param x1 defines the left coordinate on X axis
  83775. * @param y1 defines the left coordinate on Y axis
  83776. * @param x2 defines the right coordinate on X axis
  83777. * @param y2 defines the right coordinate on Y axis
  83778. * @returns the interpolated value
  83779. */
  83780. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83781. }
  83782. /**
  83783. * Defines angle representation
  83784. */
  83785. export class Angle {
  83786. private _radians;
  83787. /**
  83788. * Creates an Angle object of "radians" radians (float).
  83789. * @param radians the angle in radians
  83790. */
  83791. constructor(radians: number);
  83792. /**
  83793. * Get value in degrees
  83794. * @returns the Angle value in degrees (float)
  83795. */
  83796. degrees(): number;
  83797. /**
  83798. * Get value in radians
  83799. * @returns the Angle value in radians (float)
  83800. */
  83801. radians(): number;
  83802. /**
  83803. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83804. * @param a defines first point as the origin
  83805. * @param b defines point
  83806. * @returns a new Angle
  83807. */
  83808. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83809. /**
  83810. * Gets a new Angle object from the given float in radians
  83811. * @param radians defines the angle value in radians
  83812. * @returns a new Angle
  83813. */
  83814. static FromRadians(radians: number): Angle;
  83815. /**
  83816. * Gets a new Angle object from the given float in degrees
  83817. * @param degrees defines the angle value in degrees
  83818. * @returns a new Angle
  83819. */
  83820. static FromDegrees(degrees: number): Angle;
  83821. }
  83822. /**
  83823. * This represents an arc in a 2d space.
  83824. */
  83825. export class Arc2 {
  83826. /** Defines the start point of the arc */
  83827. startPoint: Vector2;
  83828. /** Defines the mid point of the arc */
  83829. midPoint: Vector2;
  83830. /** Defines the end point of the arc */
  83831. endPoint: Vector2;
  83832. /**
  83833. * Defines the center point of the arc.
  83834. */
  83835. centerPoint: Vector2;
  83836. /**
  83837. * Defines the radius of the arc.
  83838. */
  83839. radius: number;
  83840. /**
  83841. * Defines the angle of the arc (from mid point to end point).
  83842. */
  83843. angle: Angle;
  83844. /**
  83845. * Defines the start angle of the arc (from start point to middle point).
  83846. */
  83847. startAngle: Angle;
  83848. /**
  83849. * Defines the orientation of the arc (clock wise/counter clock wise).
  83850. */
  83851. orientation: Orientation;
  83852. /**
  83853. * Creates an Arc object from the three given points : start, middle and end.
  83854. * @param startPoint Defines the start point of the arc
  83855. * @param midPoint Defines the midlle point of the arc
  83856. * @param endPoint Defines the end point of the arc
  83857. */
  83858. constructor(
  83859. /** Defines the start point of the arc */
  83860. startPoint: Vector2,
  83861. /** Defines the mid point of the arc */
  83862. midPoint: Vector2,
  83863. /** Defines the end point of the arc */
  83864. endPoint: Vector2);
  83865. }
  83866. /**
  83867. * Represents a 2D path made up of multiple 2D points
  83868. */
  83869. export class Path2 {
  83870. private _points;
  83871. private _length;
  83872. /**
  83873. * If the path start and end point are the same
  83874. */
  83875. closed: boolean;
  83876. /**
  83877. * Creates a Path2 object from the starting 2D coordinates x and y.
  83878. * @param x the starting points x value
  83879. * @param y the starting points y value
  83880. */
  83881. constructor(x: number, y: number);
  83882. /**
  83883. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83884. * @param x the added points x value
  83885. * @param y the added points y value
  83886. * @returns the updated Path2.
  83887. */
  83888. addLineTo(x: number, y: number): Path2;
  83889. /**
  83890. * 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.
  83891. * @param midX middle point x value
  83892. * @param midY middle point y value
  83893. * @param endX end point x value
  83894. * @param endY end point y value
  83895. * @param numberOfSegments (default: 36)
  83896. * @returns the updated Path2.
  83897. */
  83898. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83899. /**
  83900. * Closes the Path2.
  83901. * @returns the Path2.
  83902. */
  83903. close(): Path2;
  83904. /**
  83905. * Gets the sum of the distance between each sequential point in the path
  83906. * @returns the Path2 total length (float).
  83907. */
  83908. length(): number;
  83909. /**
  83910. * Gets the points which construct the path
  83911. * @returns the Path2 internal array of points.
  83912. */
  83913. getPoints(): Vector2[];
  83914. /**
  83915. * Retreives the point at the distance aways from the starting point
  83916. * @param normalizedLengthPosition the length along the path to retreive the point from
  83917. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83918. */
  83919. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83920. /**
  83921. * Creates a new path starting from an x and y position
  83922. * @param x starting x value
  83923. * @param y starting y value
  83924. * @returns a new Path2 starting at the coordinates (x, y).
  83925. */
  83926. static StartingAt(x: number, y: number): Path2;
  83927. }
  83928. /**
  83929. * Represents a 3D path made up of multiple 3D points
  83930. */
  83931. export class Path3D {
  83932. /**
  83933. * an array of Vector3, the curve axis of the Path3D
  83934. */
  83935. path: Vector3[];
  83936. private _curve;
  83937. private _distances;
  83938. private _tangents;
  83939. private _normals;
  83940. private _binormals;
  83941. private _raw;
  83942. private _alignTangentsWithPath;
  83943. private readonly _pointAtData;
  83944. /**
  83945. * new Path3D(path, normal, raw)
  83946. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83947. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83948. * @param path an array of Vector3, the curve axis of the Path3D
  83949. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83950. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83951. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83952. */
  83953. constructor(
  83954. /**
  83955. * an array of Vector3, the curve axis of the Path3D
  83956. */
  83957. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83958. /**
  83959. * Returns the Path3D array of successive Vector3 designing its curve.
  83960. * @returns the Path3D array of successive Vector3 designing its curve.
  83961. */
  83962. getCurve(): Vector3[];
  83963. /**
  83964. * Returns the Path3D array of successive Vector3 designing its curve.
  83965. * @returns the Path3D array of successive Vector3 designing its curve.
  83966. */
  83967. getPoints(): Vector3[];
  83968. /**
  83969. * @returns the computed length (float) of the path.
  83970. */
  83971. length(): number;
  83972. /**
  83973. * Returns an array populated with tangent vectors on each Path3D curve point.
  83974. * @returns an array populated with tangent vectors on each Path3D curve point.
  83975. */
  83976. getTangents(): Vector3[];
  83977. /**
  83978. * Returns an array populated with normal vectors on each Path3D curve point.
  83979. * @returns an array populated with normal vectors on each Path3D curve point.
  83980. */
  83981. getNormals(): Vector3[];
  83982. /**
  83983. * Returns an array populated with binormal vectors on each Path3D curve point.
  83984. * @returns an array populated with binormal vectors on each Path3D curve point.
  83985. */
  83986. getBinormals(): Vector3[];
  83987. /**
  83988. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83989. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83990. */
  83991. getDistances(): number[];
  83992. /**
  83993. * Returns an interpolated point along this path
  83994. * @param position the position of the point along this path, from 0.0 to 1.0
  83995. * @returns a new Vector3 as the point
  83996. */
  83997. getPointAt(position: number): Vector3;
  83998. /**
  83999. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84000. * @param position the position of the point along this path, from 0.0 to 1.0
  84001. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84002. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84003. */
  84004. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84005. /**
  84006. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84007. * @param position the position of the point along this path, from 0.0 to 1.0
  84008. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84009. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84010. */
  84011. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84012. /**
  84013. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84014. * @param position the position of the point along this path, from 0.0 to 1.0
  84015. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84016. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84017. */
  84018. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84019. /**
  84020. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84021. * @param position the position of the point along this path, from 0.0 to 1.0
  84022. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84023. */
  84024. getDistanceAt(position: number): number;
  84025. /**
  84026. * Returns the array index of the previous point of an interpolated point along this path
  84027. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84028. * @returns the array index
  84029. */
  84030. getPreviousPointIndexAt(position: number): number;
  84031. /**
  84032. * 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)
  84033. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84034. * @returns the sub position
  84035. */
  84036. getSubPositionAt(position: number): number;
  84037. /**
  84038. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84039. * @param target the vector of which to get the closest position to
  84040. * @returns the position of the closest virtual point on this path to the target vector
  84041. */
  84042. getClosestPositionTo(target: Vector3): number;
  84043. /**
  84044. * Returns a sub path (slice) of this path
  84045. * @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
  84046. * @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
  84047. * @returns a sub path (slice) of this path
  84048. */
  84049. slice(start?: number, end?: number): Path3D;
  84050. /**
  84051. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84052. * @param path path which all values are copied into the curves points
  84053. * @param firstNormal which should be projected onto the curve
  84054. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84055. * @returns the same object updated.
  84056. */
  84057. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84058. private _compute;
  84059. private _getFirstNonNullVector;
  84060. private _getLastNonNullVector;
  84061. private _normalVector;
  84062. /**
  84063. * Updates the point at data for an interpolated point along this curve
  84064. * @param position the position of the point along this curve, from 0.0 to 1.0
  84065. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84066. * @returns the (updated) point at data
  84067. */
  84068. private _updatePointAtData;
  84069. /**
  84070. * Updates the point at data from the specified parameters
  84071. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84072. * @param point the interpolated point
  84073. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84074. */
  84075. private _setPointAtData;
  84076. /**
  84077. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84078. */
  84079. private _updateInterpolationMatrix;
  84080. }
  84081. /**
  84082. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84083. * A Curve3 is designed from a series of successive Vector3.
  84084. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84085. */
  84086. export class Curve3 {
  84087. private _points;
  84088. private _length;
  84089. /**
  84090. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84091. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84092. * @param v1 (Vector3) the control point
  84093. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84094. * @param nbPoints (integer) the wanted number of points in the curve
  84095. * @returns the created Curve3
  84096. */
  84097. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84098. /**
  84099. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84100. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84101. * @param v1 (Vector3) the first control point
  84102. * @param v2 (Vector3) the second control point
  84103. * @param v3 (Vector3) the end point of the Cubic Bezier
  84104. * @param nbPoints (integer) the wanted number of points in the curve
  84105. * @returns the created Curve3
  84106. */
  84107. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84108. /**
  84109. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84110. * @param p1 (Vector3) the origin point of the Hermite Spline
  84111. * @param t1 (Vector3) the tangent vector at the origin point
  84112. * @param p2 (Vector3) the end point of the Hermite Spline
  84113. * @param t2 (Vector3) the tangent vector at the end point
  84114. * @param nbPoints (integer) the wanted number of points in the curve
  84115. * @returns the created Curve3
  84116. */
  84117. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84118. /**
  84119. * Returns a Curve3 object along a CatmullRom Spline curve :
  84120. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84121. * @param nbPoints (integer) the wanted number of points between each curve control points
  84122. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84123. * @returns the created Curve3
  84124. */
  84125. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84126. /**
  84127. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84128. * A Curve3 is designed from a series of successive Vector3.
  84129. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84130. * @param points points which make up the curve
  84131. */
  84132. constructor(points: Vector3[]);
  84133. /**
  84134. * @returns the Curve3 stored array of successive Vector3
  84135. */
  84136. getPoints(): Vector3[];
  84137. /**
  84138. * @returns the computed length (float) of the curve.
  84139. */
  84140. length(): number;
  84141. /**
  84142. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  84143. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  84144. * curveA and curveB keep unchanged.
  84145. * @param curve the curve to continue from this curve
  84146. * @returns the newly constructed curve
  84147. */
  84148. continue(curve: DeepImmutable<Curve3>): Curve3;
  84149. private _computeLength;
  84150. }
  84151. }
  84152. declare module BABYLON {
  84153. /**
  84154. * This represents the main contract an easing function should follow.
  84155. * Easing functions are used throughout the animation system.
  84156. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84157. */
  84158. export interface IEasingFunction {
  84159. /**
  84160. * Given an input gradient between 0 and 1, this returns the corrseponding value
  84161. * of the easing function.
  84162. * The link below provides some of the most common examples of easing functions.
  84163. * @see https://easings.net/
  84164. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84165. * @returns the corresponding value on the curve defined by the easing function
  84166. */
  84167. ease(gradient: number): number;
  84168. }
  84169. /**
  84170. * Base class used for every default easing function.
  84171. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84172. */
  84173. export class EasingFunction implements IEasingFunction {
  84174. /**
  84175. * Interpolation follows the mathematical formula associated with the easing function.
  84176. */
  84177. static readonly EASINGMODE_EASEIN: number;
  84178. /**
  84179. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  84180. */
  84181. static readonly EASINGMODE_EASEOUT: number;
  84182. /**
  84183. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  84184. */
  84185. static readonly EASINGMODE_EASEINOUT: number;
  84186. private _easingMode;
  84187. /**
  84188. * Sets the easing mode of the current function.
  84189. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  84190. */
  84191. setEasingMode(easingMode: number): void;
  84192. /**
  84193. * Gets the current easing mode.
  84194. * @returns the easing mode
  84195. */
  84196. getEasingMode(): number;
  84197. /**
  84198. * @hidden
  84199. */
  84200. easeInCore(gradient: number): number;
  84201. /**
  84202. * Given an input gradient between 0 and 1, this returns the corresponding value
  84203. * of the easing function.
  84204. * @param gradient Defines the value between 0 and 1 we want the easing value for
  84205. * @returns the corresponding value on the curve defined by the easing function
  84206. */
  84207. ease(gradient: number): number;
  84208. }
  84209. /**
  84210. * Easing function with a circle shape (see link below).
  84211. * @see https://easings.net/#easeInCirc
  84212. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84213. */
  84214. export class CircleEase extends EasingFunction implements IEasingFunction {
  84215. /** @hidden */
  84216. easeInCore(gradient: number): number;
  84217. }
  84218. /**
  84219. * Easing function with a ease back shape (see link below).
  84220. * @see https://easings.net/#easeInBack
  84221. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84222. */
  84223. export class BackEase extends EasingFunction implements IEasingFunction {
  84224. /** Defines the amplitude of the function */
  84225. amplitude: number;
  84226. /**
  84227. * Instantiates a back ease easing
  84228. * @see https://easings.net/#easeInBack
  84229. * @param amplitude Defines the amplitude of the function
  84230. */
  84231. constructor(
  84232. /** Defines the amplitude of the function */
  84233. amplitude?: number);
  84234. /** @hidden */
  84235. easeInCore(gradient: number): number;
  84236. }
  84237. /**
  84238. * Easing function with a bouncing shape (see link below).
  84239. * @see https://easings.net/#easeInBounce
  84240. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84241. */
  84242. export class BounceEase extends EasingFunction implements IEasingFunction {
  84243. /** Defines the number of bounces */
  84244. bounces: number;
  84245. /** Defines the amplitude of the bounce */
  84246. bounciness: number;
  84247. /**
  84248. * Instantiates a bounce easing
  84249. * @see https://easings.net/#easeInBounce
  84250. * @param bounces Defines the number of bounces
  84251. * @param bounciness Defines the amplitude of the bounce
  84252. */
  84253. constructor(
  84254. /** Defines the number of bounces */
  84255. bounces?: number,
  84256. /** Defines the amplitude of the bounce */
  84257. bounciness?: number);
  84258. /** @hidden */
  84259. easeInCore(gradient: number): number;
  84260. }
  84261. /**
  84262. * Easing function with a power of 3 shape (see link below).
  84263. * @see https://easings.net/#easeInCubic
  84264. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84265. */
  84266. export class CubicEase extends EasingFunction implements IEasingFunction {
  84267. /** @hidden */
  84268. easeInCore(gradient: number): number;
  84269. }
  84270. /**
  84271. * Easing function with an elastic shape (see link below).
  84272. * @see https://easings.net/#easeInElastic
  84273. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84274. */
  84275. export class ElasticEase extends EasingFunction implements IEasingFunction {
  84276. /** Defines the number of oscillations*/
  84277. oscillations: number;
  84278. /** Defines the amplitude of the oscillations*/
  84279. springiness: number;
  84280. /**
  84281. * Instantiates an elastic easing function
  84282. * @see https://easings.net/#easeInElastic
  84283. * @param oscillations Defines the number of oscillations
  84284. * @param springiness Defines the amplitude of the oscillations
  84285. */
  84286. constructor(
  84287. /** Defines the number of oscillations*/
  84288. oscillations?: number,
  84289. /** Defines the amplitude of the oscillations*/
  84290. springiness?: number);
  84291. /** @hidden */
  84292. easeInCore(gradient: number): number;
  84293. }
  84294. /**
  84295. * Easing function with an exponential shape (see link below).
  84296. * @see https://easings.net/#easeInExpo
  84297. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84298. */
  84299. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  84300. /** Defines the exponent of the function */
  84301. exponent: number;
  84302. /**
  84303. * Instantiates an exponential easing function
  84304. * @see https://easings.net/#easeInExpo
  84305. * @param exponent Defines the exponent of the function
  84306. */
  84307. constructor(
  84308. /** Defines the exponent of the function */
  84309. exponent?: number);
  84310. /** @hidden */
  84311. easeInCore(gradient: number): number;
  84312. }
  84313. /**
  84314. * Easing function with a power shape (see link below).
  84315. * @see https://easings.net/#easeInQuad
  84316. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84317. */
  84318. export class PowerEase extends EasingFunction implements IEasingFunction {
  84319. /** Defines the power of the function */
  84320. power: number;
  84321. /**
  84322. * Instantiates an power base easing function
  84323. * @see https://easings.net/#easeInQuad
  84324. * @param power Defines the power of the function
  84325. */
  84326. constructor(
  84327. /** Defines the power of the function */
  84328. power?: number);
  84329. /** @hidden */
  84330. easeInCore(gradient: number): number;
  84331. }
  84332. /**
  84333. * Easing function with a power of 2 shape (see link below).
  84334. * @see https://easings.net/#easeInQuad
  84335. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84336. */
  84337. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  84338. /** @hidden */
  84339. easeInCore(gradient: number): number;
  84340. }
  84341. /**
  84342. * Easing function with a power of 4 shape (see link below).
  84343. * @see https://easings.net/#easeInQuart
  84344. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84345. */
  84346. export class QuarticEase extends EasingFunction implements IEasingFunction {
  84347. /** @hidden */
  84348. easeInCore(gradient: number): number;
  84349. }
  84350. /**
  84351. * Easing function with a power of 5 shape (see link below).
  84352. * @see https://easings.net/#easeInQuint
  84353. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84354. */
  84355. export class QuinticEase extends EasingFunction implements IEasingFunction {
  84356. /** @hidden */
  84357. easeInCore(gradient: number): number;
  84358. }
  84359. /**
  84360. * Easing function with a sin shape (see link below).
  84361. * @see https://easings.net/#easeInSine
  84362. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84363. */
  84364. export class SineEase extends EasingFunction implements IEasingFunction {
  84365. /** @hidden */
  84366. easeInCore(gradient: number): number;
  84367. }
  84368. /**
  84369. * Easing function with a bezier shape (see link below).
  84370. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  84372. */
  84373. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  84374. /** Defines the x component of the start tangent in the bezier curve */
  84375. x1: number;
  84376. /** Defines the y component of the start tangent in the bezier curve */
  84377. y1: number;
  84378. /** Defines the x component of the end tangent in the bezier curve */
  84379. x2: number;
  84380. /** Defines the y component of the end tangent in the bezier curve */
  84381. y2: number;
  84382. /**
  84383. * Instantiates a bezier function
  84384. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  84385. * @param x1 Defines the x component of the start tangent in the bezier curve
  84386. * @param y1 Defines the y component of the start tangent in the bezier curve
  84387. * @param x2 Defines the x component of the end tangent in the bezier curve
  84388. * @param y2 Defines the y component of the end tangent in the bezier curve
  84389. */
  84390. constructor(
  84391. /** Defines the x component of the start tangent in the bezier curve */
  84392. x1?: number,
  84393. /** Defines the y component of the start tangent in the bezier curve */
  84394. y1?: number,
  84395. /** Defines the x component of the end tangent in the bezier curve */
  84396. x2?: number,
  84397. /** Defines the y component of the end tangent in the bezier curve */
  84398. y2?: number);
  84399. /** @hidden */
  84400. easeInCore(gradient: number): number;
  84401. }
  84402. }
  84403. declare module BABYLON {
  84404. /**
  84405. * Class used to hold a RBG color
  84406. */
  84407. export class Color3 {
  84408. /**
  84409. * Defines the red component (between 0 and 1, default is 0)
  84410. */
  84411. r: number;
  84412. /**
  84413. * Defines the green component (between 0 and 1, default is 0)
  84414. */
  84415. g: number;
  84416. /**
  84417. * Defines the blue component (between 0 and 1, default is 0)
  84418. */
  84419. b: number;
  84420. /**
  84421. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  84422. * @param r defines the red component (between 0 and 1, default is 0)
  84423. * @param g defines the green component (between 0 and 1, default is 0)
  84424. * @param b defines the blue component (between 0 and 1, default is 0)
  84425. */
  84426. constructor(
  84427. /**
  84428. * Defines the red component (between 0 and 1, default is 0)
  84429. */
  84430. r?: number,
  84431. /**
  84432. * Defines the green component (between 0 and 1, default is 0)
  84433. */
  84434. g?: number,
  84435. /**
  84436. * Defines the blue component (between 0 and 1, default is 0)
  84437. */
  84438. b?: number);
  84439. /**
  84440. * Creates a string with the Color3 current values
  84441. * @returns the string representation of the Color3 object
  84442. */
  84443. toString(): string;
  84444. /**
  84445. * Returns the string "Color3"
  84446. * @returns "Color3"
  84447. */
  84448. getClassName(): string;
  84449. /**
  84450. * Compute the Color3 hash code
  84451. * @returns an unique number that can be used to hash Color3 objects
  84452. */
  84453. getHashCode(): number;
  84454. /**
  84455. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  84456. * @param array defines the array where to store the r,g,b components
  84457. * @param index defines an optional index in the target array to define where to start storing values
  84458. * @returns the current Color3 object
  84459. */
  84460. toArray(array: FloatArray, index?: number): Color3;
  84461. /**
  84462. * Update the current color with values stored in an array from the starting index of the given array
  84463. * @param array defines the source array
  84464. * @param offset defines an offset in the source array
  84465. * @returns the current Color3 object
  84466. */
  84467. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84468. /**
  84469. * Returns a new Color4 object from the current Color3 and the given alpha
  84470. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  84471. * @returns a new Color4 object
  84472. */
  84473. toColor4(alpha?: number): Color4;
  84474. /**
  84475. * Returns a new array populated with 3 numeric elements : red, green and blue values
  84476. * @returns the new array
  84477. */
  84478. asArray(): number[];
  84479. /**
  84480. * Returns the luminance value
  84481. * @returns a float value
  84482. */
  84483. toLuminance(): number;
  84484. /**
  84485. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  84486. * @param otherColor defines the second operand
  84487. * @returns the new Color3 object
  84488. */
  84489. multiply(otherColor: DeepImmutable<Color3>): Color3;
  84490. /**
  84491. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  84492. * @param otherColor defines the second operand
  84493. * @param result defines the Color3 object where to store the result
  84494. * @returns the current Color3
  84495. */
  84496. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84497. /**
  84498. * Determines equality between Color3 objects
  84499. * @param otherColor defines the second operand
  84500. * @returns true if the rgb values are equal to the given ones
  84501. */
  84502. equals(otherColor: DeepImmutable<Color3>): boolean;
  84503. /**
  84504. * Determines equality between the current Color3 object and a set of r,b,g values
  84505. * @param r defines the red component to check
  84506. * @param g defines the green component to check
  84507. * @param b defines the blue component to check
  84508. * @returns true if the rgb values are equal to the given ones
  84509. */
  84510. equalsFloats(r: number, g: number, b: number): boolean;
  84511. /**
  84512. * Multiplies in place each rgb value by scale
  84513. * @param scale defines the scaling factor
  84514. * @returns the updated Color3
  84515. */
  84516. scale(scale: number): Color3;
  84517. /**
  84518. * Multiplies the rgb values by scale and stores the result into "result"
  84519. * @param scale defines the scaling factor
  84520. * @param result defines the Color3 object where to store the result
  84521. * @returns the unmodified current Color3
  84522. */
  84523. scaleToRef(scale: number, result: Color3): Color3;
  84524. /**
  84525. * Scale the current Color3 values by a factor and add the result to a given Color3
  84526. * @param scale defines the scale factor
  84527. * @param result defines color to store the result into
  84528. * @returns the unmodified current Color3
  84529. */
  84530. scaleAndAddToRef(scale: number, result: Color3): Color3;
  84531. /**
  84532. * Clamps the rgb values by the min and max values and stores the result into "result"
  84533. * @param min defines minimum clamping value (default is 0)
  84534. * @param max defines maximum clamping value (default is 1)
  84535. * @param result defines color to store the result into
  84536. * @returns the original Color3
  84537. */
  84538. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  84539. /**
  84540. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  84541. * @param otherColor defines the second operand
  84542. * @returns the new Color3
  84543. */
  84544. add(otherColor: DeepImmutable<Color3>): Color3;
  84545. /**
  84546. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  84547. * @param otherColor defines the second operand
  84548. * @param result defines Color3 object to store the result into
  84549. * @returns the unmodified current Color3
  84550. */
  84551. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84552. /**
  84553. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  84554. * @param otherColor defines the second operand
  84555. * @returns the new Color3
  84556. */
  84557. subtract(otherColor: DeepImmutable<Color3>): Color3;
  84558. /**
  84559. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  84560. * @param otherColor defines the second operand
  84561. * @param result defines Color3 object to store the result into
  84562. * @returns the unmodified current Color3
  84563. */
  84564. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  84565. /**
  84566. * Copy the current object
  84567. * @returns a new Color3 copied the current one
  84568. */
  84569. clone(): Color3;
  84570. /**
  84571. * Copies the rgb values from the source in the current Color3
  84572. * @param source defines the source Color3 object
  84573. * @returns the updated Color3 object
  84574. */
  84575. copyFrom(source: DeepImmutable<Color3>): Color3;
  84576. /**
  84577. * Updates the Color3 rgb values from the given floats
  84578. * @param r defines the red component to read from
  84579. * @param g defines the green component to read from
  84580. * @param b defines the blue component to read from
  84581. * @returns the current Color3 object
  84582. */
  84583. copyFromFloats(r: number, g: number, b: number): Color3;
  84584. /**
  84585. * Updates the Color3 rgb values from the given floats
  84586. * @param r defines the red component to read from
  84587. * @param g defines the green component to read from
  84588. * @param b defines the blue component to read from
  84589. * @returns the current Color3 object
  84590. */
  84591. set(r: number, g: number, b: number): Color3;
  84592. /**
  84593. * Compute the Color3 hexadecimal code as a string
  84594. * @returns a string containing the hexadecimal representation of the Color3 object
  84595. */
  84596. toHexString(): string;
  84597. /**
  84598. * Computes a new Color3 converted from the current one to linear space
  84599. * @returns a new Color3 object
  84600. */
  84601. toLinearSpace(): Color3;
  84602. /**
  84603. * Converts current color in rgb space to HSV values
  84604. * @returns a new color3 representing the HSV values
  84605. */
  84606. toHSV(): Color3;
  84607. /**
  84608. * Converts current color in rgb space to HSV values
  84609. * @param result defines the Color3 where to store the HSV values
  84610. */
  84611. toHSVToRef(result: Color3): void;
  84612. /**
  84613. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84614. * @param convertedColor defines the Color3 object where to store the linear space version
  84615. * @returns the unmodified Color3
  84616. */
  84617. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84618. /**
  84619. * Computes a new Color3 converted from the current one to gamma space
  84620. * @returns a new Color3 object
  84621. */
  84622. toGammaSpace(): Color3;
  84623. /**
  84624. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84625. * @param convertedColor defines the Color3 object where to store the gamma space version
  84626. * @returns the unmodified Color3
  84627. */
  84628. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84629. private static _BlackReadOnly;
  84630. /**
  84631. * Convert Hue, saturation and value to a Color3 (RGB)
  84632. * @param hue defines the hue
  84633. * @param saturation defines the saturation
  84634. * @param value defines the value
  84635. * @param result defines the Color3 where to store the RGB values
  84636. */
  84637. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84638. /**
  84639. * Creates a new Color3 from the string containing valid hexadecimal values
  84640. * @param hex defines a string containing valid hexadecimal values
  84641. * @returns a new Color3 object
  84642. */
  84643. static FromHexString(hex: string): Color3;
  84644. /**
  84645. * Creates a new Color3 from the starting index of the given array
  84646. * @param array defines the source array
  84647. * @param offset defines an offset in the source array
  84648. * @returns a new Color3 object
  84649. */
  84650. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84651. /**
  84652. * Creates a new Color3 from the starting index element of the given array
  84653. * @param array defines the source array to read from
  84654. * @param offset defines the offset in the source array
  84655. * @param result defines the target Color3 object
  84656. */
  84657. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  84658. /**
  84659. * Creates a new Color3 from integer values (< 256)
  84660. * @param r defines the red component to read from (value between 0 and 255)
  84661. * @param g defines the green component to read from (value between 0 and 255)
  84662. * @param b defines the blue component to read from (value between 0 and 255)
  84663. * @returns a new Color3 object
  84664. */
  84665. static FromInts(r: number, g: number, b: number): Color3;
  84666. /**
  84667. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84668. * @param start defines the start Color3 value
  84669. * @param end defines the end Color3 value
  84670. * @param amount defines the gradient value between start and end
  84671. * @returns a new Color3 object
  84672. */
  84673. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84674. /**
  84675. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84676. * @param left defines the start value
  84677. * @param right defines the end value
  84678. * @param amount defines the gradient factor
  84679. * @param result defines the Color3 object where to store the result
  84680. */
  84681. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84682. /**
  84683. * Returns a Color3 value containing a red color
  84684. * @returns a new Color3 object
  84685. */
  84686. static Red(): Color3;
  84687. /**
  84688. * Returns a Color3 value containing a green color
  84689. * @returns a new Color3 object
  84690. */
  84691. static Green(): Color3;
  84692. /**
  84693. * Returns a Color3 value containing a blue color
  84694. * @returns a new Color3 object
  84695. */
  84696. static Blue(): Color3;
  84697. /**
  84698. * Returns a Color3 value containing a black color
  84699. * @returns a new Color3 object
  84700. */
  84701. static Black(): Color3;
  84702. /**
  84703. * Gets a Color3 value containing a black color that must not be updated
  84704. */
  84705. static get BlackReadOnly(): DeepImmutable<Color3>;
  84706. /**
  84707. * Returns a Color3 value containing a white color
  84708. * @returns a new Color3 object
  84709. */
  84710. static White(): Color3;
  84711. /**
  84712. * Returns a Color3 value containing a purple color
  84713. * @returns a new Color3 object
  84714. */
  84715. static Purple(): Color3;
  84716. /**
  84717. * Returns a Color3 value containing a magenta color
  84718. * @returns a new Color3 object
  84719. */
  84720. static Magenta(): Color3;
  84721. /**
  84722. * Returns a Color3 value containing a yellow color
  84723. * @returns a new Color3 object
  84724. */
  84725. static Yellow(): Color3;
  84726. /**
  84727. * Returns a Color3 value containing a gray color
  84728. * @returns a new Color3 object
  84729. */
  84730. static Gray(): Color3;
  84731. /**
  84732. * Returns a Color3 value containing a teal color
  84733. * @returns a new Color3 object
  84734. */
  84735. static Teal(): Color3;
  84736. /**
  84737. * Returns a Color3 value containing a random color
  84738. * @returns a new Color3 object
  84739. */
  84740. static Random(): Color3;
  84741. }
  84742. /**
  84743. * Class used to hold a RBGA color
  84744. */
  84745. export class Color4 {
  84746. /**
  84747. * Defines the red component (between 0 and 1, default is 0)
  84748. */
  84749. r: number;
  84750. /**
  84751. * Defines the green component (between 0 and 1, default is 0)
  84752. */
  84753. g: number;
  84754. /**
  84755. * Defines the blue component (between 0 and 1, default is 0)
  84756. */
  84757. b: number;
  84758. /**
  84759. * Defines the alpha component (between 0 and 1, default is 1)
  84760. */
  84761. a: number;
  84762. /**
  84763. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84764. * @param r defines the red component (between 0 and 1, default is 0)
  84765. * @param g defines the green component (between 0 and 1, default is 0)
  84766. * @param b defines the blue component (between 0 and 1, default is 0)
  84767. * @param a defines the alpha component (between 0 and 1, default is 1)
  84768. */
  84769. constructor(
  84770. /**
  84771. * Defines the red component (between 0 and 1, default is 0)
  84772. */
  84773. r?: number,
  84774. /**
  84775. * Defines the green component (between 0 and 1, default is 0)
  84776. */
  84777. g?: number,
  84778. /**
  84779. * Defines the blue component (between 0 and 1, default is 0)
  84780. */
  84781. b?: number,
  84782. /**
  84783. * Defines the alpha component (between 0 and 1, default is 1)
  84784. */
  84785. a?: number);
  84786. /**
  84787. * Adds in place the given Color4 values to the current Color4 object
  84788. * @param right defines the second operand
  84789. * @returns the current updated Color4 object
  84790. */
  84791. addInPlace(right: DeepImmutable<Color4>): Color4;
  84792. /**
  84793. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84794. * @returns the new array
  84795. */
  84796. asArray(): number[];
  84797. /**
  84798. * Stores from the starting index in the given array the Color4 successive values
  84799. * @param array defines the array where to store the r,g,b components
  84800. * @param index defines an optional index in the target array to define where to start storing values
  84801. * @returns the current Color4 object
  84802. */
  84803. toArray(array: number[], index?: number): Color4;
  84804. /**
  84805. * Update the current color with values stored in an array from the starting index of the given array
  84806. * @param array defines the source array
  84807. * @param offset defines an offset in the source array
  84808. * @returns the current Color4 object
  84809. */
  84810. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84811. /**
  84812. * Determines equality between Color4 objects
  84813. * @param otherColor defines the second operand
  84814. * @returns true if the rgba values are equal to the given ones
  84815. */
  84816. equals(otherColor: DeepImmutable<Color4>): boolean;
  84817. /**
  84818. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84819. * @param right defines the second operand
  84820. * @returns a new Color4 object
  84821. */
  84822. add(right: DeepImmutable<Color4>): Color4;
  84823. /**
  84824. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84825. * @param right defines the second operand
  84826. * @returns a new Color4 object
  84827. */
  84828. subtract(right: DeepImmutable<Color4>): Color4;
  84829. /**
  84830. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84831. * @param right defines the second operand
  84832. * @param result defines the Color4 object where to store the result
  84833. * @returns the current Color4 object
  84834. */
  84835. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84836. /**
  84837. * Creates a new Color4 with the current Color4 values multiplied by scale
  84838. * @param scale defines the scaling factor to apply
  84839. * @returns a new Color4 object
  84840. */
  84841. scale(scale: number): Color4;
  84842. /**
  84843. * Multiplies the current Color4 values by scale and stores the result in "result"
  84844. * @param scale defines the scaling factor to apply
  84845. * @param result defines the Color4 object where to store the result
  84846. * @returns the current unmodified Color4
  84847. */
  84848. scaleToRef(scale: number, result: Color4): Color4;
  84849. /**
  84850. * Scale the current Color4 values by a factor and add the result to a given Color4
  84851. * @param scale defines the scale factor
  84852. * @param result defines the Color4 object where to store the result
  84853. * @returns the unmodified current Color4
  84854. */
  84855. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84856. /**
  84857. * Clamps the rgb values by the min and max values and stores the result into "result"
  84858. * @param min defines minimum clamping value (default is 0)
  84859. * @param max defines maximum clamping value (default is 1)
  84860. * @param result defines color to store the result into.
  84861. * @returns the cuurent Color4
  84862. */
  84863. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84864. /**
  84865. * Multipy an Color4 value by another and return a new Color4 object
  84866. * @param color defines the Color4 value to multiply by
  84867. * @returns a new Color4 object
  84868. */
  84869. multiply(color: Color4): Color4;
  84870. /**
  84871. * Multipy a Color4 value by another and push the result in a reference value
  84872. * @param color defines the Color4 value to multiply by
  84873. * @param result defines the Color4 to fill the result in
  84874. * @returns the result Color4
  84875. */
  84876. multiplyToRef(color: Color4, result: Color4): Color4;
  84877. /**
  84878. * Creates a string with the Color4 current values
  84879. * @returns the string representation of the Color4 object
  84880. */
  84881. toString(): string;
  84882. /**
  84883. * Returns the string "Color4"
  84884. * @returns "Color4"
  84885. */
  84886. getClassName(): string;
  84887. /**
  84888. * Compute the Color4 hash code
  84889. * @returns an unique number that can be used to hash Color4 objects
  84890. */
  84891. getHashCode(): number;
  84892. /**
  84893. * Creates a new Color4 copied from the current one
  84894. * @returns a new Color4 object
  84895. */
  84896. clone(): Color4;
  84897. /**
  84898. * Copies the given Color4 values into the current one
  84899. * @param source defines the source Color4 object
  84900. * @returns the current updated Color4 object
  84901. */
  84902. copyFrom(source: Color4): Color4;
  84903. /**
  84904. * Copies the given float values into the current one
  84905. * @param r defines the red component to read from
  84906. * @param g defines the green component to read from
  84907. * @param b defines the blue component to read from
  84908. * @param a defines the alpha component to read from
  84909. * @returns the current updated Color4 object
  84910. */
  84911. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84912. /**
  84913. * Copies the given float values into the current one
  84914. * @param r defines the red component to read from
  84915. * @param g defines the green component to read from
  84916. * @param b defines the blue component to read from
  84917. * @param a defines the alpha component to read from
  84918. * @returns the current updated Color4 object
  84919. */
  84920. set(r: number, g: number, b: number, a: number): Color4;
  84921. /**
  84922. * Compute the Color4 hexadecimal code as a string
  84923. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84924. * @returns a string containing the hexadecimal representation of the Color4 object
  84925. */
  84926. toHexString(returnAsColor3?: boolean): string;
  84927. /**
  84928. * Computes a new Color4 converted from the current one to linear space
  84929. * @returns a new Color4 object
  84930. */
  84931. toLinearSpace(): Color4;
  84932. /**
  84933. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84934. * @param convertedColor defines the Color4 object where to store the linear space version
  84935. * @returns the unmodified Color4
  84936. */
  84937. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84938. /**
  84939. * Computes a new Color4 converted from the current one to gamma space
  84940. * @returns a new Color4 object
  84941. */
  84942. toGammaSpace(): Color4;
  84943. /**
  84944. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84945. * @param convertedColor defines the Color4 object where to store the gamma space version
  84946. * @returns the unmodified Color4
  84947. */
  84948. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84949. /**
  84950. * Creates a new Color4 from the string containing valid hexadecimal values
  84951. * @param hex defines a string containing valid hexadecimal values
  84952. * @returns a new Color4 object
  84953. */
  84954. static FromHexString(hex: string): Color4;
  84955. /**
  84956. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84957. * @param left defines the start value
  84958. * @param right defines the end value
  84959. * @param amount defines the gradient factor
  84960. * @returns a new Color4 object
  84961. */
  84962. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84963. /**
  84964. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84965. * @param left defines the start value
  84966. * @param right defines the end value
  84967. * @param amount defines the gradient factor
  84968. * @param result defines the Color4 object where to store data
  84969. */
  84970. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84971. /**
  84972. * Creates a new Color4 from a Color3 and an alpha value
  84973. * @param color3 defines the source Color3 to read from
  84974. * @param alpha defines the alpha component (1.0 by default)
  84975. * @returns a new Color4 object
  84976. */
  84977. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84978. /**
  84979. * Creates a new Color4 from the starting index element of the given array
  84980. * @param array defines the source array to read from
  84981. * @param offset defines the offset in the source array
  84982. * @returns a new Color4 object
  84983. */
  84984. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84985. /**
  84986. * Creates a new Color4 from the starting index element of the given array
  84987. * @param array defines the source array to read from
  84988. * @param offset defines the offset in the source array
  84989. * @param result defines the target Color4 object
  84990. */
  84991. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  84992. /**
  84993. * Creates a new Color3 from integer values (< 256)
  84994. * @param r defines the red component to read from (value between 0 and 255)
  84995. * @param g defines the green component to read from (value between 0 and 255)
  84996. * @param b defines the blue component to read from (value between 0 and 255)
  84997. * @param a defines the alpha component to read from (value between 0 and 255)
  84998. * @returns a new Color3 object
  84999. */
  85000. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85001. /**
  85002. * Check the content of a given array and convert it to an array containing RGBA data
  85003. * If the original array was already containing count * 4 values then it is returned directly
  85004. * @param colors defines the array to check
  85005. * @param count defines the number of RGBA data to expect
  85006. * @returns an array containing count * 4 values (RGBA)
  85007. */
  85008. static CheckColors4(colors: number[], count: number): number[];
  85009. }
  85010. /**
  85011. * @hidden
  85012. */
  85013. export class TmpColors {
  85014. static Color3: Color3[];
  85015. static Color4: Color4[];
  85016. }
  85017. }
  85018. declare module BABYLON {
  85019. /**
  85020. * Defines an interface which represents an animation key frame
  85021. */
  85022. export interface IAnimationKey {
  85023. /**
  85024. * Frame of the key frame
  85025. */
  85026. frame: number;
  85027. /**
  85028. * Value at the specifies key frame
  85029. */
  85030. value: any;
  85031. /**
  85032. * The input tangent for the cubic hermite spline
  85033. */
  85034. inTangent?: any;
  85035. /**
  85036. * The output tangent for the cubic hermite spline
  85037. */
  85038. outTangent?: any;
  85039. /**
  85040. * The animation interpolation type
  85041. */
  85042. interpolation?: AnimationKeyInterpolation;
  85043. }
  85044. /**
  85045. * Enum for the animation key frame interpolation type
  85046. */
  85047. export enum AnimationKeyInterpolation {
  85048. /**
  85049. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85050. */
  85051. STEP = 1
  85052. }
  85053. }
  85054. declare module BABYLON {
  85055. /**
  85056. * Represents the range of an animation
  85057. */
  85058. export class AnimationRange {
  85059. /**The name of the animation range**/
  85060. name: string;
  85061. /**The starting frame of the animation */
  85062. from: number;
  85063. /**The ending frame of the animation*/
  85064. to: number;
  85065. /**
  85066. * Initializes the range of an animation
  85067. * @param name The name of the animation range
  85068. * @param from The starting frame of the animation
  85069. * @param to The ending frame of the animation
  85070. */
  85071. constructor(
  85072. /**The name of the animation range**/
  85073. name: string,
  85074. /**The starting frame of the animation */
  85075. from: number,
  85076. /**The ending frame of the animation*/
  85077. to: number);
  85078. /**
  85079. * Makes a copy of the animation range
  85080. * @returns A copy of the animation range
  85081. */
  85082. clone(): AnimationRange;
  85083. }
  85084. }
  85085. declare module BABYLON {
  85086. /**
  85087. * Composed of a frame, and an action function
  85088. */
  85089. export class AnimationEvent {
  85090. /** The frame for which the event is triggered **/
  85091. frame: number;
  85092. /** The event to perform when triggered **/
  85093. action: (currentFrame: number) => void;
  85094. /** Specifies if the event should be triggered only once**/
  85095. onlyOnce?: boolean | undefined;
  85096. /**
  85097. * Specifies if the animation event is done
  85098. */
  85099. isDone: boolean;
  85100. /**
  85101. * Initializes the animation event
  85102. * @param frame The frame for which the event is triggered
  85103. * @param action The event to perform when triggered
  85104. * @param onlyOnce Specifies if the event should be triggered only once
  85105. */
  85106. constructor(
  85107. /** The frame for which the event is triggered **/
  85108. frame: number,
  85109. /** The event to perform when triggered **/
  85110. action: (currentFrame: number) => void,
  85111. /** Specifies if the event should be triggered only once**/
  85112. onlyOnce?: boolean | undefined);
  85113. /** @hidden */
  85114. _clone(): AnimationEvent;
  85115. }
  85116. }
  85117. declare module BABYLON {
  85118. /**
  85119. * Interface used to define a behavior
  85120. */
  85121. export interface Behavior<T> {
  85122. /** gets or sets behavior's name */
  85123. name: string;
  85124. /**
  85125. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85126. */
  85127. init(): void;
  85128. /**
  85129. * Called when the behavior is attached to a target
  85130. * @param target defines the target where the behavior is attached to
  85131. */
  85132. attach(target: T): void;
  85133. /**
  85134. * Called when the behavior is detached from its target
  85135. */
  85136. detach(): void;
  85137. }
  85138. /**
  85139. * Interface implemented by classes supporting behaviors
  85140. */
  85141. export interface IBehaviorAware<T> {
  85142. /**
  85143. * Attach a behavior
  85144. * @param behavior defines the behavior to attach
  85145. * @returns the current host
  85146. */
  85147. addBehavior(behavior: Behavior<T>): T;
  85148. /**
  85149. * Remove a behavior from the current object
  85150. * @param behavior defines the behavior to detach
  85151. * @returns the current host
  85152. */
  85153. removeBehavior(behavior: Behavior<T>): T;
  85154. /**
  85155. * Gets a behavior using its name to search
  85156. * @param name defines the name to search
  85157. * @returns the behavior or null if not found
  85158. */
  85159. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  85160. }
  85161. }
  85162. declare module BABYLON {
  85163. /**
  85164. * Defines an array and its length.
  85165. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  85166. */
  85167. export interface ISmartArrayLike<T> {
  85168. /**
  85169. * The data of the array.
  85170. */
  85171. data: Array<T>;
  85172. /**
  85173. * The active length of the array.
  85174. */
  85175. length: number;
  85176. }
  85177. /**
  85178. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85179. */
  85180. export class SmartArray<T> implements ISmartArrayLike<T> {
  85181. /**
  85182. * The full set of data from the array.
  85183. */
  85184. data: Array<T>;
  85185. /**
  85186. * The active length of the array.
  85187. */
  85188. length: number;
  85189. protected _id: number;
  85190. /**
  85191. * Instantiates a Smart Array.
  85192. * @param capacity defines the default capacity of the array.
  85193. */
  85194. constructor(capacity: number);
  85195. /**
  85196. * Pushes a value at the end of the active data.
  85197. * @param value defines the object to push in the array.
  85198. */
  85199. push(value: T): void;
  85200. /**
  85201. * Iterates over the active data and apply the lambda to them.
  85202. * @param func defines the action to apply on each value.
  85203. */
  85204. forEach(func: (content: T) => void): void;
  85205. /**
  85206. * Sorts the full sets of data.
  85207. * @param compareFn defines the comparison function to apply.
  85208. */
  85209. sort(compareFn: (a: T, b: T) => number): void;
  85210. /**
  85211. * Resets the active data to an empty array.
  85212. */
  85213. reset(): void;
  85214. /**
  85215. * Releases all the data from the array as well as the array.
  85216. */
  85217. dispose(): void;
  85218. /**
  85219. * Concats the active data with a given array.
  85220. * @param array defines the data to concatenate with.
  85221. */
  85222. concat(array: any): void;
  85223. /**
  85224. * Returns the position of a value in the active data.
  85225. * @param value defines the value to find the index for
  85226. * @returns the index if found in the active data otherwise -1
  85227. */
  85228. indexOf(value: T): number;
  85229. /**
  85230. * Returns whether an element is part of the active data.
  85231. * @param value defines the value to look for
  85232. * @returns true if found in the active data otherwise false
  85233. */
  85234. contains(value: T): boolean;
  85235. private static _GlobalId;
  85236. }
  85237. /**
  85238. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  85239. * The data in this array can only be present once
  85240. */
  85241. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  85242. private _duplicateId;
  85243. /**
  85244. * Pushes a value at the end of the active data.
  85245. * THIS DOES NOT PREVENT DUPPLICATE DATA
  85246. * @param value defines the object to push in the array.
  85247. */
  85248. push(value: T): void;
  85249. /**
  85250. * Pushes a value at the end of the active data.
  85251. * If the data is already present, it won t be added again
  85252. * @param value defines the object to push in the array.
  85253. * @returns true if added false if it was already present
  85254. */
  85255. pushNoDuplicate(value: T): boolean;
  85256. /**
  85257. * Resets the active data to an empty array.
  85258. */
  85259. reset(): void;
  85260. /**
  85261. * Concats the active data with a given array.
  85262. * This ensures no dupplicate will be present in the result.
  85263. * @param array defines the data to concatenate with.
  85264. */
  85265. concatWithNoDuplicate(array: any): void;
  85266. }
  85267. }
  85268. declare module BABYLON {
  85269. /**
  85270. * @ignore
  85271. * This is a list of all the different input types that are available in the application.
  85272. * Fo instance: ArcRotateCameraGamepadInput...
  85273. */
  85274. export var CameraInputTypes: {};
  85275. /**
  85276. * This is the contract to implement in order to create a new input class.
  85277. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  85278. */
  85279. export interface ICameraInput<TCamera extends Camera> {
  85280. /**
  85281. * Defines the camera the input is attached to.
  85282. */
  85283. camera: Nullable<TCamera>;
  85284. /**
  85285. * Gets the class name of the current intput.
  85286. * @returns the class name
  85287. */
  85288. getClassName(): string;
  85289. /**
  85290. * Get the friendly name associated with the input class.
  85291. * @returns the input friendly name
  85292. */
  85293. getSimpleName(): string;
  85294. /**
  85295. * Attach the input controls to a specific dom element to get the input from.
  85296. * @param element Defines the element the controls should be listened from
  85297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85298. */
  85299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85300. /**
  85301. * Detach the current controls from the specified dom element.
  85302. * @param element Defines the element to stop listening the inputs from
  85303. */
  85304. detachControl(element: Nullable<HTMLElement>): void;
  85305. /**
  85306. * Update the current camera state depending on the inputs that have been used this frame.
  85307. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85308. */
  85309. checkInputs?: () => void;
  85310. }
  85311. /**
  85312. * Represents a map of input types to input instance or input index to input instance.
  85313. */
  85314. export interface CameraInputsMap<TCamera extends Camera> {
  85315. /**
  85316. * Accessor to the input by input type.
  85317. */
  85318. [name: string]: ICameraInput<TCamera>;
  85319. /**
  85320. * Accessor to the input by input index.
  85321. */
  85322. [idx: number]: ICameraInput<TCamera>;
  85323. }
  85324. /**
  85325. * This represents the input manager used within a camera.
  85326. * It helps dealing with all the different kind of input attached to a camera.
  85327. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85328. */
  85329. export class CameraInputsManager<TCamera extends Camera> {
  85330. /**
  85331. * Defines the list of inputs attahed to the camera.
  85332. */
  85333. attached: CameraInputsMap<TCamera>;
  85334. /**
  85335. * Defines the dom element the camera is collecting inputs from.
  85336. * This is null if the controls have not been attached.
  85337. */
  85338. attachedElement: Nullable<HTMLElement>;
  85339. /**
  85340. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85341. */
  85342. noPreventDefault: boolean;
  85343. /**
  85344. * Defined the camera the input manager belongs to.
  85345. */
  85346. camera: TCamera;
  85347. /**
  85348. * Update the current camera state depending on the inputs that have been used this frame.
  85349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  85350. */
  85351. checkInputs: () => void;
  85352. /**
  85353. * Instantiate a new Camera Input Manager.
  85354. * @param camera Defines the camera the input manager blongs to
  85355. */
  85356. constructor(camera: TCamera);
  85357. /**
  85358. * Add an input method to a camera
  85359. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  85360. * @param input camera input method
  85361. */
  85362. add(input: ICameraInput<TCamera>): void;
  85363. /**
  85364. * Remove a specific input method from a camera
  85365. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  85366. * @param inputToRemove camera input method
  85367. */
  85368. remove(inputToRemove: ICameraInput<TCamera>): void;
  85369. /**
  85370. * Remove a specific input type from a camera
  85371. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  85372. * @param inputType the type of the input to remove
  85373. */
  85374. removeByType(inputType: string): void;
  85375. private _addCheckInputs;
  85376. /**
  85377. * Attach the input controls to the currently attached dom element to listen the events from.
  85378. * @param input Defines the input to attach
  85379. */
  85380. attachInput(input: ICameraInput<TCamera>): void;
  85381. /**
  85382. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  85383. * @param element Defines the dom element to collect the events from
  85384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85385. */
  85386. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  85387. /**
  85388. * Detach the current manager inputs controls from a specific dom element.
  85389. * @param element Defines the dom element to collect the events from
  85390. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  85391. */
  85392. detachElement(element: HTMLElement, disconnect?: boolean): void;
  85393. /**
  85394. * Rebuild the dynamic inputCheck function from the current list of
  85395. * defined inputs in the manager.
  85396. */
  85397. rebuildInputCheck(): void;
  85398. /**
  85399. * Remove all attached input methods from a camera
  85400. */
  85401. clear(): void;
  85402. /**
  85403. * Serialize the current input manager attached to a camera.
  85404. * This ensures than once parsed,
  85405. * the input associated to the camera will be identical to the current ones
  85406. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  85407. */
  85408. serialize(serializedCamera: any): void;
  85409. /**
  85410. * Parses an input manager serialized JSON to restore the previous list of inputs
  85411. * and states associated to a camera.
  85412. * @param parsedCamera Defines the JSON to parse
  85413. */
  85414. parse(parsedCamera: any): void;
  85415. }
  85416. }
  85417. declare module BABYLON {
  85418. /**
  85419. * Class used to store data that will be store in GPU memory
  85420. */
  85421. export class Buffer {
  85422. private _engine;
  85423. private _buffer;
  85424. /** @hidden */
  85425. _data: Nullable<DataArray>;
  85426. private _updatable;
  85427. private _instanced;
  85428. private _divisor;
  85429. /**
  85430. * Gets the byte stride.
  85431. */
  85432. readonly byteStride: number;
  85433. /**
  85434. * Constructor
  85435. * @param engine the engine
  85436. * @param data the data to use for this buffer
  85437. * @param updatable whether the data is updatable
  85438. * @param stride the stride (optional)
  85439. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85440. * @param instanced whether the buffer is instanced (optional)
  85441. * @param useBytes set to true if the stride in in bytes (optional)
  85442. * @param divisor sets an optional divisor for instances (1 by default)
  85443. */
  85444. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  85445. /**
  85446. * Create a new VertexBuffer based on the current buffer
  85447. * @param kind defines the vertex buffer kind (position, normal, etc.)
  85448. * @param offset defines offset in the buffer (0 by default)
  85449. * @param size defines the size in floats of attributes (position is 3 for instance)
  85450. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  85451. * @param instanced defines if the vertex buffer contains indexed data
  85452. * @param useBytes defines if the offset and stride are in bytes *
  85453. * @param divisor sets an optional divisor for instances (1 by default)
  85454. * @returns the new vertex buffer
  85455. */
  85456. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  85457. /**
  85458. * Gets a boolean indicating if the Buffer is updatable?
  85459. * @returns true if the buffer is updatable
  85460. */
  85461. isUpdatable(): boolean;
  85462. /**
  85463. * Gets current buffer's data
  85464. * @returns a DataArray or null
  85465. */
  85466. getData(): Nullable<DataArray>;
  85467. /**
  85468. * Gets underlying native buffer
  85469. * @returns underlying native buffer
  85470. */
  85471. getBuffer(): Nullable<DataBuffer>;
  85472. /**
  85473. * Gets the stride in float32 units (i.e. byte stride / 4).
  85474. * May not be an integer if the byte stride is not divisible by 4.
  85475. * @returns the stride in float32 units
  85476. * @deprecated Please use byteStride instead.
  85477. */
  85478. getStrideSize(): number;
  85479. /**
  85480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85481. * @param data defines the data to store
  85482. */
  85483. create(data?: Nullable<DataArray>): void;
  85484. /** @hidden */
  85485. _rebuild(): void;
  85486. /**
  85487. * Update current buffer data
  85488. * @param data defines the data to store
  85489. */
  85490. update(data: DataArray): void;
  85491. /**
  85492. * Updates the data directly.
  85493. * @param data the new data
  85494. * @param offset the new offset
  85495. * @param vertexCount the vertex count (optional)
  85496. * @param useBytes set to true if the offset is in bytes
  85497. */
  85498. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  85499. /**
  85500. * Release all resources
  85501. */
  85502. dispose(): void;
  85503. }
  85504. /**
  85505. * Specialized buffer used to store vertex data
  85506. */
  85507. export class VertexBuffer {
  85508. /** @hidden */
  85509. _buffer: Buffer;
  85510. private _kind;
  85511. private _size;
  85512. private _ownsBuffer;
  85513. private _instanced;
  85514. private _instanceDivisor;
  85515. /**
  85516. * The byte type.
  85517. */
  85518. static readonly BYTE: number;
  85519. /**
  85520. * The unsigned byte type.
  85521. */
  85522. static readonly UNSIGNED_BYTE: number;
  85523. /**
  85524. * The short type.
  85525. */
  85526. static readonly SHORT: number;
  85527. /**
  85528. * The unsigned short type.
  85529. */
  85530. static readonly UNSIGNED_SHORT: number;
  85531. /**
  85532. * The integer type.
  85533. */
  85534. static readonly INT: number;
  85535. /**
  85536. * The unsigned integer type.
  85537. */
  85538. static readonly UNSIGNED_INT: number;
  85539. /**
  85540. * The float type.
  85541. */
  85542. static readonly FLOAT: number;
  85543. /**
  85544. * Gets or sets the instance divisor when in instanced mode
  85545. */
  85546. get instanceDivisor(): number;
  85547. set instanceDivisor(value: number);
  85548. /**
  85549. * Gets the byte stride.
  85550. */
  85551. readonly byteStride: number;
  85552. /**
  85553. * Gets the byte offset.
  85554. */
  85555. readonly byteOffset: number;
  85556. /**
  85557. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  85558. */
  85559. readonly normalized: boolean;
  85560. /**
  85561. * Gets the data type of each component in the array.
  85562. */
  85563. readonly type: number;
  85564. /**
  85565. * Constructor
  85566. * @param engine the engine
  85567. * @param data the data to use for this vertex buffer
  85568. * @param kind the vertex buffer kind
  85569. * @param updatable whether the data is updatable
  85570. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  85571. * @param stride the stride (optional)
  85572. * @param instanced whether the buffer is instanced (optional)
  85573. * @param offset the offset of the data (optional)
  85574. * @param size the number of components (optional)
  85575. * @param type the type of the component (optional)
  85576. * @param normalized whether the data contains normalized data (optional)
  85577. * @param useBytes set to true if stride and offset are in bytes (optional)
  85578. * @param divisor defines the instance divisor to use (1 by default)
  85579. */
  85580. 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);
  85581. /** @hidden */
  85582. _rebuild(): void;
  85583. /**
  85584. * Returns the kind of the VertexBuffer (string)
  85585. * @returns a string
  85586. */
  85587. getKind(): string;
  85588. /**
  85589. * Gets a boolean indicating if the VertexBuffer is updatable?
  85590. * @returns true if the buffer is updatable
  85591. */
  85592. isUpdatable(): boolean;
  85593. /**
  85594. * Gets current buffer's data
  85595. * @returns a DataArray or null
  85596. */
  85597. getData(): Nullable<DataArray>;
  85598. /**
  85599. * Gets underlying native buffer
  85600. * @returns underlying native buffer
  85601. */
  85602. getBuffer(): Nullable<DataBuffer>;
  85603. /**
  85604. * Gets the stride in float32 units (i.e. byte stride / 4).
  85605. * May not be an integer if the byte stride is not divisible by 4.
  85606. * @returns the stride in float32 units
  85607. * @deprecated Please use byteStride instead.
  85608. */
  85609. getStrideSize(): number;
  85610. /**
  85611. * Returns the offset as a multiple of the type byte length.
  85612. * @returns the offset in bytes
  85613. * @deprecated Please use byteOffset instead.
  85614. */
  85615. getOffset(): number;
  85616. /**
  85617. * Returns the number of components per vertex attribute (integer)
  85618. * @returns the size in float
  85619. */
  85620. getSize(): number;
  85621. /**
  85622. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  85623. * @returns true if this buffer is instanced
  85624. */
  85625. getIsInstanced(): boolean;
  85626. /**
  85627. * Returns the instancing divisor, zero for non-instanced (integer).
  85628. * @returns a number
  85629. */
  85630. getInstanceDivisor(): number;
  85631. /**
  85632. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85633. * @param data defines the data to store
  85634. */
  85635. create(data?: DataArray): void;
  85636. /**
  85637. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85638. * This function will create a new buffer if the current one is not updatable
  85639. * @param data defines the data to store
  85640. */
  85641. update(data: DataArray): void;
  85642. /**
  85643. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85644. * Returns the directly updated WebGLBuffer.
  85645. * @param data the new data
  85646. * @param offset the new offset
  85647. * @param useBytes set to true if the offset is in bytes
  85648. */
  85649. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85650. /**
  85651. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85652. */
  85653. dispose(): void;
  85654. /**
  85655. * Enumerates each value of this vertex buffer as numbers.
  85656. * @param count the number of values to enumerate
  85657. * @param callback the callback function called for each value
  85658. */
  85659. forEach(count: number, callback: (value: number, index: number) => void): void;
  85660. /**
  85661. * Positions
  85662. */
  85663. static readonly PositionKind: string;
  85664. /**
  85665. * Normals
  85666. */
  85667. static readonly NormalKind: string;
  85668. /**
  85669. * Tangents
  85670. */
  85671. static readonly TangentKind: string;
  85672. /**
  85673. * Texture coordinates
  85674. */
  85675. static readonly UVKind: string;
  85676. /**
  85677. * Texture coordinates 2
  85678. */
  85679. static readonly UV2Kind: string;
  85680. /**
  85681. * Texture coordinates 3
  85682. */
  85683. static readonly UV3Kind: string;
  85684. /**
  85685. * Texture coordinates 4
  85686. */
  85687. static readonly UV4Kind: string;
  85688. /**
  85689. * Texture coordinates 5
  85690. */
  85691. static readonly UV5Kind: string;
  85692. /**
  85693. * Texture coordinates 6
  85694. */
  85695. static readonly UV6Kind: string;
  85696. /**
  85697. * Colors
  85698. */
  85699. static readonly ColorKind: string;
  85700. /**
  85701. * Matrix indices (for bones)
  85702. */
  85703. static readonly MatricesIndicesKind: string;
  85704. /**
  85705. * Matrix weights (for bones)
  85706. */
  85707. static readonly MatricesWeightsKind: string;
  85708. /**
  85709. * Additional matrix indices (for bones)
  85710. */
  85711. static readonly MatricesIndicesExtraKind: string;
  85712. /**
  85713. * Additional matrix weights (for bones)
  85714. */
  85715. static readonly MatricesWeightsExtraKind: string;
  85716. /**
  85717. * Deduces the stride given a kind.
  85718. * @param kind The kind string to deduce
  85719. * @returns The deduced stride
  85720. */
  85721. static DeduceStride(kind: string): number;
  85722. /**
  85723. * Gets the byte length of the given type.
  85724. * @param type the type
  85725. * @returns the number of bytes
  85726. */
  85727. static GetTypeByteLength(type: number): number;
  85728. /**
  85729. * Enumerates each value of the given parameters as numbers.
  85730. * @param data the data to enumerate
  85731. * @param byteOffset the byte offset of the data
  85732. * @param byteStride the byte stride of the data
  85733. * @param componentCount the number of components per element
  85734. * @param componentType the type of the component
  85735. * @param count the number of values to enumerate
  85736. * @param normalized whether the data is normalized
  85737. * @param callback the callback function called for each value
  85738. */
  85739. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85740. private static _GetFloatValue;
  85741. }
  85742. }
  85743. declare module BABYLON {
  85744. /**
  85745. * @hidden
  85746. */
  85747. export class IntersectionInfo {
  85748. bu: Nullable<number>;
  85749. bv: Nullable<number>;
  85750. distance: number;
  85751. faceId: number;
  85752. subMeshId: number;
  85753. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85754. }
  85755. }
  85756. declare module BABYLON {
  85757. /**
  85758. * Class used to store bounding sphere information
  85759. */
  85760. export class BoundingSphere {
  85761. /**
  85762. * Gets the center of the bounding sphere in local space
  85763. */
  85764. readonly center: Vector3;
  85765. /**
  85766. * Radius of the bounding sphere in local space
  85767. */
  85768. radius: number;
  85769. /**
  85770. * Gets the center of the bounding sphere in world space
  85771. */
  85772. readonly centerWorld: Vector3;
  85773. /**
  85774. * Radius of the bounding sphere in world space
  85775. */
  85776. radiusWorld: number;
  85777. /**
  85778. * Gets the minimum vector in local space
  85779. */
  85780. readonly minimum: Vector3;
  85781. /**
  85782. * Gets the maximum vector in local space
  85783. */
  85784. readonly maximum: Vector3;
  85785. private _worldMatrix;
  85786. private static readonly TmpVector3;
  85787. /**
  85788. * Creates a new bounding sphere
  85789. * @param min defines the minimum vector (in local space)
  85790. * @param max defines the maximum vector (in local space)
  85791. * @param worldMatrix defines the new world matrix
  85792. */
  85793. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85794. /**
  85795. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85796. * @param min defines the new minimum vector (in local space)
  85797. * @param max defines the new maximum vector (in local space)
  85798. * @param worldMatrix defines the new world matrix
  85799. */
  85800. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85801. /**
  85802. * Scale the current bounding sphere by applying a scale factor
  85803. * @param factor defines the scale factor to apply
  85804. * @returns the current bounding box
  85805. */
  85806. scale(factor: number): BoundingSphere;
  85807. /**
  85808. * Gets the world matrix of the bounding box
  85809. * @returns a matrix
  85810. */
  85811. getWorldMatrix(): DeepImmutable<Matrix>;
  85812. /** @hidden */
  85813. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85814. /**
  85815. * Tests if the bounding sphere is intersecting the frustum planes
  85816. * @param frustumPlanes defines the frustum planes to test
  85817. * @returns true if there is an intersection
  85818. */
  85819. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85820. /**
  85821. * Tests if the bounding sphere center is in between the frustum planes.
  85822. * Used for optimistic fast inclusion.
  85823. * @param frustumPlanes defines the frustum planes to test
  85824. * @returns true if the sphere center is in between the frustum planes
  85825. */
  85826. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85827. /**
  85828. * Tests if a point is inside the bounding sphere
  85829. * @param point defines the point to test
  85830. * @returns true if the point is inside the bounding sphere
  85831. */
  85832. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85833. /**
  85834. * Checks if two sphere intersct
  85835. * @param sphere0 sphere 0
  85836. * @param sphere1 sphere 1
  85837. * @returns true if the speres intersect
  85838. */
  85839. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85840. }
  85841. }
  85842. declare module BABYLON {
  85843. /**
  85844. * Class used to store bounding box information
  85845. */
  85846. export class BoundingBox implements ICullable {
  85847. /**
  85848. * Gets the 8 vectors representing the bounding box in local space
  85849. */
  85850. readonly vectors: Vector3[];
  85851. /**
  85852. * Gets the center of the bounding box in local space
  85853. */
  85854. readonly center: Vector3;
  85855. /**
  85856. * Gets the center of the bounding box in world space
  85857. */
  85858. readonly centerWorld: Vector3;
  85859. /**
  85860. * Gets the extend size in local space
  85861. */
  85862. readonly extendSize: Vector3;
  85863. /**
  85864. * Gets the extend size in world space
  85865. */
  85866. readonly extendSizeWorld: Vector3;
  85867. /**
  85868. * Gets the OBB (object bounding box) directions
  85869. */
  85870. readonly directions: Vector3[];
  85871. /**
  85872. * Gets the 8 vectors representing the bounding box in world space
  85873. */
  85874. readonly vectorsWorld: Vector3[];
  85875. /**
  85876. * Gets the minimum vector in world space
  85877. */
  85878. readonly minimumWorld: Vector3;
  85879. /**
  85880. * Gets the maximum vector in world space
  85881. */
  85882. readonly maximumWorld: Vector3;
  85883. /**
  85884. * Gets the minimum vector in local space
  85885. */
  85886. readonly minimum: Vector3;
  85887. /**
  85888. * Gets the maximum vector in local space
  85889. */
  85890. readonly maximum: Vector3;
  85891. private _worldMatrix;
  85892. private static readonly TmpVector3;
  85893. /**
  85894. * @hidden
  85895. */
  85896. _tag: number;
  85897. /**
  85898. * Creates a new bounding box
  85899. * @param min defines the minimum vector (in local space)
  85900. * @param max defines the maximum vector (in local space)
  85901. * @param worldMatrix defines the new world matrix
  85902. */
  85903. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85904. /**
  85905. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85906. * @param min defines the new minimum vector (in local space)
  85907. * @param max defines the new maximum vector (in local space)
  85908. * @param worldMatrix defines the new world matrix
  85909. */
  85910. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85911. /**
  85912. * Scale the current bounding box by applying a scale factor
  85913. * @param factor defines the scale factor to apply
  85914. * @returns the current bounding box
  85915. */
  85916. scale(factor: number): BoundingBox;
  85917. /**
  85918. * Gets the world matrix of the bounding box
  85919. * @returns a matrix
  85920. */
  85921. getWorldMatrix(): DeepImmutable<Matrix>;
  85922. /** @hidden */
  85923. _update(world: DeepImmutable<Matrix>): void;
  85924. /**
  85925. * Tests if the bounding box is intersecting the frustum planes
  85926. * @param frustumPlanes defines the frustum planes to test
  85927. * @returns true if there is an intersection
  85928. */
  85929. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85930. /**
  85931. * Tests if the bounding box is entirely inside the frustum planes
  85932. * @param frustumPlanes defines the frustum planes to test
  85933. * @returns true if there is an inclusion
  85934. */
  85935. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85936. /**
  85937. * Tests if a point is inside the bounding box
  85938. * @param point defines the point to test
  85939. * @returns true if the point is inside the bounding box
  85940. */
  85941. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85942. /**
  85943. * Tests if the bounding box intersects with a bounding sphere
  85944. * @param sphere defines the sphere to test
  85945. * @returns true if there is an intersection
  85946. */
  85947. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85948. /**
  85949. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85950. * @param min defines the min vector to use
  85951. * @param max defines the max vector to use
  85952. * @returns true if there is an intersection
  85953. */
  85954. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85955. /**
  85956. * Tests if two bounding boxes are intersections
  85957. * @param box0 defines the first box to test
  85958. * @param box1 defines the second box to test
  85959. * @returns true if there is an intersection
  85960. */
  85961. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85962. /**
  85963. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85964. * @param minPoint defines the minimum vector of the bounding box
  85965. * @param maxPoint defines the maximum vector of the bounding box
  85966. * @param sphereCenter defines the sphere center
  85967. * @param sphereRadius defines the sphere radius
  85968. * @returns true if there is an intersection
  85969. */
  85970. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85971. /**
  85972. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85973. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85974. * @param frustumPlanes defines the frustum planes to test
  85975. * @return true if there is an inclusion
  85976. */
  85977. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85978. /**
  85979. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85980. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85981. * @param frustumPlanes defines the frustum planes to test
  85982. * @return true if there is an intersection
  85983. */
  85984. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85985. }
  85986. }
  85987. declare module BABYLON {
  85988. /** @hidden */
  85989. export class Collider {
  85990. /** Define if a collision was found */
  85991. collisionFound: boolean;
  85992. /**
  85993. * Define last intersection point in local space
  85994. */
  85995. intersectionPoint: Vector3;
  85996. /**
  85997. * Define last collided mesh
  85998. */
  85999. collidedMesh: Nullable<AbstractMesh>;
  86000. private _collisionPoint;
  86001. private _planeIntersectionPoint;
  86002. private _tempVector;
  86003. private _tempVector2;
  86004. private _tempVector3;
  86005. private _tempVector4;
  86006. private _edge;
  86007. private _baseToVertex;
  86008. private _destinationPoint;
  86009. private _slidePlaneNormal;
  86010. private _displacementVector;
  86011. /** @hidden */
  86012. _radius: Vector3;
  86013. /** @hidden */
  86014. _retry: number;
  86015. private _velocity;
  86016. private _basePoint;
  86017. private _epsilon;
  86018. /** @hidden */
  86019. _velocityWorldLength: number;
  86020. /** @hidden */
  86021. _basePointWorld: Vector3;
  86022. private _velocityWorld;
  86023. private _normalizedVelocity;
  86024. /** @hidden */
  86025. _initialVelocity: Vector3;
  86026. /** @hidden */
  86027. _initialPosition: Vector3;
  86028. private _nearestDistance;
  86029. private _collisionMask;
  86030. get collisionMask(): number;
  86031. set collisionMask(mask: number);
  86032. /**
  86033. * Gets the plane normal used to compute the sliding response (in local space)
  86034. */
  86035. get slidePlaneNormal(): Vector3;
  86036. /** @hidden */
  86037. _initialize(source: Vector3, dir: Vector3, e: number): void;
  86038. /** @hidden */
  86039. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  86040. /** @hidden */
  86041. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  86042. /** @hidden */
  86043. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86044. /** @hidden */
  86045. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86046. /** @hidden */
  86047. _getResponse(pos: Vector3, vel: Vector3): void;
  86048. }
  86049. }
  86050. declare module BABYLON {
  86051. /**
  86052. * Interface for cullable objects
  86053. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  86054. */
  86055. export interface ICullable {
  86056. /**
  86057. * Checks if the object or part of the object is in the frustum
  86058. * @param frustumPlanes Camera near/planes
  86059. * @returns true if the object is in frustum otherwise false
  86060. */
  86061. isInFrustum(frustumPlanes: Plane[]): boolean;
  86062. /**
  86063. * Checks if a cullable object (mesh...) is in the camera frustum
  86064. * Unlike isInFrustum this cheks the full bounding box
  86065. * @param frustumPlanes Camera near/planes
  86066. * @returns true if the object is in frustum otherwise false
  86067. */
  86068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86069. }
  86070. /**
  86071. * Info for a bounding data of a mesh
  86072. */
  86073. export class BoundingInfo implements ICullable {
  86074. /**
  86075. * Bounding box for the mesh
  86076. */
  86077. readonly boundingBox: BoundingBox;
  86078. /**
  86079. * Bounding sphere for the mesh
  86080. */
  86081. readonly boundingSphere: BoundingSphere;
  86082. private _isLocked;
  86083. private static readonly TmpVector3;
  86084. /**
  86085. * Constructs bounding info
  86086. * @param minimum min vector of the bounding box/sphere
  86087. * @param maximum max vector of the bounding box/sphere
  86088. * @param worldMatrix defines the new world matrix
  86089. */
  86090. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86091. /**
  86092. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86093. * @param min defines the new minimum vector (in local space)
  86094. * @param max defines the new maximum vector (in local space)
  86095. * @param worldMatrix defines the new world matrix
  86096. */
  86097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86098. /**
  86099. * min vector of the bounding box/sphere
  86100. */
  86101. get minimum(): Vector3;
  86102. /**
  86103. * max vector of the bounding box/sphere
  86104. */
  86105. get maximum(): Vector3;
  86106. /**
  86107. * If the info is locked and won't be updated to avoid perf overhead
  86108. */
  86109. get isLocked(): boolean;
  86110. set isLocked(value: boolean);
  86111. /**
  86112. * Updates the bounding sphere and box
  86113. * @param world world matrix to be used to update
  86114. */
  86115. update(world: DeepImmutable<Matrix>): void;
  86116. /**
  86117. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86118. * @param center New center of the bounding info
  86119. * @param extend New extend of the bounding info
  86120. * @returns the current bounding info
  86121. */
  86122. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86123. /**
  86124. * Scale the current bounding info by applying a scale factor
  86125. * @param factor defines the scale factor to apply
  86126. * @returns the current bounding info
  86127. */
  86128. scale(factor: number): BoundingInfo;
  86129. /**
  86130. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86131. * @param frustumPlanes defines the frustum to test
  86132. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  86133. * @returns true if the bounding info is in the frustum planes
  86134. */
  86135. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  86136. /**
  86137. * Gets the world distance between the min and max points of the bounding box
  86138. */
  86139. get diagonalLength(): number;
  86140. /**
  86141. * Checks if a cullable object (mesh...) is in the camera frustum
  86142. * Unlike isInFrustum this cheks the full bounding box
  86143. * @param frustumPlanes Camera near/planes
  86144. * @returns true if the object is in frustum otherwise false
  86145. */
  86146. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86147. /** @hidden */
  86148. _checkCollision(collider: Collider): boolean;
  86149. /**
  86150. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  86151. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86152. * @param point the point to check intersection with
  86153. * @returns if the point intersects
  86154. */
  86155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86156. /**
  86157. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  86158. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86159. * @param boundingInfo the bounding info to check intersection with
  86160. * @param precise if the intersection should be done using OBB
  86161. * @returns if the bounding info intersects
  86162. */
  86163. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  86164. }
  86165. }
  86166. declare module BABYLON {
  86167. /**
  86168. * Extracts minimum and maximum values from a list of indexed positions
  86169. * @param positions defines the positions to use
  86170. * @param indices defines the indices to the positions
  86171. * @param indexStart defines the start index
  86172. * @param indexCount defines the end index
  86173. * @param bias defines bias value to add to the result
  86174. * @return minimum and maximum values
  86175. */
  86176. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86177. minimum: Vector3;
  86178. maximum: Vector3;
  86179. };
  86180. /**
  86181. * Extracts minimum and maximum values from a list of positions
  86182. * @param positions defines the positions to use
  86183. * @param start defines the start index in the positions array
  86184. * @param count defines the number of positions to handle
  86185. * @param bias defines bias value to add to the result
  86186. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86187. * @return minimum and maximum values
  86188. */
  86189. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86190. minimum: Vector3;
  86191. maximum: Vector3;
  86192. };
  86193. }
  86194. declare module BABYLON {
  86195. /** @hidden */
  86196. export class WebGLDataBuffer extends DataBuffer {
  86197. private _buffer;
  86198. constructor(resource: WebGLBuffer);
  86199. get underlyingResource(): any;
  86200. }
  86201. }
  86202. declare module BABYLON {
  86203. /** @hidden */
  86204. export class WebGLPipelineContext implements IPipelineContext {
  86205. engine: ThinEngine;
  86206. program: Nullable<WebGLProgram>;
  86207. context?: WebGLRenderingContext;
  86208. vertexShader?: WebGLShader;
  86209. fragmentShader?: WebGLShader;
  86210. isParallelCompiled: boolean;
  86211. onCompiled?: () => void;
  86212. transformFeedback?: WebGLTransformFeedback | null;
  86213. vertexCompilationError: Nullable<string>;
  86214. fragmentCompilationError: Nullable<string>;
  86215. programLinkError: Nullable<string>;
  86216. programValidationError: Nullable<string>;
  86217. get isAsync(): boolean;
  86218. get isReady(): boolean;
  86219. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  86220. _getVertexShaderCode(): string | null;
  86221. _getFragmentShaderCode(): string | null;
  86222. }
  86223. }
  86224. declare module BABYLON {
  86225. interface ThinEngine {
  86226. /**
  86227. * Create an uniform buffer
  86228. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86229. * @param elements defines the content of the uniform buffer
  86230. * @returns the webGL uniform buffer
  86231. */
  86232. createUniformBuffer(elements: FloatArray): DataBuffer;
  86233. /**
  86234. * Create a dynamic uniform buffer
  86235. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86236. * @param elements defines the content of the uniform buffer
  86237. * @returns the webGL uniform buffer
  86238. */
  86239. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  86240. /**
  86241. * Update an existing uniform buffer
  86242. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86243. * @param uniformBuffer defines the target uniform buffer
  86244. * @param elements defines the content to update
  86245. * @param offset defines the offset in the uniform buffer where update should start
  86246. * @param count defines the size of the data to update
  86247. */
  86248. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86249. /**
  86250. * Bind an uniform buffer to the current webGL context
  86251. * @param buffer defines the buffer to bind
  86252. */
  86253. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  86254. /**
  86255. * Bind a buffer to the current webGL context at a given location
  86256. * @param buffer defines the buffer to bind
  86257. * @param location defines the index where to bind the buffer
  86258. */
  86259. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  86260. /**
  86261. * Bind a specific block at a given index in a specific shader program
  86262. * @param pipelineContext defines the pipeline context to use
  86263. * @param blockName defines the block name
  86264. * @param index defines the index where to bind the block
  86265. */
  86266. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  86267. }
  86268. }
  86269. declare module BABYLON {
  86270. /**
  86271. * Uniform buffer objects.
  86272. *
  86273. * Handles blocks of uniform on the GPU.
  86274. *
  86275. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86276. *
  86277. * For more information, please refer to :
  86278. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86279. */
  86280. export class UniformBuffer {
  86281. private _engine;
  86282. private _buffer;
  86283. private _data;
  86284. private _bufferData;
  86285. private _dynamic?;
  86286. private _uniformLocations;
  86287. private _uniformSizes;
  86288. private _uniformLocationPointer;
  86289. private _needSync;
  86290. private _noUBO;
  86291. private _currentEffect;
  86292. /** @hidden */
  86293. _alreadyBound: boolean;
  86294. private static _MAX_UNIFORM_SIZE;
  86295. private static _tempBuffer;
  86296. /**
  86297. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  86298. * This is dynamic to allow compat with webgl 1 and 2.
  86299. * You will need to pass the name of the uniform as well as the value.
  86300. */
  86301. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  86302. /**
  86303. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  86304. * This is dynamic to allow compat with webgl 1 and 2.
  86305. * You will need to pass the name of the uniform as well as the value.
  86306. */
  86307. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  86308. /**
  86309. * Lambda to Update a single float in a uniform buffer.
  86310. * This is dynamic to allow compat with webgl 1 and 2.
  86311. * You will need to pass the name of the uniform as well as the value.
  86312. */
  86313. updateFloat: (name: string, x: number) => void;
  86314. /**
  86315. * Lambda to Update a vec2 of float in a uniform buffer.
  86316. * This is dynamic to allow compat with webgl 1 and 2.
  86317. * You will need to pass the name of the uniform as well as the value.
  86318. */
  86319. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  86320. /**
  86321. * Lambda to Update a vec3 of float in a uniform buffer.
  86322. * This is dynamic to allow compat with webgl 1 and 2.
  86323. * You will need to pass the name of the uniform as well as the value.
  86324. */
  86325. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  86326. /**
  86327. * Lambda to Update a vec4 of float in a uniform buffer.
  86328. * This is dynamic to allow compat with webgl 1 and 2.
  86329. * You will need to pass the name of the uniform as well as the value.
  86330. */
  86331. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  86332. /**
  86333. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  86334. * This is dynamic to allow compat with webgl 1 and 2.
  86335. * You will need to pass the name of the uniform as well as the value.
  86336. */
  86337. updateMatrix: (name: string, mat: Matrix) => void;
  86338. /**
  86339. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  86340. * This is dynamic to allow compat with webgl 1 and 2.
  86341. * You will need to pass the name of the uniform as well as the value.
  86342. */
  86343. updateVector3: (name: string, vector: Vector3) => void;
  86344. /**
  86345. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  86346. * This is dynamic to allow compat with webgl 1 and 2.
  86347. * You will need to pass the name of the uniform as well as the value.
  86348. */
  86349. updateVector4: (name: string, vector: Vector4) => void;
  86350. /**
  86351. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  86352. * This is dynamic to allow compat with webgl 1 and 2.
  86353. * You will need to pass the name of the uniform as well as the value.
  86354. */
  86355. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  86356. /**
  86357. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  86358. * This is dynamic to allow compat with webgl 1 and 2.
  86359. * You will need to pass the name of the uniform as well as the value.
  86360. */
  86361. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  86362. /**
  86363. * Instantiates a new Uniform buffer objects.
  86364. *
  86365. * Handles blocks of uniform on the GPU.
  86366. *
  86367. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  86368. *
  86369. * For more information, please refer to :
  86370. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  86371. * @param engine Define the engine the buffer is associated with
  86372. * @param data Define the data contained in the buffer
  86373. * @param dynamic Define if the buffer is updatable
  86374. */
  86375. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  86376. /**
  86377. * Indicates if the buffer is using the WebGL2 UBO implementation,
  86378. * or just falling back on setUniformXXX calls.
  86379. */
  86380. get useUbo(): boolean;
  86381. /**
  86382. * Indicates if the WebGL underlying uniform buffer is in sync
  86383. * with the javascript cache data.
  86384. */
  86385. get isSync(): boolean;
  86386. /**
  86387. * Indicates if the WebGL underlying uniform buffer is dynamic.
  86388. * Also, a dynamic UniformBuffer will disable cache verification and always
  86389. * update the underlying WebGL uniform buffer to the GPU.
  86390. * @returns if Dynamic, otherwise false
  86391. */
  86392. isDynamic(): boolean;
  86393. /**
  86394. * The data cache on JS side.
  86395. * @returns the underlying data as a float array
  86396. */
  86397. getData(): Float32Array;
  86398. /**
  86399. * The underlying WebGL Uniform buffer.
  86400. * @returns the webgl buffer
  86401. */
  86402. getBuffer(): Nullable<DataBuffer>;
  86403. /**
  86404. * std140 layout specifies how to align data within an UBO structure.
  86405. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  86406. * for specs.
  86407. */
  86408. private _fillAlignment;
  86409. /**
  86410. * Adds an uniform in the buffer.
  86411. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  86412. * for the layout to be correct !
  86413. * @param name Name of the uniform, as used in the uniform block in the shader.
  86414. * @param size Data size, or data directly.
  86415. */
  86416. addUniform(name: string, size: number | number[]): void;
  86417. /**
  86418. * Adds a Matrix 4x4 to the uniform buffer.
  86419. * @param name Name of the uniform, as used in the uniform block in the shader.
  86420. * @param mat A 4x4 matrix.
  86421. */
  86422. addMatrix(name: string, mat: Matrix): void;
  86423. /**
  86424. * Adds a vec2 to the uniform buffer.
  86425. * @param name Name of the uniform, as used in the uniform block in the shader.
  86426. * @param x Define the x component value of the vec2
  86427. * @param y Define the y component value of the vec2
  86428. */
  86429. addFloat2(name: string, x: number, y: number): void;
  86430. /**
  86431. * Adds a vec3 to the uniform buffer.
  86432. * @param name Name of the uniform, as used in the uniform block in the shader.
  86433. * @param x Define the x component value of the vec3
  86434. * @param y Define the y component value of the vec3
  86435. * @param z Define the z component value of the vec3
  86436. */
  86437. addFloat3(name: string, x: number, y: number, z: number): void;
  86438. /**
  86439. * Adds a vec3 to the uniform buffer.
  86440. * @param name Name of the uniform, as used in the uniform block in the shader.
  86441. * @param color Define the vec3 from a Color
  86442. */
  86443. addColor3(name: string, color: Color3): void;
  86444. /**
  86445. * Adds a vec4 to the uniform buffer.
  86446. * @param name Name of the uniform, as used in the uniform block in the shader.
  86447. * @param color Define the rgb components from a Color
  86448. * @param alpha Define the a component of the vec4
  86449. */
  86450. addColor4(name: string, color: Color3, alpha: number): void;
  86451. /**
  86452. * Adds a vec3 to the uniform buffer.
  86453. * @param name Name of the uniform, as used in the uniform block in the shader.
  86454. * @param vector Define the vec3 components from a Vector
  86455. */
  86456. addVector3(name: string, vector: Vector3): void;
  86457. /**
  86458. * Adds a Matrix 3x3 to the uniform buffer.
  86459. * @param name Name of the uniform, as used in the uniform block in the shader.
  86460. */
  86461. addMatrix3x3(name: string): void;
  86462. /**
  86463. * Adds a Matrix 2x2 to the uniform buffer.
  86464. * @param name Name of the uniform, as used in the uniform block in the shader.
  86465. */
  86466. addMatrix2x2(name: string): void;
  86467. /**
  86468. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  86469. */
  86470. create(): void;
  86471. /** @hidden */
  86472. _rebuild(): void;
  86473. /**
  86474. * Updates the WebGL Uniform Buffer on the GPU.
  86475. * If the `dynamic` flag is set to true, no cache comparison is done.
  86476. * Otherwise, the buffer will be updated only if the cache differs.
  86477. */
  86478. update(): void;
  86479. /**
  86480. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  86481. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86482. * @param data Define the flattened data
  86483. * @param size Define the size of the data.
  86484. */
  86485. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  86486. private _valueCache;
  86487. private _cacheMatrix;
  86488. private _updateMatrix3x3ForUniform;
  86489. private _updateMatrix3x3ForEffect;
  86490. private _updateMatrix2x2ForEffect;
  86491. private _updateMatrix2x2ForUniform;
  86492. private _updateFloatForEffect;
  86493. private _updateFloatForUniform;
  86494. private _updateFloat2ForEffect;
  86495. private _updateFloat2ForUniform;
  86496. private _updateFloat3ForEffect;
  86497. private _updateFloat3ForUniform;
  86498. private _updateFloat4ForEffect;
  86499. private _updateFloat4ForUniform;
  86500. private _updateMatrixForEffect;
  86501. private _updateMatrixForUniform;
  86502. private _updateVector3ForEffect;
  86503. private _updateVector3ForUniform;
  86504. private _updateVector4ForEffect;
  86505. private _updateVector4ForUniform;
  86506. private _updateColor3ForEffect;
  86507. private _updateColor3ForUniform;
  86508. private _updateColor4ForEffect;
  86509. private _updateColor4ForUniform;
  86510. /**
  86511. * Sets a sampler uniform on the effect.
  86512. * @param name Define the name of the sampler.
  86513. * @param texture Define the texture to set in the sampler
  86514. */
  86515. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  86516. /**
  86517. * Directly updates the value of the uniform in the cache AND on the GPU.
  86518. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  86519. * @param data Define the flattened data
  86520. */
  86521. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  86522. /**
  86523. * Binds this uniform buffer to an effect.
  86524. * @param effect Define the effect to bind the buffer to
  86525. * @param name Name of the uniform block in the shader.
  86526. */
  86527. bindToEffect(effect: Effect, name: string): void;
  86528. /**
  86529. * Disposes the uniform buffer.
  86530. */
  86531. dispose(): void;
  86532. }
  86533. }
  86534. declare module BABYLON {
  86535. /**
  86536. * Enum that determines the text-wrapping mode to use.
  86537. */
  86538. export enum InspectableType {
  86539. /**
  86540. * Checkbox for booleans
  86541. */
  86542. Checkbox = 0,
  86543. /**
  86544. * Sliders for numbers
  86545. */
  86546. Slider = 1,
  86547. /**
  86548. * Vector3
  86549. */
  86550. Vector3 = 2,
  86551. /**
  86552. * Quaternions
  86553. */
  86554. Quaternion = 3,
  86555. /**
  86556. * Color3
  86557. */
  86558. Color3 = 4,
  86559. /**
  86560. * String
  86561. */
  86562. String = 5
  86563. }
  86564. /**
  86565. * Interface used to define custom inspectable properties.
  86566. * This interface is used by the inspector to display custom property grids
  86567. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86568. */
  86569. export interface IInspectable {
  86570. /**
  86571. * Gets the label to display
  86572. */
  86573. label: string;
  86574. /**
  86575. * Gets the name of the property to edit
  86576. */
  86577. propertyName: string;
  86578. /**
  86579. * Gets the type of the editor to use
  86580. */
  86581. type: InspectableType;
  86582. /**
  86583. * Gets the minimum value of the property when using in "slider" mode
  86584. */
  86585. min?: number;
  86586. /**
  86587. * Gets the maximum value of the property when using in "slider" mode
  86588. */
  86589. max?: number;
  86590. /**
  86591. * Gets the setp to use when using in "slider" mode
  86592. */
  86593. step?: number;
  86594. }
  86595. }
  86596. declare module BABYLON {
  86597. /**
  86598. * Class used to provide helper for timing
  86599. */
  86600. export class TimingTools {
  86601. /**
  86602. * Polyfill for setImmediate
  86603. * @param action defines the action to execute after the current execution block
  86604. */
  86605. static SetImmediate(action: () => void): void;
  86606. }
  86607. }
  86608. declare module BABYLON {
  86609. /**
  86610. * Class used to enable instatition of objects by class name
  86611. */
  86612. export class InstantiationTools {
  86613. /**
  86614. * Use this object to register external classes like custom textures or material
  86615. * to allow the laoders to instantiate them
  86616. */
  86617. static RegisteredExternalClasses: {
  86618. [key: string]: Object;
  86619. };
  86620. /**
  86621. * Tries to instantiate a new object from a given class name
  86622. * @param className defines the class name to instantiate
  86623. * @returns the new object or null if the system was not able to do the instantiation
  86624. */
  86625. static Instantiate(className: string): any;
  86626. }
  86627. }
  86628. declare module BABYLON {
  86629. /**
  86630. * Define options used to create a depth texture
  86631. */
  86632. export class DepthTextureCreationOptions {
  86633. /** Specifies whether or not a stencil should be allocated in the texture */
  86634. generateStencil?: boolean;
  86635. /** Specifies whether or not bilinear filtering is enable on the texture */
  86636. bilinearFiltering?: boolean;
  86637. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86638. comparisonFunction?: number;
  86639. /** Specifies if the created texture is a cube texture */
  86640. isCube?: boolean;
  86641. }
  86642. }
  86643. declare module BABYLON {
  86644. interface ThinEngine {
  86645. /**
  86646. * Creates a depth stencil cube texture.
  86647. * This is only available in WebGL 2.
  86648. * @param size The size of face edge in the cube texture.
  86649. * @param options The options defining the cube texture.
  86650. * @returns The cube texture
  86651. */
  86652. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86653. /**
  86654. * Creates a cube texture
  86655. * @param rootUrl defines the url where the files to load is located
  86656. * @param scene defines the current scene
  86657. * @param files defines the list of files to load (1 per face)
  86658. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86659. * @param onLoad defines an optional callback raised when the texture is loaded
  86660. * @param onError defines an optional callback raised if there is an issue to load the texture
  86661. * @param format defines the format of the data
  86662. * @param forcedExtension defines the extension to use to pick the right loader
  86663. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86664. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86665. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86666. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86667. * @returns the cube texture as an InternalTexture
  86668. */
  86669. 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;
  86670. /**
  86671. * Creates a cube texture
  86672. * @param rootUrl defines the url where the files to load is located
  86673. * @param scene defines the current scene
  86674. * @param files defines the list of files to load (1 per face)
  86675. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86676. * @param onLoad defines an optional callback raised when the texture is loaded
  86677. * @param onError defines an optional callback raised if there is an issue to load the texture
  86678. * @param format defines the format of the data
  86679. * @param forcedExtension defines the extension to use to pick the right loader
  86680. * @returns the cube texture as an InternalTexture
  86681. */
  86682. 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;
  86683. /**
  86684. * Creates a cube texture
  86685. * @param rootUrl defines the url where the files to load is located
  86686. * @param scene defines the current scene
  86687. * @param files defines the list of files to load (1 per face)
  86688. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86689. * @param onLoad defines an optional callback raised when the texture is loaded
  86690. * @param onError defines an optional callback raised if there is an issue to load the texture
  86691. * @param format defines the format of the data
  86692. * @param forcedExtension defines the extension to use to pick the right loader
  86693. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86694. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86695. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86696. * @returns the cube texture as an InternalTexture
  86697. */
  86698. 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;
  86699. /** @hidden */
  86700. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86701. /** @hidden */
  86702. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86703. /** @hidden */
  86704. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86705. /** @hidden */
  86706. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86707. /**
  86708. * @hidden
  86709. */
  86710. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86711. }
  86712. }
  86713. declare module BABYLON {
  86714. /**
  86715. * Class for creating a cube texture
  86716. */
  86717. export class CubeTexture extends BaseTexture {
  86718. private _delayedOnLoad;
  86719. /**
  86720. * Observable triggered once the texture has been loaded.
  86721. */
  86722. onLoadObservable: Observable<CubeTexture>;
  86723. /**
  86724. * The url of the texture
  86725. */
  86726. url: string;
  86727. /**
  86728. * Gets or sets the center of the bounding box associated with the cube texture.
  86729. * It must define where the camera used to render the texture was set
  86730. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86731. */
  86732. boundingBoxPosition: Vector3;
  86733. private _boundingBoxSize;
  86734. /**
  86735. * Gets or sets the size of the bounding box associated with the cube texture
  86736. * When defined, the cubemap will switch to local mode
  86737. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86738. * @example https://www.babylonjs-playground.com/#RNASML
  86739. */
  86740. set boundingBoxSize(value: Vector3);
  86741. /**
  86742. * Returns the bounding box size
  86743. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86744. */
  86745. get boundingBoxSize(): Vector3;
  86746. protected _rotationY: number;
  86747. /**
  86748. * Sets texture matrix rotation angle around Y axis in radians.
  86749. */
  86750. set rotationY(value: number);
  86751. /**
  86752. * Gets texture matrix rotation angle around Y axis radians.
  86753. */
  86754. get rotationY(): number;
  86755. /**
  86756. * Are mip maps generated for this texture or not.
  86757. */
  86758. get noMipmap(): boolean;
  86759. private _noMipmap;
  86760. private _files;
  86761. protected _forcedExtension: Nullable<string>;
  86762. private _extensions;
  86763. private _textureMatrix;
  86764. private _format;
  86765. private _createPolynomials;
  86766. /**
  86767. * Creates a cube texture from an array of image urls
  86768. * @param files defines an array of image urls
  86769. * @param scene defines the hosting scene
  86770. * @param noMipmap specifies if mip maps are not used
  86771. * @returns a cube texture
  86772. */
  86773. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86774. /**
  86775. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86776. * @param url defines the url of the prefiltered texture
  86777. * @param scene defines the scene the texture is attached to
  86778. * @param forcedExtension defines the extension of the file if different from the url
  86779. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86780. * @return the prefiltered texture
  86781. */
  86782. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86783. /**
  86784. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86785. * as prefiltered data.
  86786. * @param rootUrl defines the url of the texture or the root name of the six images
  86787. * @param null defines the scene or engine the texture is attached to
  86788. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86789. * @param noMipmap defines if mipmaps should be created or not
  86790. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86791. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86792. * @param onError defines a callback triggered in case of error during load
  86793. * @param format defines the internal format to use for the texture once loaded
  86794. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86795. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86796. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86797. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86798. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86799. * @return the cube texture
  86800. */
  86801. 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);
  86802. /**
  86803. * Get the current class name of the texture useful for serialization or dynamic coding.
  86804. * @returns "CubeTexture"
  86805. */
  86806. getClassName(): string;
  86807. /**
  86808. * Update the url (and optional buffer) of this texture if url was null during construction.
  86809. * @param url the url of the texture
  86810. * @param forcedExtension defines the extension to use
  86811. * @param onLoad callback called when the texture is loaded (defaults to null)
  86812. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86813. */
  86814. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86815. /**
  86816. * Delays loading of the cube texture
  86817. * @param forcedExtension defines the extension to use
  86818. */
  86819. delayLoad(forcedExtension?: string): void;
  86820. /**
  86821. * Returns the reflection texture matrix
  86822. * @returns the reflection texture matrix
  86823. */
  86824. getReflectionTextureMatrix(): Matrix;
  86825. /**
  86826. * Sets the reflection texture matrix
  86827. * @param value Reflection texture matrix
  86828. */
  86829. setReflectionTextureMatrix(value: Matrix): void;
  86830. /**
  86831. * Parses text to create a cube texture
  86832. * @param parsedTexture define the serialized text to read from
  86833. * @param scene defines the hosting scene
  86834. * @param rootUrl defines the root url of the cube texture
  86835. * @returns a cube texture
  86836. */
  86837. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86838. /**
  86839. * Makes a clone, or deep copy, of the cube texture
  86840. * @returns a new cube texture
  86841. */
  86842. clone(): CubeTexture;
  86843. }
  86844. }
  86845. declare module BABYLON {
  86846. /**
  86847. * Manages the defines for the Material
  86848. */
  86849. export class MaterialDefines {
  86850. /** @hidden */
  86851. protected _keys: string[];
  86852. private _isDirty;
  86853. /** @hidden */
  86854. _renderId: number;
  86855. /** @hidden */
  86856. _areLightsDirty: boolean;
  86857. /** @hidden */
  86858. _areLightsDisposed: boolean;
  86859. /** @hidden */
  86860. _areAttributesDirty: boolean;
  86861. /** @hidden */
  86862. _areTexturesDirty: boolean;
  86863. /** @hidden */
  86864. _areFresnelDirty: boolean;
  86865. /** @hidden */
  86866. _areMiscDirty: boolean;
  86867. /** @hidden */
  86868. _areImageProcessingDirty: boolean;
  86869. /** @hidden */
  86870. _normals: boolean;
  86871. /** @hidden */
  86872. _uvs: boolean;
  86873. /** @hidden */
  86874. _needNormals: boolean;
  86875. /** @hidden */
  86876. _needUVs: boolean;
  86877. [id: string]: any;
  86878. /**
  86879. * Specifies if the material needs to be re-calculated
  86880. */
  86881. get isDirty(): boolean;
  86882. /**
  86883. * Marks the material to indicate that it has been re-calculated
  86884. */
  86885. markAsProcessed(): void;
  86886. /**
  86887. * Marks the material to indicate that it needs to be re-calculated
  86888. */
  86889. markAsUnprocessed(): void;
  86890. /**
  86891. * Marks the material to indicate all of its defines need to be re-calculated
  86892. */
  86893. markAllAsDirty(): void;
  86894. /**
  86895. * Marks the material to indicate that image processing needs to be re-calculated
  86896. */
  86897. markAsImageProcessingDirty(): void;
  86898. /**
  86899. * Marks the material to indicate the lights need to be re-calculated
  86900. * @param disposed Defines whether the light is dirty due to dispose or not
  86901. */
  86902. markAsLightDirty(disposed?: boolean): void;
  86903. /**
  86904. * Marks the attribute state as changed
  86905. */
  86906. markAsAttributesDirty(): void;
  86907. /**
  86908. * Marks the texture state as changed
  86909. */
  86910. markAsTexturesDirty(): void;
  86911. /**
  86912. * Marks the fresnel state as changed
  86913. */
  86914. markAsFresnelDirty(): void;
  86915. /**
  86916. * Marks the misc state as changed
  86917. */
  86918. markAsMiscDirty(): void;
  86919. /**
  86920. * Rebuilds the material defines
  86921. */
  86922. rebuild(): void;
  86923. /**
  86924. * Specifies if two material defines are equal
  86925. * @param other - A material define instance to compare to
  86926. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86927. */
  86928. isEqual(other: MaterialDefines): boolean;
  86929. /**
  86930. * Clones this instance's defines to another instance
  86931. * @param other - material defines to clone values to
  86932. */
  86933. cloneTo(other: MaterialDefines): void;
  86934. /**
  86935. * Resets the material define values
  86936. */
  86937. reset(): void;
  86938. /**
  86939. * Converts the material define values to a string
  86940. * @returns - String of material define information
  86941. */
  86942. toString(): string;
  86943. }
  86944. }
  86945. declare module BABYLON {
  86946. /**
  86947. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86948. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86949. * 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;
  86950. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86951. */
  86952. export class ColorCurves {
  86953. private _dirty;
  86954. private _tempColor;
  86955. private _globalCurve;
  86956. private _highlightsCurve;
  86957. private _midtonesCurve;
  86958. private _shadowsCurve;
  86959. private _positiveCurve;
  86960. private _negativeCurve;
  86961. private _globalHue;
  86962. private _globalDensity;
  86963. private _globalSaturation;
  86964. private _globalExposure;
  86965. /**
  86966. * Gets the global Hue value.
  86967. * 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).
  86968. */
  86969. get globalHue(): number;
  86970. /**
  86971. * Sets the global Hue value.
  86972. * 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).
  86973. */
  86974. set globalHue(value: number);
  86975. /**
  86976. * Gets the global Density value.
  86977. * 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.
  86978. * Values less than zero provide a filter of opposite hue.
  86979. */
  86980. get globalDensity(): number;
  86981. /**
  86982. * Sets the global Density value.
  86983. * 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.
  86984. * Values less than zero provide a filter of opposite hue.
  86985. */
  86986. set globalDensity(value: number);
  86987. /**
  86988. * Gets the global Saturation value.
  86989. * 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.
  86990. */
  86991. get globalSaturation(): number;
  86992. /**
  86993. * Sets the global Saturation value.
  86994. * 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.
  86995. */
  86996. set globalSaturation(value: number);
  86997. /**
  86998. * Gets the global Exposure value.
  86999. * 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.
  87000. */
  87001. get globalExposure(): number;
  87002. /**
  87003. * Sets the global Exposure value.
  87004. * 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.
  87005. */
  87006. set globalExposure(value: number);
  87007. private _highlightsHue;
  87008. private _highlightsDensity;
  87009. private _highlightsSaturation;
  87010. private _highlightsExposure;
  87011. /**
  87012. * Gets the highlights Hue value.
  87013. * 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).
  87014. */
  87015. get highlightsHue(): number;
  87016. /**
  87017. * Sets the highlights Hue value.
  87018. * 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).
  87019. */
  87020. set highlightsHue(value: number);
  87021. /**
  87022. * Gets the highlights Density value.
  87023. * 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.
  87024. * Values less than zero provide a filter of opposite hue.
  87025. */
  87026. get highlightsDensity(): number;
  87027. /**
  87028. * Sets the highlights Density value.
  87029. * 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.
  87030. * Values less than zero provide a filter of opposite hue.
  87031. */
  87032. set highlightsDensity(value: number);
  87033. /**
  87034. * Gets the highlights Saturation value.
  87035. * 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.
  87036. */
  87037. get highlightsSaturation(): number;
  87038. /**
  87039. * Sets the highlights Saturation value.
  87040. * 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.
  87041. */
  87042. set highlightsSaturation(value: number);
  87043. /**
  87044. * Gets the highlights Exposure value.
  87045. * 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.
  87046. */
  87047. get highlightsExposure(): number;
  87048. /**
  87049. * Sets the highlights Exposure value.
  87050. * 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.
  87051. */
  87052. set highlightsExposure(value: number);
  87053. private _midtonesHue;
  87054. private _midtonesDensity;
  87055. private _midtonesSaturation;
  87056. private _midtonesExposure;
  87057. /**
  87058. * Gets the midtones Hue value.
  87059. * 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).
  87060. */
  87061. get midtonesHue(): number;
  87062. /**
  87063. * Sets the midtones Hue value.
  87064. * 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).
  87065. */
  87066. set midtonesHue(value: number);
  87067. /**
  87068. * Gets the midtones Density value.
  87069. * 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.
  87070. * Values less than zero provide a filter of opposite hue.
  87071. */
  87072. get midtonesDensity(): number;
  87073. /**
  87074. * Sets the midtones Density value.
  87075. * 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.
  87076. * Values less than zero provide a filter of opposite hue.
  87077. */
  87078. set midtonesDensity(value: number);
  87079. /**
  87080. * Gets the midtones Saturation value.
  87081. * 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.
  87082. */
  87083. get midtonesSaturation(): number;
  87084. /**
  87085. * Sets the midtones Saturation value.
  87086. * 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.
  87087. */
  87088. set midtonesSaturation(value: number);
  87089. /**
  87090. * Gets the midtones Exposure value.
  87091. * 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.
  87092. */
  87093. get midtonesExposure(): number;
  87094. /**
  87095. * Sets the midtones Exposure value.
  87096. * 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.
  87097. */
  87098. set midtonesExposure(value: number);
  87099. private _shadowsHue;
  87100. private _shadowsDensity;
  87101. private _shadowsSaturation;
  87102. private _shadowsExposure;
  87103. /**
  87104. * Gets the shadows Hue value.
  87105. * 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).
  87106. */
  87107. get shadowsHue(): number;
  87108. /**
  87109. * Sets the shadows Hue value.
  87110. * 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).
  87111. */
  87112. set shadowsHue(value: number);
  87113. /**
  87114. * Gets the shadows Density value.
  87115. * 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.
  87116. * Values less than zero provide a filter of opposite hue.
  87117. */
  87118. get shadowsDensity(): number;
  87119. /**
  87120. * Sets the shadows Density value.
  87121. * 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.
  87122. * Values less than zero provide a filter of opposite hue.
  87123. */
  87124. set shadowsDensity(value: number);
  87125. /**
  87126. * Gets the shadows Saturation value.
  87127. * 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.
  87128. */
  87129. get shadowsSaturation(): number;
  87130. /**
  87131. * Sets the shadows Saturation value.
  87132. * 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.
  87133. */
  87134. set shadowsSaturation(value: number);
  87135. /**
  87136. * Gets the shadows Exposure value.
  87137. * 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.
  87138. */
  87139. get shadowsExposure(): number;
  87140. /**
  87141. * Sets the shadows Exposure value.
  87142. * 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.
  87143. */
  87144. set shadowsExposure(value: number);
  87145. /**
  87146. * Returns the class name
  87147. * @returns The class name
  87148. */
  87149. getClassName(): string;
  87150. /**
  87151. * Binds the color curves to the shader.
  87152. * @param colorCurves The color curve to bind
  87153. * @param effect The effect to bind to
  87154. * @param positiveUniform The positive uniform shader parameter
  87155. * @param neutralUniform The neutral uniform shader parameter
  87156. * @param negativeUniform The negative uniform shader parameter
  87157. */
  87158. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87159. /**
  87160. * Prepare the list of uniforms associated with the ColorCurves effects.
  87161. * @param uniformsList The list of uniforms used in the effect
  87162. */
  87163. static PrepareUniforms(uniformsList: string[]): void;
  87164. /**
  87165. * Returns color grading data based on a hue, density, saturation and exposure value.
  87166. * @param filterHue The hue of the color filter.
  87167. * @param filterDensity The density of the color filter.
  87168. * @param saturation The saturation.
  87169. * @param exposure The exposure.
  87170. * @param result The result data container.
  87171. */
  87172. private getColorGradingDataToRef;
  87173. /**
  87174. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87175. * @param value The input slider value in range [-100,100].
  87176. * @returns Adjusted value.
  87177. */
  87178. private static applyColorGradingSliderNonlinear;
  87179. /**
  87180. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87181. * @param hue The hue (H) input.
  87182. * @param saturation The saturation (S) input.
  87183. * @param brightness The brightness (B) input.
  87184. * @result An RGBA color represented as Vector4.
  87185. */
  87186. private static fromHSBToRef;
  87187. /**
  87188. * Returns a value clamped between min and max
  87189. * @param value The value to clamp
  87190. * @param min The minimum of value
  87191. * @param max The maximum of value
  87192. * @returns The clamped value.
  87193. */
  87194. private static clamp;
  87195. /**
  87196. * Clones the current color curve instance.
  87197. * @return The cloned curves
  87198. */
  87199. clone(): ColorCurves;
  87200. /**
  87201. * Serializes the current color curve instance to a json representation.
  87202. * @return a JSON representation
  87203. */
  87204. serialize(): any;
  87205. /**
  87206. * Parses the color curve from a json representation.
  87207. * @param source the JSON source to parse
  87208. * @return The parsed curves
  87209. */
  87210. static Parse(source: any): ColorCurves;
  87211. }
  87212. }
  87213. declare module BABYLON {
  87214. /**
  87215. * Interface to follow in your material defines to integrate easily the
  87216. * Image proccessing functions.
  87217. * @hidden
  87218. */
  87219. export interface IImageProcessingConfigurationDefines {
  87220. IMAGEPROCESSING: boolean;
  87221. VIGNETTE: boolean;
  87222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87223. VIGNETTEBLENDMODEOPAQUE: boolean;
  87224. TONEMAPPING: boolean;
  87225. TONEMAPPING_ACES: boolean;
  87226. CONTRAST: boolean;
  87227. EXPOSURE: boolean;
  87228. COLORCURVES: boolean;
  87229. COLORGRADING: boolean;
  87230. COLORGRADING3D: boolean;
  87231. SAMPLER3DGREENDEPTH: boolean;
  87232. SAMPLER3DBGRMAP: boolean;
  87233. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87234. }
  87235. /**
  87236. * @hidden
  87237. */
  87238. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87239. IMAGEPROCESSING: boolean;
  87240. VIGNETTE: boolean;
  87241. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87242. VIGNETTEBLENDMODEOPAQUE: boolean;
  87243. TONEMAPPING: boolean;
  87244. TONEMAPPING_ACES: boolean;
  87245. CONTRAST: boolean;
  87246. COLORCURVES: boolean;
  87247. COLORGRADING: boolean;
  87248. COLORGRADING3D: boolean;
  87249. SAMPLER3DGREENDEPTH: boolean;
  87250. SAMPLER3DBGRMAP: boolean;
  87251. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87252. EXPOSURE: boolean;
  87253. constructor();
  87254. }
  87255. /**
  87256. * This groups together the common properties used for image processing either in direct forward pass
  87257. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87258. * or not.
  87259. */
  87260. export class ImageProcessingConfiguration {
  87261. /**
  87262. * Default tone mapping applied in BabylonJS.
  87263. */
  87264. static readonly TONEMAPPING_STANDARD: number;
  87265. /**
  87266. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87267. * to other engines rendering to increase portability.
  87268. */
  87269. static readonly TONEMAPPING_ACES: number;
  87270. /**
  87271. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87272. */
  87273. colorCurves: Nullable<ColorCurves>;
  87274. private _colorCurvesEnabled;
  87275. /**
  87276. * Gets wether the color curves effect is enabled.
  87277. */
  87278. get colorCurvesEnabled(): boolean;
  87279. /**
  87280. * Sets wether the color curves effect is enabled.
  87281. */
  87282. set colorCurvesEnabled(value: boolean);
  87283. private _colorGradingTexture;
  87284. /**
  87285. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87286. */
  87287. get colorGradingTexture(): Nullable<BaseTexture>;
  87288. /**
  87289. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87290. */
  87291. set colorGradingTexture(value: Nullable<BaseTexture>);
  87292. private _colorGradingEnabled;
  87293. /**
  87294. * Gets wether the color grading effect is enabled.
  87295. */
  87296. get colorGradingEnabled(): boolean;
  87297. /**
  87298. * Sets wether the color grading effect is enabled.
  87299. */
  87300. set colorGradingEnabled(value: boolean);
  87301. private _colorGradingWithGreenDepth;
  87302. /**
  87303. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87304. */
  87305. get colorGradingWithGreenDepth(): boolean;
  87306. /**
  87307. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87308. */
  87309. set colorGradingWithGreenDepth(value: boolean);
  87310. private _colorGradingBGR;
  87311. /**
  87312. * Gets wether the color grading texture contains BGR values.
  87313. */
  87314. get colorGradingBGR(): boolean;
  87315. /**
  87316. * Sets wether the color grading texture contains BGR values.
  87317. */
  87318. set colorGradingBGR(value: boolean);
  87319. /** @hidden */
  87320. _exposure: number;
  87321. /**
  87322. * Gets the Exposure used in the effect.
  87323. */
  87324. get exposure(): number;
  87325. /**
  87326. * Sets the Exposure used in the effect.
  87327. */
  87328. set exposure(value: number);
  87329. private _toneMappingEnabled;
  87330. /**
  87331. * Gets wether the tone mapping effect is enabled.
  87332. */
  87333. get toneMappingEnabled(): boolean;
  87334. /**
  87335. * Sets wether the tone mapping effect is enabled.
  87336. */
  87337. set toneMappingEnabled(value: boolean);
  87338. private _toneMappingType;
  87339. /**
  87340. * Gets the type of tone mapping effect.
  87341. */
  87342. get toneMappingType(): number;
  87343. /**
  87344. * Sets the type of tone mapping effect used in BabylonJS.
  87345. */
  87346. set toneMappingType(value: number);
  87347. protected _contrast: number;
  87348. /**
  87349. * Gets the contrast used in the effect.
  87350. */
  87351. get contrast(): number;
  87352. /**
  87353. * Sets the contrast used in the effect.
  87354. */
  87355. set contrast(value: number);
  87356. /**
  87357. * Vignette stretch size.
  87358. */
  87359. vignetteStretch: number;
  87360. /**
  87361. * Vignette centre X Offset.
  87362. */
  87363. vignetteCentreX: number;
  87364. /**
  87365. * Vignette centre Y Offset.
  87366. */
  87367. vignetteCentreY: number;
  87368. /**
  87369. * Vignette weight or intensity of the vignette effect.
  87370. */
  87371. vignetteWeight: number;
  87372. /**
  87373. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87374. * if vignetteEnabled is set to true.
  87375. */
  87376. vignetteColor: Color4;
  87377. /**
  87378. * Camera field of view used by the Vignette effect.
  87379. */
  87380. vignetteCameraFov: number;
  87381. private _vignetteBlendMode;
  87382. /**
  87383. * Gets the vignette blend mode allowing different kind of effect.
  87384. */
  87385. get vignetteBlendMode(): number;
  87386. /**
  87387. * Sets the vignette blend mode allowing different kind of effect.
  87388. */
  87389. set vignetteBlendMode(value: number);
  87390. private _vignetteEnabled;
  87391. /**
  87392. * Gets wether the vignette effect is enabled.
  87393. */
  87394. get vignetteEnabled(): boolean;
  87395. /**
  87396. * Sets wether the vignette effect is enabled.
  87397. */
  87398. set vignetteEnabled(value: boolean);
  87399. private _applyByPostProcess;
  87400. /**
  87401. * Gets wether the image processing is applied through a post process or not.
  87402. */
  87403. get applyByPostProcess(): boolean;
  87404. /**
  87405. * Sets wether the image processing is applied through a post process or not.
  87406. */
  87407. set applyByPostProcess(value: boolean);
  87408. private _isEnabled;
  87409. /**
  87410. * Gets wether the image processing is enabled or not.
  87411. */
  87412. get isEnabled(): boolean;
  87413. /**
  87414. * Sets wether the image processing is enabled or not.
  87415. */
  87416. set isEnabled(value: boolean);
  87417. /**
  87418. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87419. */
  87420. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87421. /**
  87422. * Method called each time the image processing information changes requires to recompile the effect.
  87423. */
  87424. protected _updateParameters(): void;
  87425. /**
  87426. * Gets the current class name.
  87427. * @return "ImageProcessingConfiguration"
  87428. */
  87429. getClassName(): string;
  87430. /**
  87431. * Prepare the list of uniforms associated with the Image Processing effects.
  87432. * @param uniforms The list of uniforms used in the effect
  87433. * @param defines the list of defines currently in use
  87434. */
  87435. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87436. /**
  87437. * Prepare the list of samplers associated with the Image Processing effects.
  87438. * @param samplersList The list of uniforms used in the effect
  87439. * @param defines the list of defines currently in use
  87440. */
  87441. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87442. /**
  87443. * Prepare the list of defines associated to the shader.
  87444. * @param defines the list of defines to complete
  87445. * @param forPostProcess Define if we are currently in post process mode or not
  87446. */
  87447. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  87448. /**
  87449. * Returns true if all the image processing information are ready.
  87450. * @returns True if ready, otherwise, false
  87451. */
  87452. isReady(): boolean;
  87453. /**
  87454. * Binds the image processing to the shader.
  87455. * @param effect The effect to bind to
  87456. * @param overrideAspectRatio Override the aspect ratio of the effect
  87457. */
  87458. bind(effect: Effect, overrideAspectRatio?: number): void;
  87459. /**
  87460. * Clones the current image processing instance.
  87461. * @return The cloned image processing
  87462. */
  87463. clone(): ImageProcessingConfiguration;
  87464. /**
  87465. * Serializes the current image processing instance to a json representation.
  87466. * @return a JSON representation
  87467. */
  87468. serialize(): any;
  87469. /**
  87470. * Parses the image processing from a json representation.
  87471. * @param source the JSON source to parse
  87472. * @return The parsed image processing
  87473. */
  87474. static Parse(source: any): ImageProcessingConfiguration;
  87475. private static _VIGNETTEMODE_MULTIPLY;
  87476. private static _VIGNETTEMODE_OPAQUE;
  87477. /**
  87478. * Used to apply the vignette as a mix with the pixel color.
  87479. */
  87480. static get VIGNETTEMODE_MULTIPLY(): number;
  87481. /**
  87482. * Used to apply the vignette as a replacement of the pixel color.
  87483. */
  87484. static get VIGNETTEMODE_OPAQUE(): number;
  87485. }
  87486. }
  87487. declare module BABYLON {
  87488. /** @hidden */
  87489. export var postprocessVertexShader: {
  87490. name: string;
  87491. shader: string;
  87492. };
  87493. }
  87494. declare module BABYLON {
  87495. interface ThinEngine {
  87496. /**
  87497. * Creates a new render target texture
  87498. * @param size defines the size of the texture
  87499. * @param options defines the options used to create the texture
  87500. * @returns a new render target texture stored in an InternalTexture
  87501. */
  87502. createRenderTargetTexture(size: number | {
  87503. width: number;
  87504. height: number;
  87505. layers?: number;
  87506. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87507. /**
  87508. * Creates a depth stencil texture.
  87509. * This is only available in WebGL 2 or with the depth texture extension available.
  87510. * @param size The size of face edge in the texture.
  87511. * @param options The options defining the texture.
  87512. * @returns The texture
  87513. */
  87514. createDepthStencilTexture(size: number | {
  87515. width: number;
  87516. height: number;
  87517. layers?: number;
  87518. }, options: DepthTextureCreationOptions): InternalTexture;
  87519. /** @hidden */
  87520. _createDepthStencilTexture(size: number | {
  87521. width: number;
  87522. height: number;
  87523. layers?: number;
  87524. }, options: DepthTextureCreationOptions): InternalTexture;
  87525. }
  87526. }
  87527. declare module BABYLON {
  87528. /**
  87529. * Defines the kind of connection point for node based material
  87530. */
  87531. export enum NodeMaterialBlockConnectionPointTypes {
  87532. /** Float */
  87533. Float = 1,
  87534. /** Int */
  87535. Int = 2,
  87536. /** Vector2 */
  87537. Vector2 = 4,
  87538. /** Vector3 */
  87539. Vector3 = 8,
  87540. /** Vector4 */
  87541. Vector4 = 16,
  87542. /** Color3 */
  87543. Color3 = 32,
  87544. /** Color4 */
  87545. Color4 = 64,
  87546. /** Matrix */
  87547. Matrix = 128,
  87548. /** Custom object */
  87549. Object = 256,
  87550. /** Detect type based on connection */
  87551. AutoDetect = 1024,
  87552. /** Output type that will be defined by input type */
  87553. BasedOnInput = 2048
  87554. }
  87555. }
  87556. declare module BABYLON {
  87557. /**
  87558. * Enum used to define the target of a block
  87559. */
  87560. export enum NodeMaterialBlockTargets {
  87561. /** Vertex shader */
  87562. Vertex = 1,
  87563. /** Fragment shader */
  87564. Fragment = 2,
  87565. /** Neutral */
  87566. Neutral = 4,
  87567. /** Vertex and Fragment */
  87568. VertexAndFragment = 3
  87569. }
  87570. }
  87571. declare module BABYLON {
  87572. /**
  87573. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  87574. */
  87575. export enum NodeMaterialBlockConnectionPointMode {
  87576. /** Value is an uniform */
  87577. Uniform = 0,
  87578. /** Value is a mesh attribute */
  87579. Attribute = 1,
  87580. /** Value is a varying between vertex and fragment shaders */
  87581. Varying = 2,
  87582. /** Mode is undefined */
  87583. Undefined = 3
  87584. }
  87585. }
  87586. declare module BABYLON {
  87587. /**
  87588. * Enum used to define system values e.g. values automatically provided by the system
  87589. */
  87590. export enum NodeMaterialSystemValues {
  87591. /** World */
  87592. World = 1,
  87593. /** View */
  87594. View = 2,
  87595. /** Projection */
  87596. Projection = 3,
  87597. /** ViewProjection */
  87598. ViewProjection = 4,
  87599. /** WorldView */
  87600. WorldView = 5,
  87601. /** WorldViewProjection */
  87602. WorldViewProjection = 6,
  87603. /** CameraPosition */
  87604. CameraPosition = 7,
  87605. /** Fog Color */
  87606. FogColor = 8,
  87607. /** Delta time */
  87608. DeltaTime = 9
  87609. }
  87610. }
  87611. declare module BABYLON {
  87612. /** Defines supported spaces */
  87613. export enum Space {
  87614. /** Local (object) space */
  87615. LOCAL = 0,
  87616. /** World space */
  87617. WORLD = 1,
  87618. /** Bone space */
  87619. BONE = 2
  87620. }
  87621. /** Defines the 3 main axes */
  87622. export class Axis {
  87623. /** X axis */
  87624. static X: Vector3;
  87625. /** Y axis */
  87626. static Y: Vector3;
  87627. /** Z axis */
  87628. static Z: Vector3;
  87629. }
  87630. }
  87631. declare module BABYLON {
  87632. /**
  87633. * Represents a camera frustum
  87634. */
  87635. export class Frustum {
  87636. /**
  87637. * Gets the planes representing the frustum
  87638. * @param transform matrix to be applied to the returned planes
  87639. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87640. */
  87641. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87642. /**
  87643. * Gets the near frustum plane transformed by the transform matrix
  87644. * @param transform transformation matrix to be applied to the resulting frustum plane
  87645. * @param frustumPlane the resuling frustum plane
  87646. */
  87647. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87648. /**
  87649. * Gets the far frustum plane transformed by the transform matrix
  87650. * @param transform transformation matrix to be applied to the resulting frustum plane
  87651. * @param frustumPlane the resuling frustum plane
  87652. */
  87653. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87654. /**
  87655. * Gets the left frustum plane transformed by the transform matrix
  87656. * @param transform transformation matrix to be applied to the resulting frustum plane
  87657. * @param frustumPlane the resuling frustum plane
  87658. */
  87659. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87660. /**
  87661. * Gets the right frustum plane transformed by the transform matrix
  87662. * @param transform transformation matrix to be applied to the resulting frustum plane
  87663. * @param frustumPlane the resuling frustum plane
  87664. */
  87665. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87666. /**
  87667. * Gets the top frustum plane transformed by the transform matrix
  87668. * @param transform transformation matrix to be applied to the resulting frustum plane
  87669. * @param frustumPlane the resuling frustum plane
  87670. */
  87671. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87672. /**
  87673. * Gets the bottom frustum plane transformed by the transform matrix
  87674. * @param transform transformation matrix to be applied to the resulting frustum plane
  87675. * @param frustumPlane the resuling frustum plane
  87676. */
  87677. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87678. /**
  87679. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87680. * @param transform transformation matrix to be applied to the resulting frustum planes
  87681. * @param frustumPlanes the resuling frustum planes
  87682. */
  87683. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87684. }
  87685. }
  87686. declare module BABYLON {
  87687. /**
  87688. * Interface for the size containing width and height
  87689. */
  87690. export interface ISize {
  87691. /**
  87692. * Width
  87693. */
  87694. width: number;
  87695. /**
  87696. * Heighht
  87697. */
  87698. height: number;
  87699. }
  87700. /**
  87701. * Size containing widht and height
  87702. */
  87703. export class Size implements ISize {
  87704. /**
  87705. * Width
  87706. */
  87707. width: number;
  87708. /**
  87709. * Height
  87710. */
  87711. height: number;
  87712. /**
  87713. * Creates a Size object from the given width and height (floats).
  87714. * @param width width of the new size
  87715. * @param height height of the new size
  87716. */
  87717. constructor(width: number, height: number);
  87718. /**
  87719. * Returns a string with the Size width and height
  87720. * @returns a string with the Size width and height
  87721. */
  87722. toString(): string;
  87723. /**
  87724. * "Size"
  87725. * @returns the string "Size"
  87726. */
  87727. getClassName(): string;
  87728. /**
  87729. * Returns the Size hash code.
  87730. * @returns a hash code for a unique width and height
  87731. */
  87732. getHashCode(): number;
  87733. /**
  87734. * Updates the current size from the given one.
  87735. * @param src the given size
  87736. */
  87737. copyFrom(src: Size): void;
  87738. /**
  87739. * Updates in place the current Size from the given floats.
  87740. * @param width width of the new size
  87741. * @param height height of the new size
  87742. * @returns the updated Size.
  87743. */
  87744. copyFromFloats(width: number, height: number): Size;
  87745. /**
  87746. * Updates in place the current Size from the given floats.
  87747. * @param width width to set
  87748. * @param height height to set
  87749. * @returns the updated Size.
  87750. */
  87751. set(width: number, height: number): Size;
  87752. /**
  87753. * Multiplies the width and height by numbers
  87754. * @param w factor to multiple the width by
  87755. * @param h factor to multiple the height by
  87756. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87757. */
  87758. multiplyByFloats(w: number, h: number): Size;
  87759. /**
  87760. * Clones the size
  87761. * @returns a new Size copied from the given one.
  87762. */
  87763. clone(): Size;
  87764. /**
  87765. * True if the current Size and the given one width and height are strictly equal.
  87766. * @param other the other size to compare against
  87767. * @returns True if the current Size and the given one width and height are strictly equal.
  87768. */
  87769. equals(other: Size): boolean;
  87770. /**
  87771. * The surface of the Size : width * height (float).
  87772. */
  87773. get surface(): number;
  87774. /**
  87775. * Create a new size of zero
  87776. * @returns a new Size set to (0.0, 0.0)
  87777. */
  87778. static Zero(): Size;
  87779. /**
  87780. * Sums the width and height of two sizes
  87781. * @param otherSize size to add to this size
  87782. * @returns a new Size set as the addition result of the current Size and the given one.
  87783. */
  87784. add(otherSize: Size): Size;
  87785. /**
  87786. * Subtracts the width and height of two
  87787. * @param otherSize size to subtract to this size
  87788. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87789. */
  87790. subtract(otherSize: Size): Size;
  87791. /**
  87792. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87793. * @param start starting size to lerp between
  87794. * @param end end size to lerp between
  87795. * @param amount amount to lerp between the start and end values
  87796. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87797. */
  87798. static Lerp(start: Size, end: Size, amount: number): Size;
  87799. }
  87800. }
  87801. declare module BABYLON {
  87802. /**
  87803. * Contains position and normal vectors for a vertex
  87804. */
  87805. export class PositionNormalVertex {
  87806. /** the position of the vertex (defaut: 0,0,0) */
  87807. position: Vector3;
  87808. /** the normal of the vertex (defaut: 0,1,0) */
  87809. normal: Vector3;
  87810. /**
  87811. * Creates a PositionNormalVertex
  87812. * @param position the position of the vertex (defaut: 0,0,0)
  87813. * @param normal the normal of the vertex (defaut: 0,1,0)
  87814. */
  87815. constructor(
  87816. /** the position of the vertex (defaut: 0,0,0) */
  87817. position?: Vector3,
  87818. /** the normal of the vertex (defaut: 0,1,0) */
  87819. normal?: Vector3);
  87820. /**
  87821. * Clones the PositionNormalVertex
  87822. * @returns the cloned PositionNormalVertex
  87823. */
  87824. clone(): PositionNormalVertex;
  87825. }
  87826. /**
  87827. * Contains position, normal and uv vectors for a vertex
  87828. */
  87829. export class PositionNormalTextureVertex {
  87830. /** the position of the vertex (defaut: 0,0,0) */
  87831. position: Vector3;
  87832. /** the normal of the vertex (defaut: 0,1,0) */
  87833. normal: Vector3;
  87834. /** the uv of the vertex (default: 0,0) */
  87835. uv: Vector2;
  87836. /**
  87837. * Creates a PositionNormalTextureVertex
  87838. * @param position the position of the vertex (defaut: 0,0,0)
  87839. * @param normal the normal of the vertex (defaut: 0,1,0)
  87840. * @param uv the uv of the vertex (default: 0,0)
  87841. */
  87842. constructor(
  87843. /** the position of the vertex (defaut: 0,0,0) */
  87844. position?: Vector3,
  87845. /** the normal of the vertex (defaut: 0,1,0) */
  87846. normal?: Vector3,
  87847. /** the uv of the vertex (default: 0,0) */
  87848. uv?: Vector2);
  87849. /**
  87850. * Clones the PositionNormalTextureVertex
  87851. * @returns the cloned PositionNormalTextureVertex
  87852. */
  87853. clone(): PositionNormalTextureVertex;
  87854. }
  87855. }
  87856. declare module BABYLON {
  87857. /**
  87858. * Enum defining the type of animations supported by InputBlock
  87859. */
  87860. export enum AnimatedInputBlockTypes {
  87861. /** No animation */
  87862. None = 0,
  87863. /** Time based animation. Will only work for floats */
  87864. Time = 1
  87865. }
  87866. }
  87867. declare module BABYLON {
  87868. /**
  87869. * Interface describing all the common properties and methods a shadow light needs to implement.
  87870. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87871. * as well as binding the different shadow properties to the effects.
  87872. */
  87873. export interface IShadowLight extends Light {
  87874. /**
  87875. * The light id in the scene (used in scene.findLighById for instance)
  87876. */
  87877. id: string;
  87878. /**
  87879. * The position the shdow will be casted from.
  87880. */
  87881. position: Vector3;
  87882. /**
  87883. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87884. */
  87885. direction: Vector3;
  87886. /**
  87887. * The transformed position. Position of the light in world space taking parenting in account.
  87888. */
  87889. transformedPosition: Vector3;
  87890. /**
  87891. * The transformed direction. Direction of the light in world space taking parenting in account.
  87892. */
  87893. transformedDirection: Vector3;
  87894. /**
  87895. * The friendly name of the light in the scene.
  87896. */
  87897. name: string;
  87898. /**
  87899. * Defines the shadow projection clipping minimum z value.
  87900. */
  87901. shadowMinZ: number;
  87902. /**
  87903. * Defines the shadow projection clipping maximum z value.
  87904. */
  87905. shadowMaxZ: number;
  87906. /**
  87907. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87908. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87909. */
  87910. computeTransformedInformation(): boolean;
  87911. /**
  87912. * Gets the scene the light belongs to.
  87913. * @returns The scene
  87914. */
  87915. getScene(): Scene;
  87916. /**
  87917. * Callback defining a custom Projection Matrix Builder.
  87918. * This can be used to override the default projection matrix computation.
  87919. */
  87920. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87921. /**
  87922. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87923. * @param matrix The materix to updated with the projection information
  87924. * @param viewMatrix The transform matrix of the light
  87925. * @param renderList The list of mesh to render in the map
  87926. * @returns The current light
  87927. */
  87928. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87929. /**
  87930. * Gets the current depth scale used in ESM.
  87931. * @returns The scale
  87932. */
  87933. getDepthScale(): number;
  87934. /**
  87935. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87936. * @returns true if a cube texture needs to be use
  87937. */
  87938. needCube(): boolean;
  87939. /**
  87940. * Detects if the projection matrix requires to be recomputed this frame.
  87941. * @returns true if it requires to be recomputed otherwise, false.
  87942. */
  87943. needProjectionMatrixCompute(): boolean;
  87944. /**
  87945. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87946. */
  87947. forceProjectionMatrixCompute(): void;
  87948. /**
  87949. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87950. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87951. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87952. */
  87953. getShadowDirection(faceIndex?: number): Vector3;
  87954. /**
  87955. * Gets the minZ used for shadow according to both the scene and the light.
  87956. * @param activeCamera The camera we are returning the min for
  87957. * @returns the depth min z
  87958. */
  87959. getDepthMinZ(activeCamera: Camera): number;
  87960. /**
  87961. * Gets the maxZ used for shadow according to both the scene and the light.
  87962. * @param activeCamera The camera we are returning the max for
  87963. * @returns the depth max z
  87964. */
  87965. getDepthMaxZ(activeCamera: Camera): number;
  87966. }
  87967. /**
  87968. * Base implementation IShadowLight
  87969. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87970. */
  87971. export abstract class ShadowLight extends Light implements IShadowLight {
  87972. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87973. protected _position: Vector3;
  87974. protected _setPosition(value: Vector3): void;
  87975. /**
  87976. * Sets the position the shadow will be casted from. Also use as the light position for both
  87977. * point and spot lights.
  87978. */
  87979. get position(): Vector3;
  87980. /**
  87981. * Sets the position the shadow will be casted from. Also use as the light position for both
  87982. * point and spot lights.
  87983. */
  87984. set position(value: Vector3);
  87985. protected _direction: Vector3;
  87986. protected _setDirection(value: Vector3): void;
  87987. /**
  87988. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87989. * Also use as the light direction on spot and directional lights.
  87990. */
  87991. get direction(): Vector3;
  87992. /**
  87993. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87994. * Also use as the light direction on spot and directional lights.
  87995. */
  87996. set direction(value: Vector3);
  87997. protected _shadowMinZ: number;
  87998. /**
  87999. * Gets the shadow projection clipping minimum z value.
  88000. */
  88001. get shadowMinZ(): number;
  88002. /**
  88003. * Sets the shadow projection clipping minimum z value.
  88004. */
  88005. set shadowMinZ(value: number);
  88006. protected _shadowMaxZ: number;
  88007. /**
  88008. * Sets the shadow projection clipping maximum z value.
  88009. */
  88010. get shadowMaxZ(): number;
  88011. /**
  88012. * Gets the shadow projection clipping maximum z value.
  88013. */
  88014. set shadowMaxZ(value: number);
  88015. /**
  88016. * Callback defining a custom Projection Matrix Builder.
  88017. * This can be used to override the default projection matrix computation.
  88018. */
  88019. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88020. /**
  88021. * The transformed position. Position of the light in world space taking parenting in account.
  88022. */
  88023. transformedPosition: Vector3;
  88024. /**
  88025. * The transformed direction. Direction of the light in world space taking parenting in account.
  88026. */
  88027. transformedDirection: Vector3;
  88028. private _needProjectionMatrixCompute;
  88029. /**
  88030. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88031. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88032. */
  88033. computeTransformedInformation(): boolean;
  88034. /**
  88035. * Return the depth scale used for the shadow map.
  88036. * @returns the depth scale.
  88037. */
  88038. getDepthScale(): number;
  88039. /**
  88040. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88041. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88042. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88043. */
  88044. getShadowDirection(faceIndex?: number): Vector3;
  88045. /**
  88046. * Returns the ShadowLight absolute position in the World.
  88047. * @returns the position vector in world space
  88048. */
  88049. getAbsolutePosition(): Vector3;
  88050. /**
  88051. * Sets the ShadowLight direction toward the passed target.
  88052. * @param target The point to target in local space
  88053. * @returns the updated ShadowLight direction
  88054. */
  88055. setDirectionToTarget(target: Vector3): Vector3;
  88056. /**
  88057. * Returns the light rotation in euler definition.
  88058. * @returns the x y z rotation in local space.
  88059. */
  88060. getRotation(): Vector3;
  88061. /**
  88062. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88063. * @returns true if a cube texture needs to be use
  88064. */
  88065. needCube(): boolean;
  88066. /**
  88067. * Detects if the projection matrix requires to be recomputed this frame.
  88068. * @returns true if it requires to be recomputed otherwise, false.
  88069. */
  88070. needProjectionMatrixCompute(): boolean;
  88071. /**
  88072. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88073. */
  88074. forceProjectionMatrixCompute(): void;
  88075. /** @hidden */
  88076. _initCache(): void;
  88077. /** @hidden */
  88078. _isSynchronized(): boolean;
  88079. /**
  88080. * Computes the world matrix of the node
  88081. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88082. * @returns the world matrix
  88083. */
  88084. computeWorldMatrix(force?: boolean): Matrix;
  88085. /**
  88086. * Gets the minZ used for shadow according to both the scene and the light.
  88087. * @param activeCamera The camera we are returning the min for
  88088. * @returns the depth min z
  88089. */
  88090. getDepthMinZ(activeCamera: Camera): number;
  88091. /**
  88092. * Gets the maxZ used for shadow according to both the scene and the light.
  88093. * @param activeCamera The camera we are returning the max for
  88094. * @returns the depth max z
  88095. */
  88096. getDepthMaxZ(activeCamera: Camera): number;
  88097. /**
  88098. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88099. * @param matrix The materix to updated with the projection information
  88100. * @param viewMatrix The transform matrix of the light
  88101. * @param renderList The list of mesh to render in the map
  88102. * @returns The current light
  88103. */
  88104. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88105. }
  88106. }
  88107. declare module BABYLON {
  88108. /** @hidden */
  88109. export var packingFunctions: {
  88110. name: string;
  88111. shader: string;
  88112. };
  88113. }
  88114. declare module BABYLON {
  88115. /** @hidden */
  88116. export var bayerDitherFunctions: {
  88117. name: string;
  88118. shader: string;
  88119. };
  88120. }
  88121. declare module BABYLON {
  88122. /** @hidden */
  88123. export var shadowMapFragmentDeclaration: {
  88124. name: string;
  88125. shader: string;
  88126. };
  88127. }
  88128. declare module BABYLON {
  88129. /** @hidden */
  88130. export var clipPlaneFragmentDeclaration: {
  88131. name: string;
  88132. shader: string;
  88133. };
  88134. }
  88135. declare module BABYLON {
  88136. /** @hidden */
  88137. export var clipPlaneFragment: {
  88138. name: string;
  88139. shader: string;
  88140. };
  88141. }
  88142. declare module BABYLON {
  88143. /** @hidden */
  88144. export var shadowMapFragment: {
  88145. name: string;
  88146. shader: string;
  88147. };
  88148. }
  88149. declare module BABYLON {
  88150. /** @hidden */
  88151. export var shadowMapPixelShader: {
  88152. name: string;
  88153. shader: string;
  88154. };
  88155. }
  88156. declare module BABYLON {
  88157. /** @hidden */
  88158. export var bonesDeclaration: {
  88159. name: string;
  88160. shader: string;
  88161. };
  88162. }
  88163. declare module BABYLON {
  88164. /** @hidden */
  88165. export var morphTargetsVertexGlobalDeclaration: {
  88166. name: string;
  88167. shader: string;
  88168. };
  88169. }
  88170. declare module BABYLON {
  88171. /** @hidden */
  88172. export var morphTargetsVertexDeclaration: {
  88173. name: string;
  88174. shader: string;
  88175. };
  88176. }
  88177. declare module BABYLON {
  88178. /** @hidden */
  88179. export var instancesDeclaration: {
  88180. name: string;
  88181. shader: string;
  88182. };
  88183. }
  88184. declare module BABYLON {
  88185. /** @hidden */
  88186. export var helperFunctions: {
  88187. name: string;
  88188. shader: string;
  88189. };
  88190. }
  88191. declare module BABYLON {
  88192. /** @hidden */
  88193. export var shadowMapVertexDeclaration: {
  88194. name: string;
  88195. shader: string;
  88196. };
  88197. }
  88198. declare module BABYLON {
  88199. /** @hidden */
  88200. export var clipPlaneVertexDeclaration: {
  88201. name: string;
  88202. shader: string;
  88203. };
  88204. }
  88205. declare module BABYLON {
  88206. /** @hidden */
  88207. export var morphTargetsVertex: {
  88208. name: string;
  88209. shader: string;
  88210. };
  88211. }
  88212. declare module BABYLON {
  88213. /** @hidden */
  88214. export var instancesVertex: {
  88215. name: string;
  88216. shader: string;
  88217. };
  88218. }
  88219. declare module BABYLON {
  88220. /** @hidden */
  88221. export var bonesVertex: {
  88222. name: string;
  88223. shader: string;
  88224. };
  88225. }
  88226. declare module BABYLON {
  88227. /** @hidden */
  88228. export var shadowMapVertexNormalBias: {
  88229. name: string;
  88230. shader: string;
  88231. };
  88232. }
  88233. declare module BABYLON {
  88234. /** @hidden */
  88235. export var shadowMapVertexMetric: {
  88236. name: string;
  88237. shader: string;
  88238. };
  88239. }
  88240. declare module BABYLON {
  88241. /** @hidden */
  88242. export var clipPlaneVertex: {
  88243. name: string;
  88244. shader: string;
  88245. };
  88246. }
  88247. declare module BABYLON {
  88248. /** @hidden */
  88249. export var shadowMapVertexShader: {
  88250. name: string;
  88251. shader: string;
  88252. };
  88253. }
  88254. declare module BABYLON {
  88255. /** @hidden */
  88256. export var depthBoxBlurPixelShader: {
  88257. name: string;
  88258. shader: string;
  88259. };
  88260. }
  88261. declare module BABYLON {
  88262. /** @hidden */
  88263. export var shadowMapFragmentSoftTransparentShadow: {
  88264. name: string;
  88265. shader: string;
  88266. };
  88267. }
  88268. declare module BABYLON {
  88269. /**
  88270. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88271. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88272. */
  88273. export class EffectFallbacks implements IEffectFallbacks {
  88274. private _defines;
  88275. private _currentRank;
  88276. private _maxRank;
  88277. private _mesh;
  88278. /**
  88279. * Removes the fallback from the bound mesh.
  88280. */
  88281. unBindMesh(): void;
  88282. /**
  88283. * Adds a fallback on the specified property.
  88284. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88285. * @param define The name of the define in the shader
  88286. */
  88287. addFallback(rank: number, define: string): void;
  88288. /**
  88289. * Sets the mesh to use CPU skinning when needing to fallback.
  88290. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88291. * @param mesh The mesh to use the fallbacks.
  88292. */
  88293. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88294. /**
  88295. * Checks to see if more fallbacks are still availible.
  88296. */
  88297. get hasMoreFallbacks(): boolean;
  88298. /**
  88299. * Removes the defines that should be removed when falling back.
  88300. * @param currentDefines defines the current define statements for the shader.
  88301. * @param effect defines the current effect we try to compile
  88302. * @returns The resulting defines with defines of the current rank removed.
  88303. */
  88304. reduce(currentDefines: string, effect: Effect): string;
  88305. }
  88306. }
  88307. declare module BABYLON {
  88308. /**
  88309. * Interface used to define Action
  88310. */
  88311. export interface IAction {
  88312. /**
  88313. * Trigger for the action
  88314. */
  88315. trigger: number;
  88316. /** Options of the trigger */
  88317. triggerOptions: any;
  88318. /**
  88319. * Gets the trigger parameters
  88320. * @returns the trigger parameters
  88321. */
  88322. getTriggerParameter(): any;
  88323. /**
  88324. * Internal only - executes current action event
  88325. * @hidden
  88326. */
  88327. _executeCurrent(evt?: ActionEvent): void;
  88328. /**
  88329. * Serialize placeholder for child classes
  88330. * @param parent of child
  88331. * @returns the serialized object
  88332. */
  88333. serialize(parent: any): any;
  88334. /**
  88335. * Internal only
  88336. * @hidden
  88337. */
  88338. _prepare(): void;
  88339. /**
  88340. * Internal only - manager for action
  88341. * @hidden
  88342. */
  88343. _actionManager: AbstractActionManager;
  88344. /**
  88345. * Adds action to chain of actions, may be a DoNothingAction
  88346. * @param action defines the next action to execute
  88347. * @returns The action passed in
  88348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88349. */
  88350. then(action: IAction): IAction;
  88351. }
  88352. /**
  88353. * The action to be carried out following a trigger
  88354. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  88355. */
  88356. export class Action implements IAction {
  88357. /** the trigger, with or without parameters, for the action */
  88358. triggerOptions: any;
  88359. /**
  88360. * Trigger for the action
  88361. */
  88362. trigger: number;
  88363. /**
  88364. * Internal only - manager for action
  88365. * @hidden
  88366. */
  88367. _actionManager: ActionManager;
  88368. private _nextActiveAction;
  88369. private _child;
  88370. private _condition?;
  88371. private _triggerParameter;
  88372. /**
  88373. * An event triggered prior to action being executed.
  88374. */
  88375. onBeforeExecuteObservable: Observable<Action>;
  88376. /**
  88377. * Creates a new Action
  88378. * @param triggerOptions the trigger, with or without parameters, for the action
  88379. * @param condition an optional determinant of action
  88380. */
  88381. constructor(
  88382. /** the trigger, with or without parameters, for the action */
  88383. triggerOptions: any, condition?: Condition);
  88384. /**
  88385. * Internal only
  88386. * @hidden
  88387. */
  88388. _prepare(): void;
  88389. /**
  88390. * Gets the trigger parameters
  88391. * @returns the trigger parameters
  88392. */
  88393. getTriggerParameter(): any;
  88394. /**
  88395. * Internal only - executes current action event
  88396. * @hidden
  88397. */
  88398. _executeCurrent(evt?: ActionEvent): void;
  88399. /**
  88400. * Execute placeholder for child classes
  88401. * @param evt optional action event
  88402. */
  88403. execute(evt?: ActionEvent): void;
  88404. /**
  88405. * Skips to next active action
  88406. */
  88407. skipToNextActiveAction(): void;
  88408. /**
  88409. * Adds action to chain of actions, may be a DoNothingAction
  88410. * @param action defines the next action to execute
  88411. * @returns The action passed in
  88412. * @see https://www.babylonjs-playground.com/#1T30HR#0
  88413. */
  88414. then(action: Action): Action;
  88415. /**
  88416. * Internal only
  88417. * @hidden
  88418. */
  88419. _getProperty(propertyPath: string): string;
  88420. /**
  88421. * Internal only
  88422. * @hidden
  88423. */
  88424. _getEffectiveTarget(target: any, propertyPath: string): any;
  88425. /**
  88426. * Serialize placeholder for child classes
  88427. * @param parent of child
  88428. * @returns the serialized object
  88429. */
  88430. serialize(parent: any): any;
  88431. /**
  88432. * Internal only called by serialize
  88433. * @hidden
  88434. */
  88435. protected _serialize(serializedAction: any, parent?: any): any;
  88436. /**
  88437. * Internal only
  88438. * @hidden
  88439. */
  88440. static _SerializeValueAsString: (value: any) => string;
  88441. /**
  88442. * Internal only
  88443. * @hidden
  88444. */
  88445. static _GetTargetProperty: (target: Scene | Node) => {
  88446. name: string;
  88447. targetType: string;
  88448. value: string;
  88449. };
  88450. }
  88451. }
  88452. declare module BABYLON {
  88453. /**
  88454. * A Condition applied to an Action
  88455. */
  88456. export class Condition {
  88457. /**
  88458. * Internal only - manager for action
  88459. * @hidden
  88460. */
  88461. _actionManager: ActionManager;
  88462. /**
  88463. * Internal only
  88464. * @hidden
  88465. */
  88466. _evaluationId: number;
  88467. /**
  88468. * Internal only
  88469. * @hidden
  88470. */
  88471. _currentResult: boolean;
  88472. /**
  88473. * Creates a new Condition
  88474. * @param actionManager the manager of the action the condition is applied to
  88475. */
  88476. constructor(actionManager: ActionManager);
  88477. /**
  88478. * Check if the current condition is valid
  88479. * @returns a boolean
  88480. */
  88481. isValid(): boolean;
  88482. /**
  88483. * Internal only
  88484. * @hidden
  88485. */
  88486. _getProperty(propertyPath: string): string;
  88487. /**
  88488. * Internal only
  88489. * @hidden
  88490. */
  88491. _getEffectiveTarget(target: any, propertyPath: string): any;
  88492. /**
  88493. * Serialize placeholder for child classes
  88494. * @returns the serialized object
  88495. */
  88496. serialize(): any;
  88497. /**
  88498. * Internal only
  88499. * @hidden
  88500. */
  88501. protected _serialize(serializedCondition: any): any;
  88502. }
  88503. /**
  88504. * Defines specific conditional operators as extensions of Condition
  88505. */
  88506. export class ValueCondition extends Condition {
  88507. /** path to specify the property of the target the conditional operator uses */
  88508. propertyPath: string;
  88509. /** the value compared by the conditional operator against the current value of the property */
  88510. value: any;
  88511. /** the conditional operator, default ValueCondition.IsEqual */
  88512. operator: number;
  88513. /**
  88514. * Internal only
  88515. * @hidden
  88516. */
  88517. private static _IsEqual;
  88518. /**
  88519. * Internal only
  88520. * @hidden
  88521. */
  88522. private static _IsDifferent;
  88523. /**
  88524. * Internal only
  88525. * @hidden
  88526. */
  88527. private static _IsGreater;
  88528. /**
  88529. * Internal only
  88530. * @hidden
  88531. */
  88532. private static _IsLesser;
  88533. /**
  88534. * returns the number for IsEqual
  88535. */
  88536. static get IsEqual(): number;
  88537. /**
  88538. * Returns the number for IsDifferent
  88539. */
  88540. static get IsDifferent(): number;
  88541. /**
  88542. * Returns the number for IsGreater
  88543. */
  88544. static get IsGreater(): number;
  88545. /**
  88546. * Returns the number for IsLesser
  88547. */
  88548. static get IsLesser(): number;
  88549. /**
  88550. * Internal only The action manager for the condition
  88551. * @hidden
  88552. */
  88553. _actionManager: ActionManager;
  88554. /**
  88555. * Internal only
  88556. * @hidden
  88557. */
  88558. private _target;
  88559. /**
  88560. * Internal only
  88561. * @hidden
  88562. */
  88563. private _effectiveTarget;
  88564. /**
  88565. * Internal only
  88566. * @hidden
  88567. */
  88568. private _property;
  88569. /**
  88570. * Creates a new ValueCondition
  88571. * @param actionManager manager for the action the condition applies to
  88572. * @param target for the action
  88573. * @param propertyPath path to specify the property of the target the conditional operator uses
  88574. * @param value the value compared by the conditional operator against the current value of the property
  88575. * @param operator the conditional operator, default ValueCondition.IsEqual
  88576. */
  88577. constructor(actionManager: ActionManager, target: any,
  88578. /** path to specify the property of the target the conditional operator uses */
  88579. propertyPath: string,
  88580. /** the value compared by the conditional operator against the current value of the property */
  88581. value: any,
  88582. /** the conditional operator, default ValueCondition.IsEqual */
  88583. operator?: number);
  88584. /**
  88585. * Compares the given value with the property value for the specified conditional operator
  88586. * @returns the result of the comparison
  88587. */
  88588. isValid(): boolean;
  88589. /**
  88590. * Serialize the ValueCondition into a JSON compatible object
  88591. * @returns serialization object
  88592. */
  88593. serialize(): any;
  88594. /**
  88595. * Gets the name of the conditional operator for the ValueCondition
  88596. * @param operator the conditional operator
  88597. * @returns the name
  88598. */
  88599. static GetOperatorName(operator: number): string;
  88600. }
  88601. /**
  88602. * Defines a predicate condition as an extension of Condition
  88603. */
  88604. export class PredicateCondition extends Condition {
  88605. /** defines the predicate function used to validate the condition */
  88606. predicate: () => boolean;
  88607. /**
  88608. * Internal only - manager for action
  88609. * @hidden
  88610. */
  88611. _actionManager: ActionManager;
  88612. /**
  88613. * Creates a new PredicateCondition
  88614. * @param actionManager manager for the action the condition applies to
  88615. * @param predicate defines the predicate function used to validate the condition
  88616. */
  88617. constructor(actionManager: ActionManager,
  88618. /** defines the predicate function used to validate the condition */
  88619. predicate: () => boolean);
  88620. /**
  88621. * @returns the validity of the predicate condition
  88622. */
  88623. isValid(): boolean;
  88624. }
  88625. /**
  88626. * Defines a state condition as an extension of Condition
  88627. */
  88628. export class StateCondition extends Condition {
  88629. /** Value to compare with target state */
  88630. value: string;
  88631. /**
  88632. * Internal only - manager for action
  88633. * @hidden
  88634. */
  88635. _actionManager: ActionManager;
  88636. /**
  88637. * Internal only
  88638. * @hidden
  88639. */
  88640. private _target;
  88641. /**
  88642. * Creates a new StateCondition
  88643. * @param actionManager manager for the action the condition applies to
  88644. * @param target of the condition
  88645. * @param value to compare with target state
  88646. */
  88647. constructor(actionManager: ActionManager, target: any,
  88648. /** Value to compare with target state */
  88649. value: string);
  88650. /**
  88651. * Gets a boolean indicating if the current condition is met
  88652. * @returns the validity of the state
  88653. */
  88654. isValid(): boolean;
  88655. /**
  88656. * Serialize the StateCondition into a JSON compatible object
  88657. * @returns serialization object
  88658. */
  88659. serialize(): any;
  88660. }
  88661. }
  88662. declare module BABYLON {
  88663. /**
  88664. * This defines an action responsible to toggle a boolean once triggered.
  88665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88666. */
  88667. export class SwitchBooleanAction extends Action {
  88668. /**
  88669. * The path to the boolean property in the target object
  88670. */
  88671. propertyPath: string;
  88672. private _target;
  88673. private _effectiveTarget;
  88674. private _property;
  88675. /**
  88676. * Instantiate the action
  88677. * @param triggerOptions defines the trigger options
  88678. * @param target defines the object containing the boolean
  88679. * @param propertyPath defines the path to the boolean property in the target object
  88680. * @param condition defines the trigger related conditions
  88681. */
  88682. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88683. /** @hidden */
  88684. _prepare(): void;
  88685. /**
  88686. * Execute the action toggle the boolean value.
  88687. */
  88688. execute(): void;
  88689. /**
  88690. * Serializes the actions and its related information.
  88691. * @param parent defines the object to serialize in
  88692. * @returns the serialized object
  88693. */
  88694. serialize(parent: any): any;
  88695. }
  88696. /**
  88697. * This defines an action responsible to set a the state field of the target
  88698. * to a desired value once triggered.
  88699. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88700. */
  88701. export class SetStateAction extends Action {
  88702. /**
  88703. * The value to store in the state field.
  88704. */
  88705. value: string;
  88706. private _target;
  88707. /**
  88708. * Instantiate the action
  88709. * @param triggerOptions defines the trigger options
  88710. * @param target defines the object containing the state property
  88711. * @param value defines the value to store in the state field
  88712. * @param condition defines the trigger related conditions
  88713. */
  88714. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88715. /**
  88716. * Execute the action and store the value on the target state property.
  88717. */
  88718. execute(): void;
  88719. /**
  88720. * Serializes the actions and its related information.
  88721. * @param parent defines the object to serialize in
  88722. * @returns the serialized object
  88723. */
  88724. serialize(parent: any): any;
  88725. }
  88726. /**
  88727. * This defines an action responsible to set a property of the target
  88728. * to a desired value once triggered.
  88729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88730. */
  88731. export class SetValueAction extends Action {
  88732. /**
  88733. * The path of the property to set in the target.
  88734. */
  88735. propertyPath: string;
  88736. /**
  88737. * The value to set in the property
  88738. */
  88739. value: any;
  88740. private _target;
  88741. private _effectiveTarget;
  88742. private _property;
  88743. /**
  88744. * Instantiate the action
  88745. * @param triggerOptions defines the trigger options
  88746. * @param target defines the object containing the property
  88747. * @param propertyPath defines the path of the property to set in the target
  88748. * @param value defines the value to set in the property
  88749. * @param condition defines the trigger related conditions
  88750. */
  88751. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88752. /** @hidden */
  88753. _prepare(): void;
  88754. /**
  88755. * Execute the action and set the targetted property to the desired value.
  88756. */
  88757. execute(): void;
  88758. /**
  88759. * Serializes the actions and its related information.
  88760. * @param parent defines the object to serialize in
  88761. * @returns the serialized object
  88762. */
  88763. serialize(parent: any): any;
  88764. }
  88765. /**
  88766. * This defines an action responsible to increment the target value
  88767. * to a desired value once triggered.
  88768. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88769. */
  88770. export class IncrementValueAction extends Action {
  88771. /**
  88772. * The path of the property to increment in the target.
  88773. */
  88774. propertyPath: string;
  88775. /**
  88776. * The value we should increment the property by.
  88777. */
  88778. value: any;
  88779. private _target;
  88780. private _effectiveTarget;
  88781. private _property;
  88782. /**
  88783. * Instantiate the action
  88784. * @param triggerOptions defines the trigger options
  88785. * @param target defines the object containing the property
  88786. * @param propertyPath defines the path of the property to increment in the target
  88787. * @param value defines the value value we should increment the property by
  88788. * @param condition defines the trigger related conditions
  88789. */
  88790. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88791. /** @hidden */
  88792. _prepare(): void;
  88793. /**
  88794. * Execute the action and increment the target of the value amount.
  88795. */
  88796. execute(): void;
  88797. /**
  88798. * Serializes the actions and its related information.
  88799. * @param parent defines the object to serialize in
  88800. * @returns the serialized object
  88801. */
  88802. serialize(parent: any): any;
  88803. }
  88804. /**
  88805. * This defines an action responsible to start an animation once triggered.
  88806. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88807. */
  88808. export class PlayAnimationAction extends Action {
  88809. /**
  88810. * Where the animation should start (animation frame)
  88811. */
  88812. from: number;
  88813. /**
  88814. * Where the animation should stop (animation frame)
  88815. */
  88816. to: number;
  88817. /**
  88818. * Define if the animation should loop or stop after the first play.
  88819. */
  88820. loop?: boolean;
  88821. private _target;
  88822. /**
  88823. * Instantiate the action
  88824. * @param triggerOptions defines the trigger options
  88825. * @param target defines the target animation or animation name
  88826. * @param from defines from where the animation should start (animation frame)
  88827. * @param end defines where the animation should stop (animation frame)
  88828. * @param loop defines if the animation should loop or stop after the first play
  88829. * @param condition defines the trigger related conditions
  88830. */
  88831. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88832. /** @hidden */
  88833. _prepare(): void;
  88834. /**
  88835. * Execute the action and play the animation.
  88836. */
  88837. execute(): void;
  88838. /**
  88839. * Serializes the actions and its related information.
  88840. * @param parent defines the object to serialize in
  88841. * @returns the serialized object
  88842. */
  88843. serialize(parent: any): any;
  88844. }
  88845. /**
  88846. * This defines an action responsible to stop an animation once triggered.
  88847. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88848. */
  88849. export class StopAnimationAction extends Action {
  88850. private _target;
  88851. /**
  88852. * Instantiate the action
  88853. * @param triggerOptions defines the trigger options
  88854. * @param target defines the target animation or animation name
  88855. * @param condition defines the trigger related conditions
  88856. */
  88857. constructor(triggerOptions: any, target: any, condition?: Condition);
  88858. /** @hidden */
  88859. _prepare(): void;
  88860. /**
  88861. * Execute the action and stop the animation.
  88862. */
  88863. execute(): void;
  88864. /**
  88865. * Serializes the actions and its related information.
  88866. * @param parent defines the object to serialize in
  88867. * @returns the serialized object
  88868. */
  88869. serialize(parent: any): any;
  88870. }
  88871. /**
  88872. * This defines an action responsible that does nothing once triggered.
  88873. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88874. */
  88875. export class DoNothingAction extends Action {
  88876. /**
  88877. * Instantiate the action
  88878. * @param triggerOptions defines the trigger options
  88879. * @param condition defines the trigger related conditions
  88880. */
  88881. constructor(triggerOptions?: any, condition?: Condition);
  88882. /**
  88883. * Execute the action and do nothing.
  88884. */
  88885. execute(): void;
  88886. /**
  88887. * Serializes the actions and its related information.
  88888. * @param parent defines the object to serialize in
  88889. * @returns the serialized object
  88890. */
  88891. serialize(parent: any): any;
  88892. }
  88893. /**
  88894. * This defines an action responsible to trigger several actions once triggered.
  88895. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88896. */
  88897. export class CombineAction extends Action {
  88898. /**
  88899. * The list of aggregated animations to run.
  88900. */
  88901. children: Action[];
  88902. /**
  88903. * Instantiate the action
  88904. * @param triggerOptions defines the trigger options
  88905. * @param children defines the list of aggregated animations to run
  88906. * @param condition defines the trigger related conditions
  88907. */
  88908. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88909. /** @hidden */
  88910. _prepare(): void;
  88911. /**
  88912. * Execute the action and executes all the aggregated actions.
  88913. */
  88914. execute(evt: ActionEvent): void;
  88915. /**
  88916. * Serializes the actions and its related information.
  88917. * @param parent defines the object to serialize in
  88918. * @returns the serialized object
  88919. */
  88920. serialize(parent: any): any;
  88921. }
  88922. /**
  88923. * This defines an action responsible to run code (external event) once triggered.
  88924. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88925. */
  88926. export class ExecuteCodeAction extends Action {
  88927. /**
  88928. * The callback function to run.
  88929. */
  88930. func: (evt: ActionEvent) => void;
  88931. /**
  88932. * Instantiate the action
  88933. * @param triggerOptions defines the trigger options
  88934. * @param func defines the callback function to run
  88935. * @param condition defines the trigger related conditions
  88936. */
  88937. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88938. /**
  88939. * Execute the action and run the attached code.
  88940. */
  88941. execute(evt: ActionEvent): void;
  88942. }
  88943. /**
  88944. * This defines an action responsible to set the parent property of the target once triggered.
  88945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88946. */
  88947. export class SetParentAction extends Action {
  88948. private _parent;
  88949. private _target;
  88950. /**
  88951. * Instantiate the action
  88952. * @param triggerOptions defines the trigger options
  88953. * @param target defines the target containing the parent property
  88954. * @param parent defines from where the animation should start (animation frame)
  88955. * @param condition defines the trigger related conditions
  88956. */
  88957. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88958. /** @hidden */
  88959. _prepare(): void;
  88960. /**
  88961. * Execute the action and set the parent property.
  88962. */
  88963. execute(): void;
  88964. /**
  88965. * Serializes the actions and its related information.
  88966. * @param parent defines the object to serialize in
  88967. * @returns the serialized object
  88968. */
  88969. serialize(parent: any): any;
  88970. }
  88971. }
  88972. declare module BABYLON {
  88973. /**
  88974. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88975. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88977. */
  88978. export class ActionManager extends AbstractActionManager {
  88979. /**
  88980. * Nothing
  88981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88982. */
  88983. static readonly NothingTrigger: number;
  88984. /**
  88985. * On pick
  88986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88987. */
  88988. static readonly OnPickTrigger: number;
  88989. /**
  88990. * On left pick
  88991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88992. */
  88993. static readonly OnLeftPickTrigger: number;
  88994. /**
  88995. * On right pick
  88996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88997. */
  88998. static readonly OnRightPickTrigger: number;
  88999. /**
  89000. * On center pick
  89001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89002. */
  89003. static readonly OnCenterPickTrigger: number;
  89004. /**
  89005. * On pick down
  89006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89007. */
  89008. static readonly OnPickDownTrigger: number;
  89009. /**
  89010. * On double pick
  89011. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89012. */
  89013. static readonly OnDoublePickTrigger: number;
  89014. /**
  89015. * On pick up
  89016. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89017. */
  89018. static readonly OnPickUpTrigger: number;
  89019. /**
  89020. * On pick out.
  89021. * This trigger will only be raised if you also declared a OnPickDown
  89022. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89023. */
  89024. static readonly OnPickOutTrigger: number;
  89025. /**
  89026. * On long press
  89027. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89028. */
  89029. static readonly OnLongPressTrigger: number;
  89030. /**
  89031. * On pointer over
  89032. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89033. */
  89034. static readonly OnPointerOverTrigger: number;
  89035. /**
  89036. * On pointer out
  89037. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89038. */
  89039. static readonly OnPointerOutTrigger: number;
  89040. /**
  89041. * On every frame
  89042. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89043. */
  89044. static readonly OnEveryFrameTrigger: number;
  89045. /**
  89046. * On intersection enter
  89047. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89048. */
  89049. static readonly OnIntersectionEnterTrigger: number;
  89050. /**
  89051. * On intersection exit
  89052. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89053. */
  89054. static readonly OnIntersectionExitTrigger: number;
  89055. /**
  89056. * On key down
  89057. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89058. */
  89059. static readonly OnKeyDownTrigger: number;
  89060. /**
  89061. * On key up
  89062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89063. */
  89064. static readonly OnKeyUpTrigger: number;
  89065. private _scene;
  89066. /**
  89067. * Creates a new action manager
  89068. * @param scene defines the hosting scene
  89069. */
  89070. constructor(scene: Scene);
  89071. /**
  89072. * Releases all associated resources
  89073. */
  89074. dispose(): void;
  89075. /**
  89076. * Gets hosting scene
  89077. * @returns the hosting scene
  89078. */
  89079. getScene(): Scene;
  89080. /**
  89081. * Does this action manager handles actions of any of the given triggers
  89082. * @param triggers defines the triggers to be tested
  89083. * @return a boolean indicating whether one (or more) of the triggers is handled
  89084. */
  89085. hasSpecificTriggers(triggers: number[]): boolean;
  89086. /**
  89087. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89088. * speed.
  89089. * @param triggerA defines the trigger to be tested
  89090. * @param triggerB defines the trigger to be tested
  89091. * @return a boolean indicating whether one (or more) of the triggers is handled
  89092. */
  89093. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89094. /**
  89095. * Does this action manager handles actions of a given trigger
  89096. * @param trigger defines the trigger to be tested
  89097. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89098. * @return whether the trigger is handled
  89099. */
  89100. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89101. /**
  89102. * Does this action manager has pointer triggers
  89103. */
  89104. get hasPointerTriggers(): boolean;
  89105. /**
  89106. * Does this action manager has pick triggers
  89107. */
  89108. get hasPickTriggers(): boolean;
  89109. /**
  89110. * Registers an action to this action manager
  89111. * @param action defines the action to be registered
  89112. * @return the action amended (prepared) after registration
  89113. */
  89114. registerAction(action: IAction): Nullable<IAction>;
  89115. /**
  89116. * Unregisters an action to this action manager
  89117. * @param action defines the action to be unregistered
  89118. * @return a boolean indicating whether the action has been unregistered
  89119. */
  89120. unregisterAction(action: IAction): Boolean;
  89121. /**
  89122. * Process a specific trigger
  89123. * @param trigger defines the trigger to process
  89124. * @param evt defines the event details to be processed
  89125. */
  89126. processTrigger(trigger: number, evt?: IActionEvent): void;
  89127. /** @hidden */
  89128. _getEffectiveTarget(target: any, propertyPath: string): any;
  89129. /** @hidden */
  89130. _getProperty(propertyPath: string): string;
  89131. /**
  89132. * Serialize this manager to a JSON object
  89133. * @param name defines the property name to store this manager
  89134. * @returns a JSON representation of this manager
  89135. */
  89136. serialize(name: string): any;
  89137. /**
  89138. * Creates a new ActionManager from a JSON data
  89139. * @param parsedActions defines the JSON data to read from
  89140. * @param object defines the hosting mesh
  89141. * @param scene defines the hosting scene
  89142. */
  89143. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  89144. /**
  89145. * Get a trigger name by index
  89146. * @param trigger defines the trigger index
  89147. * @returns a trigger name
  89148. */
  89149. static GetTriggerName(trigger: number): string;
  89150. }
  89151. }
  89152. declare module BABYLON {
  89153. /**
  89154. * Class used to represent a sprite
  89155. * @see https://doc.babylonjs.com/babylon101/sprites
  89156. */
  89157. export class Sprite implements IAnimatable {
  89158. /** defines the name */
  89159. name: string;
  89160. /** Gets or sets the current world position */
  89161. position: Vector3;
  89162. /** Gets or sets the main color */
  89163. color: Color4;
  89164. /** Gets or sets the width */
  89165. width: number;
  89166. /** Gets or sets the height */
  89167. height: number;
  89168. /** Gets or sets rotation angle */
  89169. angle: number;
  89170. /** Gets or sets the cell index in the sprite sheet */
  89171. cellIndex: number;
  89172. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  89173. cellRef: string;
  89174. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  89175. invertU: boolean;
  89176. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  89177. invertV: boolean;
  89178. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  89179. disposeWhenFinishedAnimating: boolean;
  89180. /** Gets the list of attached animations */
  89181. animations: Nullable<Array<Animation>>;
  89182. /** Gets or sets a boolean indicating if the sprite can be picked */
  89183. isPickable: boolean;
  89184. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  89185. useAlphaForPicking: boolean;
  89186. /** @hidden */
  89187. _xOffset: number;
  89188. /** @hidden */
  89189. _yOffset: number;
  89190. /** @hidden */
  89191. _xSize: number;
  89192. /** @hidden */
  89193. _ySize: number;
  89194. /**
  89195. * Gets or sets the associated action manager
  89196. */
  89197. actionManager: Nullable<ActionManager>;
  89198. /**
  89199. * An event triggered when the control has been disposed
  89200. */
  89201. onDisposeObservable: Observable<Sprite>;
  89202. private _animationStarted;
  89203. private _loopAnimation;
  89204. private _fromIndex;
  89205. private _toIndex;
  89206. private _delay;
  89207. private _direction;
  89208. private _manager;
  89209. private _time;
  89210. private _onAnimationEnd;
  89211. /**
  89212. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  89213. */
  89214. isVisible: boolean;
  89215. /**
  89216. * Gets or sets the sprite size
  89217. */
  89218. get size(): number;
  89219. set size(value: number);
  89220. /**
  89221. * Returns a boolean indicating if the animation is started
  89222. */
  89223. get animationStarted(): boolean;
  89224. /**
  89225. * Gets or sets the unique id of the sprite
  89226. */
  89227. uniqueId: number;
  89228. /**
  89229. * Gets the manager of this sprite
  89230. */
  89231. get manager(): ISpriteManager;
  89232. /**
  89233. * Creates a new Sprite
  89234. * @param name defines the name
  89235. * @param manager defines the manager
  89236. */
  89237. constructor(
  89238. /** defines the name */
  89239. name: string, manager: ISpriteManager);
  89240. /**
  89241. * Returns the string "Sprite"
  89242. * @returns "Sprite"
  89243. */
  89244. getClassName(): string;
  89245. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  89246. get fromIndex(): number;
  89247. set fromIndex(value: number);
  89248. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  89249. get toIndex(): number;
  89250. set toIndex(value: number);
  89251. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  89252. get loopAnimation(): boolean;
  89253. set loopAnimation(value: boolean);
  89254. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  89255. get delay(): number;
  89256. set delay(value: number);
  89257. /**
  89258. * Starts an animation
  89259. * @param from defines the initial key
  89260. * @param to defines the end key
  89261. * @param loop defines if the animation must loop
  89262. * @param delay defines the start delay (in ms)
  89263. * @param onAnimationEnd defines a callback to call when animation ends
  89264. */
  89265. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  89266. /** Stops current animation (if any) */
  89267. stopAnimation(): void;
  89268. /** @hidden */
  89269. _animate(deltaTime: number): void;
  89270. /** Release associated resources */
  89271. dispose(): void;
  89272. /**
  89273. * Serializes the sprite to a JSON object
  89274. * @returns the JSON object
  89275. */
  89276. serialize(): any;
  89277. /**
  89278. * Parses a JSON object to create a new sprite
  89279. * @param parsedSprite The JSON object to parse
  89280. * @param manager defines the hosting manager
  89281. * @returns the new sprite
  89282. */
  89283. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  89284. }
  89285. }
  89286. declare module BABYLON {
  89287. /**
  89288. * Information about the result of picking within a scene
  89289. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  89290. */
  89291. export class PickingInfo {
  89292. /** @hidden */
  89293. _pickingUnavailable: boolean;
  89294. /**
  89295. * If the pick collided with an object
  89296. */
  89297. hit: boolean;
  89298. /**
  89299. * Distance away where the pick collided
  89300. */
  89301. distance: number;
  89302. /**
  89303. * The location of pick collision
  89304. */
  89305. pickedPoint: Nullable<Vector3>;
  89306. /**
  89307. * The mesh corresponding the the pick collision
  89308. */
  89309. pickedMesh: Nullable<AbstractMesh>;
  89310. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  89311. bu: number;
  89312. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  89313. bv: number;
  89314. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89315. faceId: number;
  89316. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  89317. subMeshFaceId: number;
  89318. /** Id of the the submesh that was picked */
  89319. subMeshId: number;
  89320. /** If a sprite was picked, this will be the sprite the pick collided with */
  89321. pickedSprite: Nullable<Sprite>;
  89322. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  89323. thinInstanceIndex: number;
  89324. /**
  89325. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  89326. */
  89327. originMesh: Nullable<AbstractMesh>;
  89328. /**
  89329. * The ray that was used to perform the picking.
  89330. */
  89331. ray: Nullable<Ray>;
  89332. /**
  89333. * Gets the normal correspodning to the face the pick collided with
  89334. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  89335. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  89336. * @returns The normal correspodning to the face the pick collided with
  89337. */
  89338. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  89339. /**
  89340. * Gets the texture coordinates of where the pick occured
  89341. * @returns the vector containing the coordnates of the texture
  89342. */
  89343. getTextureCoordinates(): Nullable<Vector2>;
  89344. }
  89345. }
  89346. declare module BABYLON {
  89347. /**
  89348. * Class representing a ray with position and direction
  89349. */
  89350. export class Ray {
  89351. /** origin point */
  89352. origin: Vector3;
  89353. /** direction */
  89354. direction: Vector3;
  89355. /** length of the ray */
  89356. length: number;
  89357. private static readonly _TmpVector3;
  89358. private _tmpRay;
  89359. /**
  89360. * Creates a new ray
  89361. * @param origin origin point
  89362. * @param direction direction
  89363. * @param length length of the ray
  89364. */
  89365. constructor(
  89366. /** origin point */
  89367. origin: Vector3,
  89368. /** direction */
  89369. direction: Vector3,
  89370. /** length of the ray */
  89371. length?: number);
  89372. /**
  89373. * Checks if the ray intersects a box
  89374. * This does not account for the ray lenght by design to improve perfs.
  89375. * @param minimum bound of the box
  89376. * @param maximum bound of the box
  89377. * @param intersectionTreshold extra extend to be added to the box in all direction
  89378. * @returns if the box was hit
  89379. */
  89380. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  89381. /**
  89382. * Checks if the ray intersects a box
  89383. * This does not account for the ray lenght by design to improve perfs.
  89384. * @param box the bounding box to check
  89385. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  89386. * @returns if the box was hit
  89387. */
  89388. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  89389. /**
  89390. * If the ray hits a sphere
  89391. * @param sphere the bounding sphere to check
  89392. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  89393. * @returns true if it hits the sphere
  89394. */
  89395. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  89396. /**
  89397. * If the ray hits a triange
  89398. * @param vertex0 triangle vertex
  89399. * @param vertex1 triangle vertex
  89400. * @param vertex2 triangle vertex
  89401. * @returns intersection information if hit
  89402. */
  89403. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  89404. /**
  89405. * Checks if ray intersects a plane
  89406. * @param plane the plane to check
  89407. * @returns the distance away it was hit
  89408. */
  89409. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  89410. /**
  89411. * Calculate the intercept of a ray on a given axis
  89412. * @param axis to check 'x' | 'y' | 'z'
  89413. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  89414. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  89415. */
  89416. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  89417. /**
  89418. * Checks if ray intersects a mesh
  89419. * @param mesh the mesh to check
  89420. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89421. * @returns picking info of the intersecton
  89422. */
  89423. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  89424. /**
  89425. * Checks if ray intersects a mesh
  89426. * @param meshes the meshes to check
  89427. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89428. * @param results array to store result in
  89429. * @returns Array of picking infos
  89430. */
  89431. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  89432. private _comparePickingInfo;
  89433. private static smallnum;
  89434. private static rayl;
  89435. /**
  89436. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  89437. * @param sega the first point of the segment to test the intersection against
  89438. * @param segb the second point of the segment to test the intersection against
  89439. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  89440. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  89441. */
  89442. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  89443. /**
  89444. * Update the ray from viewport position
  89445. * @param x position
  89446. * @param y y position
  89447. * @param viewportWidth viewport width
  89448. * @param viewportHeight viewport height
  89449. * @param world world matrix
  89450. * @param view view matrix
  89451. * @param projection projection matrix
  89452. * @returns this ray updated
  89453. */
  89454. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89455. /**
  89456. * Creates a ray with origin and direction of 0,0,0
  89457. * @returns the new ray
  89458. */
  89459. static Zero(): Ray;
  89460. /**
  89461. * Creates a new ray from screen space and viewport
  89462. * @param x position
  89463. * @param y y position
  89464. * @param viewportWidth viewport width
  89465. * @param viewportHeight viewport height
  89466. * @param world world matrix
  89467. * @param view view matrix
  89468. * @param projection projection matrix
  89469. * @returns new ray
  89470. */
  89471. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  89472. /**
  89473. * 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
  89474. * transformed to the given world matrix.
  89475. * @param origin The origin point
  89476. * @param end The end point
  89477. * @param world a matrix to transform the ray to. Default is the identity matrix.
  89478. * @returns the new ray
  89479. */
  89480. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  89481. /**
  89482. * Transforms a ray by a matrix
  89483. * @param ray ray to transform
  89484. * @param matrix matrix to apply
  89485. * @returns the resulting new ray
  89486. */
  89487. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  89488. /**
  89489. * Transforms a ray by a matrix
  89490. * @param ray ray to transform
  89491. * @param matrix matrix to apply
  89492. * @param result ray to store result in
  89493. */
  89494. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  89495. /**
  89496. * Unproject a ray from screen space to object space
  89497. * @param sourceX defines the screen space x coordinate to use
  89498. * @param sourceY defines the screen space y coordinate to use
  89499. * @param viewportWidth defines the current width of the viewport
  89500. * @param viewportHeight defines the current height of the viewport
  89501. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  89502. * @param view defines the view matrix to use
  89503. * @param projection defines the projection matrix to use
  89504. */
  89505. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  89506. }
  89507. /**
  89508. * Type used to define predicate used to select faces when a mesh intersection is detected
  89509. */
  89510. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  89511. interface Scene {
  89512. /** @hidden */
  89513. _tempPickingRay: Nullable<Ray>;
  89514. /** @hidden */
  89515. _cachedRayForTransform: Ray;
  89516. /** @hidden */
  89517. _pickWithRayInverseMatrix: Matrix;
  89518. /** @hidden */
  89519. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89520. /** @hidden */
  89521. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  89522. /** @hidden */
  89523. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  89524. }
  89525. }
  89526. declare module BABYLON {
  89527. /**
  89528. * Groups all the scene component constants in one place to ease maintenance.
  89529. * @hidden
  89530. */
  89531. export class SceneComponentConstants {
  89532. static readonly NAME_EFFECTLAYER: string;
  89533. static readonly NAME_LAYER: string;
  89534. static readonly NAME_LENSFLARESYSTEM: string;
  89535. static readonly NAME_BOUNDINGBOXRENDERER: string;
  89536. static readonly NAME_PARTICLESYSTEM: string;
  89537. static readonly NAME_GAMEPAD: string;
  89538. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  89539. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  89540. static readonly NAME_PREPASSRENDERER: string;
  89541. static readonly NAME_DEPTHRENDERER: string;
  89542. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  89543. static readonly NAME_SPRITE: string;
  89544. static readonly NAME_OUTLINERENDERER: string;
  89545. static readonly NAME_PROCEDURALTEXTURE: string;
  89546. static readonly NAME_SHADOWGENERATOR: string;
  89547. static readonly NAME_OCTREE: string;
  89548. static readonly NAME_PHYSICSENGINE: string;
  89549. static readonly NAME_AUDIO: string;
  89550. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  89551. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89552. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  89553. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  89554. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  89555. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  89556. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  89557. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  89558. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  89559. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  89560. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  89561. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  89562. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  89563. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  89564. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  89565. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  89566. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  89567. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  89568. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  89569. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  89570. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  89571. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  89572. static readonly STEP_AFTERRENDER_AUDIO: number;
  89573. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  89574. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  89575. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  89576. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  89577. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  89578. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  89579. static readonly STEP_POINTERMOVE_SPRITE: number;
  89580. static readonly STEP_POINTERDOWN_SPRITE: number;
  89581. static readonly STEP_POINTERUP_SPRITE: number;
  89582. }
  89583. /**
  89584. * This represents a scene component.
  89585. *
  89586. * This is used to decouple the dependency the scene is having on the different workloads like
  89587. * layers, post processes...
  89588. */
  89589. export interface ISceneComponent {
  89590. /**
  89591. * The name of the component. Each component must have a unique name.
  89592. */
  89593. name: string;
  89594. /**
  89595. * The scene the component belongs to.
  89596. */
  89597. scene: Scene;
  89598. /**
  89599. * Register the component to one instance of a scene.
  89600. */
  89601. register(): void;
  89602. /**
  89603. * Rebuilds the elements related to this component in case of
  89604. * context lost for instance.
  89605. */
  89606. rebuild(): void;
  89607. /**
  89608. * Disposes the component and the associated ressources.
  89609. */
  89610. dispose(): void;
  89611. }
  89612. /**
  89613. * This represents a SERIALIZABLE scene component.
  89614. *
  89615. * This extends Scene Component to add Serialization methods on top.
  89616. */
  89617. export interface ISceneSerializableComponent extends ISceneComponent {
  89618. /**
  89619. * Adds all the elements from the container to the scene
  89620. * @param container the container holding the elements
  89621. */
  89622. addFromContainer(container: AbstractScene): void;
  89623. /**
  89624. * Removes all the elements in the container from the scene
  89625. * @param container contains the elements to remove
  89626. * @param dispose if the removed element should be disposed (default: false)
  89627. */
  89628. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  89629. /**
  89630. * Serializes the component data to the specified json object
  89631. * @param serializationObject The object to serialize to
  89632. */
  89633. serialize(serializationObject: any): void;
  89634. }
  89635. /**
  89636. * Strong typing of a Mesh related stage step action
  89637. */
  89638. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89639. /**
  89640. * Strong typing of a Evaluate Sub Mesh related stage step action
  89641. */
  89642. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89643. /**
  89644. * Strong typing of a Active Mesh related stage step action
  89645. */
  89646. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89647. /**
  89648. * Strong typing of a Camera related stage step action
  89649. */
  89650. export type CameraStageAction = (camera: Camera) => void;
  89651. /**
  89652. * Strong typing of a Camera Frame buffer related stage step action
  89653. */
  89654. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89655. /**
  89656. * Strong typing of a Render Target related stage step action
  89657. */
  89658. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89659. /**
  89660. * Strong typing of a RenderingGroup related stage step action
  89661. */
  89662. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89663. /**
  89664. * Strong typing of a Mesh Render related stage step action
  89665. */
  89666. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89667. /**
  89668. * Strong typing of a simple stage step action
  89669. */
  89670. export type SimpleStageAction = () => void;
  89671. /**
  89672. * Strong typing of a render target action.
  89673. */
  89674. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89675. /**
  89676. * Strong typing of a pointer move action.
  89677. */
  89678. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89679. /**
  89680. * Strong typing of a pointer up/down action.
  89681. */
  89682. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89683. /**
  89684. * Representation of a stage in the scene (Basically a list of ordered steps)
  89685. * @hidden
  89686. */
  89687. export class Stage<T extends Function> extends Array<{
  89688. index: number;
  89689. component: ISceneComponent;
  89690. action: T;
  89691. }> {
  89692. /**
  89693. * Hide ctor from the rest of the world.
  89694. * @param items The items to add.
  89695. */
  89696. private constructor();
  89697. /**
  89698. * Creates a new Stage.
  89699. * @returns A new instance of a Stage
  89700. */
  89701. static Create<T extends Function>(): Stage<T>;
  89702. /**
  89703. * Registers a step in an ordered way in the targeted stage.
  89704. * @param index Defines the position to register the step in
  89705. * @param component Defines the component attached to the step
  89706. * @param action Defines the action to launch during the step
  89707. */
  89708. registerStep(index: number, component: ISceneComponent, action: T): void;
  89709. /**
  89710. * Clears all the steps from the stage.
  89711. */
  89712. clear(): void;
  89713. }
  89714. }
  89715. declare module BABYLON {
  89716. interface Scene {
  89717. /** @hidden */
  89718. _pointerOverSprite: Nullable<Sprite>;
  89719. /** @hidden */
  89720. _pickedDownSprite: Nullable<Sprite>;
  89721. /** @hidden */
  89722. _tempSpritePickingRay: Nullable<Ray>;
  89723. /**
  89724. * All of the sprite managers added to this scene
  89725. * @see https://doc.babylonjs.com/babylon101/sprites
  89726. */
  89727. spriteManagers: Array<ISpriteManager>;
  89728. /**
  89729. * An event triggered when sprites rendering is about to start
  89730. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89731. */
  89732. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89733. /**
  89734. * An event triggered when sprites rendering is done
  89735. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89736. */
  89737. onAfterSpritesRenderingObservable: Observable<Scene>;
  89738. /** @hidden */
  89739. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89740. /** Launch a ray to try to pick a sprite in the scene
  89741. * @param x position on screen
  89742. * @param y position on screen
  89743. * @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
  89744. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89745. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89746. * @returns a PickingInfo
  89747. */
  89748. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89749. /** Use the given ray to pick a sprite in the scene
  89750. * @param ray The ray (in world space) to use to pick meshes
  89751. * @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
  89752. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89753. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89754. * @returns a PickingInfo
  89755. */
  89756. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89757. /** @hidden */
  89758. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89759. /** Launch a ray to try to pick sprites in the scene
  89760. * @param x position on screen
  89761. * @param y position on screen
  89762. * @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
  89763. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89764. * @returns a PickingInfo array
  89765. */
  89766. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89767. /** Use the given ray to pick sprites in the scene
  89768. * @param ray The ray (in world space) to use to pick meshes
  89769. * @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
  89770. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89771. * @returns a PickingInfo array
  89772. */
  89773. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89774. /**
  89775. * Force the sprite under the pointer
  89776. * @param sprite defines the sprite to use
  89777. */
  89778. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89779. /**
  89780. * Gets the sprite under the pointer
  89781. * @returns a Sprite or null if no sprite is under the pointer
  89782. */
  89783. getPointerOverSprite(): Nullable<Sprite>;
  89784. }
  89785. /**
  89786. * Defines the sprite scene component responsible to manage sprites
  89787. * in a given scene.
  89788. */
  89789. export class SpriteSceneComponent implements ISceneComponent {
  89790. /**
  89791. * The component name helpfull to identify the component in the list of scene components.
  89792. */
  89793. readonly name: string;
  89794. /**
  89795. * The scene the component belongs to.
  89796. */
  89797. scene: Scene;
  89798. /** @hidden */
  89799. private _spritePredicate;
  89800. /**
  89801. * Creates a new instance of the component for the given scene
  89802. * @param scene Defines the scene to register the component in
  89803. */
  89804. constructor(scene: Scene);
  89805. /**
  89806. * Registers the component in a given scene
  89807. */
  89808. register(): void;
  89809. /**
  89810. * Rebuilds the elements related to this component in case of
  89811. * context lost for instance.
  89812. */
  89813. rebuild(): void;
  89814. /**
  89815. * Disposes the component and the associated ressources.
  89816. */
  89817. dispose(): void;
  89818. private _pickSpriteButKeepRay;
  89819. private _pointerMove;
  89820. private _pointerDown;
  89821. private _pointerUp;
  89822. }
  89823. }
  89824. declare module BABYLON {
  89825. /** @hidden */
  89826. export var fogFragmentDeclaration: {
  89827. name: string;
  89828. shader: string;
  89829. };
  89830. }
  89831. declare module BABYLON {
  89832. /** @hidden */
  89833. export var fogFragment: {
  89834. name: string;
  89835. shader: string;
  89836. };
  89837. }
  89838. declare module BABYLON {
  89839. /** @hidden */
  89840. export var spritesPixelShader: {
  89841. name: string;
  89842. shader: string;
  89843. };
  89844. }
  89845. declare module BABYLON {
  89846. /** @hidden */
  89847. export var fogVertexDeclaration: {
  89848. name: string;
  89849. shader: string;
  89850. };
  89851. }
  89852. declare module BABYLON {
  89853. /** @hidden */
  89854. export var spritesVertexShader: {
  89855. name: string;
  89856. shader: string;
  89857. };
  89858. }
  89859. declare module BABYLON {
  89860. /**
  89861. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89862. */
  89863. export interface ISpriteManager extends IDisposable {
  89864. /**
  89865. * Gets manager's name
  89866. */
  89867. name: string;
  89868. /**
  89869. * Restricts the camera to viewing objects with the same layerMask.
  89870. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89871. */
  89872. layerMask: number;
  89873. /**
  89874. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89875. */
  89876. isPickable: boolean;
  89877. /**
  89878. * Gets the hosting scene
  89879. */
  89880. scene: Scene;
  89881. /**
  89882. * Specifies the rendering group id for this mesh (0 by default)
  89883. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89884. */
  89885. renderingGroupId: number;
  89886. /**
  89887. * Defines the list of sprites managed by the manager.
  89888. */
  89889. sprites: Array<Sprite>;
  89890. /**
  89891. * Gets or sets the spritesheet texture
  89892. */
  89893. texture: Texture;
  89894. /** Defines the default width of a cell in the spritesheet */
  89895. cellWidth: number;
  89896. /** Defines the default height of a cell in the spritesheet */
  89897. cellHeight: number;
  89898. /**
  89899. * Tests the intersection of a sprite with a specific ray.
  89900. * @param ray The ray we are sending to test the collision
  89901. * @param camera The camera space we are sending rays in
  89902. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89903. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89904. * @returns picking info or null.
  89905. */
  89906. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89907. /**
  89908. * Intersects the sprites with a ray
  89909. * @param ray defines the ray to intersect with
  89910. * @param camera defines the current active camera
  89911. * @param predicate defines a predicate used to select candidate sprites
  89912. * @returns null if no hit or a PickingInfo array
  89913. */
  89914. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89915. /**
  89916. * Renders the list of sprites on screen.
  89917. */
  89918. render(): void;
  89919. }
  89920. /**
  89921. * Class used to manage multiple sprites on the same spritesheet
  89922. * @see https://doc.babylonjs.com/babylon101/sprites
  89923. */
  89924. export class SpriteManager implements ISpriteManager {
  89925. /** defines the manager's name */
  89926. name: string;
  89927. /** Define the Url to load snippets */
  89928. static SnippetUrl: string;
  89929. /** Snippet ID if the manager was created from the snippet server */
  89930. snippetId: string;
  89931. /** Gets the list of sprites */
  89932. sprites: Sprite[];
  89933. /** Gets or sets the rendering group id (0 by default) */
  89934. renderingGroupId: number;
  89935. /** Gets or sets camera layer mask */
  89936. layerMask: number;
  89937. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89938. fogEnabled: boolean;
  89939. /** Gets or sets a boolean indicating if the sprites are pickable */
  89940. isPickable: boolean;
  89941. /** Defines the default width of a cell in the spritesheet */
  89942. cellWidth: number;
  89943. /** Defines the default height of a cell in the spritesheet */
  89944. cellHeight: number;
  89945. /** Associative array from JSON sprite data file */
  89946. private _cellData;
  89947. /** Array of sprite names from JSON sprite data file */
  89948. private _spriteMap;
  89949. /** True when packed cell data from JSON file is ready*/
  89950. private _packedAndReady;
  89951. private _textureContent;
  89952. /**
  89953. * An event triggered when the manager is disposed.
  89954. */
  89955. onDisposeObservable: Observable<SpriteManager>;
  89956. private _onDisposeObserver;
  89957. /**
  89958. * Callback called when the manager is disposed
  89959. */
  89960. set onDispose(callback: () => void);
  89961. private _capacity;
  89962. private _fromPacked;
  89963. private _spriteTexture;
  89964. private _epsilon;
  89965. private _scene;
  89966. private _vertexData;
  89967. private _buffer;
  89968. private _vertexBuffers;
  89969. private _indexBuffer;
  89970. private _effectBase;
  89971. private _effectFog;
  89972. /**
  89973. * Gets or sets the unique id of the sprite
  89974. */
  89975. uniqueId: number;
  89976. /**
  89977. * Gets the array of sprites
  89978. */
  89979. get children(): Sprite[];
  89980. /**
  89981. * Gets the hosting scene
  89982. */
  89983. get scene(): Scene;
  89984. /**
  89985. * Gets the capacity of the manager
  89986. */
  89987. get capacity(): number;
  89988. /**
  89989. * Gets or sets the spritesheet texture
  89990. */
  89991. get texture(): Texture;
  89992. set texture(value: Texture);
  89993. private _blendMode;
  89994. /**
  89995. * Blend mode use to render the particle, it can be any of
  89996. * the static Constants.ALPHA_x properties provided in this class.
  89997. * Default value is Constants.ALPHA_COMBINE
  89998. */
  89999. get blendMode(): number;
  90000. set blendMode(blendMode: number);
  90001. /** Disables writing to the depth buffer when rendering the sprites.
  90002. * It can be handy to disable depth writing when using textures without alpha channel
  90003. * and setting some specific blend modes.
  90004. */
  90005. disableDepthWrite: boolean;
  90006. /**
  90007. * Creates a new sprite manager
  90008. * @param name defines the manager's name
  90009. * @param imgUrl defines the sprite sheet url
  90010. * @param capacity defines the maximum allowed number of sprites
  90011. * @param cellSize defines the size of a sprite cell
  90012. * @param scene defines the hosting scene
  90013. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90014. * @param samplingMode defines the smapling mode to use with spritesheet
  90015. * @param fromPacked set to false; do not alter
  90016. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90017. */
  90018. constructor(
  90019. /** defines the manager's name */
  90020. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90021. /**
  90022. * Returns the string "SpriteManager"
  90023. * @returns "SpriteManager"
  90024. */
  90025. getClassName(): string;
  90026. private _makePacked;
  90027. private _appendSpriteVertex;
  90028. private _checkTextureAlpha;
  90029. /**
  90030. * Intersects the sprites with a ray
  90031. * @param ray defines the ray to intersect with
  90032. * @param camera defines the current active camera
  90033. * @param predicate defines a predicate used to select candidate sprites
  90034. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  90035. * @returns null if no hit or a PickingInfo
  90036. */
  90037. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90038. /**
  90039. * Intersects the sprites with a ray
  90040. * @param ray defines the ray to intersect with
  90041. * @param camera defines the current active camera
  90042. * @param predicate defines a predicate used to select candidate sprites
  90043. * @returns null if no hit or a PickingInfo array
  90044. */
  90045. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90046. /**
  90047. * Render all child sprites
  90048. */
  90049. render(): void;
  90050. /**
  90051. * Release associated resources
  90052. */
  90053. dispose(): void;
  90054. /**
  90055. * Serializes the sprite manager to a JSON object
  90056. * @param serializeTexture defines if the texture must be serialized as well
  90057. * @returns the JSON object
  90058. */
  90059. serialize(serializeTexture?: boolean): any;
  90060. /**
  90061. * Parses a JSON object to create a new sprite manager.
  90062. * @param parsedManager The JSON object to parse
  90063. * @param scene The scene to create the sprite managerin
  90064. * @param rootUrl The root url to use to load external dependencies like texture
  90065. * @returns the new sprite manager
  90066. */
  90067. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90068. /**
  90069. * Creates a sprite manager from a snippet saved in a remote file
  90070. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90071. * @param url defines the url to load from
  90072. * @param scene defines the hosting scene
  90073. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90074. * @returns a promise that will resolve to the new sprite manager
  90075. */
  90076. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90077. /**
  90078. * Creates a sprite manager from a snippet saved by the sprite editor
  90079. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90080. * @param scene defines the hosting scene
  90081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90082. * @returns a promise that will resolve to the new sprite manager
  90083. */
  90084. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90085. }
  90086. }
  90087. declare module BABYLON {
  90088. /** Interface used by value gradients (color, factor, ...) */
  90089. export interface IValueGradient {
  90090. /**
  90091. * Gets or sets the gradient value (between 0 and 1)
  90092. */
  90093. gradient: number;
  90094. }
  90095. /** Class used to store color4 gradient */
  90096. export class ColorGradient implements IValueGradient {
  90097. /**
  90098. * Gets or sets the gradient value (between 0 and 1)
  90099. */
  90100. gradient: number;
  90101. /**
  90102. * Gets or sets first associated color
  90103. */
  90104. color1: Color4;
  90105. /**
  90106. * Gets or sets second associated color
  90107. */
  90108. color2?: Color4 | undefined;
  90109. /**
  90110. * Creates a new color4 gradient
  90111. * @param gradient gets or sets the gradient value (between 0 and 1)
  90112. * @param color1 gets or sets first associated color
  90113. * @param color2 gets or sets first second color
  90114. */
  90115. constructor(
  90116. /**
  90117. * Gets or sets the gradient value (between 0 and 1)
  90118. */
  90119. gradient: number,
  90120. /**
  90121. * Gets or sets first associated color
  90122. */
  90123. color1: Color4,
  90124. /**
  90125. * Gets or sets second associated color
  90126. */
  90127. color2?: Color4 | undefined);
  90128. /**
  90129. * Will get a color picked randomly between color1 and color2.
  90130. * If color2 is undefined then color1 will be used
  90131. * @param result defines the target Color4 to store the result in
  90132. */
  90133. getColorToRef(result: Color4): void;
  90134. }
  90135. /** Class used to store color 3 gradient */
  90136. export class Color3Gradient implements IValueGradient {
  90137. /**
  90138. * Gets or sets the gradient value (between 0 and 1)
  90139. */
  90140. gradient: number;
  90141. /**
  90142. * Gets or sets the associated color
  90143. */
  90144. color: Color3;
  90145. /**
  90146. * Creates a new color3 gradient
  90147. * @param gradient gets or sets the gradient value (between 0 and 1)
  90148. * @param color gets or sets associated color
  90149. */
  90150. constructor(
  90151. /**
  90152. * Gets or sets the gradient value (between 0 and 1)
  90153. */
  90154. gradient: number,
  90155. /**
  90156. * Gets or sets the associated color
  90157. */
  90158. color: Color3);
  90159. }
  90160. /** Class used to store factor gradient */
  90161. export class FactorGradient implements IValueGradient {
  90162. /**
  90163. * Gets or sets the gradient value (between 0 and 1)
  90164. */
  90165. gradient: number;
  90166. /**
  90167. * Gets or sets first associated factor
  90168. */
  90169. factor1: number;
  90170. /**
  90171. * Gets or sets second associated factor
  90172. */
  90173. factor2?: number | undefined;
  90174. /**
  90175. * Creates a new factor gradient
  90176. * @param gradient gets or sets the gradient value (between 0 and 1)
  90177. * @param factor1 gets or sets first associated factor
  90178. * @param factor2 gets or sets second associated factor
  90179. */
  90180. constructor(
  90181. /**
  90182. * Gets or sets the gradient value (between 0 and 1)
  90183. */
  90184. gradient: number,
  90185. /**
  90186. * Gets or sets first associated factor
  90187. */
  90188. factor1: number,
  90189. /**
  90190. * Gets or sets second associated factor
  90191. */
  90192. factor2?: number | undefined);
  90193. /**
  90194. * Will get a number picked randomly between factor1 and factor2.
  90195. * If factor2 is undefined then factor1 will be used
  90196. * @returns the picked number
  90197. */
  90198. getFactor(): number;
  90199. }
  90200. /**
  90201. * Helper used to simplify some generic gradient tasks
  90202. */
  90203. export class GradientHelper {
  90204. /**
  90205. * Gets the current gradient from an array of IValueGradient
  90206. * @param ratio defines the current ratio to get
  90207. * @param gradients defines the array of IValueGradient
  90208. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90209. */
  90210. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90211. }
  90212. }
  90213. declare module BABYLON {
  90214. interface ThinEngine {
  90215. /**
  90216. * Creates a raw texture
  90217. * @param data defines the data to store in the texture
  90218. * @param width defines the width of the texture
  90219. * @param height defines the height of the texture
  90220. * @param format defines the format of the data
  90221. * @param generateMipMaps defines if the engine should generate the mip levels
  90222. * @param invertY defines if data must be stored with Y axis inverted
  90223. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90224. * @param compression defines the compression used (null by default)
  90225. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90226. * @returns the raw texture inside an InternalTexture
  90227. */
  90228. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  90229. /**
  90230. * Update a raw texture
  90231. * @param texture defines the texture to update
  90232. * @param data defines the data to store in the texture
  90233. * @param format defines the format of the data
  90234. * @param invertY defines if data must be stored with Y axis inverted
  90235. */
  90236. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90237. /**
  90238. * Update a raw texture
  90239. * @param texture defines the texture to update
  90240. * @param data defines the data to store in the texture
  90241. * @param format defines the format of the data
  90242. * @param invertY defines if data must be stored with Y axis inverted
  90243. * @param compression defines the compression used (null by default)
  90244. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90245. */
  90246. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  90247. /**
  90248. * Creates a new raw cube texture
  90249. * @param data defines the array of data to use to create each face
  90250. * @param size defines the size of the textures
  90251. * @param format defines the format of the data
  90252. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90253. * @param generateMipMaps defines if the engine should generate the mip levels
  90254. * @param invertY defines if data must be stored with Y axis inverted
  90255. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90256. * @param compression defines the compression used (null by default)
  90257. * @returns the cube texture as an InternalTexture
  90258. */
  90259. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  90260. /**
  90261. * Update a raw cube texture
  90262. * @param texture defines the texture to udpdate
  90263. * @param data defines the data to store
  90264. * @param format defines the data format
  90265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90266. * @param invertY defines if data must be stored with Y axis inverted
  90267. */
  90268. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  90269. /**
  90270. * Update a raw cube texture
  90271. * @param texture defines the texture to udpdate
  90272. * @param data defines the data to store
  90273. * @param format defines the data format
  90274. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90275. * @param invertY defines if data must be stored with Y axis inverted
  90276. * @param compression defines the compression used (null by default)
  90277. */
  90278. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  90279. /**
  90280. * Update a raw cube texture
  90281. * @param texture defines the texture to udpdate
  90282. * @param data defines the data to store
  90283. * @param format defines the data format
  90284. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  90285. * @param invertY defines if data must be stored with Y axis inverted
  90286. * @param compression defines the compression used (null by default)
  90287. * @param level defines which level of the texture to update
  90288. */
  90289. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  90290. /**
  90291. * Creates a new raw cube texture from a specified url
  90292. * @param url defines the url where the data is located
  90293. * @param scene defines the current scene
  90294. * @param size defines the size of the textures
  90295. * @param format defines the format of the data
  90296. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90297. * @param noMipmap defines if the engine should avoid generating the mip levels
  90298. * @param callback defines a callback used to extract texture data from loaded data
  90299. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90300. * @param onLoad defines a callback called when texture is loaded
  90301. * @param onError defines a callback called if there is an error
  90302. * @returns the cube texture as an InternalTexture
  90303. */
  90304. 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;
  90305. /**
  90306. * Creates a new raw cube texture from a specified url
  90307. * @param url defines the url where the data is located
  90308. * @param scene defines the current scene
  90309. * @param size defines the size of the textures
  90310. * @param format defines the format of the data
  90311. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  90312. * @param noMipmap defines if the engine should avoid generating the mip levels
  90313. * @param callback defines a callback used to extract texture data from loaded data
  90314. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  90315. * @param onLoad defines a callback called when texture is loaded
  90316. * @param onError defines a callback called if there is an error
  90317. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90318. * @param invertY defines if data must be stored with Y axis inverted
  90319. * @returns the cube texture as an InternalTexture
  90320. */
  90321. 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;
  90322. /**
  90323. * Creates a new raw 3D texture
  90324. * @param data defines the data used to create the texture
  90325. * @param width defines the width of the texture
  90326. * @param height defines the height of the texture
  90327. * @param depth defines the depth of the texture
  90328. * @param format defines the format of the texture
  90329. * @param generateMipMaps defines if the engine must generate mip levels
  90330. * @param invertY defines if data must be stored with Y axis inverted
  90331. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90332. * @param compression defines the compressed used (can be null)
  90333. * @param textureType defines the compressed used (can be null)
  90334. * @returns a new raw 3D texture (stored in an InternalTexture)
  90335. */
  90336. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90337. /**
  90338. * Update a raw 3D texture
  90339. * @param texture defines the texture to update
  90340. * @param data defines the data to store
  90341. * @param format defines the data format
  90342. * @param invertY defines if data must be stored with Y axis inverted
  90343. */
  90344. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90345. /**
  90346. * Update a raw 3D texture
  90347. * @param texture defines the texture to update
  90348. * @param data defines the data to store
  90349. * @param format defines the data format
  90350. * @param invertY defines if data must be stored with Y axis inverted
  90351. * @param compression defines the used compression (can be null)
  90352. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90353. */
  90354. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90355. /**
  90356. * Creates a new raw 2D array texture
  90357. * @param data defines the data used to create the texture
  90358. * @param width defines the width of the texture
  90359. * @param height defines the height of the texture
  90360. * @param depth defines the number of layers of the texture
  90361. * @param format defines the format of the texture
  90362. * @param generateMipMaps defines if the engine must generate mip levels
  90363. * @param invertY defines if data must be stored with Y axis inverted
  90364. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  90365. * @param compression defines the compressed used (can be null)
  90366. * @param textureType defines the compressed used (can be null)
  90367. * @returns a new raw 2D array texture (stored in an InternalTexture)
  90368. */
  90369. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  90370. /**
  90371. * Update a raw 2D array texture
  90372. * @param texture defines the texture to update
  90373. * @param data defines the data to store
  90374. * @param format defines the data format
  90375. * @param invertY defines if data must be stored with Y axis inverted
  90376. */
  90377. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  90378. /**
  90379. * Update a raw 2D array texture
  90380. * @param texture defines the texture to update
  90381. * @param data defines the data to store
  90382. * @param format defines the data format
  90383. * @param invertY defines if data must be stored with Y axis inverted
  90384. * @param compression defines the used compression (can be null)
  90385. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  90386. */
  90387. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  90388. }
  90389. }
  90390. declare module BABYLON {
  90391. /**
  90392. * Raw texture can help creating a texture directly from an array of data.
  90393. * This can be super useful if you either get the data from an uncompressed source or
  90394. * if you wish to create your texture pixel by pixel.
  90395. */
  90396. export class RawTexture extends Texture {
  90397. /**
  90398. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90399. */
  90400. format: number;
  90401. /**
  90402. * Instantiates a new RawTexture.
  90403. * Raw texture can help creating a texture directly from an array of data.
  90404. * This can be super useful if you either get the data from an uncompressed source or
  90405. * if you wish to create your texture pixel by pixel.
  90406. * @param data define the array of data to use to create the texture
  90407. * @param width define the width of the texture
  90408. * @param height define the height of the texture
  90409. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90410. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90411. * @param generateMipMaps define whether mip maps should be generated or not
  90412. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90413. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90414. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90415. */
  90416. constructor(data: ArrayBufferView, width: number, height: number,
  90417. /**
  90418. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  90419. */
  90420. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  90421. /**
  90422. * Updates the texture underlying data.
  90423. * @param data Define the new data of the texture
  90424. */
  90425. update(data: ArrayBufferView): void;
  90426. /**
  90427. * Creates a luminance texture from some data.
  90428. * @param data Define the texture data
  90429. * @param width Define the width of the texture
  90430. * @param height Define the height of the texture
  90431. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90432. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90433. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90434. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90435. * @returns the luminance texture
  90436. */
  90437. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90438. /**
  90439. * Creates a luminance alpha texture from some data.
  90440. * @param data Define the texture data
  90441. * @param width Define the width of the texture
  90442. * @param height Define the height of the texture
  90443. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90444. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90445. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90446. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90447. * @returns the luminance alpha texture
  90448. */
  90449. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90450. /**
  90451. * Creates an alpha texture from some data.
  90452. * @param data Define the texture data
  90453. * @param width Define the width of the texture
  90454. * @param height Define the height of the texture
  90455. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90456. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90457. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90458. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90459. * @returns the alpha texture
  90460. */
  90461. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  90462. /**
  90463. * Creates a RGB texture from some data.
  90464. * @param data Define the texture data
  90465. * @param width Define the width of the texture
  90466. * @param height Define the height of the texture
  90467. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90468. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90469. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90470. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90471. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90472. * @returns the RGB alpha texture
  90473. */
  90474. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90475. /**
  90476. * Creates a RGBA texture from some data.
  90477. * @param data Define the texture data
  90478. * @param width Define the width of the texture
  90479. * @param height Define the height of the texture
  90480. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90481. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90482. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90483. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90484. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90485. * @returns the RGBA texture
  90486. */
  90487. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90488. /**
  90489. * Creates a R texture from some data.
  90490. * @param data Define the texture data
  90491. * @param width Define the width of the texture
  90492. * @param height Define the height of the texture
  90493. * @param sceneOrEngine defines the scene or engine the texture will belong to
  90494. * @param generateMipMaps Define whether or not to create mip maps for the texture
  90495. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  90496. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  90497. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  90498. * @returns the R texture
  90499. */
  90500. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  90501. }
  90502. }
  90503. declare module BABYLON {
  90504. interface AbstractScene {
  90505. /**
  90506. * The list of procedural textures added to the scene
  90507. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90508. */
  90509. proceduralTextures: Array<ProceduralTexture>;
  90510. }
  90511. /**
  90512. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  90513. * in a given scene.
  90514. */
  90515. export class ProceduralTextureSceneComponent implements ISceneComponent {
  90516. /**
  90517. * The component name helpfull to identify the component in the list of scene components.
  90518. */
  90519. readonly name: string;
  90520. /**
  90521. * The scene the component belongs to.
  90522. */
  90523. scene: Scene;
  90524. /**
  90525. * Creates a new instance of the component for the given scene
  90526. * @param scene Defines the scene to register the component in
  90527. */
  90528. constructor(scene: Scene);
  90529. /**
  90530. * Registers the component in a given scene
  90531. */
  90532. register(): void;
  90533. /**
  90534. * Rebuilds the elements related to this component in case of
  90535. * context lost for instance.
  90536. */
  90537. rebuild(): void;
  90538. /**
  90539. * Disposes the component and the associated ressources.
  90540. */
  90541. dispose(): void;
  90542. private _beforeClear;
  90543. }
  90544. }
  90545. declare module BABYLON {
  90546. interface ThinEngine {
  90547. /**
  90548. * Creates a new render target cube texture
  90549. * @param size defines the size of the texture
  90550. * @param options defines the options used to create the texture
  90551. * @returns a new render target cube texture stored in an InternalTexture
  90552. */
  90553. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  90554. }
  90555. }
  90556. declare module BABYLON {
  90557. /** @hidden */
  90558. export var proceduralVertexShader: {
  90559. name: string;
  90560. shader: string;
  90561. };
  90562. }
  90563. declare module BABYLON {
  90564. /**
  90565. * 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.
  90566. * This is the base class of any Procedural texture and contains most of the shareable code.
  90567. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90568. */
  90569. export class ProceduralTexture extends Texture {
  90570. isCube: boolean;
  90571. /**
  90572. * Define if the texture is enabled or not (disabled texture will not render)
  90573. */
  90574. isEnabled: boolean;
  90575. /**
  90576. * Define if the texture must be cleared before rendering (default is true)
  90577. */
  90578. autoClear: boolean;
  90579. /**
  90580. * Callback called when the texture is generated
  90581. */
  90582. onGenerated: () => void;
  90583. /**
  90584. * Event raised when the texture is generated
  90585. */
  90586. onGeneratedObservable: Observable<ProceduralTexture>;
  90587. /** @hidden */
  90588. _generateMipMaps: boolean;
  90589. /** @hidden **/
  90590. _effect: Effect;
  90591. /** @hidden */
  90592. _textures: {
  90593. [key: string]: Texture;
  90594. };
  90595. /** @hidden */
  90596. protected _fallbackTexture: Nullable<Texture>;
  90597. private _size;
  90598. private _currentRefreshId;
  90599. private _frameId;
  90600. private _refreshRate;
  90601. private _vertexBuffers;
  90602. private _indexBuffer;
  90603. private _uniforms;
  90604. private _samplers;
  90605. private _fragment;
  90606. private _floats;
  90607. private _ints;
  90608. private _floatsArrays;
  90609. private _colors3;
  90610. private _colors4;
  90611. private _vectors2;
  90612. private _vectors3;
  90613. private _matrices;
  90614. private _fallbackTextureUsed;
  90615. private _fullEngine;
  90616. private _cachedDefines;
  90617. private _contentUpdateId;
  90618. private _contentData;
  90619. /**
  90620. * Instantiates a new procedural texture.
  90621. * 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.
  90622. * This is the base class of any Procedural texture and contains most of the shareable code.
  90623. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  90624. * @param name Define the name of the texture
  90625. * @param size Define the size of the texture to create
  90626. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  90627. * @param scene Define the scene the texture belongs to
  90628. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  90629. * @param generateMipMaps Define if the texture should creates mip maps or not
  90630. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  90631. */
  90632. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  90633. /**
  90634. * The effect that is created when initializing the post process.
  90635. * @returns The created effect corresponding the the postprocess.
  90636. */
  90637. getEffect(): Effect;
  90638. /**
  90639. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90640. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90641. */
  90642. getContent(): Nullable<ArrayBufferView>;
  90643. private _createIndexBuffer;
  90644. /** @hidden */
  90645. _rebuild(): void;
  90646. /**
  90647. * Resets the texture in order to recreate its associated resources.
  90648. * This can be called in case of context loss
  90649. */
  90650. reset(): void;
  90651. protected _getDefines(): string;
  90652. /**
  90653. * Is the texture ready to be used ? (rendered at least once)
  90654. * @returns true if ready, otherwise, false.
  90655. */
  90656. isReady(): boolean;
  90657. /**
  90658. * Resets the refresh counter of the texture and start bak from scratch.
  90659. * Could be useful to regenerate the texture if it is setup to render only once.
  90660. */
  90661. resetRefreshCounter(): void;
  90662. /**
  90663. * Set the fragment shader to use in order to render the texture.
  90664. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90665. */
  90666. setFragment(fragment: any): void;
  90667. /**
  90668. * Define the refresh rate of the texture or the rendering frequency.
  90669. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90670. */
  90671. get refreshRate(): number;
  90672. set refreshRate(value: number);
  90673. /** @hidden */
  90674. _shouldRender(): boolean;
  90675. /**
  90676. * Get the size the texture is rendering at.
  90677. * @returns the size (texture is always squared)
  90678. */
  90679. getRenderSize(): number;
  90680. /**
  90681. * Resize the texture to new value.
  90682. * @param size Define the new size the texture should have
  90683. * @param generateMipMaps Define whether the new texture should create mip maps
  90684. */
  90685. resize(size: number, generateMipMaps: boolean): void;
  90686. private _checkUniform;
  90687. /**
  90688. * Set a texture in the shader program used to render.
  90689. * @param name Define the name of the uniform samplers as defined in the shader
  90690. * @param texture Define the texture to bind to this sampler
  90691. * @return the texture itself allowing "fluent" like uniform updates
  90692. */
  90693. setTexture(name: string, texture: Texture): ProceduralTexture;
  90694. /**
  90695. * Set a float in the shader.
  90696. * @param name Define the name of the uniform as defined in the shader
  90697. * @param value Define the value to give to the uniform
  90698. * @return the texture itself allowing "fluent" like uniform updates
  90699. */
  90700. setFloat(name: string, value: number): ProceduralTexture;
  90701. /**
  90702. * Set a int in the shader.
  90703. * @param name Define the name of the uniform as defined in the shader
  90704. * @param value Define the value to give to the uniform
  90705. * @return the texture itself allowing "fluent" like uniform updates
  90706. */
  90707. setInt(name: string, value: number): ProceduralTexture;
  90708. /**
  90709. * Set an array of floats in the shader.
  90710. * @param name Define the name of the uniform as defined in the shader
  90711. * @param value Define the value to give to the uniform
  90712. * @return the texture itself allowing "fluent" like uniform updates
  90713. */
  90714. setFloats(name: string, value: number[]): ProceduralTexture;
  90715. /**
  90716. * Set a vec3 in the shader from a Color3.
  90717. * @param name Define the name of the uniform as defined in the shader
  90718. * @param value Define the value to give to the uniform
  90719. * @return the texture itself allowing "fluent" like uniform updates
  90720. */
  90721. setColor3(name: string, value: Color3): ProceduralTexture;
  90722. /**
  90723. * Set a vec4 in the shader from a Color4.
  90724. * @param name Define the name of the uniform as defined in the shader
  90725. * @param value Define the value to give to the uniform
  90726. * @return the texture itself allowing "fluent" like uniform updates
  90727. */
  90728. setColor4(name: string, value: Color4): ProceduralTexture;
  90729. /**
  90730. * Set a vec2 in the shader from a Vector2.
  90731. * @param name Define the name of the uniform as defined in the shader
  90732. * @param value Define the value to give to the uniform
  90733. * @return the texture itself allowing "fluent" like uniform updates
  90734. */
  90735. setVector2(name: string, value: Vector2): ProceduralTexture;
  90736. /**
  90737. * Set a vec3 in the shader from a Vector3.
  90738. * @param name Define the name of the uniform as defined in the shader
  90739. * @param value Define the value to give to the uniform
  90740. * @return the texture itself allowing "fluent" like uniform updates
  90741. */
  90742. setVector3(name: string, value: Vector3): ProceduralTexture;
  90743. /**
  90744. * Set a mat4 in the shader from a MAtrix.
  90745. * @param name Define the name of the uniform as defined in the shader
  90746. * @param value Define the value to give to the uniform
  90747. * @return the texture itself allowing "fluent" like uniform updates
  90748. */
  90749. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90750. /**
  90751. * Render the texture to its associated render target.
  90752. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90753. */
  90754. render(useCameraPostProcess?: boolean): void;
  90755. /**
  90756. * Clone the texture.
  90757. * @returns the cloned texture
  90758. */
  90759. clone(): ProceduralTexture;
  90760. /**
  90761. * Dispose the texture and release its asoociated resources.
  90762. */
  90763. dispose(): void;
  90764. }
  90765. }
  90766. declare module BABYLON {
  90767. /**
  90768. * This represents the base class for particle system in Babylon.
  90769. * 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.
  90770. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90771. * @example https://doc.babylonjs.com/babylon101/particles
  90772. */
  90773. export class BaseParticleSystem {
  90774. /**
  90775. * Source color is added to the destination color without alpha affecting the result
  90776. */
  90777. static BLENDMODE_ONEONE: number;
  90778. /**
  90779. * Blend current color and particle color using particle’s alpha
  90780. */
  90781. static BLENDMODE_STANDARD: number;
  90782. /**
  90783. * Add current color and particle color multiplied by particle’s alpha
  90784. */
  90785. static BLENDMODE_ADD: number;
  90786. /**
  90787. * Multiply current color with particle color
  90788. */
  90789. static BLENDMODE_MULTIPLY: number;
  90790. /**
  90791. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90792. */
  90793. static BLENDMODE_MULTIPLYADD: number;
  90794. /**
  90795. * List of animations used by the particle system.
  90796. */
  90797. animations: Animation[];
  90798. /**
  90799. * Gets or sets the unique id of the particle system
  90800. */
  90801. uniqueId: number;
  90802. /**
  90803. * The id of the Particle system.
  90804. */
  90805. id: string;
  90806. /**
  90807. * The friendly name of the Particle system.
  90808. */
  90809. name: string;
  90810. /**
  90811. * Snippet ID if the particle system was created from the snippet server
  90812. */
  90813. snippetId: string;
  90814. /**
  90815. * The rendering group used by the Particle system to chose when to render.
  90816. */
  90817. renderingGroupId: number;
  90818. /**
  90819. * The emitter represents the Mesh or position we are attaching the particle system to.
  90820. */
  90821. emitter: Nullable<AbstractMesh | Vector3>;
  90822. /**
  90823. * The maximum number of particles to emit per frame
  90824. */
  90825. emitRate: number;
  90826. /**
  90827. * If you want to launch only a few particles at once, that can be done, as well.
  90828. */
  90829. manualEmitCount: number;
  90830. /**
  90831. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90832. */
  90833. updateSpeed: number;
  90834. /**
  90835. * The amount of time the particle system is running (depends of the overall update speed).
  90836. */
  90837. targetStopDuration: number;
  90838. /**
  90839. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90840. */
  90841. disposeOnStop: boolean;
  90842. /**
  90843. * Minimum power of emitting particles.
  90844. */
  90845. minEmitPower: number;
  90846. /**
  90847. * Maximum power of emitting particles.
  90848. */
  90849. maxEmitPower: number;
  90850. /**
  90851. * Minimum life time of emitting particles.
  90852. */
  90853. minLifeTime: number;
  90854. /**
  90855. * Maximum life time of emitting particles.
  90856. */
  90857. maxLifeTime: number;
  90858. /**
  90859. * Minimum Size of emitting particles.
  90860. */
  90861. minSize: number;
  90862. /**
  90863. * Maximum Size of emitting particles.
  90864. */
  90865. maxSize: number;
  90866. /**
  90867. * Minimum scale of emitting particles on X axis.
  90868. */
  90869. minScaleX: number;
  90870. /**
  90871. * Maximum scale of emitting particles on X axis.
  90872. */
  90873. maxScaleX: number;
  90874. /**
  90875. * Minimum scale of emitting particles on Y axis.
  90876. */
  90877. minScaleY: number;
  90878. /**
  90879. * Maximum scale of emitting particles on Y axis.
  90880. */
  90881. maxScaleY: number;
  90882. /**
  90883. * Gets or sets the minimal initial rotation in radians.
  90884. */
  90885. minInitialRotation: number;
  90886. /**
  90887. * Gets or sets the maximal initial rotation in radians.
  90888. */
  90889. maxInitialRotation: number;
  90890. /**
  90891. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90892. */
  90893. minAngularSpeed: number;
  90894. /**
  90895. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90896. */
  90897. maxAngularSpeed: number;
  90898. /**
  90899. * The texture used to render each particle. (this can be a spritesheet)
  90900. */
  90901. particleTexture: Nullable<Texture>;
  90902. /**
  90903. * The layer mask we are rendering the particles through.
  90904. */
  90905. layerMask: number;
  90906. /**
  90907. * This can help using your own shader to render the particle system.
  90908. * The according effect will be created
  90909. */
  90910. customShader: any;
  90911. /**
  90912. * By default particle system starts as soon as they are created. This prevents the
  90913. * automatic start to happen and let you decide when to start emitting particles.
  90914. */
  90915. preventAutoStart: boolean;
  90916. private _noiseTexture;
  90917. /**
  90918. * Gets or sets a texture used to add random noise to particle positions
  90919. */
  90920. get noiseTexture(): Nullable<ProceduralTexture>;
  90921. set noiseTexture(value: Nullable<ProceduralTexture>);
  90922. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90923. noiseStrength: Vector3;
  90924. /**
  90925. * Callback triggered when the particle animation is ending.
  90926. */
  90927. onAnimationEnd: Nullable<() => void>;
  90928. /**
  90929. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90930. */
  90931. blendMode: number;
  90932. /**
  90933. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90934. * to override the particles.
  90935. */
  90936. forceDepthWrite: boolean;
  90937. /** 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 */
  90938. preWarmCycles: number;
  90939. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90940. preWarmStepOffset: number;
  90941. /**
  90942. * 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)
  90943. */
  90944. spriteCellChangeSpeed: number;
  90945. /**
  90946. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90947. */
  90948. startSpriteCellID: number;
  90949. /**
  90950. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90951. */
  90952. endSpriteCellID: number;
  90953. /**
  90954. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90955. */
  90956. spriteCellWidth: number;
  90957. /**
  90958. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90959. */
  90960. spriteCellHeight: number;
  90961. /**
  90962. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90963. */
  90964. spriteRandomStartCell: boolean;
  90965. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90966. translationPivot: Vector2;
  90967. /** @hidden */
  90968. protected _isAnimationSheetEnabled: boolean;
  90969. /**
  90970. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90971. */
  90972. beginAnimationOnStart: boolean;
  90973. /**
  90974. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90975. */
  90976. beginAnimationFrom: number;
  90977. /**
  90978. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90979. */
  90980. beginAnimationTo: number;
  90981. /**
  90982. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90983. */
  90984. beginAnimationLoop: boolean;
  90985. /**
  90986. * Gets or sets a world offset applied to all particles
  90987. */
  90988. worldOffset: Vector3;
  90989. /**
  90990. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90991. */
  90992. get isAnimationSheetEnabled(): boolean;
  90993. set isAnimationSheetEnabled(value: boolean);
  90994. /**
  90995. * Get hosting scene
  90996. * @returns the scene
  90997. */
  90998. getScene(): Nullable<Scene>;
  90999. /**
  91000. * You can use gravity if you want to give an orientation to your particles.
  91001. */
  91002. gravity: Vector3;
  91003. protected _colorGradients: Nullable<Array<ColorGradient>>;
  91004. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  91005. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  91006. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  91007. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  91008. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  91009. protected _dragGradients: Nullable<Array<FactorGradient>>;
  91010. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  91011. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  91012. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  91013. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  91014. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  91015. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  91016. /**
  91017. * Defines the delay in milliseconds before starting the system (0 by default)
  91018. */
  91019. startDelay: number;
  91020. /**
  91021. * Gets the current list of drag gradients.
  91022. * You must use addDragGradient and removeDragGradient to udpate this list
  91023. * @returns the list of drag gradients
  91024. */
  91025. getDragGradients(): Nullable<Array<FactorGradient>>;
  91026. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91027. limitVelocityDamping: number;
  91028. /**
  91029. * Gets the current list of limit velocity gradients.
  91030. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91031. * @returns the list of limit velocity gradients
  91032. */
  91033. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91034. /**
  91035. * Gets the current list of color gradients.
  91036. * You must use addColorGradient and removeColorGradient to udpate this list
  91037. * @returns the list of color gradients
  91038. */
  91039. getColorGradients(): Nullable<Array<ColorGradient>>;
  91040. /**
  91041. * Gets the current list of size gradients.
  91042. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91043. * @returns the list of size gradients
  91044. */
  91045. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91046. /**
  91047. * Gets the current list of color remap gradients.
  91048. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91049. * @returns the list of color remap gradients
  91050. */
  91051. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91052. /**
  91053. * Gets the current list of alpha remap gradients.
  91054. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91055. * @returns the list of alpha remap gradients
  91056. */
  91057. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91058. /**
  91059. * Gets the current list of life time gradients.
  91060. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91061. * @returns the list of life time gradients
  91062. */
  91063. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91064. /**
  91065. * Gets the current list of angular speed gradients.
  91066. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91067. * @returns the list of angular speed gradients
  91068. */
  91069. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91070. /**
  91071. * Gets the current list of velocity gradients.
  91072. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91073. * @returns the list of velocity gradients
  91074. */
  91075. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91076. /**
  91077. * Gets the current list of start size gradients.
  91078. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91079. * @returns the list of start size gradients
  91080. */
  91081. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91082. /**
  91083. * Gets the current list of emit rate gradients.
  91084. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91085. * @returns the list of emit rate gradients
  91086. */
  91087. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91088. /**
  91089. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91090. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91091. */
  91092. get direction1(): Vector3;
  91093. set direction1(value: Vector3);
  91094. /**
  91095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91096. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91097. */
  91098. get direction2(): Vector3;
  91099. set direction2(value: Vector3);
  91100. /**
  91101. * 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.
  91102. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91103. */
  91104. get minEmitBox(): Vector3;
  91105. set minEmitBox(value: Vector3);
  91106. /**
  91107. * 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.
  91108. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91109. */
  91110. get maxEmitBox(): Vector3;
  91111. set maxEmitBox(value: Vector3);
  91112. /**
  91113. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91114. */
  91115. color1: Color4;
  91116. /**
  91117. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  91118. */
  91119. color2: Color4;
  91120. /**
  91121. * Color the particle will have at the end of its lifetime
  91122. */
  91123. colorDead: Color4;
  91124. /**
  91125. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  91126. */
  91127. textureMask: Color4;
  91128. /**
  91129. * The particle emitter type defines the emitter used by the particle system.
  91130. * It can be for example box, sphere, or cone...
  91131. */
  91132. particleEmitterType: IParticleEmitterType;
  91133. /** @hidden */
  91134. _isSubEmitter: boolean;
  91135. /**
  91136. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91137. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91138. */
  91139. billboardMode: number;
  91140. protected _isBillboardBased: boolean;
  91141. /**
  91142. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91143. */
  91144. get isBillboardBased(): boolean;
  91145. set isBillboardBased(value: boolean);
  91146. /**
  91147. * The scene the particle system belongs to.
  91148. */
  91149. protected _scene: Nullable<Scene>;
  91150. /**
  91151. * The engine the particle system belongs to.
  91152. */
  91153. protected _engine: ThinEngine;
  91154. /**
  91155. * Local cache of defines for image processing.
  91156. */
  91157. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  91158. /**
  91159. * Default configuration related to image processing available in the standard Material.
  91160. */
  91161. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  91162. /**
  91163. * Gets the image processing configuration used either in this material.
  91164. */
  91165. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  91166. /**
  91167. * Sets the Default image processing configuration used either in the this material.
  91168. *
  91169. * If sets to null, the scene one is in use.
  91170. */
  91171. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  91172. /**
  91173. * Attaches a new image processing configuration to the Standard Material.
  91174. * @param configuration
  91175. */
  91176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  91177. /** @hidden */
  91178. protected _reset(): void;
  91179. /** @hidden */
  91180. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  91181. /**
  91182. * Instantiates a particle system.
  91183. * 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.
  91184. * @param name The name of the particle system
  91185. */
  91186. constructor(name: string);
  91187. /**
  91188. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  91189. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91190. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91191. * @returns the emitter
  91192. */
  91193. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  91194. /**
  91195. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  91196. * @param radius The radius of the hemisphere to emit from
  91197. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91198. * @returns the emitter
  91199. */
  91200. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  91201. /**
  91202. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  91203. * @param radius The radius of the sphere to emit from
  91204. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  91205. * @returns the emitter
  91206. */
  91207. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  91208. /**
  91209. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  91210. * @param radius The radius of the sphere to emit from
  91211. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  91212. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  91213. * @returns the emitter
  91214. */
  91215. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  91216. /**
  91217. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  91218. * @param radius The radius of the emission cylinder
  91219. * @param height The height of the emission cylinder
  91220. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  91221. * @param directionRandomizer How much to randomize the particle direction [0-1]
  91222. * @returns the emitter
  91223. */
  91224. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  91225. /**
  91226. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  91227. * @param radius The radius of the cylinder to emit from
  91228. * @param height The height of the emission cylinder
  91229. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91230. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  91231. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  91232. * @returns the emitter
  91233. */
  91234. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  91235. /**
  91236. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  91237. * @param radius The radius of the cone to emit from
  91238. * @param angle The base angle of the cone
  91239. * @returns the emitter
  91240. */
  91241. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  91242. /**
  91243. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  91244. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  91245. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  91246. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91247. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  91248. * @returns the emitter
  91249. */
  91250. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  91251. }
  91252. }
  91253. declare module BABYLON {
  91254. /**
  91255. * Type of sub emitter
  91256. */
  91257. export enum SubEmitterType {
  91258. /**
  91259. * Attached to the particle over it's lifetime
  91260. */
  91261. ATTACHED = 0,
  91262. /**
  91263. * Created when the particle dies
  91264. */
  91265. END = 1
  91266. }
  91267. /**
  91268. * Sub emitter class used to emit particles from an existing particle
  91269. */
  91270. export class SubEmitter {
  91271. /**
  91272. * the particle system to be used by the sub emitter
  91273. */
  91274. particleSystem: ParticleSystem;
  91275. /**
  91276. * Type of the submitter (Default: END)
  91277. */
  91278. type: SubEmitterType;
  91279. /**
  91280. * 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)
  91281. * Note: This only is supported when using an emitter of type Mesh
  91282. */
  91283. inheritDirection: boolean;
  91284. /**
  91285. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  91286. */
  91287. inheritedVelocityAmount: number;
  91288. /**
  91289. * Creates a sub emitter
  91290. * @param particleSystem the particle system to be used by the sub emitter
  91291. */
  91292. constructor(
  91293. /**
  91294. * the particle system to be used by the sub emitter
  91295. */
  91296. particleSystem: ParticleSystem);
  91297. /**
  91298. * Clones the sub emitter
  91299. * @returns the cloned sub emitter
  91300. */
  91301. clone(): SubEmitter;
  91302. /**
  91303. * Serialize current object to a JSON object
  91304. * @returns the serialized object
  91305. */
  91306. serialize(): any;
  91307. /** @hidden */
  91308. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  91309. /**
  91310. * Creates a new SubEmitter from a serialized JSON version
  91311. * @param serializationObject defines the JSON object to read from
  91312. * @param sceneOrEngine defines the hosting scene or the hosting engine
  91313. * @param rootUrl defines the rootUrl for data loading
  91314. * @returns a new SubEmitter
  91315. */
  91316. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  91317. /** Release associated resources */
  91318. dispose(): void;
  91319. }
  91320. }
  91321. declare module BABYLON {
  91322. /** @hidden */
  91323. export var imageProcessingDeclaration: {
  91324. name: string;
  91325. shader: string;
  91326. };
  91327. }
  91328. declare module BABYLON {
  91329. /** @hidden */
  91330. export var imageProcessingFunctions: {
  91331. name: string;
  91332. shader: string;
  91333. };
  91334. }
  91335. declare module BABYLON {
  91336. /** @hidden */
  91337. export var particlesPixelShader: {
  91338. name: string;
  91339. shader: string;
  91340. };
  91341. }
  91342. declare module BABYLON {
  91343. /** @hidden */
  91344. export var particlesVertexShader: {
  91345. name: string;
  91346. shader: string;
  91347. };
  91348. }
  91349. declare module BABYLON {
  91350. /**
  91351. * This represents a particle system in Babylon.
  91352. * 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.
  91353. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91354. * @example https://doc.babylonjs.com/babylon101/particles
  91355. */
  91356. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  91357. /**
  91358. * Billboard mode will only apply to Y axis
  91359. */
  91360. static readonly BILLBOARDMODE_Y: number;
  91361. /**
  91362. * Billboard mode will apply to all axes
  91363. */
  91364. static readonly BILLBOARDMODE_ALL: number;
  91365. /**
  91366. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  91367. */
  91368. static readonly BILLBOARDMODE_STRETCHED: number;
  91369. /**
  91370. * This function can be defined to provide custom update for active particles.
  91371. * This function will be called instead of regular update (age, position, color, etc.).
  91372. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  91373. */
  91374. updateFunction: (particles: Particle[]) => void;
  91375. private _emitterWorldMatrix;
  91376. /**
  91377. * This function can be defined to specify initial direction for every new particle.
  91378. * It by default use the emitterType defined function
  91379. */
  91380. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91381. /**
  91382. * This function can be defined to specify initial position for every new particle.
  91383. * It by default use the emitterType defined function
  91384. */
  91385. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  91386. /**
  91387. * @hidden
  91388. */
  91389. _inheritedVelocityOffset: Vector3;
  91390. /**
  91391. * An event triggered when the system is disposed
  91392. */
  91393. onDisposeObservable: Observable<IParticleSystem>;
  91394. private _onDisposeObserver;
  91395. /**
  91396. * Sets a callback that will be triggered when the system is disposed
  91397. */
  91398. set onDispose(callback: () => void);
  91399. private _particles;
  91400. private _epsilon;
  91401. private _capacity;
  91402. private _stockParticles;
  91403. private _newPartsExcess;
  91404. private _vertexData;
  91405. private _vertexBuffer;
  91406. private _vertexBuffers;
  91407. private _spriteBuffer;
  91408. private _indexBuffer;
  91409. private _effect;
  91410. private _customEffect;
  91411. private _cachedDefines;
  91412. private _scaledColorStep;
  91413. private _colorDiff;
  91414. private _scaledDirection;
  91415. private _scaledGravity;
  91416. private _currentRenderId;
  91417. private _alive;
  91418. private _useInstancing;
  91419. private _started;
  91420. private _stopped;
  91421. private _actualFrame;
  91422. private _scaledUpdateSpeed;
  91423. private _vertexBufferSize;
  91424. /** @hidden */
  91425. _currentEmitRateGradient: Nullable<FactorGradient>;
  91426. /** @hidden */
  91427. _currentEmitRate1: number;
  91428. /** @hidden */
  91429. _currentEmitRate2: number;
  91430. /** @hidden */
  91431. _currentStartSizeGradient: Nullable<FactorGradient>;
  91432. /** @hidden */
  91433. _currentStartSize1: number;
  91434. /** @hidden */
  91435. _currentStartSize2: number;
  91436. private readonly _rawTextureWidth;
  91437. private _rampGradientsTexture;
  91438. private _useRampGradients;
  91439. /** Gets or sets a matrix to use to compute projection */
  91440. defaultProjectionMatrix: Matrix;
  91441. /** Gets or sets a boolean indicating that ramp gradients must be used
  91442. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  91443. */
  91444. get useRampGradients(): boolean;
  91445. set useRampGradients(value: boolean);
  91446. /**
  91447. * 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.
  91448. * 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: [])
  91449. */
  91450. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  91451. private _subEmitters;
  91452. /**
  91453. * @hidden
  91454. * If the particle systems emitter should be disposed when the particle system is disposed
  91455. */
  91456. _disposeEmitterOnDispose: boolean;
  91457. /**
  91458. * The current active Sub-systems, this property is used by the root particle system only.
  91459. */
  91460. activeSubSystems: Array<ParticleSystem>;
  91461. /**
  91462. * Specifies if the particles are updated in emitter local space or world space
  91463. */
  91464. isLocal: boolean;
  91465. private _rootParticleSystem;
  91466. /**
  91467. * Gets the current list of active particles
  91468. */
  91469. get particles(): Particle[];
  91470. /**
  91471. * Gets the number of particles active at the same time.
  91472. * @returns The number of active particles.
  91473. */
  91474. getActiveCount(): number;
  91475. /**
  91476. * Returns the string "ParticleSystem"
  91477. * @returns a string containing the class name
  91478. */
  91479. getClassName(): string;
  91480. /**
  91481. * Gets a boolean indicating that the system is stopping
  91482. * @returns true if the system is currently stopping
  91483. */
  91484. isStopping(): boolean;
  91485. /**
  91486. * Gets the custom effect used to render the particles
  91487. * @param blendMode Blend mode for which the effect should be retrieved
  91488. * @returns The effect
  91489. */
  91490. getCustomEffect(blendMode?: number): Nullable<Effect>;
  91491. /**
  91492. * Sets the custom effect used to render the particles
  91493. * @param effect The effect to set
  91494. * @param blendMode Blend mode for which the effect should be set
  91495. */
  91496. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  91497. /** @hidden */
  91498. private _onBeforeDrawParticlesObservable;
  91499. /**
  91500. * Observable that will be called just before the particles are drawn
  91501. */
  91502. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  91503. /**
  91504. * Gets the name of the particle vertex shader
  91505. */
  91506. get vertexShaderName(): string;
  91507. /**
  91508. * Instantiates a particle system.
  91509. * 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.
  91510. * @param name The name of the particle system
  91511. * @param capacity The max number of particles alive at the same time
  91512. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  91513. * @param customEffect a custom effect used to change the way particles are rendered by default
  91514. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  91515. * @param epsilon Offset used to render the particles
  91516. */
  91517. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  91518. private _addFactorGradient;
  91519. private _removeFactorGradient;
  91520. /**
  91521. * Adds a new life time gradient
  91522. * @param gradient defines the gradient to use (between 0 and 1)
  91523. * @param factor defines the life time factor to affect to the specified gradient
  91524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91525. * @returns the current particle system
  91526. */
  91527. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91528. /**
  91529. * Remove a specific life time gradient
  91530. * @param gradient defines the gradient to remove
  91531. * @returns the current particle system
  91532. */
  91533. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91534. /**
  91535. * Adds a new size gradient
  91536. * @param gradient defines the gradient to use (between 0 and 1)
  91537. * @param factor defines the size factor to affect to the specified gradient
  91538. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91539. * @returns the current particle system
  91540. */
  91541. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91542. /**
  91543. * Remove a specific size gradient
  91544. * @param gradient defines the gradient to remove
  91545. * @returns the current particle system
  91546. */
  91547. removeSizeGradient(gradient: number): IParticleSystem;
  91548. /**
  91549. * Adds a new color remap gradient
  91550. * @param gradient defines the gradient to use (between 0 and 1)
  91551. * @param min defines the color remap minimal range
  91552. * @param max defines the color remap maximal range
  91553. * @returns the current particle system
  91554. */
  91555. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91556. /**
  91557. * Remove a specific color remap gradient
  91558. * @param gradient defines the gradient to remove
  91559. * @returns the current particle system
  91560. */
  91561. removeColorRemapGradient(gradient: number): IParticleSystem;
  91562. /**
  91563. * Adds a new alpha remap gradient
  91564. * @param gradient defines the gradient to use (between 0 and 1)
  91565. * @param min defines the alpha remap minimal range
  91566. * @param max defines the alpha remap maximal range
  91567. * @returns the current particle system
  91568. */
  91569. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  91570. /**
  91571. * Remove a specific alpha remap gradient
  91572. * @param gradient defines the gradient to remove
  91573. * @returns the current particle system
  91574. */
  91575. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  91576. /**
  91577. * Adds a new angular speed gradient
  91578. * @param gradient defines the gradient to use (between 0 and 1)
  91579. * @param factor defines the angular speed to affect to the specified gradient
  91580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91581. * @returns the current particle system
  91582. */
  91583. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91584. /**
  91585. * Remove a specific angular speed gradient
  91586. * @param gradient defines the gradient to remove
  91587. * @returns the current particle system
  91588. */
  91589. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91590. /**
  91591. * Adds a new velocity gradient
  91592. * @param gradient defines the gradient to use (between 0 and 1)
  91593. * @param factor defines the velocity to affect to the specified gradient
  91594. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91595. * @returns the current particle system
  91596. */
  91597. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91598. /**
  91599. * Remove a specific velocity gradient
  91600. * @param gradient defines the gradient to remove
  91601. * @returns the current particle system
  91602. */
  91603. removeVelocityGradient(gradient: number): IParticleSystem;
  91604. /**
  91605. * Adds a new limit velocity gradient
  91606. * @param gradient defines the gradient to use (between 0 and 1)
  91607. * @param factor defines the limit velocity value to affect to the specified gradient
  91608. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91609. * @returns the current particle system
  91610. */
  91611. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91612. /**
  91613. * Remove a specific limit velocity gradient
  91614. * @param gradient defines the gradient to remove
  91615. * @returns the current particle system
  91616. */
  91617. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91618. /**
  91619. * Adds a new drag gradient
  91620. * @param gradient defines the gradient to use (between 0 and 1)
  91621. * @param factor defines the drag value to affect to the specified gradient
  91622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91623. * @returns the current particle system
  91624. */
  91625. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91626. /**
  91627. * Remove a specific drag gradient
  91628. * @param gradient defines the gradient to remove
  91629. * @returns the current particle system
  91630. */
  91631. removeDragGradient(gradient: number): IParticleSystem;
  91632. /**
  91633. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91634. * @param gradient defines the gradient to use (between 0 and 1)
  91635. * @param factor defines the emit rate value to affect to the specified gradient
  91636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91637. * @returns the current particle system
  91638. */
  91639. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91640. /**
  91641. * Remove a specific emit rate gradient
  91642. * @param gradient defines the gradient to remove
  91643. * @returns the current particle system
  91644. */
  91645. removeEmitRateGradient(gradient: number): IParticleSystem;
  91646. /**
  91647. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91648. * @param gradient defines the gradient to use (between 0 and 1)
  91649. * @param factor defines the start size value to affect to the specified gradient
  91650. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91651. * @returns the current particle system
  91652. */
  91653. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91654. /**
  91655. * Remove a specific start size gradient
  91656. * @param gradient defines the gradient to remove
  91657. * @returns the current particle system
  91658. */
  91659. removeStartSizeGradient(gradient: number): IParticleSystem;
  91660. private _createRampGradientTexture;
  91661. /**
  91662. * Gets the current list of ramp gradients.
  91663. * You must use addRampGradient and removeRampGradient to udpate this list
  91664. * @returns the list of ramp gradients
  91665. */
  91666. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91667. /** Force the system to rebuild all gradients that need to be resync */
  91668. forceRefreshGradients(): void;
  91669. private _syncRampGradientTexture;
  91670. /**
  91671. * Adds a new ramp gradient used to remap particle colors
  91672. * @param gradient defines the gradient to use (between 0 and 1)
  91673. * @param color defines the color to affect to the specified gradient
  91674. * @returns the current particle system
  91675. */
  91676. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91677. /**
  91678. * Remove a specific ramp gradient
  91679. * @param gradient defines the gradient to remove
  91680. * @returns the current particle system
  91681. */
  91682. removeRampGradient(gradient: number): ParticleSystem;
  91683. /**
  91684. * Adds a new color gradient
  91685. * @param gradient defines the gradient to use (between 0 and 1)
  91686. * @param color1 defines the color to affect to the specified gradient
  91687. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91688. * @returns this particle system
  91689. */
  91690. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91691. /**
  91692. * Remove a specific color gradient
  91693. * @param gradient defines the gradient to remove
  91694. * @returns this particle system
  91695. */
  91696. removeColorGradient(gradient: number): IParticleSystem;
  91697. private _fetchR;
  91698. protected _reset(): void;
  91699. private _resetEffect;
  91700. private _createVertexBuffers;
  91701. private _createIndexBuffer;
  91702. /**
  91703. * Gets the maximum number of particles active at the same time.
  91704. * @returns The max number of active particles.
  91705. */
  91706. getCapacity(): number;
  91707. /**
  91708. * Gets whether there are still active particles in the system.
  91709. * @returns True if it is alive, otherwise false.
  91710. */
  91711. isAlive(): boolean;
  91712. /**
  91713. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91714. * @returns True if it has been started, otherwise false.
  91715. */
  91716. isStarted(): boolean;
  91717. private _prepareSubEmitterInternalArray;
  91718. /**
  91719. * Starts the particle system and begins to emit
  91720. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91721. */
  91722. start(delay?: number): void;
  91723. /**
  91724. * Stops the particle system.
  91725. * @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.
  91726. */
  91727. stop(stopSubEmitters?: boolean): void;
  91728. /**
  91729. * Remove all active particles
  91730. */
  91731. reset(): void;
  91732. /**
  91733. * @hidden (for internal use only)
  91734. */
  91735. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91736. /**
  91737. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91738. * Its lifetime will start back at 0.
  91739. */
  91740. recycleParticle: (particle: Particle) => void;
  91741. private _stopSubEmitters;
  91742. private _createParticle;
  91743. private _removeFromRoot;
  91744. private _emitFromParticle;
  91745. private _update;
  91746. /** @hidden */
  91747. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91748. /** @hidden */
  91749. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91750. /**
  91751. * Fill the defines array according to the current settings of the particle system
  91752. * @param defines Array to be updated
  91753. * @param blendMode blend mode to take into account when updating the array
  91754. */
  91755. fillDefines(defines: Array<string>, blendMode: number): void;
  91756. /**
  91757. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91758. * @param uniforms Uniforms array to fill
  91759. * @param attributes Attributes array to fill
  91760. * @param samplers Samplers array to fill
  91761. */
  91762. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91763. /** @hidden */
  91764. private _getEffect;
  91765. /**
  91766. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91767. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91768. */
  91769. animate(preWarmOnly?: boolean): void;
  91770. private _appendParticleVertices;
  91771. /**
  91772. * Rebuilds the particle system.
  91773. */
  91774. rebuild(): void;
  91775. /**
  91776. * Is this system ready to be used/rendered
  91777. * @return true if the system is ready
  91778. */
  91779. isReady(): boolean;
  91780. private _render;
  91781. /**
  91782. * Renders the particle system in its current state.
  91783. * @returns the current number of particles
  91784. */
  91785. render(): number;
  91786. /**
  91787. * Disposes the particle system and free the associated resources
  91788. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91789. */
  91790. dispose(disposeTexture?: boolean): void;
  91791. /**
  91792. * Clones the particle system.
  91793. * @param name The name of the cloned object
  91794. * @param newEmitter The new emitter to use
  91795. * @returns the cloned particle system
  91796. */
  91797. clone(name: string, newEmitter: any): ParticleSystem;
  91798. /**
  91799. * Serializes the particle system to a JSON object
  91800. * @param serializeTexture defines if the texture must be serialized as well
  91801. * @returns the JSON object
  91802. */
  91803. serialize(serializeTexture?: boolean): any;
  91804. /** @hidden */
  91805. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91806. /** @hidden */
  91807. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  91808. /**
  91809. * Parses a JSON object to create a particle system.
  91810. * @param parsedParticleSystem The JSON object to parse
  91811. * @param sceneOrEngine The scene or the engine to create the particle system in
  91812. * @param rootUrl The root url to use to load external dependencies like texture
  91813. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91814. * @returns the Parsed particle system
  91815. */
  91816. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91817. }
  91818. }
  91819. declare module BABYLON {
  91820. /**
  91821. * A particle represents one of the element emitted by a particle system.
  91822. * This is mainly define by its coordinates, direction, velocity and age.
  91823. */
  91824. export class Particle {
  91825. /**
  91826. * The particle system the particle belongs to.
  91827. */
  91828. particleSystem: ParticleSystem;
  91829. private static _Count;
  91830. /**
  91831. * Unique ID of the particle
  91832. */
  91833. id: number;
  91834. /**
  91835. * The world position of the particle in the scene.
  91836. */
  91837. position: Vector3;
  91838. /**
  91839. * The world direction of the particle in the scene.
  91840. */
  91841. direction: Vector3;
  91842. /**
  91843. * The color of the particle.
  91844. */
  91845. color: Color4;
  91846. /**
  91847. * The color change of the particle per step.
  91848. */
  91849. colorStep: Color4;
  91850. /**
  91851. * Defines how long will the life of the particle be.
  91852. */
  91853. lifeTime: number;
  91854. /**
  91855. * The current age of the particle.
  91856. */
  91857. age: number;
  91858. /**
  91859. * The current size of the particle.
  91860. */
  91861. size: number;
  91862. /**
  91863. * The current scale of the particle.
  91864. */
  91865. scale: Vector2;
  91866. /**
  91867. * The current angle of the particle.
  91868. */
  91869. angle: number;
  91870. /**
  91871. * Defines how fast is the angle changing.
  91872. */
  91873. angularSpeed: number;
  91874. /**
  91875. * Defines the cell index used by the particle to be rendered from a sprite.
  91876. */
  91877. cellIndex: number;
  91878. /**
  91879. * The information required to support color remapping
  91880. */
  91881. remapData: Vector4;
  91882. /** @hidden */
  91883. _randomCellOffset?: number;
  91884. /** @hidden */
  91885. _initialDirection: Nullable<Vector3>;
  91886. /** @hidden */
  91887. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91888. /** @hidden */
  91889. _initialStartSpriteCellID: number;
  91890. /** @hidden */
  91891. _initialEndSpriteCellID: number;
  91892. /** @hidden */
  91893. _currentColorGradient: Nullable<ColorGradient>;
  91894. /** @hidden */
  91895. _currentColor1: Color4;
  91896. /** @hidden */
  91897. _currentColor2: Color4;
  91898. /** @hidden */
  91899. _currentSizeGradient: Nullable<FactorGradient>;
  91900. /** @hidden */
  91901. _currentSize1: number;
  91902. /** @hidden */
  91903. _currentSize2: number;
  91904. /** @hidden */
  91905. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91906. /** @hidden */
  91907. _currentAngularSpeed1: number;
  91908. /** @hidden */
  91909. _currentAngularSpeed2: number;
  91910. /** @hidden */
  91911. _currentVelocityGradient: Nullable<FactorGradient>;
  91912. /** @hidden */
  91913. _currentVelocity1: number;
  91914. /** @hidden */
  91915. _currentVelocity2: number;
  91916. /** @hidden */
  91917. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91918. /** @hidden */
  91919. _currentLimitVelocity1: number;
  91920. /** @hidden */
  91921. _currentLimitVelocity2: number;
  91922. /** @hidden */
  91923. _currentDragGradient: Nullable<FactorGradient>;
  91924. /** @hidden */
  91925. _currentDrag1: number;
  91926. /** @hidden */
  91927. _currentDrag2: number;
  91928. /** @hidden */
  91929. _randomNoiseCoordinates1: Vector3;
  91930. /** @hidden */
  91931. _randomNoiseCoordinates2: Vector3;
  91932. /** @hidden */
  91933. _localPosition?: Vector3;
  91934. /**
  91935. * Creates a new instance Particle
  91936. * @param particleSystem the particle system the particle belongs to
  91937. */
  91938. constructor(
  91939. /**
  91940. * The particle system the particle belongs to.
  91941. */
  91942. particleSystem: ParticleSystem);
  91943. private updateCellInfoFromSystem;
  91944. /**
  91945. * Defines how the sprite cell index is updated for the particle
  91946. */
  91947. updateCellIndex(): void;
  91948. /** @hidden */
  91949. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91950. /** @hidden */
  91951. _inheritParticleInfoToSubEmitters(): void;
  91952. /** @hidden */
  91953. _reset(): void;
  91954. /**
  91955. * Copy the properties of particle to another one.
  91956. * @param other the particle to copy the information to.
  91957. */
  91958. copyTo(other: Particle): void;
  91959. }
  91960. }
  91961. declare module BABYLON {
  91962. /**
  91963. * Particle emitter represents a volume emitting particles.
  91964. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91965. */
  91966. export interface IParticleEmitterType {
  91967. /**
  91968. * Called by the particle System when the direction is computed for the created particle.
  91969. * @param worldMatrix is the world matrix of the particle system
  91970. * @param directionToUpdate is the direction vector to update with the result
  91971. * @param particle is the particle we are computed the direction for
  91972. * @param isLocal defines if the direction should be set in local space
  91973. */
  91974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91975. /**
  91976. * Called by the particle System when the position is computed for the created particle.
  91977. * @param worldMatrix is the world matrix of the particle system
  91978. * @param positionToUpdate is the position vector to update with the result
  91979. * @param particle is the particle we are computed the position for
  91980. * @param isLocal defines if the position should be set in local space
  91981. */
  91982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91983. /**
  91984. * Clones the current emitter and returns a copy of it
  91985. * @returns the new emitter
  91986. */
  91987. clone(): IParticleEmitterType;
  91988. /**
  91989. * Called by the GPUParticleSystem to setup the update shader
  91990. * @param effect defines the update shader
  91991. */
  91992. applyToShader(effect: Effect): void;
  91993. /**
  91994. * Returns a string to use to update the GPU particles update shader
  91995. * @returns the effect defines string
  91996. */
  91997. getEffectDefines(): string;
  91998. /**
  91999. * Returns a string representing the class name
  92000. * @returns a string containing the class name
  92001. */
  92002. getClassName(): string;
  92003. /**
  92004. * Serializes the particle system to a JSON object.
  92005. * @returns the JSON object
  92006. */
  92007. serialize(): any;
  92008. /**
  92009. * Parse properties from a JSON object
  92010. * @param serializationObject defines the JSON object
  92011. * @param scene defines the hosting scene
  92012. */
  92013. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92014. }
  92015. }
  92016. declare module BABYLON {
  92017. /**
  92018. * Particle emitter emitting particles from the inside of a box.
  92019. * It emits the particles randomly between 2 given directions.
  92020. */
  92021. export class BoxParticleEmitter implements IParticleEmitterType {
  92022. /**
  92023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92024. */
  92025. direction1: Vector3;
  92026. /**
  92027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92028. */
  92029. direction2: Vector3;
  92030. /**
  92031. * 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.
  92032. */
  92033. minEmitBox: Vector3;
  92034. /**
  92035. * 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.
  92036. */
  92037. maxEmitBox: Vector3;
  92038. /**
  92039. * Creates a new instance BoxParticleEmitter
  92040. */
  92041. constructor();
  92042. /**
  92043. * Called by the particle System when the direction is computed for the created particle.
  92044. * @param worldMatrix is the world matrix of the particle system
  92045. * @param directionToUpdate is the direction vector to update with the result
  92046. * @param particle is the particle we are computed the direction for
  92047. * @param isLocal defines if the direction should be set in local space
  92048. */
  92049. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92050. /**
  92051. * Called by the particle System when the position is computed for the created particle.
  92052. * @param worldMatrix is the world matrix of the particle system
  92053. * @param positionToUpdate is the position vector to update with the result
  92054. * @param particle is the particle we are computed the position for
  92055. * @param isLocal defines if the position should be set in local space
  92056. */
  92057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92058. /**
  92059. * Clones the current emitter and returns a copy of it
  92060. * @returns the new emitter
  92061. */
  92062. clone(): BoxParticleEmitter;
  92063. /**
  92064. * Called by the GPUParticleSystem to setup the update shader
  92065. * @param effect defines the update shader
  92066. */
  92067. applyToShader(effect: Effect): void;
  92068. /**
  92069. * Returns a string to use to update the GPU particles update shader
  92070. * @returns a string containng the defines string
  92071. */
  92072. getEffectDefines(): string;
  92073. /**
  92074. * Returns the string "BoxParticleEmitter"
  92075. * @returns a string containing the class name
  92076. */
  92077. getClassName(): string;
  92078. /**
  92079. * Serializes the particle system to a JSON object.
  92080. * @returns the JSON object
  92081. */
  92082. serialize(): any;
  92083. /**
  92084. * Parse properties from a JSON object
  92085. * @param serializationObject defines the JSON object
  92086. */
  92087. parse(serializationObject: any): void;
  92088. }
  92089. }
  92090. declare module BABYLON {
  92091. /**
  92092. * Particle emitter emitting particles from the inside of a cone.
  92093. * It emits the particles alongside the cone volume from the base to the particle.
  92094. * The emission direction might be randomized.
  92095. */
  92096. export class ConeParticleEmitter implements IParticleEmitterType {
  92097. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92098. directionRandomizer: number;
  92099. private _radius;
  92100. private _angle;
  92101. private _height;
  92102. /**
  92103. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  92104. */
  92105. radiusRange: number;
  92106. /**
  92107. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  92108. */
  92109. heightRange: number;
  92110. /**
  92111. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  92112. */
  92113. emitFromSpawnPointOnly: boolean;
  92114. /**
  92115. * Gets or sets the radius of the emission cone
  92116. */
  92117. get radius(): number;
  92118. set radius(value: number);
  92119. /**
  92120. * Gets or sets the angle of the emission cone
  92121. */
  92122. get angle(): number;
  92123. set angle(value: number);
  92124. private _buildHeight;
  92125. /**
  92126. * Creates a new instance ConeParticleEmitter
  92127. * @param radius the radius of the emission cone (1 by default)
  92128. * @param angle the cone base angle (PI by default)
  92129. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  92130. */
  92131. constructor(radius?: number, angle?: number,
  92132. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  92133. directionRandomizer?: number);
  92134. /**
  92135. * Called by the particle System when the direction is computed for the created particle.
  92136. * @param worldMatrix is the world matrix of the particle system
  92137. * @param directionToUpdate is the direction vector to update with the result
  92138. * @param particle is the particle we are computed the direction for
  92139. * @param isLocal defines if the direction should be set in local space
  92140. */
  92141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92142. /**
  92143. * Called by the particle System when the position is computed for the created particle.
  92144. * @param worldMatrix is the world matrix of the particle system
  92145. * @param positionToUpdate is the position vector to update with the result
  92146. * @param particle is the particle we are computed the position for
  92147. * @param isLocal defines if the position should be set in local space
  92148. */
  92149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92150. /**
  92151. * Clones the current emitter and returns a copy of it
  92152. * @returns the new emitter
  92153. */
  92154. clone(): ConeParticleEmitter;
  92155. /**
  92156. * Called by the GPUParticleSystem to setup the update shader
  92157. * @param effect defines the update shader
  92158. */
  92159. applyToShader(effect: Effect): void;
  92160. /**
  92161. * Returns a string to use to update the GPU particles update shader
  92162. * @returns a string containng the defines string
  92163. */
  92164. getEffectDefines(): string;
  92165. /**
  92166. * Returns the string "ConeParticleEmitter"
  92167. * @returns a string containing the class name
  92168. */
  92169. getClassName(): string;
  92170. /**
  92171. * Serializes the particle system to a JSON object.
  92172. * @returns the JSON object
  92173. */
  92174. serialize(): any;
  92175. /**
  92176. * Parse properties from a JSON object
  92177. * @param serializationObject defines the JSON object
  92178. */
  92179. parse(serializationObject: any): void;
  92180. }
  92181. }
  92182. declare module BABYLON {
  92183. /**
  92184. * Particle emitter emitting particles from the inside of a cylinder.
  92185. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  92186. */
  92187. export class CylinderParticleEmitter implements IParticleEmitterType {
  92188. /**
  92189. * The radius of the emission cylinder.
  92190. */
  92191. radius: number;
  92192. /**
  92193. * The height of the emission cylinder.
  92194. */
  92195. height: number;
  92196. /**
  92197. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92198. */
  92199. radiusRange: number;
  92200. /**
  92201. * How much to randomize the particle direction [0-1].
  92202. */
  92203. directionRandomizer: number;
  92204. /**
  92205. * Creates a new instance CylinderParticleEmitter
  92206. * @param radius the radius of the emission cylinder (1 by default)
  92207. * @param height the height of the emission cylinder (1 by default)
  92208. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92209. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92210. */
  92211. constructor(
  92212. /**
  92213. * The radius of the emission cylinder.
  92214. */
  92215. radius?: number,
  92216. /**
  92217. * The height of the emission cylinder.
  92218. */
  92219. height?: number,
  92220. /**
  92221. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92222. */
  92223. radiusRange?: number,
  92224. /**
  92225. * How much to randomize the particle direction [0-1].
  92226. */
  92227. directionRandomizer?: number);
  92228. /**
  92229. * Called by the particle System when the direction is computed for the created particle.
  92230. * @param worldMatrix is the world matrix of the particle system
  92231. * @param directionToUpdate is the direction vector to update with the result
  92232. * @param particle is the particle we are computed the direction for
  92233. * @param isLocal defines if the direction should be set in local space
  92234. */
  92235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92236. /**
  92237. * Called by the particle System when the position is computed for the created particle.
  92238. * @param worldMatrix is the world matrix of the particle system
  92239. * @param positionToUpdate is the position vector to update with the result
  92240. * @param particle is the particle we are computed the position for
  92241. * @param isLocal defines if the position should be set in local space
  92242. */
  92243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92244. /**
  92245. * Clones the current emitter and returns a copy of it
  92246. * @returns the new emitter
  92247. */
  92248. clone(): CylinderParticleEmitter;
  92249. /**
  92250. * Called by the GPUParticleSystem to setup the update shader
  92251. * @param effect defines the update shader
  92252. */
  92253. applyToShader(effect: Effect): void;
  92254. /**
  92255. * Returns a string to use to update the GPU particles update shader
  92256. * @returns a string containng the defines string
  92257. */
  92258. getEffectDefines(): string;
  92259. /**
  92260. * Returns the string "CylinderParticleEmitter"
  92261. * @returns a string containing the class name
  92262. */
  92263. getClassName(): string;
  92264. /**
  92265. * Serializes the particle system to a JSON object.
  92266. * @returns the JSON object
  92267. */
  92268. serialize(): any;
  92269. /**
  92270. * Parse properties from a JSON object
  92271. * @param serializationObject defines the JSON object
  92272. */
  92273. parse(serializationObject: any): void;
  92274. }
  92275. /**
  92276. * Particle emitter emitting particles from the inside of a cylinder.
  92277. * It emits the particles randomly between two vectors.
  92278. */
  92279. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  92280. /**
  92281. * The min limit of the emission direction.
  92282. */
  92283. direction1: Vector3;
  92284. /**
  92285. * The max limit of the emission direction.
  92286. */
  92287. direction2: Vector3;
  92288. /**
  92289. * Creates a new instance CylinderDirectedParticleEmitter
  92290. * @param radius the radius of the emission cylinder (1 by default)
  92291. * @param height the height of the emission cylinder (1 by default)
  92292. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92293. * @param direction1 the min limit of the emission direction (up vector by default)
  92294. * @param direction2 the max limit of the emission direction (up vector by default)
  92295. */
  92296. constructor(radius?: number, height?: number, radiusRange?: number,
  92297. /**
  92298. * The min limit of the emission direction.
  92299. */
  92300. direction1?: Vector3,
  92301. /**
  92302. * The max limit of the emission direction.
  92303. */
  92304. direction2?: Vector3);
  92305. /**
  92306. * Called by the particle System when the direction is computed for the created particle.
  92307. * @param worldMatrix is the world matrix of the particle system
  92308. * @param directionToUpdate is the direction vector to update with the result
  92309. * @param particle is the particle we are computed the direction for
  92310. */
  92311. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92312. /**
  92313. * Clones the current emitter and returns a copy of it
  92314. * @returns the new emitter
  92315. */
  92316. clone(): CylinderDirectedParticleEmitter;
  92317. /**
  92318. * Called by the GPUParticleSystem to setup the update shader
  92319. * @param effect defines the update shader
  92320. */
  92321. applyToShader(effect: Effect): void;
  92322. /**
  92323. * Returns a string to use to update the GPU particles update shader
  92324. * @returns a string containng the defines string
  92325. */
  92326. getEffectDefines(): string;
  92327. /**
  92328. * Returns the string "CylinderDirectedParticleEmitter"
  92329. * @returns a string containing the class name
  92330. */
  92331. getClassName(): string;
  92332. /**
  92333. * Serializes the particle system to a JSON object.
  92334. * @returns the JSON object
  92335. */
  92336. serialize(): any;
  92337. /**
  92338. * Parse properties from a JSON object
  92339. * @param serializationObject defines the JSON object
  92340. */
  92341. parse(serializationObject: any): void;
  92342. }
  92343. }
  92344. declare module BABYLON {
  92345. /**
  92346. * Particle emitter emitting particles from the inside of a hemisphere.
  92347. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  92348. */
  92349. export class HemisphericParticleEmitter implements IParticleEmitterType {
  92350. /**
  92351. * The radius of the emission hemisphere.
  92352. */
  92353. radius: number;
  92354. /**
  92355. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92356. */
  92357. radiusRange: number;
  92358. /**
  92359. * How much to randomize the particle direction [0-1].
  92360. */
  92361. directionRandomizer: number;
  92362. /**
  92363. * Creates a new instance HemisphericParticleEmitter
  92364. * @param radius the radius of the emission hemisphere (1 by default)
  92365. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92366. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92367. */
  92368. constructor(
  92369. /**
  92370. * The radius of the emission hemisphere.
  92371. */
  92372. radius?: number,
  92373. /**
  92374. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92375. */
  92376. radiusRange?: number,
  92377. /**
  92378. * How much to randomize the particle direction [0-1].
  92379. */
  92380. directionRandomizer?: number);
  92381. /**
  92382. * Called by the particle System when the direction is computed for the created particle.
  92383. * @param worldMatrix is the world matrix of the particle system
  92384. * @param directionToUpdate is the direction vector to update with the result
  92385. * @param particle is the particle we are computed the direction for
  92386. * @param isLocal defines if the direction should be set in local space
  92387. */
  92388. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92389. /**
  92390. * Called by the particle System when the position is computed for the created particle.
  92391. * @param worldMatrix is the world matrix of the particle system
  92392. * @param positionToUpdate is the position vector to update with the result
  92393. * @param particle is the particle we are computed the position for
  92394. * @param isLocal defines if the position should be set in local space
  92395. */
  92396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92397. /**
  92398. * Clones the current emitter and returns a copy of it
  92399. * @returns the new emitter
  92400. */
  92401. clone(): HemisphericParticleEmitter;
  92402. /**
  92403. * Called by the GPUParticleSystem to setup the update shader
  92404. * @param effect defines the update shader
  92405. */
  92406. applyToShader(effect: Effect): void;
  92407. /**
  92408. * Returns a string to use to update the GPU particles update shader
  92409. * @returns a string containng the defines string
  92410. */
  92411. getEffectDefines(): string;
  92412. /**
  92413. * Returns the string "HemisphericParticleEmitter"
  92414. * @returns a string containing the class name
  92415. */
  92416. getClassName(): string;
  92417. /**
  92418. * Serializes the particle system to a JSON object.
  92419. * @returns the JSON object
  92420. */
  92421. serialize(): any;
  92422. /**
  92423. * Parse properties from a JSON object
  92424. * @param serializationObject defines the JSON object
  92425. */
  92426. parse(serializationObject: any): void;
  92427. }
  92428. }
  92429. declare module BABYLON {
  92430. /**
  92431. * Particle emitter emitting particles from a point.
  92432. * It emits the particles randomly between 2 given directions.
  92433. */
  92434. export class PointParticleEmitter implements IParticleEmitterType {
  92435. /**
  92436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92437. */
  92438. direction1: Vector3;
  92439. /**
  92440. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92441. */
  92442. direction2: Vector3;
  92443. /**
  92444. * Creates a new instance PointParticleEmitter
  92445. */
  92446. constructor();
  92447. /**
  92448. * Called by the particle System when the direction is computed for the created particle.
  92449. * @param worldMatrix is the world matrix of the particle system
  92450. * @param directionToUpdate is the direction vector to update with the result
  92451. * @param particle is the particle we are computed the direction for
  92452. * @param isLocal defines if the direction should be set in local space
  92453. */
  92454. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92455. /**
  92456. * Called by the particle System when the position is computed for the created particle.
  92457. * @param worldMatrix is the world matrix of the particle system
  92458. * @param positionToUpdate is the position vector to update with the result
  92459. * @param particle is the particle we are computed the position for
  92460. * @param isLocal defines if the position should be set in local space
  92461. */
  92462. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92463. /**
  92464. * Clones the current emitter and returns a copy of it
  92465. * @returns the new emitter
  92466. */
  92467. clone(): PointParticleEmitter;
  92468. /**
  92469. * Called by the GPUParticleSystem to setup the update shader
  92470. * @param effect defines the update shader
  92471. */
  92472. applyToShader(effect: Effect): void;
  92473. /**
  92474. * Returns a string to use to update the GPU particles update shader
  92475. * @returns a string containng the defines string
  92476. */
  92477. getEffectDefines(): string;
  92478. /**
  92479. * Returns the string "PointParticleEmitter"
  92480. * @returns a string containing the class name
  92481. */
  92482. getClassName(): string;
  92483. /**
  92484. * Serializes the particle system to a JSON object.
  92485. * @returns the JSON object
  92486. */
  92487. serialize(): any;
  92488. /**
  92489. * Parse properties from a JSON object
  92490. * @param serializationObject defines the JSON object
  92491. */
  92492. parse(serializationObject: any): void;
  92493. }
  92494. }
  92495. declare module BABYLON {
  92496. /**
  92497. * Particle emitter emitting particles from the inside of a sphere.
  92498. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  92499. */
  92500. export class SphereParticleEmitter implements IParticleEmitterType {
  92501. /**
  92502. * The radius of the emission sphere.
  92503. */
  92504. radius: number;
  92505. /**
  92506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92507. */
  92508. radiusRange: number;
  92509. /**
  92510. * How much to randomize the particle direction [0-1].
  92511. */
  92512. directionRandomizer: number;
  92513. /**
  92514. * Creates a new instance SphereParticleEmitter
  92515. * @param radius the radius of the emission sphere (1 by default)
  92516. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92517. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  92518. */
  92519. constructor(
  92520. /**
  92521. * The radius of the emission sphere.
  92522. */
  92523. radius?: number,
  92524. /**
  92525. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  92526. */
  92527. radiusRange?: number,
  92528. /**
  92529. * How much to randomize the particle direction [0-1].
  92530. */
  92531. directionRandomizer?: number);
  92532. /**
  92533. * Called by the particle System when the direction is computed for the created particle.
  92534. * @param worldMatrix is the world matrix of the particle system
  92535. * @param directionToUpdate is the direction vector to update with the result
  92536. * @param particle is the particle we are computed the direction for
  92537. * @param isLocal defines if the direction should be set in local space
  92538. */
  92539. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92540. /**
  92541. * Called by the particle System when the position is computed for the created particle.
  92542. * @param worldMatrix is the world matrix of the particle system
  92543. * @param positionToUpdate is the position vector to update with the result
  92544. * @param particle is the particle we are computed the position for
  92545. * @param isLocal defines if the position should be set in local space
  92546. */
  92547. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92548. /**
  92549. * Clones the current emitter and returns a copy of it
  92550. * @returns the new emitter
  92551. */
  92552. clone(): SphereParticleEmitter;
  92553. /**
  92554. * Called by the GPUParticleSystem to setup the update shader
  92555. * @param effect defines the update shader
  92556. */
  92557. applyToShader(effect: Effect): void;
  92558. /**
  92559. * Returns a string to use to update the GPU particles update shader
  92560. * @returns a string containng the defines string
  92561. */
  92562. getEffectDefines(): string;
  92563. /**
  92564. * Returns the string "SphereParticleEmitter"
  92565. * @returns a string containing the class name
  92566. */
  92567. getClassName(): string;
  92568. /**
  92569. * Serializes the particle system to a JSON object.
  92570. * @returns the JSON object
  92571. */
  92572. serialize(): any;
  92573. /**
  92574. * Parse properties from a JSON object
  92575. * @param serializationObject defines the JSON object
  92576. */
  92577. parse(serializationObject: any): void;
  92578. }
  92579. /**
  92580. * Particle emitter emitting particles from the inside of a sphere.
  92581. * It emits the particles randomly between two vectors.
  92582. */
  92583. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  92584. /**
  92585. * The min limit of the emission direction.
  92586. */
  92587. direction1: Vector3;
  92588. /**
  92589. * The max limit of the emission direction.
  92590. */
  92591. direction2: Vector3;
  92592. /**
  92593. * Creates a new instance SphereDirectedParticleEmitter
  92594. * @param radius the radius of the emission sphere (1 by default)
  92595. * @param direction1 the min limit of the emission direction (up vector by default)
  92596. * @param direction2 the max limit of the emission direction (up vector by default)
  92597. */
  92598. constructor(radius?: number,
  92599. /**
  92600. * The min limit of the emission direction.
  92601. */
  92602. direction1?: Vector3,
  92603. /**
  92604. * The max limit of the emission direction.
  92605. */
  92606. direction2?: Vector3);
  92607. /**
  92608. * Called by the particle System when the direction is computed for the created particle.
  92609. * @param worldMatrix is the world matrix of the particle system
  92610. * @param directionToUpdate is the direction vector to update with the result
  92611. * @param particle is the particle we are computed the direction for
  92612. */
  92613. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  92614. /**
  92615. * Clones the current emitter and returns a copy of it
  92616. * @returns the new emitter
  92617. */
  92618. clone(): SphereDirectedParticleEmitter;
  92619. /**
  92620. * Called by the GPUParticleSystem to setup the update shader
  92621. * @param effect defines the update shader
  92622. */
  92623. applyToShader(effect: Effect): void;
  92624. /**
  92625. * Returns a string to use to update the GPU particles update shader
  92626. * @returns a string containng the defines string
  92627. */
  92628. getEffectDefines(): string;
  92629. /**
  92630. * Returns the string "SphereDirectedParticleEmitter"
  92631. * @returns a string containing the class name
  92632. */
  92633. getClassName(): string;
  92634. /**
  92635. * Serializes the particle system to a JSON object.
  92636. * @returns the JSON object
  92637. */
  92638. serialize(): any;
  92639. /**
  92640. * Parse properties from a JSON object
  92641. * @param serializationObject defines the JSON object
  92642. */
  92643. parse(serializationObject: any): void;
  92644. }
  92645. }
  92646. declare module BABYLON {
  92647. /**
  92648. * Particle emitter emitting particles from a custom list of positions.
  92649. */
  92650. export class CustomParticleEmitter implements IParticleEmitterType {
  92651. /**
  92652. * Gets or sets the position generator that will create the inital position of each particle.
  92653. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92654. */
  92655. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92656. /**
  92657. * Gets or sets the destination generator that will create the final destination of each particle.
  92658. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92659. */
  92660. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92661. /**
  92662. * Creates a new instance CustomParticleEmitter
  92663. */
  92664. constructor();
  92665. /**
  92666. * Called by the particle System when the direction is computed for the created particle.
  92667. * @param worldMatrix is the world matrix of the particle system
  92668. * @param directionToUpdate is the direction vector to update with the result
  92669. * @param particle is the particle we are computed the direction for
  92670. * @param isLocal defines if the direction should be set in local space
  92671. */
  92672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92673. /**
  92674. * Called by the particle System when the position is computed for the created particle.
  92675. * @param worldMatrix is the world matrix of the particle system
  92676. * @param positionToUpdate is the position vector to update with the result
  92677. * @param particle is the particle we are computed the position for
  92678. * @param isLocal defines if the position should be set in local space
  92679. */
  92680. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92681. /**
  92682. * Clones the current emitter and returns a copy of it
  92683. * @returns the new emitter
  92684. */
  92685. clone(): CustomParticleEmitter;
  92686. /**
  92687. * Called by the GPUParticleSystem to setup the update shader
  92688. * @param effect defines the update shader
  92689. */
  92690. applyToShader(effect: Effect): void;
  92691. /**
  92692. * Returns a string to use to update the GPU particles update shader
  92693. * @returns a string containng the defines string
  92694. */
  92695. getEffectDefines(): string;
  92696. /**
  92697. * Returns the string "PointParticleEmitter"
  92698. * @returns a string containing the class name
  92699. */
  92700. getClassName(): string;
  92701. /**
  92702. * Serializes the particle system to a JSON object.
  92703. * @returns the JSON object
  92704. */
  92705. serialize(): any;
  92706. /**
  92707. * Parse properties from a JSON object
  92708. * @param serializationObject defines the JSON object
  92709. */
  92710. parse(serializationObject: any): void;
  92711. }
  92712. }
  92713. declare module BABYLON {
  92714. /**
  92715. * Particle emitter emitting particles from the inside of a box.
  92716. * It emits the particles randomly between 2 given directions.
  92717. */
  92718. export class MeshParticleEmitter implements IParticleEmitterType {
  92719. private _indices;
  92720. private _positions;
  92721. private _normals;
  92722. private _storedNormal;
  92723. private _mesh;
  92724. /**
  92725. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92726. */
  92727. direction1: Vector3;
  92728. /**
  92729. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92730. */
  92731. direction2: Vector3;
  92732. /**
  92733. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92734. */
  92735. useMeshNormalsForDirection: boolean;
  92736. /** Defines the mesh to use as source */
  92737. get mesh(): Nullable<AbstractMesh>;
  92738. set mesh(value: Nullable<AbstractMesh>);
  92739. /**
  92740. * Creates a new instance MeshParticleEmitter
  92741. * @param mesh defines the mesh to use as source
  92742. */
  92743. constructor(mesh?: Nullable<AbstractMesh>);
  92744. /**
  92745. * Called by the particle System when the direction is computed for the created particle.
  92746. * @param worldMatrix is the world matrix of the particle system
  92747. * @param directionToUpdate is the direction vector to update with the result
  92748. * @param particle is the particle we are computed the direction for
  92749. * @param isLocal defines if the direction should be set in local space
  92750. */
  92751. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92752. /**
  92753. * Called by the particle System when the position is computed for the created particle.
  92754. * @param worldMatrix is the world matrix of the particle system
  92755. * @param positionToUpdate is the position vector to update with the result
  92756. * @param particle is the particle we are computed the position for
  92757. * @param isLocal defines if the position should be set in local space
  92758. */
  92759. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92760. /**
  92761. * Clones the current emitter and returns a copy of it
  92762. * @returns the new emitter
  92763. */
  92764. clone(): MeshParticleEmitter;
  92765. /**
  92766. * Called by the GPUParticleSystem to setup the update shader
  92767. * @param effect defines the update shader
  92768. */
  92769. applyToShader(effect: Effect): void;
  92770. /**
  92771. * Returns a string to use to update the GPU particles update shader
  92772. * @returns a string containng the defines string
  92773. */
  92774. getEffectDefines(): string;
  92775. /**
  92776. * Returns the string "BoxParticleEmitter"
  92777. * @returns a string containing the class name
  92778. */
  92779. getClassName(): string;
  92780. /**
  92781. * Serializes the particle system to a JSON object.
  92782. * @returns the JSON object
  92783. */
  92784. serialize(): any;
  92785. /**
  92786. * Parse properties from a JSON object
  92787. * @param serializationObject defines the JSON object
  92788. * @param scene defines the hosting scene
  92789. */
  92790. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92791. }
  92792. }
  92793. declare module BABYLON {
  92794. /**
  92795. * Interface representing a particle system in Babylon.js.
  92796. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92797. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92798. */
  92799. export interface IParticleSystem {
  92800. /**
  92801. * List of animations used by the particle system.
  92802. */
  92803. animations: Animation[];
  92804. /**
  92805. * The id of the Particle system.
  92806. */
  92807. id: string;
  92808. /**
  92809. * The name of the Particle system.
  92810. */
  92811. name: string;
  92812. /**
  92813. * The emitter represents the Mesh or position we are attaching the particle system to.
  92814. */
  92815. emitter: Nullable<AbstractMesh | Vector3>;
  92816. /**
  92817. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92818. */
  92819. isBillboardBased: boolean;
  92820. /**
  92821. * The rendering group used by the Particle system to chose when to render.
  92822. */
  92823. renderingGroupId: number;
  92824. /**
  92825. * The layer mask we are rendering the particles through.
  92826. */
  92827. layerMask: number;
  92828. /**
  92829. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92830. */
  92831. updateSpeed: number;
  92832. /**
  92833. * The amount of time the particle system is running (depends of the overall update speed).
  92834. */
  92835. targetStopDuration: number;
  92836. /**
  92837. * The texture used to render each particle. (this can be a spritesheet)
  92838. */
  92839. particleTexture: Nullable<BaseTexture>;
  92840. /**
  92841. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92842. */
  92843. blendMode: number;
  92844. /**
  92845. * Minimum life time of emitting particles.
  92846. */
  92847. minLifeTime: number;
  92848. /**
  92849. * Maximum life time of emitting particles.
  92850. */
  92851. maxLifeTime: number;
  92852. /**
  92853. * Minimum Size of emitting particles.
  92854. */
  92855. minSize: number;
  92856. /**
  92857. * Maximum Size of emitting particles.
  92858. */
  92859. maxSize: number;
  92860. /**
  92861. * Minimum scale of emitting particles on X axis.
  92862. */
  92863. minScaleX: number;
  92864. /**
  92865. * Maximum scale of emitting particles on X axis.
  92866. */
  92867. maxScaleX: number;
  92868. /**
  92869. * Minimum scale of emitting particles on Y axis.
  92870. */
  92871. minScaleY: number;
  92872. /**
  92873. * Maximum scale of emitting particles on Y axis.
  92874. */
  92875. maxScaleY: number;
  92876. /**
  92877. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92878. */
  92879. color1: Color4;
  92880. /**
  92881. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92882. */
  92883. color2: Color4;
  92884. /**
  92885. * Color the particle will have at the end of its lifetime.
  92886. */
  92887. colorDead: Color4;
  92888. /**
  92889. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92890. */
  92891. emitRate: number;
  92892. /**
  92893. * You can use gravity if you want to give an orientation to your particles.
  92894. */
  92895. gravity: Vector3;
  92896. /**
  92897. * Minimum power of emitting particles.
  92898. */
  92899. minEmitPower: number;
  92900. /**
  92901. * Maximum power of emitting particles.
  92902. */
  92903. maxEmitPower: number;
  92904. /**
  92905. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92906. */
  92907. minAngularSpeed: number;
  92908. /**
  92909. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92910. */
  92911. maxAngularSpeed: number;
  92912. /**
  92913. * Gets or sets the minimal initial rotation in radians.
  92914. */
  92915. minInitialRotation: number;
  92916. /**
  92917. * Gets or sets the maximal initial rotation in radians.
  92918. */
  92919. maxInitialRotation: number;
  92920. /**
  92921. * The particle emitter type defines the emitter used by the particle system.
  92922. * It can be for example box, sphere, or cone...
  92923. */
  92924. particleEmitterType: Nullable<IParticleEmitterType>;
  92925. /**
  92926. * Defines the delay in milliseconds before starting the system (0 by default)
  92927. */
  92928. startDelay: number;
  92929. /**
  92930. * 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
  92931. */
  92932. preWarmCycles: number;
  92933. /**
  92934. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92935. */
  92936. preWarmStepOffset: number;
  92937. /**
  92938. * 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)
  92939. */
  92940. spriteCellChangeSpeed: number;
  92941. /**
  92942. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92943. */
  92944. startSpriteCellID: number;
  92945. /**
  92946. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92947. */
  92948. endSpriteCellID: number;
  92949. /**
  92950. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92951. */
  92952. spriteCellWidth: number;
  92953. /**
  92954. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92955. */
  92956. spriteCellHeight: number;
  92957. /**
  92958. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92959. */
  92960. spriteRandomStartCell: boolean;
  92961. /**
  92962. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92963. */
  92964. isAnimationSheetEnabled: boolean;
  92965. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92966. translationPivot: Vector2;
  92967. /**
  92968. * Gets or sets a texture used to add random noise to particle positions
  92969. */
  92970. noiseTexture: Nullable<BaseTexture>;
  92971. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92972. noiseStrength: Vector3;
  92973. /**
  92974. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92975. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92976. */
  92977. billboardMode: number;
  92978. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92979. limitVelocityDamping: number;
  92980. /**
  92981. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92982. */
  92983. beginAnimationOnStart: boolean;
  92984. /**
  92985. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92986. */
  92987. beginAnimationFrom: number;
  92988. /**
  92989. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92990. */
  92991. beginAnimationTo: number;
  92992. /**
  92993. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92994. */
  92995. beginAnimationLoop: boolean;
  92996. /**
  92997. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92998. */
  92999. disposeOnStop: boolean;
  93000. /**
  93001. * Specifies if the particles are updated in emitter local space or world space
  93002. */
  93003. isLocal: boolean;
  93004. /** Snippet ID if the particle system was created from the snippet server */
  93005. snippetId: string;
  93006. /** Gets or sets a matrix to use to compute projection */
  93007. defaultProjectionMatrix: Matrix;
  93008. /**
  93009. * Gets the maximum number of particles active at the same time.
  93010. * @returns The max number of active particles.
  93011. */
  93012. getCapacity(): number;
  93013. /**
  93014. * Gets the number of particles active at the same time.
  93015. * @returns The number of active particles.
  93016. */
  93017. getActiveCount(): number;
  93018. /**
  93019. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93020. * @returns True if it has been started, otherwise false.
  93021. */
  93022. isStarted(): boolean;
  93023. /**
  93024. * Animates the particle system for this frame.
  93025. */
  93026. animate(): void;
  93027. /**
  93028. * Renders the particle system in its current state.
  93029. * @returns the current number of particles
  93030. */
  93031. render(): number;
  93032. /**
  93033. * Dispose the particle system and frees its associated resources.
  93034. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93035. */
  93036. dispose(disposeTexture?: boolean): void;
  93037. /**
  93038. * An event triggered when the system is disposed
  93039. */
  93040. onDisposeObservable: Observable<IParticleSystem>;
  93041. /**
  93042. * Clones the particle system.
  93043. * @param name The name of the cloned object
  93044. * @param newEmitter The new emitter to use
  93045. * @returns the cloned particle system
  93046. */
  93047. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  93048. /**
  93049. * Serializes the particle system to a JSON object
  93050. * @param serializeTexture defines if the texture must be serialized as well
  93051. * @returns the JSON object
  93052. */
  93053. serialize(serializeTexture: boolean): any;
  93054. /**
  93055. * Rebuild the particle system
  93056. */
  93057. rebuild(): void;
  93058. /** Force the system to rebuild all gradients that need to be resync */
  93059. forceRefreshGradients(): void;
  93060. /**
  93061. * Starts the particle system and begins to emit
  93062. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  93063. */
  93064. start(delay?: number): void;
  93065. /**
  93066. * Stops the particle system.
  93067. */
  93068. stop(): void;
  93069. /**
  93070. * Remove all active particles
  93071. */
  93072. reset(): void;
  93073. /**
  93074. * Gets a boolean indicating that the system is stopping
  93075. * @returns true if the system is currently stopping
  93076. */
  93077. isStopping(): boolean;
  93078. /**
  93079. * Is this system ready to be used/rendered
  93080. * @return true if the system is ready
  93081. */
  93082. isReady(): boolean;
  93083. /**
  93084. * Returns the string "ParticleSystem"
  93085. * @returns a string containing the class name
  93086. */
  93087. getClassName(): string;
  93088. /**
  93089. * Gets the custom effect used to render the particles
  93090. * @param blendMode Blend mode for which the effect should be retrieved
  93091. * @returns The effect
  93092. */
  93093. getCustomEffect(blendMode: number): Nullable<Effect>;
  93094. /**
  93095. * Sets the custom effect used to render the particles
  93096. * @param effect The effect to set
  93097. * @param blendMode Blend mode for which the effect should be set
  93098. */
  93099. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  93100. /**
  93101. * Fill the defines array according to the current settings of the particle system
  93102. * @param defines Array to be updated
  93103. * @param blendMode blend mode to take into account when updating the array
  93104. */
  93105. fillDefines(defines: Array<string>, blendMode: number): void;
  93106. /**
  93107. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93108. * @param uniforms Uniforms array to fill
  93109. * @param attributes Attributes array to fill
  93110. * @param samplers Samplers array to fill
  93111. */
  93112. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93113. /**
  93114. * Observable that will be called just before the particles are drawn
  93115. */
  93116. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  93117. /**
  93118. * Gets the name of the particle vertex shader
  93119. */
  93120. vertexShaderName: string;
  93121. /**
  93122. * Adds a new color gradient
  93123. * @param gradient defines the gradient to use (between 0 and 1)
  93124. * @param color1 defines the color to affect to the specified gradient
  93125. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93126. * @returns the current particle system
  93127. */
  93128. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93129. /**
  93130. * Remove a specific color gradient
  93131. * @param gradient defines the gradient to remove
  93132. * @returns the current particle system
  93133. */
  93134. removeColorGradient(gradient: number): IParticleSystem;
  93135. /**
  93136. * Adds a new size gradient
  93137. * @param gradient defines the gradient to use (between 0 and 1)
  93138. * @param factor defines the size factor to affect to the specified gradient
  93139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93140. * @returns the current particle system
  93141. */
  93142. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93143. /**
  93144. * Remove a specific size gradient
  93145. * @param gradient defines the gradient to remove
  93146. * @returns the current particle system
  93147. */
  93148. removeSizeGradient(gradient: number): IParticleSystem;
  93149. /**
  93150. * Gets the current list of color gradients.
  93151. * You must use addColorGradient and removeColorGradient to udpate this list
  93152. * @returns the list of color gradients
  93153. */
  93154. getColorGradients(): Nullable<Array<ColorGradient>>;
  93155. /**
  93156. * Gets the current list of size gradients.
  93157. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93158. * @returns the list of size gradients
  93159. */
  93160. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93161. /**
  93162. * Gets the current list of angular speed gradients.
  93163. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93164. * @returns the list of angular speed gradients
  93165. */
  93166. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93167. /**
  93168. * Adds a new angular speed gradient
  93169. * @param gradient defines the gradient to use (between 0 and 1)
  93170. * @param factor defines the angular speed to affect to the specified gradient
  93171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93172. * @returns the current particle system
  93173. */
  93174. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93175. /**
  93176. * Remove a specific angular speed gradient
  93177. * @param gradient defines the gradient to remove
  93178. * @returns the current particle system
  93179. */
  93180. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93181. /**
  93182. * Gets the current list of velocity gradients.
  93183. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93184. * @returns the list of velocity gradients
  93185. */
  93186. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93187. /**
  93188. * Adds a new velocity gradient
  93189. * @param gradient defines the gradient to use (between 0 and 1)
  93190. * @param factor defines the velocity to affect to the specified gradient
  93191. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93192. * @returns the current particle system
  93193. */
  93194. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93195. /**
  93196. * Remove a specific velocity gradient
  93197. * @param gradient defines the gradient to remove
  93198. * @returns the current particle system
  93199. */
  93200. removeVelocityGradient(gradient: number): IParticleSystem;
  93201. /**
  93202. * Gets the current list of limit velocity gradients.
  93203. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93204. * @returns the list of limit velocity gradients
  93205. */
  93206. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93207. /**
  93208. * Adds a new limit velocity gradient
  93209. * @param gradient defines the gradient to use (between 0 and 1)
  93210. * @param factor defines the limit velocity to affect to the specified gradient
  93211. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93212. * @returns the current particle system
  93213. */
  93214. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93215. /**
  93216. * Remove a specific limit velocity gradient
  93217. * @param gradient defines the gradient to remove
  93218. * @returns the current particle system
  93219. */
  93220. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93221. /**
  93222. * Adds a new drag gradient
  93223. * @param gradient defines the gradient to use (between 0 and 1)
  93224. * @param factor defines the drag to affect to the specified gradient
  93225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93226. * @returns the current particle system
  93227. */
  93228. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93229. /**
  93230. * Remove a specific drag gradient
  93231. * @param gradient defines the gradient to remove
  93232. * @returns the current particle system
  93233. */
  93234. removeDragGradient(gradient: number): IParticleSystem;
  93235. /**
  93236. * Gets the current list of drag gradients.
  93237. * You must use addDragGradient and removeDragGradient to udpate this list
  93238. * @returns the list of drag gradients
  93239. */
  93240. getDragGradients(): Nullable<Array<FactorGradient>>;
  93241. /**
  93242. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93243. * @param gradient defines the gradient to use (between 0 and 1)
  93244. * @param factor defines the emit rate to affect to the specified gradient
  93245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93246. * @returns the current particle system
  93247. */
  93248. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93249. /**
  93250. * Remove a specific emit rate gradient
  93251. * @param gradient defines the gradient to remove
  93252. * @returns the current particle system
  93253. */
  93254. removeEmitRateGradient(gradient: number): IParticleSystem;
  93255. /**
  93256. * Gets the current list of emit rate gradients.
  93257. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93258. * @returns the list of emit rate gradients
  93259. */
  93260. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93261. /**
  93262. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93263. * @param gradient defines the gradient to use (between 0 and 1)
  93264. * @param factor defines the start size to affect to the specified gradient
  93265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93266. * @returns the current particle system
  93267. */
  93268. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93269. /**
  93270. * Remove a specific start size gradient
  93271. * @param gradient defines the gradient to remove
  93272. * @returns the current particle system
  93273. */
  93274. removeStartSizeGradient(gradient: number): IParticleSystem;
  93275. /**
  93276. * Gets the current list of start size gradients.
  93277. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93278. * @returns the list of start size gradients
  93279. */
  93280. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93281. /**
  93282. * Adds a new life time gradient
  93283. * @param gradient defines the gradient to use (between 0 and 1)
  93284. * @param factor defines the life time factor to affect to the specified gradient
  93285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93286. * @returns the current particle system
  93287. */
  93288. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93289. /**
  93290. * Remove a specific life time gradient
  93291. * @param gradient defines the gradient to remove
  93292. * @returns the current particle system
  93293. */
  93294. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93295. /**
  93296. * Gets the current list of life time gradients.
  93297. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93298. * @returns the list of life time gradients
  93299. */
  93300. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93301. /**
  93302. * Gets the current list of color gradients.
  93303. * You must use addColorGradient and removeColorGradient to udpate this list
  93304. * @returns the list of color gradients
  93305. */
  93306. getColorGradients(): Nullable<Array<ColorGradient>>;
  93307. /**
  93308. * Adds a new ramp gradient used to remap particle colors
  93309. * @param gradient defines the gradient to use (between 0 and 1)
  93310. * @param color defines the color to affect to the specified gradient
  93311. * @returns the current particle system
  93312. */
  93313. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  93314. /**
  93315. * Gets the current list of ramp gradients.
  93316. * You must use addRampGradient and removeRampGradient to udpate this list
  93317. * @returns the list of ramp gradients
  93318. */
  93319. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93320. /** Gets or sets a boolean indicating that ramp gradients must be used
  93321. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93322. */
  93323. useRampGradients: boolean;
  93324. /**
  93325. * Adds a new color remap gradient
  93326. * @param gradient defines the gradient to use (between 0 and 1)
  93327. * @param min defines the color remap minimal range
  93328. * @param max defines the color remap maximal range
  93329. * @returns the current particle system
  93330. */
  93331. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93332. /**
  93333. * Gets the current list of color remap gradients.
  93334. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93335. * @returns the list of color remap gradients
  93336. */
  93337. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93338. /**
  93339. * Adds a new alpha remap gradient
  93340. * @param gradient defines the gradient to use (between 0 and 1)
  93341. * @param min defines the alpha remap minimal range
  93342. * @param max defines the alpha remap maximal range
  93343. * @returns the current particle system
  93344. */
  93345. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93346. /**
  93347. * Gets the current list of alpha remap gradients.
  93348. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93349. * @returns the list of alpha remap gradients
  93350. */
  93351. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93352. /**
  93353. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93354. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93355. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93356. * @returns the emitter
  93357. */
  93358. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93359. /**
  93360. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93361. * @param radius The radius of the hemisphere to emit from
  93362. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93363. * @returns the emitter
  93364. */
  93365. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  93366. /**
  93367. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93368. * @param radius The radius of the sphere to emit from
  93369. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93370. * @returns the emitter
  93371. */
  93372. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  93373. /**
  93374. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93375. * @param radius The radius of the sphere to emit from
  93376. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93377. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93378. * @returns the emitter
  93379. */
  93380. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93381. /**
  93382. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93383. * @param radius The radius of the emission cylinder
  93384. * @param height The height of the emission cylinder
  93385. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93386. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93387. * @returns the emitter
  93388. */
  93389. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  93390. /**
  93391. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93392. * @param radius The radius of the cylinder to emit from
  93393. * @param height The height of the emission cylinder
  93394. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93397. * @returns the emitter
  93398. */
  93399. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  93400. /**
  93401. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93402. * @param radius The radius of the cone to emit from
  93403. * @param angle The base angle of the cone
  93404. * @returns the emitter
  93405. */
  93406. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  93407. /**
  93408. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93409. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93410. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93411. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93412. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93413. * @returns the emitter
  93414. */
  93415. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93416. /**
  93417. * Get hosting scene
  93418. * @returns the scene
  93419. */
  93420. getScene(): Nullable<Scene>;
  93421. }
  93422. }
  93423. declare module BABYLON {
  93424. /**
  93425. * 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.
  93426. * @see https://doc.babylonjs.com/how_to/transformnode
  93427. */
  93428. export class TransformNode extends Node {
  93429. /**
  93430. * Object will not rotate to face the camera
  93431. */
  93432. static BILLBOARDMODE_NONE: number;
  93433. /**
  93434. * Object will rotate to face the camera but only on the x axis
  93435. */
  93436. static BILLBOARDMODE_X: number;
  93437. /**
  93438. * Object will rotate to face the camera but only on the y axis
  93439. */
  93440. static BILLBOARDMODE_Y: number;
  93441. /**
  93442. * Object will rotate to face the camera but only on the z axis
  93443. */
  93444. static BILLBOARDMODE_Z: number;
  93445. /**
  93446. * Object will rotate to face the camera
  93447. */
  93448. static BILLBOARDMODE_ALL: number;
  93449. /**
  93450. * Object will rotate to face the camera's position instead of orientation
  93451. */
  93452. static BILLBOARDMODE_USE_POSITION: number;
  93453. private static _TmpRotation;
  93454. private static _TmpScaling;
  93455. private static _TmpTranslation;
  93456. private _forward;
  93457. private _forwardInverted;
  93458. private _up;
  93459. private _right;
  93460. private _rightInverted;
  93461. private _position;
  93462. private _rotation;
  93463. private _rotationQuaternion;
  93464. protected _scaling: Vector3;
  93465. protected _isDirty: boolean;
  93466. private _transformToBoneReferal;
  93467. private _isAbsoluteSynced;
  93468. private _billboardMode;
  93469. /**
  93470. * Gets or sets the billboard mode. Default is 0.
  93471. *
  93472. * | Value | Type | Description |
  93473. * | --- | --- | --- |
  93474. * | 0 | BILLBOARDMODE_NONE | |
  93475. * | 1 | BILLBOARDMODE_X | |
  93476. * | 2 | BILLBOARDMODE_Y | |
  93477. * | 4 | BILLBOARDMODE_Z | |
  93478. * | 7 | BILLBOARDMODE_ALL | |
  93479. *
  93480. */
  93481. get billboardMode(): number;
  93482. set billboardMode(value: number);
  93483. private _preserveParentRotationForBillboard;
  93484. /**
  93485. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  93486. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  93487. */
  93488. get preserveParentRotationForBillboard(): boolean;
  93489. set preserveParentRotationForBillboard(value: boolean);
  93490. /**
  93491. * 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
  93492. */
  93493. scalingDeterminant: number;
  93494. private _infiniteDistance;
  93495. /**
  93496. * Gets or sets the distance of the object to max, often used by skybox
  93497. */
  93498. get infiniteDistance(): boolean;
  93499. set infiniteDistance(value: boolean);
  93500. /**
  93501. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  93502. * By default the system will update normals to compensate
  93503. */
  93504. ignoreNonUniformScaling: boolean;
  93505. /**
  93506. * 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
  93507. */
  93508. reIntegrateRotationIntoRotationQuaternion: boolean;
  93509. /** @hidden */
  93510. _poseMatrix: Nullable<Matrix>;
  93511. /** @hidden */
  93512. _localMatrix: Matrix;
  93513. private _usePivotMatrix;
  93514. private _absolutePosition;
  93515. private _absoluteScaling;
  93516. private _absoluteRotationQuaternion;
  93517. private _pivotMatrix;
  93518. private _pivotMatrixInverse;
  93519. protected _postMultiplyPivotMatrix: boolean;
  93520. protected _isWorldMatrixFrozen: boolean;
  93521. /** @hidden */
  93522. _indexInSceneTransformNodesArray: number;
  93523. /**
  93524. * An event triggered after the world matrix is updated
  93525. */
  93526. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  93527. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  93528. /**
  93529. * Gets a string identifying the name of the class
  93530. * @returns "TransformNode" string
  93531. */
  93532. getClassName(): string;
  93533. /**
  93534. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  93535. */
  93536. get position(): Vector3;
  93537. set position(newPosition: Vector3);
  93538. /**
  93539. * 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)).
  93540. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  93541. */
  93542. get rotation(): Vector3;
  93543. set rotation(newRotation: Vector3);
  93544. /**
  93545. * 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)).
  93546. */
  93547. get scaling(): Vector3;
  93548. set scaling(newScaling: Vector3);
  93549. /**
  93550. * 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).
  93551. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  93552. */
  93553. get rotationQuaternion(): Nullable<Quaternion>;
  93554. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  93555. /**
  93556. * The forward direction of that transform in world space.
  93557. */
  93558. get forward(): Vector3;
  93559. /**
  93560. * The up direction of that transform in world space.
  93561. */
  93562. get up(): Vector3;
  93563. /**
  93564. * The right direction of that transform in world space.
  93565. */
  93566. get right(): Vector3;
  93567. /**
  93568. * Copies the parameter passed Matrix into the mesh Pose matrix.
  93569. * @param matrix the matrix to copy the pose from
  93570. * @returns this TransformNode.
  93571. */
  93572. updatePoseMatrix(matrix: Matrix): TransformNode;
  93573. /**
  93574. * Returns the mesh Pose matrix.
  93575. * @returns the pose matrix
  93576. */
  93577. getPoseMatrix(): Matrix;
  93578. /** @hidden */
  93579. _isSynchronized(): boolean;
  93580. /** @hidden */
  93581. _initCache(): void;
  93582. /**
  93583. * Flag the transform node as dirty (Forcing it to update everything)
  93584. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  93585. * @returns this transform node
  93586. */
  93587. markAsDirty(property: string): TransformNode;
  93588. /**
  93589. * Returns the current mesh absolute position.
  93590. * Returns a Vector3.
  93591. */
  93592. get absolutePosition(): Vector3;
  93593. /**
  93594. * Returns the current mesh absolute scaling.
  93595. * Returns a Vector3.
  93596. */
  93597. get absoluteScaling(): Vector3;
  93598. /**
  93599. * Returns the current mesh absolute rotation.
  93600. * Returns a Quaternion.
  93601. */
  93602. get absoluteRotationQuaternion(): Quaternion;
  93603. /**
  93604. * Sets a new matrix to apply before all other transformation
  93605. * @param matrix defines the transform matrix
  93606. * @returns the current TransformNode
  93607. */
  93608. setPreTransformMatrix(matrix: Matrix): TransformNode;
  93609. /**
  93610. * Sets a new pivot matrix to the current node
  93611. * @param matrix defines the new pivot matrix to use
  93612. * @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
  93613. * @returns the current TransformNode
  93614. */
  93615. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  93616. /**
  93617. * Returns the mesh pivot matrix.
  93618. * Default : Identity.
  93619. * @returns the matrix
  93620. */
  93621. getPivotMatrix(): Matrix;
  93622. /**
  93623. * Instantiate (when possible) or clone that node with its hierarchy
  93624. * @param newParent defines the new parent to use for the instance (or clone)
  93625. * @param options defines options to configure how copy is done
  93626. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  93627. * @returns an instance (or a clone) of the current node with its hiearchy
  93628. */
  93629. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93630. doNotInstantiate: boolean;
  93631. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93632. /**
  93633. * Prevents the World matrix to be computed any longer
  93634. * @param newWorldMatrix defines an optional matrix to use as world matrix
  93635. * @returns the TransformNode.
  93636. */
  93637. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  93638. /**
  93639. * Allows back the World matrix computation.
  93640. * @returns the TransformNode.
  93641. */
  93642. unfreezeWorldMatrix(): this;
  93643. /**
  93644. * True if the World matrix has been frozen.
  93645. */
  93646. get isWorldMatrixFrozen(): boolean;
  93647. /**
  93648. * Retuns the mesh absolute position in the World.
  93649. * @returns a Vector3.
  93650. */
  93651. getAbsolutePosition(): Vector3;
  93652. /**
  93653. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93654. * @param absolutePosition the absolute position to set
  93655. * @returns the TransformNode.
  93656. */
  93657. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93658. /**
  93659. * Sets the mesh position in its local space.
  93660. * @param vector3 the position to set in localspace
  93661. * @returns the TransformNode.
  93662. */
  93663. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93664. /**
  93665. * Returns the mesh position in the local space from the current World matrix values.
  93666. * @returns a new Vector3.
  93667. */
  93668. getPositionExpressedInLocalSpace(): Vector3;
  93669. /**
  93670. * Translates the mesh along the passed Vector3 in its local space.
  93671. * @param vector3 the distance to translate in localspace
  93672. * @returns the TransformNode.
  93673. */
  93674. locallyTranslate(vector3: Vector3): TransformNode;
  93675. private static _lookAtVectorCache;
  93676. /**
  93677. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93678. * @param targetPoint the position (must be in same space as current mesh) to look at
  93679. * @param yawCor optional yaw (y-axis) correction in radians
  93680. * @param pitchCor optional pitch (x-axis) correction in radians
  93681. * @param rollCor optional roll (z-axis) correction in radians
  93682. * @param space the choosen space of the target
  93683. * @returns the TransformNode.
  93684. */
  93685. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93686. /**
  93687. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93688. * This Vector3 is expressed in the World space.
  93689. * @param localAxis axis to rotate
  93690. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93691. */
  93692. getDirection(localAxis: Vector3): Vector3;
  93693. /**
  93694. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93695. * localAxis is expressed in the mesh local space.
  93696. * result is computed in the Wordl space from the mesh World matrix.
  93697. * @param localAxis axis to rotate
  93698. * @param result the resulting transformnode
  93699. * @returns this TransformNode.
  93700. */
  93701. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93702. /**
  93703. * Sets this transform node rotation to the given local axis.
  93704. * @param localAxis the axis in local space
  93705. * @param yawCor optional yaw (y-axis) correction in radians
  93706. * @param pitchCor optional pitch (x-axis) correction in radians
  93707. * @param rollCor optional roll (z-axis) correction in radians
  93708. * @returns this TransformNode
  93709. */
  93710. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93711. /**
  93712. * Sets a new pivot point to the current node
  93713. * @param point defines the new pivot point to use
  93714. * @param space defines if the point is in world or local space (local by default)
  93715. * @returns the current TransformNode
  93716. */
  93717. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93718. /**
  93719. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93720. * @returns the pivot point
  93721. */
  93722. getPivotPoint(): Vector3;
  93723. /**
  93724. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93725. * @param result the vector3 to store the result
  93726. * @returns this TransformNode.
  93727. */
  93728. getPivotPointToRef(result: Vector3): TransformNode;
  93729. /**
  93730. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93731. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93732. */
  93733. getAbsolutePivotPoint(): Vector3;
  93734. /**
  93735. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93736. * @param result vector3 to store the result
  93737. * @returns this TransformNode.
  93738. */
  93739. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93740. /**
  93741. * Defines the passed node as the parent of the current node.
  93742. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93743. * @see https://doc.babylonjs.com/how_to/parenting
  93744. * @param node the node ot set as the parent
  93745. * @returns this TransformNode.
  93746. */
  93747. setParent(node: Nullable<Node>): TransformNode;
  93748. private _nonUniformScaling;
  93749. /**
  93750. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93751. */
  93752. get nonUniformScaling(): boolean;
  93753. /** @hidden */
  93754. _updateNonUniformScalingState(value: boolean): boolean;
  93755. /**
  93756. * Attach the current TransformNode to another TransformNode associated with a bone
  93757. * @param bone Bone affecting the TransformNode
  93758. * @param affectedTransformNode TransformNode associated with the bone
  93759. * @returns this object
  93760. */
  93761. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93762. /**
  93763. * Detach the transform node if its associated with a bone
  93764. * @returns this object
  93765. */
  93766. detachFromBone(): TransformNode;
  93767. private static _rotationAxisCache;
  93768. /**
  93769. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93770. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93771. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93772. * The passed axis is also normalized.
  93773. * @param axis the axis to rotate around
  93774. * @param amount the amount to rotate in radians
  93775. * @param space Space to rotate in (Default: local)
  93776. * @returns the TransformNode.
  93777. */
  93778. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93779. /**
  93780. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93781. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93782. * The passed axis is also normalized. .
  93783. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93784. * @param point the point to rotate around
  93785. * @param axis the axis to rotate around
  93786. * @param amount the amount to rotate in radians
  93787. * @returns the TransformNode
  93788. */
  93789. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93790. /**
  93791. * Translates the mesh along the axis vector for the passed distance in the given space.
  93792. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93793. * @param axis the axis to translate in
  93794. * @param distance the distance to translate
  93795. * @param space Space to rotate in (Default: local)
  93796. * @returns the TransformNode.
  93797. */
  93798. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93799. /**
  93800. * Adds a rotation step to the mesh current rotation.
  93801. * x, y, z are Euler angles expressed in radians.
  93802. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93803. * This means this rotation is made in the mesh local space only.
  93804. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93805. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93806. * ```javascript
  93807. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93808. * ```
  93809. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93810. * 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.
  93811. * @param x Rotation to add
  93812. * @param y Rotation to add
  93813. * @param z Rotation to add
  93814. * @returns the TransformNode.
  93815. */
  93816. addRotation(x: number, y: number, z: number): TransformNode;
  93817. /**
  93818. * @hidden
  93819. */
  93820. protected _getEffectiveParent(): Nullable<Node>;
  93821. /**
  93822. * Computes the world matrix of the node
  93823. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93824. * @returns the world matrix
  93825. */
  93826. computeWorldMatrix(force?: boolean): Matrix;
  93827. /**
  93828. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93829. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93830. */
  93831. resetLocalMatrix(independentOfChildren?: boolean): void;
  93832. protected _afterComputeWorldMatrix(): void;
  93833. /**
  93834. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93835. * @param func callback function to add
  93836. *
  93837. * @returns the TransformNode.
  93838. */
  93839. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93840. /**
  93841. * Removes a registered callback function.
  93842. * @param func callback function to remove
  93843. * @returns the TransformNode.
  93844. */
  93845. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93846. /**
  93847. * Gets the position of the current mesh in camera space
  93848. * @param camera defines the camera to use
  93849. * @returns a position
  93850. */
  93851. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93852. /**
  93853. * Returns the distance from the mesh to the active camera
  93854. * @param camera defines the camera to use
  93855. * @returns the distance
  93856. */
  93857. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93858. /**
  93859. * Clone the current transform node
  93860. * @param name Name of the new clone
  93861. * @param newParent New parent for the clone
  93862. * @param doNotCloneChildren Do not clone children hierarchy
  93863. * @returns the new transform node
  93864. */
  93865. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93866. /**
  93867. * Serializes the objects information.
  93868. * @param currentSerializationObject defines the object to serialize in
  93869. * @returns the serialized object
  93870. */
  93871. serialize(currentSerializationObject?: any): any;
  93872. /**
  93873. * Returns a new TransformNode object parsed from the source provided.
  93874. * @param parsedTransformNode is the source.
  93875. * @param scene the scne the object belongs to
  93876. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93877. * @returns a new TransformNode object parsed from the source provided.
  93878. */
  93879. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93880. /**
  93881. * Get all child-transformNodes of this node
  93882. * @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
  93883. * @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
  93884. * @returns an array of TransformNode
  93885. */
  93886. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93887. /**
  93888. * Releases resources associated with this transform node.
  93889. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93890. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93891. */
  93892. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93893. /**
  93894. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93895. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93896. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93897. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93898. * @returns the current mesh
  93899. */
  93900. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93901. private _syncAbsoluteScalingAndRotation;
  93902. }
  93903. }
  93904. declare module BABYLON {
  93905. /**
  93906. * Class used to override all child animations of a given target
  93907. */
  93908. export class AnimationPropertiesOverride {
  93909. /**
  93910. * Gets or sets a value indicating if animation blending must be used
  93911. */
  93912. enableBlending: boolean;
  93913. /**
  93914. * Gets or sets the blending speed to use when enableBlending is true
  93915. */
  93916. blendingSpeed: number;
  93917. /**
  93918. * Gets or sets the default loop mode to use
  93919. */
  93920. loopMode: number;
  93921. }
  93922. }
  93923. declare module BABYLON {
  93924. /**
  93925. * Class used to store bone information
  93926. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93927. */
  93928. export class Bone extends Node {
  93929. /**
  93930. * defines the bone name
  93931. */
  93932. name: string;
  93933. private static _tmpVecs;
  93934. private static _tmpQuat;
  93935. private static _tmpMats;
  93936. /**
  93937. * Gets the list of child bones
  93938. */
  93939. children: Bone[];
  93940. /** Gets the animations associated with this bone */
  93941. animations: Animation[];
  93942. /**
  93943. * Gets or sets bone length
  93944. */
  93945. length: number;
  93946. /**
  93947. * @hidden Internal only
  93948. * Set this value to map this bone to a different index in the transform matrices
  93949. * Set this value to -1 to exclude the bone from the transform matrices
  93950. */
  93951. _index: Nullable<number>;
  93952. private _skeleton;
  93953. private _localMatrix;
  93954. private _restPose;
  93955. private _bindPose;
  93956. private _baseMatrix;
  93957. private _absoluteTransform;
  93958. private _invertedAbsoluteTransform;
  93959. private _parent;
  93960. private _scalingDeterminant;
  93961. private _worldTransform;
  93962. private _localScaling;
  93963. private _localRotation;
  93964. private _localPosition;
  93965. private _needToDecompose;
  93966. private _needToCompose;
  93967. /** @hidden */
  93968. _linkedTransformNode: Nullable<TransformNode>;
  93969. /** @hidden */
  93970. _waitingTransformNodeId: Nullable<string>;
  93971. /** @hidden */
  93972. get _matrix(): Matrix;
  93973. /** @hidden */
  93974. set _matrix(value: Matrix);
  93975. /**
  93976. * Create a new bone
  93977. * @param name defines the bone name
  93978. * @param skeleton defines the parent skeleton
  93979. * @param parentBone defines the parent (can be null if the bone is the root)
  93980. * @param localMatrix defines the local matrix
  93981. * @param restPose defines the rest pose matrix
  93982. * @param baseMatrix defines the base matrix
  93983. * @param index defines index of the bone in the hiearchy
  93984. */
  93985. constructor(
  93986. /**
  93987. * defines the bone name
  93988. */
  93989. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93990. /**
  93991. * Gets the current object class name.
  93992. * @return the class name
  93993. */
  93994. getClassName(): string;
  93995. /**
  93996. * Gets the parent skeleton
  93997. * @returns a skeleton
  93998. */
  93999. getSkeleton(): Skeleton;
  94000. /**
  94001. * Gets parent bone
  94002. * @returns a bone or null if the bone is the root of the bone hierarchy
  94003. */
  94004. getParent(): Nullable<Bone>;
  94005. /**
  94006. * Returns an array containing the root bones
  94007. * @returns an array containing the root bones
  94008. */
  94009. getChildren(): Array<Bone>;
  94010. /**
  94011. * Gets the node index in matrix array generated for rendering
  94012. * @returns the node index
  94013. */
  94014. getIndex(): number;
  94015. /**
  94016. * Sets the parent bone
  94017. * @param parent defines the parent (can be null if the bone is the root)
  94018. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94019. */
  94020. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  94021. /**
  94022. * Gets the local matrix
  94023. * @returns a matrix
  94024. */
  94025. getLocalMatrix(): Matrix;
  94026. /**
  94027. * Gets the base matrix (initial matrix which remains unchanged)
  94028. * @returns a matrix
  94029. */
  94030. getBaseMatrix(): Matrix;
  94031. /**
  94032. * Gets the rest pose matrix
  94033. * @returns a matrix
  94034. */
  94035. getRestPose(): Matrix;
  94036. /**
  94037. * Sets the rest pose matrix
  94038. * @param matrix the local-space rest pose to set for this bone
  94039. */
  94040. setRestPose(matrix: Matrix): void;
  94041. /**
  94042. * Gets the bind pose matrix
  94043. * @returns the bind pose matrix
  94044. */
  94045. getBindPose(): Matrix;
  94046. /**
  94047. * Sets the bind pose matrix
  94048. * @param matrix the local-space bind pose to set for this bone
  94049. */
  94050. setBindPose(matrix: Matrix): void;
  94051. /**
  94052. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  94053. */
  94054. getWorldMatrix(): Matrix;
  94055. /**
  94056. * Sets the local matrix to rest pose matrix
  94057. */
  94058. returnToRest(): void;
  94059. /**
  94060. * Gets the inverse of the absolute transform matrix.
  94061. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  94062. * @returns a matrix
  94063. */
  94064. getInvertedAbsoluteTransform(): Matrix;
  94065. /**
  94066. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  94067. * @returns a matrix
  94068. */
  94069. getAbsoluteTransform(): Matrix;
  94070. /**
  94071. * Links with the given transform node.
  94072. * The local matrix of this bone is copied from the transform node every frame.
  94073. * @param transformNode defines the transform node to link to
  94074. */
  94075. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  94076. /**
  94077. * Gets the node used to drive the bone's transformation
  94078. * @returns a transform node or null
  94079. */
  94080. getTransformNode(): Nullable<TransformNode>;
  94081. /** Gets or sets current position (in local space) */
  94082. get position(): Vector3;
  94083. set position(newPosition: Vector3);
  94084. /** Gets or sets current rotation (in local space) */
  94085. get rotation(): Vector3;
  94086. set rotation(newRotation: Vector3);
  94087. /** Gets or sets current rotation quaternion (in local space) */
  94088. get rotationQuaternion(): Quaternion;
  94089. set rotationQuaternion(newRotation: Quaternion);
  94090. /** Gets or sets current scaling (in local space) */
  94091. get scaling(): Vector3;
  94092. set scaling(newScaling: Vector3);
  94093. /**
  94094. * Gets the animation properties override
  94095. */
  94096. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94097. private _decompose;
  94098. private _compose;
  94099. /**
  94100. * Update the base and local matrices
  94101. * @param matrix defines the new base or local matrix
  94102. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94103. * @param updateLocalMatrix defines if the local matrix should be updated
  94104. */
  94105. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  94106. /** @hidden */
  94107. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  94108. /**
  94109. * Flag the bone as dirty (Forcing it to update everything)
  94110. */
  94111. markAsDirty(): void;
  94112. /** @hidden */
  94113. _markAsDirtyAndCompose(): void;
  94114. private _markAsDirtyAndDecompose;
  94115. /**
  94116. * Translate the bone in local or world space
  94117. * @param vec The amount to translate the bone
  94118. * @param space The space that the translation is in
  94119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94120. */
  94121. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94122. /**
  94123. * Set the postion of the bone in local or world space
  94124. * @param position The position to set the bone
  94125. * @param space The space that the position is in
  94126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94127. */
  94128. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94129. /**
  94130. * Set the absolute position of the bone (world space)
  94131. * @param position The position to set the bone
  94132. * @param mesh The mesh that this bone is attached to
  94133. */
  94134. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  94135. /**
  94136. * Scale the bone on the x, y and z axes (in local space)
  94137. * @param x The amount to scale the bone on the x axis
  94138. * @param y The amount to scale the bone on the y axis
  94139. * @param z The amount to scale the bone on the z axis
  94140. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  94141. */
  94142. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  94143. /**
  94144. * Set the bone scaling in local space
  94145. * @param scale defines the scaling vector
  94146. */
  94147. setScale(scale: Vector3): void;
  94148. /**
  94149. * Gets the current scaling in local space
  94150. * @returns the current scaling vector
  94151. */
  94152. getScale(): Vector3;
  94153. /**
  94154. * Gets the current scaling in local space and stores it in a target vector
  94155. * @param result defines the target vector
  94156. */
  94157. getScaleToRef(result: Vector3): void;
  94158. /**
  94159. * Set the yaw, pitch, and roll of the bone in local or world space
  94160. * @param yaw The rotation of the bone on the y axis
  94161. * @param pitch The rotation of the bone on the x axis
  94162. * @param roll The rotation of the bone on the z axis
  94163. * @param space The space that the axes of rotation are in
  94164. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94165. */
  94166. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  94167. /**
  94168. * Add a rotation to the bone on an axis in local or world space
  94169. * @param axis The axis to rotate the bone on
  94170. * @param amount The amount to rotate the bone
  94171. * @param space The space that the axis is in
  94172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94173. */
  94174. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  94175. /**
  94176. * Set the rotation of the bone to a particular axis angle in local or world space
  94177. * @param axis The axis to rotate the bone on
  94178. * @param angle The angle that the bone should be rotated to
  94179. * @param space The space that the axis is in
  94180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94181. */
  94182. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  94183. /**
  94184. * Set the euler rotation of the bone in local of world space
  94185. * @param rotation The euler rotation that the bone should be set to
  94186. * @param space The space that the rotation is in
  94187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94188. */
  94189. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  94190. /**
  94191. * Set the quaternion rotation of the bone in local of world space
  94192. * @param quat The quaternion rotation that the bone should be set to
  94193. * @param space The space that the rotation is in
  94194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94195. */
  94196. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  94197. /**
  94198. * Set the rotation matrix of the bone in local of world space
  94199. * @param rotMat The rotation matrix that the bone should be set to
  94200. * @param space The space that the rotation is in
  94201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94202. */
  94203. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  94204. private _rotateWithMatrix;
  94205. private _getNegativeRotationToRef;
  94206. /**
  94207. * Get the position of the bone in local or world space
  94208. * @param space The space that the returned position is in
  94209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94210. * @returns The position of the bone
  94211. */
  94212. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94213. /**
  94214. * Copy the position of the bone to a vector3 in local or world space
  94215. * @param space The space that the returned position is in
  94216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94217. * @param result The vector3 to copy the position to
  94218. */
  94219. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  94220. /**
  94221. * Get the absolute position of the bone (world space)
  94222. * @param mesh The mesh that this bone is attached to
  94223. * @returns The absolute position of the bone
  94224. */
  94225. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  94226. /**
  94227. * Copy the absolute position of the bone (world space) to the result param
  94228. * @param mesh The mesh that this bone is attached to
  94229. * @param result The vector3 to copy the absolute position to
  94230. */
  94231. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  94232. /**
  94233. * Compute the absolute transforms of this bone and its children
  94234. */
  94235. computeAbsoluteTransforms(): void;
  94236. /**
  94237. * Get the world direction from an axis that is in the local space of the bone
  94238. * @param localAxis The local direction that is used to compute the world direction
  94239. * @param mesh The mesh that this bone is attached to
  94240. * @returns The world direction
  94241. */
  94242. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94243. /**
  94244. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  94245. * @param localAxis The local direction that is used to compute the world direction
  94246. * @param mesh The mesh that this bone is attached to
  94247. * @param result The vector3 that the world direction will be copied to
  94248. */
  94249. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94250. /**
  94251. * Get the euler rotation of the bone in local or world space
  94252. * @param space The space that the rotation should be in
  94253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94254. * @returns The euler rotation
  94255. */
  94256. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  94257. /**
  94258. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  94259. * @param space The space that the rotation should be in
  94260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94261. * @param result The vector3 that the rotation should be copied to
  94262. */
  94263. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94264. /**
  94265. * Get the quaternion rotation of the bone in either local or world space
  94266. * @param space The space that the rotation should be in
  94267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94268. * @returns The quaternion rotation
  94269. */
  94270. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  94271. /**
  94272. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  94273. * @param space The space that the rotation should be in
  94274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94275. * @param result The quaternion that the rotation should be copied to
  94276. */
  94277. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  94278. /**
  94279. * Get the rotation matrix of the bone in local or world space
  94280. * @param space The space that the rotation should be in
  94281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94282. * @returns The rotation matrix
  94283. */
  94284. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  94285. /**
  94286. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  94287. * @param space The space that the rotation should be in
  94288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  94289. * @param result The quaternion that the rotation should be copied to
  94290. */
  94291. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  94292. /**
  94293. * Get the world position of a point that is in the local space of the bone
  94294. * @param position The local position
  94295. * @param mesh The mesh that this bone is attached to
  94296. * @returns The world position
  94297. */
  94298. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94299. /**
  94300. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  94301. * @param position The local position
  94302. * @param mesh The mesh that this bone is attached to
  94303. * @param result The vector3 that the world position should be copied to
  94304. */
  94305. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94306. /**
  94307. * Get the local position of a point that is in world space
  94308. * @param position The world position
  94309. * @param mesh The mesh that this bone is attached to
  94310. * @returns The local position
  94311. */
  94312. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  94313. /**
  94314. * Get the local position of a point that is in world space and copy it to the result param
  94315. * @param position The world position
  94316. * @param mesh The mesh that this bone is attached to
  94317. * @param result The vector3 that the local position should be copied to
  94318. */
  94319. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  94320. }
  94321. }
  94322. declare module BABYLON {
  94323. /**
  94324. * Defines a runtime animation
  94325. */
  94326. export class RuntimeAnimation {
  94327. private _events;
  94328. /**
  94329. * The current frame of the runtime animation
  94330. */
  94331. private _currentFrame;
  94332. /**
  94333. * The animation used by the runtime animation
  94334. */
  94335. private _animation;
  94336. /**
  94337. * The target of the runtime animation
  94338. */
  94339. private _target;
  94340. /**
  94341. * The initiating animatable
  94342. */
  94343. private _host;
  94344. /**
  94345. * The original value of the runtime animation
  94346. */
  94347. private _originalValue;
  94348. /**
  94349. * The original blend value of the runtime animation
  94350. */
  94351. private _originalBlendValue;
  94352. /**
  94353. * The offsets cache of the runtime animation
  94354. */
  94355. private _offsetsCache;
  94356. /**
  94357. * The high limits cache of the runtime animation
  94358. */
  94359. private _highLimitsCache;
  94360. /**
  94361. * Specifies if the runtime animation has been stopped
  94362. */
  94363. private _stopped;
  94364. /**
  94365. * The blending factor of the runtime animation
  94366. */
  94367. private _blendingFactor;
  94368. /**
  94369. * The BabylonJS scene
  94370. */
  94371. private _scene;
  94372. /**
  94373. * The current value of the runtime animation
  94374. */
  94375. private _currentValue;
  94376. /** @hidden */
  94377. _animationState: _IAnimationState;
  94378. /**
  94379. * The active target of the runtime animation
  94380. */
  94381. private _activeTargets;
  94382. private _currentActiveTarget;
  94383. private _directTarget;
  94384. /**
  94385. * The target path of the runtime animation
  94386. */
  94387. private _targetPath;
  94388. /**
  94389. * The weight of the runtime animation
  94390. */
  94391. private _weight;
  94392. /**
  94393. * The ratio offset of the runtime animation
  94394. */
  94395. private _ratioOffset;
  94396. /**
  94397. * The previous delay of the runtime animation
  94398. */
  94399. private _previousDelay;
  94400. /**
  94401. * The previous ratio of the runtime animation
  94402. */
  94403. private _previousRatio;
  94404. private _enableBlending;
  94405. private _keys;
  94406. private _minFrame;
  94407. private _maxFrame;
  94408. private _minValue;
  94409. private _maxValue;
  94410. private _targetIsArray;
  94411. /**
  94412. * Gets the current frame of the runtime animation
  94413. */
  94414. get currentFrame(): number;
  94415. /**
  94416. * Gets the weight of the runtime animation
  94417. */
  94418. get weight(): number;
  94419. /**
  94420. * Gets the current value of the runtime animation
  94421. */
  94422. get currentValue(): any;
  94423. /**
  94424. * Gets the target path of the runtime animation
  94425. */
  94426. get targetPath(): string;
  94427. /**
  94428. * Gets the actual target of the runtime animation
  94429. */
  94430. get target(): any;
  94431. /**
  94432. * Gets the additive state of the runtime animation
  94433. */
  94434. get isAdditive(): boolean;
  94435. /** @hidden */
  94436. _onLoop: () => void;
  94437. /**
  94438. * Create a new RuntimeAnimation object
  94439. * @param target defines the target of the animation
  94440. * @param animation defines the source animation object
  94441. * @param scene defines the hosting scene
  94442. * @param host defines the initiating Animatable
  94443. */
  94444. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  94445. private _preparePath;
  94446. /**
  94447. * Gets the animation from the runtime animation
  94448. */
  94449. get animation(): Animation;
  94450. /**
  94451. * Resets the runtime animation to the beginning
  94452. * @param restoreOriginal defines whether to restore the target property to the original value
  94453. */
  94454. reset(restoreOriginal?: boolean): void;
  94455. /**
  94456. * Specifies if the runtime animation is stopped
  94457. * @returns Boolean specifying if the runtime animation is stopped
  94458. */
  94459. isStopped(): boolean;
  94460. /**
  94461. * Disposes of the runtime animation
  94462. */
  94463. dispose(): void;
  94464. /**
  94465. * Apply the interpolated value to the target
  94466. * @param currentValue defines the value computed by the animation
  94467. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  94468. */
  94469. setValue(currentValue: any, weight: number): void;
  94470. private _getOriginalValues;
  94471. private _setValue;
  94472. /**
  94473. * Gets the loop pmode of the runtime animation
  94474. * @returns Loop Mode
  94475. */
  94476. private _getCorrectLoopMode;
  94477. /**
  94478. * Move the current animation to a given frame
  94479. * @param frame defines the frame to move to
  94480. */
  94481. goToFrame(frame: number): void;
  94482. /**
  94483. * @hidden Internal use only
  94484. */
  94485. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  94486. /**
  94487. * Execute the current animation
  94488. * @param delay defines the delay to add to the current frame
  94489. * @param from defines the lower bound of the animation range
  94490. * @param to defines the upper bound of the animation range
  94491. * @param loop defines if the current animation must loop
  94492. * @param speedRatio defines the current speed ratio
  94493. * @param weight defines the weight of the animation (default is -1 so no weight)
  94494. * @param onLoop optional callback called when animation loops
  94495. * @returns a boolean indicating if the animation is running
  94496. */
  94497. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  94498. }
  94499. }
  94500. declare module BABYLON {
  94501. /**
  94502. * Class used to store an actual running animation
  94503. */
  94504. export class Animatable {
  94505. /** defines the target object */
  94506. target: any;
  94507. /** defines the starting frame number (default is 0) */
  94508. fromFrame: number;
  94509. /** defines the ending frame number (default is 100) */
  94510. toFrame: number;
  94511. /** defines if the animation must loop (default is false) */
  94512. loopAnimation: boolean;
  94513. /** defines a callback to call when animation ends if it is not looping */
  94514. onAnimationEnd?: (() => void) | null | undefined;
  94515. /** defines a callback to call when animation loops */
  94516. onAnimationLoop?: (() => void) | null | undefined;
  94517. /** defines whether the animation should be evaluated additively */
  94518. isAdditive: boolean;
  94519. private _localDelayOffset;
  94520. private _pausedDelay;
  94521. private _runtimeAnimations;
  94522. private _paused;
  94523. private _scene;
  94524. private _speedRatio;
  94525. private _weight;
  94526. private _syncRoot;
  94527. /**
  94528. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  94529. * This will only apply for non looping animation (default is true)
  94530. */
  94531. disposeOnEnd: boolean;
  94532. /**
  94533. * Gets a boolean indicating if the animation has started
  94534. */
  94535. animationStarted: boolean;
  94536. /**
  94537. * Observer raised when the animation ends
  94538. */
  94539. onAnimationEndObservable: Observable<Animatable>;
  94540. /**
  94541. * Observer raised when the animation loops
  94542. */
  94543. onAnimationLoopObservable: Observable<Animatable>;
  94544. /**
  94545. * Gets the root Animatable used to synchronize and normalize animations
  94546. */
  94547. get syncRoot(): Nullable<Animatable>;
  94548. /**
  94549. * Gets the current frame of the first RuntimeAnimation
  94550. * Used to synchronize Animatables
  94551. */
  94552. get masterFrame(): number;
  94553. /**
  94554. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  94555. */
  94556. get weight(): number;
  94557. set weight(value: number);
  94558. /**
  94559. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  94560. */
  94561. get speedRatio(): number;
  94562. set speedRatio(value: number);
  94563. /**
  94564. * Creates a new Animatable
  94565. * @param scene defines the hosting scene
  94566. * @param target defines the target object
  94567. * @param fromFrame defines the starting frame number (default is 0)
  94568. * @param toFrame defines the ending frame number (default is 100)
  94569. * @param loopAnimation defines if the animation must loop (default is false)
  94570. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  94571. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  94572. * @param animations defines a group of animation to add to the new Animatable
  94573. * @param onAnimationLoop defines a callback to call when animation loops
  94574. * @param isAdditive defines whether the animation should be evaluated additively
  94575. */
  94576. constructor(scene: Scene,
  94577. /** defines the target object */
  94578. target: any,
  94579. /** defines the starting frame number (default is 0) */
  94580. fromFrame?: number,
  94581. /** defines the ending frame number (default is 100) */
  94582. toFrame?: number,
  94583. /** defines if the animation must loop (default is false) */
  94584. loopAnimation?: boolean, speedRatio?: number,
  94585. /** defines a callback to call when animation ends if it is not looping */
  94586. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  94587. /** defines a callback to call when animation loops */
  94588. onAnimationLoop?: (() => void) | null | undefined,
  94589. /** defines whether the animation should be evaluated additively */
  94590. isAdditive?: boolean);
  94591. /**
  94592. * Synchronize and normalize current Animatable with a source Animatable
  94593. * This is useful when using animation weights and when animations are not of the same length
  94594. * @param root defines the root Animatable to synchronize with
  94595. * @returns the current Animatable
  94596. */
  94597. syncWith(root: Animatable): Animatable;
  94598. /**
  94599. * Gets the list of runtime animations
  94600. * @returns an array of RuntimeAnimation
  94601. */
  94602. getAnimations(): RuntimeAnimation[];
  94603. /**
  94604. * Adds more animations to the current animatable
  94605. * @param target defines the target of the animations
  94606. * @param animations defines the new animations to add
  94607. */
  94608. appendAnimations(target: any, animations: Animation[]): void;
  94609. /**
  94610. * Gets the source animation for a specific property
  94611. * @param property defines the propertyu to look for
  94612. * @returns null or the source animation for the given property
  94613. */
  94614. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  94615. /**
  94616. * Gets the runtime animation for a specific property
  94617. * @param property defines the propertyu to look for
  94618. * @returns null or the runtime animation for the given property
  94619. */
  94620. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  94621. /**
  94622. * Resets the animatable to its original state
  94623. */
  94624. reset(): void;
  94625. /**
  94626. * Allows the animatable to blend with current running animations
  94627. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94628. * @param blendingSpeed defines the blending speed to use
  94629. */
  94630. enableBlending(blendingSpeed: number): void;
  94631. /**
  94632. * Disable animation blending
  94633. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94634. */
  94635. disableBlending(): void;
  94636. /**
  94637. * Jump directly to a given frame
  94638. * @param frame defines the frame to jump to
  94639. */
  94640. goToFrame(frame: number): void;
  94641. /**
  94642. * Pause the animation
  94643. */
  94644. pause(): void;
  94645. /**
  94646. * Restart the animation
  94647. */
  94648. restart(): void;
  94649. private _raiseOnAnimationEnd;
  94650. /**
  94651. * Stop and delete the current animation
  94652. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  94653. * @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)
  94654. */
  94655. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  94656. /**
  94657. * Wait asynchronously for the animation to end
  94658. * @returns a promise which will be fullfilled when the animation ends
  94659. */
  94660. waitAsync(): Promise<Animatable>;
  94661. /** @hidden */
  94662. _animate(delay: number): boolean;
  94663. }
  94664. interface Scene {
  94665. /** @hidden */
  94666. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94667. /** @hidden */
  94668. _processLateAnimationBindingsForMatrices(holder: {
  94669. totalWeight: number;
  94670. totalAdditiveWeight: number;
  94671. animations: RuntimeAnimation[];
  94672. additiveAnimations: RuntimeAnimation[];
  94673. originalValue: Matrix;
  94674. }): any;
  94675. /** @hidden */
  94676. _processLateAnimationBindingsForQuaternions(holder: {
  94677. totalWeight: number;
  94678. totalAdditiveWeight: number;
  94679. animations: RuntimeAnimation[];
  94680. additiveAnimations: RuntimeAnimation[];
  94681. originalValue: Quaternion;
  94682. }, refQuaternion: Quaternion): Quaternion;
  94683. /** @hidden */
  94684. _processLateAnimationBindings(): void;
  94685. /**
  94686. * Will start the animation sequence of a given target
  94687. * @param target defines the target
  94688. * @param from defines from which frame should animation start
  94689. * @param to defines until which frame should animation run.
  94690. * @param weight defines the weight to apply to the animation (1.0 by default)
  94691. * @param loop defines if the animation loops
  94692. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94693. * @param onAnimationEnd defines the function to be executed when the animation ends
  94694. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94695. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94696. * @param onAnimationLoop defines the callback to call when an animation loops
  94697. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94698. * @returns the animatable object created for this animation
  94699. */
  94700. 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;
  94701. /**
  94702. * Will start the animation sequence of a given target
  94703. * @param target defines the target
  94704. * @param from defines from which frame should animation start
  94705. * @param to defines until which frame should animation run.
  94706. * @param loop defines if the animation loops
  94707. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94708. * @param onAnimationEnd defines the function to be executed when the animation ends
  94709. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94710. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94711. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94712. * @param onAnimationLoop defines the callback to call when an animation loops
  94713. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94714. * @returns the animatable object created for this animation
  94715. */
  94716. 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;
  94717. /**
  94718. * Will start the animation sequence of a given target and its hierarchy
  94719. * @param target defines the target
  94720. * @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.
  94721. * @param from defines from which frame should animation start
  94722. * @param to defines until which frame should animation run.
  94723. * @param loop defines if the animation loops
  94724. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94725. * @param onAnimationEnd defines the function to be executed when the animation ends
  94726. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94727. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94728. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94729. * @param onAnimationLoop defines the callback to call when an animation loops
  94730. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94731. * @returns the list of created animatables
  94732. */
  94733. 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[];
  94734. /**
  94735. * Begin a new animation on a given node
  94736. * @param target defines the target where the animation will take place
  94737. * @param animations defines the list of animations to start
  94738. * @param from defines the initial value
  94739. * @param to defines the final value
  94740. * @param loop defines if you want animation to loop (off by default)
  94741. * @param speedRatio defines the speed ratio to apply to all animations
  94742. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94743. * @param onAnimationLoop defines the callback to call when an animation loops
  94744. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94745. * @returns the list of created animatables
  94746. */
  94747. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94748. /**
  94749. * Begin a new animation on a given node and its hierarchy
  94750. * @param target defines the root node where the animation will take place
  94751. * @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.
  94752. * @param animations defines the list of animations to start
  94753. * @param from defines the initial value
  94754. * @param to defines the final value
  94755. * @param loop defines if you want animation to loop (off by default)
  94756. * @param speedRatio defines the speed ratio to apply to all animations
  94757. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94758. * @param onAnimationLoop defines the callback to call when an animation loops
  94759. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94760. * @returns the list of animatables created for all nodes
  94761. */
  94762. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94763. /**
  94764. * Gets the animatable associated with a specific target
  94765. * @param target defines the target of the animatable
  94766. * @returns the required animatable if found
  94767. */
  94768. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94769. /**
  94770. * Gets all animatables associated with a given target
  94771. * @param target defines the target to look animatables for
  94772. * @returns an array of Animatables
  94773. */
  94774. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94775. /**
  94776. * Stops and removes all animations that have been applied to the scene
  94777. */
  94778. stopAllAnimations(): void;
  94779. /**
  94780. * Gets the current delta time used by animation engine
  94781. */
  94782. deltaTime: number;
  94783. }
  94784. interface Bone {
  94785. /**
  94786. * Copy an animation range from another bone
  94787. * @param source defines the source bone
  94788. * @param rangeName defines the range name to copy
  94789. * @param frameOffset defines the frame offset
  94790. * @param rescaleAsRequired defines if rescaling must be applied if required
  94791. * @param skelDimensionsRatio defines the scaling ratio
  94792. * @returns true if operation was successful
  94793. */
  94794. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94795. }
  94796. }
  94797. declare module BABYLON {
  94798. /**
  94799. * Class used to handle skinning animations
  94800. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94801. */
  94802. export class Skeleton implements IAnimatable {
  94803. /** defines the skeleton name */
  94804. name: string;
  94805. /** defines the skeleton Id */
  94806. id: string;
  94807. /**
  94808. * Defines the list of child bones
  94809. */
  94810. bones: Bone[];
  94811. /**
  94812. * Defines an estimate of the dimension of the skeleton at rest
  94813. */
  94814. dimensionsAtRest: Vector3;
  94815. /**
  94816. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94817. */
  94818. needInitialSkinMatrix: boolean;
  94819. /**
  94820. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94821. */
  94822. overrideMesh: Nullable<AbstractMesh>;
  94823. /**
  94824. * Gets the list of animations attached to this skeleton
  94825. */
  94826. animations: Array<Animation>;
  94827. private _scene;
  94828. private _isDirty;
  94829. private _transformMatrices;
  94830. private _transformMatrixTexture;
  94831. private _meshesWithPoseMatrix;
  94832. private _animatables;
  94833. private _identity;
  94834. private _synchronizedWithMesh;
  94835. private _ranges;
  94836. private _lastAbsoluteTransformsUpdateId;
  94837. private _canUseTextureForBones;
  94838. private _uniqueId;
  94839. /** @hidden */
  94840. _numBonesWithLinkedTransformNode: number;
  94841. /** @hidden */
  94842. _hasWaitingData: Nullable<boolean>;
  94843. /**
  94844. * Specifies if the skeleton should be serialized
  94845. */
  94846. doNotSerialize: boolean;
  94847. private _useTextureToStoreBoneMatrices;
  94848. /**
  94849. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94850. * Please note that this option is not available if the hardware does not support it
  94851. */
  94852. get useTextureToStoreBoneMatrices(): boolean;
  94853. set useTextureToStoreBoneMatrices(value: boolean);
  94854. private _animationPropertiesOverride;
  94855. /**
  94856. * Gets or sets the animation properties override
  94857. */
  94858. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94859. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94860. /**
  94861. * List of inspectable custom properties (used by the Inspector)
  94862. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94863. */
  94864. inspectableCustomProperties: IInspectable[];
  94865. /**
  94866. * An observable triggered before computing the skeleton's matrices
  94867. */
  94868. onBeforeComputeObservable: Observable<Skeleton>;
  94869. /**
  94870. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94871. */
  94872. get isUsingTextureForMatrices(): boolean;
  94873. /**
  94874. * Gets the unique ID of this skeleton
  94875. */
  94876. get uniqueId(): number;
  94877. /**
  94878. * Creates a new skeleton
  94879. * @param name defines the skeleton name
  94880. * @param id defines the skeleton Id
  94881. * @param scene defines the hosting scene
  94882. */
  94883. constructor(
  94884. /** defines the skeleton name */
  94885. name: string,
  94886. /** defines the skeleton Id */
  94887. id: string, scene: Scene);
  94888. /**
  94889. * Gets the current object class name.
  94890. * @return the class name
  94891. */
  94892. getClassName(): string;
  94893. /**
  94894. * Returns an array containing the root bones
  94895. * @returns an array containing the root bones
  94896. */
  94897. getChildren(): Array<Bone>;
  94898. /**
  94899. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94900. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94901. * @returns a Float32Array containing matrices data
  94902. */
  94903. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94904. /**
  94905. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94906. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94907. * @returns a raw texture containing the data
  94908. */
  94909. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94910. /**
  94911. * Gets the current hosting scene
  94912. * @returns a scene object
  94913. */
  94914. getScene(): Scene;
  94915. /**
  94916. * Gets a string representing the current skeleton data
  94917. * @param fullDetails defines a boolean indicating if we want a verbose version
  94918. * @returns a string representing the current skeleton data
  94919. */
  94920. toString(fullDetails?: boolean): string;
  94921. /**
  94922. * Get bone's index searching by name
  94923. * @param name defines bone's name to search for
  94924. * @return the indice of the bone. Returns -1 if not found
  94925. */
  94926. getBoneIndexByName(name: string): number;
  94927. /**
  94928. * Creater a new animation range
  94929. * @param name defines the name of the range
  94930. * @param from defines the start key
  94931. * @param to defines the end key
  94932. */
  94933. createAnimationRange(name: string, from: number, to: number): void;
  94934. /**
  94935. * Delete a specific animation range
  94936. * @param name defines the name of the range
  94937. * @param deleteFrames defines if frames must be removed as well
  94938. */
  94939. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94940. /**
  94941. * Gets a specific animation range
  94942. * @param name defines the name of the range to look for
  94943. * @returns the requested animation range or null if not found
  94944. */
  94945. getAnimationRange(name: string): Nullable<AnimationRange>;
  94946. /**
  94947. * Gets the list of all animation ranges defined on this skeleton
  94948. * @returns an array
  94949. */
  94950. getAnimationRanges(): Nullable<AnimationRange>[];
  94951. /**
  94952. * Copy animation range from a source skeleton.
  94953. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94954. * @param source defines the source skeleton
  94955. * @param name defines the name of the range to copy
  94956. * @param rescaleAsRequired defines if rescaling must be applied if required
  94957. * @returns true if operation was successful
  94958. */
  94959. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94960. /**
  94961. * Forces the skeleton to go to rest pose
  94962. */
  94963. returnToRest(): void;
  94964. private _getHighestAnimationFrame;
  94965. /**
  94966. * Begin a specific animation range
  94967. * @param name defines the name of the range to start
  94968. * @param loop defines if looping must be turned on (false by default)
  94969. * @param speedRatio defines the speed ratio to apply (1 by default)
  94970. * @param onAnimationEnd defines a callback which will be called when animation will end
  94971. * @returns a new animatable
  94972. */
  94973. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94974. /**
  94975. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94976. * @param skeleton defines the Skeleton containing the animation range to convert
  94977. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94978. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94979. * @returns the original skeleton
  94980. */
  94981. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94982. /** @hidden */
  94983. _markAsDirty(): void;
  94984. /** @hidden */
  94985. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94986. /** @hidden */
  94987. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94988. private _computeTransformMatrices;
  94989. /**
  94990. * Build all resources required to render a skeleton
  94991. */
  94992. prepare(): void;
  94993. /**
  94994. * Gets the list of animatables currently running for this skeleton
  94995. * @returns an array of animatables
  94996. */
  94997. getAnimatables(): IAnimatable[];
  94998. /**
  94999. * Clone the current skeleton
  95000. * @param name defines the name of the new skeleton
  95001. * @param id defines the id of the new skeleton
  95002. * @returns the new skeleton
  95003. */
  95004. clone(name: string, id?: string): Skeleton;
  95005. /**
  95006. * Enable animation blending for this skeleton
  95007. * @param blendingSpeed defines the blending speed to apply
  95008. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95009. */
  95010. enableBlending(blendingSpeed?: number): void;
  95011. /**
  95012. * Releases all resources associated with the current skeleton
  95013. */
  95014. dispose(): void;
  95015. /**
  95016. * Serialize the skeleton in a JSON object
  95017. * @returns a JSON object
  95018. */
  95019. serialize(): any;
  95020. /**
  95021. * Creates a new skeleton from serialized data
  95022. * @param parsedSkeleton defines the serialized data
  95023. * @param scene defines the hosting scene
  95024. * @returns a new skeleton
  95025. */
  95026. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  95027. /**
  95028. * Compute all node absolute transforms
  95029. * @param forceUpdate defines if computation must be done even if cache is up to date
  95030. */
  95031. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  95032. /**
  95033. * Gets the root pose matrix
  95034. * @returns a matrix
  95035. */
  95036. getPoseMatrix(): Nullable<Matrix>;
  95037. /**
  95038. * Sorts bones per internal index
  95039. */
  95040. sortBones(): void;
  95041. private _sortBones;
  95042. }
  95043. }
  95044. declare module BABYLON {
  95045. /**
  95046. * Creates an instance based on a source mesh.
  95047. */
  95048. export class InstancedMesh extends AbstractMesh {
  95049. private _sourceMesh;
  95050. private _currentLOD;
  95051. /** @hidden */
  95052. _indexInSourceMeshInstanceArray: number;
  95053. constructor(name: string, source: Mesh);
  95054. /**
  95055. * Returns the string "InstancedMesh".
  95056. */
  95057. getClassName(): string;
  95058. /** Gets the list of lights affecting that mesh */
  95059. get lightSources(): Light[];
  95060. _resyncLightSources(): void;
  95061. _resyncLightSource(light: Light): void;
  95062. _removeLightSource(light: Light, dispose: boolean): void;
  95063. /**
  95064. * If the source mesh receives shadows
  95065. */
  95066. get receiveShadows(): boolean;
  95067. /**
  95068. * The material of the source mesh
  95069. */
  95070. get material(): Nullable<Material>;
  95071. /**
  95072. * Visibility of the source mesh
  95073. */
  95074. get visibility(): number;
  95075. /**
  95076. * Skeleton of the source mesh
  95077. */
  95078. get skeleton(): Nullable<Skeleton>;
  95079. /**
  95080. * Rendering ground id of the source mesh
  95081. */
  95082. get renderingGroupId(): number;
  95083. set renderingGroupId(value: number);
  95084. /**
  95085. * Returns the total number of vertices (integer).
  95086. */
  95087. getTotalVertices(): number;
  95088. /**
  95089. * Returns a positive integer : the total number of indices in this mesh geometry.
  95090. * @returns the numner of indices or zero if the mesh has no geometry.
  95091. */
  95092. getTotalIndices(): number;
  95093. /**
  95094. * The source mesh of the instance
  95095. */
  95096. get sourceMesh(): Mesh;
  95097. /**
  95098. * Creates a new InstancedMesh object from the mesh model.
  95099. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95100. * @param name defines the name of the new instance
  95101. * @returns a new InstancedMesh
  95102. */
  95103. createInstance(name: string): InstancedMesh;
  95104. /**
  95105. * Is this node ready to be used/rendered
  95106. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95107. * @return {boolean} is it ready
  95108. */
  95109. isReady(completeCheck?: boolean): boolean;
  95110. /**
  95111. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95112. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  95113. * @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.
  95114. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  95115. */
  95116. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  95117. /**
  95118. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95119. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95120. * The `data` are either a numeric array either a Float32Array.
  95121. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  95122. * 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).
  95123. * Note that a new underlying VertexBuffer object is created each call.
  95124. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95125. *
  95126. * Possible `kind` values :
  95127. * - VertexBuffer.PositionKind
  95128. * - VertexBuffer.UVKind
  95129. * - VertexBuffer.UV2Kind
  95130. * - VertexBuffer.UV3Kind
  95131. * - VertexBuffer.UV4Kind
  95132. * - VertexBuffer.UV5Kind
  95133. * - VertexBuffer.UV6Kind
  95134. * - VertexBuffer.ColorKind
  95135. * - VertexBuffer.MatricesIndicesKind
  95136. * - VertexBuffer.MatricesIndicesExtraKind
  95137. * - VertexBuffer.MatricesWeightsKind
  95138. * - VertexBuffer.MatricesWeightsExtraKind
  95139. *
  95140. * Returns the Mesh.
  95141. */
  95142. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95143. /**
  95144. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95145. * If the mesh has no geometry, it is simply returned as it is.
  95146. * The `data` are either a numeric array either a Float32Array.
  95147. * No new underlying VertexBuffer object is created.
  95148. * 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.
  95149. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  95150. *
  95151. * Possible `kind` values :
  95152. * - VertexBuffer.PositionKind
  95153. * - VertexBuffer.UVKind
  95154. * - VertexBuffer.UV2Kind
  95155. * - VertexBuffer.UV3Kind
  95156. * - VertexBuffer.UV4Kind
  95157. * - VertexBuffer.UV5Kind
  95158. * - VertexBuffer.UV6Kind
  95159. * - VertexBuffer.ColorKind
  95160. * - VertexBuffer.MatricesIndicesKind
  95161. * - VertexBuffer.MatricesIndicesExtraKind
  95162. * - VertexBuffer.MatricesWeightsKind
  95163. * - VertexBuffer.MatricesWeightsExtraKind
  95164. *
  95165. * Returns the Mesh.
  95166. */
  95167. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  95168. /**
  95169. * Sets the mesh indices.
  95170. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  95171. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95172. * This method creates a new index buffer each call.
  95173. * Returns the Mesh.
  95174. */
  95175. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  95176. /**
  95177. * Boolean : True if the mesh owns the requested kind of data.
  95178. */
  95179. isVerticesDataPresent(kind: string): boolean;
  95180. /**
  95181. * Returns an array of indices (IndicesArray).
  95182. */
  95183. getIndices(): Nullable<IndicesArray>;
  95184. get _positions(): Nullable<Vector3[]>;
  95185. /**
  95186. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95187. * This means the mesh underlying bounding box and sphere are recomputed.
  95188. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95189. * @returns the current mesh
  95190. */
  95191. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  95192. /** @hidden */
  95193. _preActivate(): InstancedMesh;
  95194. /** @hidden */
  95195. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95196. /** @hidden */
  95197. _postActivate(): void;
  95198. getWorldMatrix(): Matrix;
  95199. get isAnInstance(): boolean;
  95200. /**
  95201. * Returns the current associated LOD AbstractMesh.
  95202. */
  95203. getLOD(camera: Camera): AbstractMesh;
  95204. /** @hidden */
  95205. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95206. /** @hidden */
  95207. _syncSubMeshes(): InstancedMesh;
  95208. /** @hidden */
  95209. _generatePointsArray(): boolean;
  95210. /**
  95211. * Creates a new InstancedMesh from the current mesh.
  95212. * - name (string) : the cloned mesh name
  95213. * - newParent (optional Node) : the optional Node to parent the clone to.
  95214. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  95215. *
  95216. * Returns the clone.
  95217. */
  95218. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  95219. /**
  95220. * Disposes the InstancedMesh.
  95221. * Returns nothing.
  95222. */
  95223. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95224. }
  95225. interface Mesh {
  95226. /**
  95227. * Register a custom buffer that will be instanced
  95228. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95229. * @param kind defines the buffer kind
  95230. * @param stride defines the stride in floats
  95231. */
  95232. registerInstancedBuffer(kind: string, stride: number): void;
  95233. /**
  95234. * true to use the edge renderer for all instances of this mesh
  95235. */
  95236. edgesShareWithInstances: boolean;
  95237. /** @hidden */
  95238. _userInstancedBuffersStorage: {
  95239. data: {
  95240. [key: string]: Float32Array;
  95241. };
  95242. sizes: {
  95243. [key: string]: number;
  95244. };
  95245. vertexBuffers: {
  95246. [key: string]: Nullable<VertexBuffer>;
  95247. };
  95248. strides: {
  95249. [key: string]: number;
  95250. };
  95251. };
  95252. }
  95253. interface AbstractMesh {
  95254. /**
  95255. * Object used to store instanced buffers defined by user
  95256. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  95257. */
  95258. instancedBuffers: {
  95259. [key: string]: any;
  95260. };
  95261. }
  95262. }
  95263. declare module BABYLON {
  95264. /**
  95265. * Defines the options associated with the creation of a shader material.
  95266. */
  95267. export interface IShaderMaterialOptions {
  95268. /**
  95269. * Does the material work in alpha blend mode
  95270. */
  95271. needAlphaBlending: boolean;
  95272. /**
  95273. * Does the material work in alpha test mode
  95274. */
  95275. needAlphaTesting: boolean;
  95276. /**
  95277. * The list of attribute names used in the shader
  95278. */
  95279. attributes: string[];
  95280. /**
  95281. * The list of unifrom names used in the shader
  95282. */
  95283. uniforms: string[];
  95284. /**
  95285. * The list of UBO names used in the shader
  95286. */
  95287. uniformBuffers: string[];
  95288. /**
  95289. * The list of sampler names used in the shader
  95290. */
  95291. samplers: string[];
  95292. /**
  95293. * The list of defines used in the shader
  95294. */
  95295. defines: string[];
  95296. }
  95297. /**
  95298. * 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.
  95299. *
  95300. * This returned material effects how the mesh will look based on the code in the shaders.
  95301. *
  95302. * @see https://doc.babylonjs.com/how_to/shader_material
  95303. */
  95304. export class ShaderMaterial extends Material {
  95305. private _shaderPath;
  95306. private _options;
  95307. private _textures;
  95308. private _textureArrays;
  95309. private _floats;
  95310. private _ints;
  95311. private _floatsArrays;
  95312. private _colors3;
  95313. private _colors3Arrays;
  95314. private _colors4;
  95315. private _colors4Arrays;
  95316. private _vectors2;
  95317. private _vectors3;
  95318. private _vectors4;
  95319. private _matrices;
  95320. private _matrixArrays;
  95321. private _matrices3x3;
  95322. private _matrices2x2;
  95323. private _vectors2Arrays;
  95324. private _vectors3Arrays;
  95325. private _vectors4Arrays;
  95326. private _cachedWorldViewMatrix;
  95327. private _cachedWorldViewProjectionMatrix;
  95328. private _renderId;
  95329. private _multiview;
  95330. private _cachedDefines;
  95331. /** Define the Url to load snippets */
  95332. static SnippetUrl: string;
  95333. /** Snippet ID if the material was created from the snippet server */
  95334. snippetId: string;
  95335. /**
  95336. * Instantiate a new shader material.
  95337. * 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.
  95338. * This returned material effects how the mesh will look based on the code in the shaders.
  95339. * @see https://doc.babylonjs.com/how_to/shader_material
  95340. * @param name Define the name of the material in the scene
  95341. * @param scene Define the scene the material belongs to
  95342. * @param shaderPath Defines the route to the shader code in one of three ways:
  95343. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  95344. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  95345. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  95346. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  95347. * @param options Define the options used to create the shader
  95348. */
  95349. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  95350. /**
  95351. * Gets the shader path used to define the shader code
  95352. * It can be modified to trigger a new compilation
  95353. */
  95354. get shaderPath(): any;
  95355. /**
  95356. * Sets the shader path used to define the shader code
  95357. * It can be modified to trigger a new compilation
  95358. */
  95359. set shaderPath(shaderPath: any);
  95360. /**
  95361. * Gets the options used to compile the shader.
  95362. * They can be modified to trigger a new compilation
  95363. */
  95364. get options(): IShaderMaterialOptions;
  95365. /**
  95366. * Gets the current class name of the material e.g. "ShaderMaterial"
  95367. * Mainly use in serialization.
  95368. * @returns the class name
  95369. */
  95370. getClassName(): string;
  95371. /**
  95372. * Specifies if the material will require alpha blending
  95373. * @returns a boolean specifying if alpha blending is needed
  95374. */
  95375. needAlphaBlending(): boolean;
  95376. /**
  95377. * Specifies if this material should be rendered in alpha test mode
  95378. * @returns a boolean specifying if an alpha test is needed.
  95379. */
  95380. needAlphaTesting(): boolean;
  95381. private _checkUniform;
  95382. /**
  95383. * Set a texture in the shader.
  95384. * @param name Define the name of the uniform samplers as defined in the shader
  95385. * @param texture Define the texture to bind to this sampler
  95386. * @return the material itself allowing "fluent" like uniform updates
  95387. */
  95388. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  95389. /**
  95390. * Set a texture array in the shader.
  95391. * @param name Define the name of the uniform sampler array as defined in the shader
  95392. * @param textures Define the list of textures to bind to this sampler
  95393. * @return the material itself allowing "fluent" like uniform updates
  95394. */
  95395. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  95396. /**
  95397. * Set a float in the shader.
  95398. * @param name Define the name of the uniform as defined in the shader
  95399. * @param value Define the value to give to the uniform
  95400. * @return the material itself allowing "fluent" like uniform updates
  95401. */
  95402. setFloat(name: string, value: number): ShaderMaterial;
  95403. /**
  95404. * Set a int in the shader.
  95405. * @param name Define the name of the uniform as defined in the shader
  95406. * @param value Define the value to give to the uniform
  95407. * @return the material itself allowing "fluent" like uniform updates
  95408. */
  95409. setInt(name: string, value: number): ShaderMaterial;
  95410. /**
  95411. * Set an array of floats in the shader.
  95412. * @param name Define the name of the uniform as defined in the shader
  95413. * @param value Define the value to give to the uniform
  95414. * @return the material itself allowing "fluent" like uniform updates
  95415. */
  95416. setFloats(name: string, value: number[]): ShaderMaterial;
  95417. /**
  95418. * Set a vec3 in the shader from a Color3.
  95419. * @param name Define the name of the uniform as defined in the shader
  95420. * @param value Define the value to give to the uniform
  95421. * @return the material itself allowing "fluent" like uniform updates
  95422. */
  95423. setColor3(name: string, value: Color3): ShaderMaterial;
  95424. /**
  95425. * Set a vec3 array in the shader from a Color3 array.
  95426. * @param name Define the name of the uniform as defined in the shader
  95427. * @param value Define the value to give to the uniform
  95428. * @return the material itself allowing "fluent" like uniform updates
  95429. */
  95430. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  95431. /**
  95432. * Set a vec4 in the shader from a Color4.
  95433. * @param name Define the name of the uniform as defined in the shader
  95434. * @param value Define the value to give to the uniform
  95435. * @return the material itself allowing "fluent" like uniform updates
  95436. */
  95437. setColor4(name: string, value: Color4): ShaderMaterial;
  95438. /**
  95439. * Set a vec4 array in the shader from a Color4 array.
  95440. * @param name Define the name of the uniform as defined in the shader
  95441. * @param value Define the value to give to the uniform
  95442. * @return the material itself allowing "fluent" like uniform updates
  95443. */
  95444. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  95445. /**
  95446. * Set a vec2 in the shader from a Vector2.
  95447. * @param name Define the name of the uniform as defined in the shader
  95448. * @param value Define the value to give to the uniform
  95449. * @return the material itself allowing "fluent" like uniform updates
  95450. */
  95451. setVector2(name: string, value: Vector2): ShaderMaterial;
  95452. /**
  95453. * Set a vec3 in the shader from a Vector3.
  95454. * @param name Define the name of the uniform as defined in the shader
  95455. * @param value Define the value to give to the uniform
  95456. * @return the material itself allowing "fluent" like uniform updates
  95457. */
  95458. setVector3(name: string, value: Vector3): ShaderMaterial;
  95459. /**
  95460. * Set a vec4 in the shader from a Vector4.
  95461. * @param name Define the name of the uniform as defined in the shader
  95462. * @param value Define the value to give to the uniform
  95463. * @return the material itself allowing "fluent" like uniform updates
  95464. */
  95465. setVector4(name: string, value: Vector4): ShaderMaterial;
  95466. /**
  95467. * Set a mat4 in the shader from a Matrix.
  95468. * @param name Define the name of the uniform as defined in the shader
  95469. * @param value Define the value to give to the uniform
  95470. * @return the material itself allowing "fluent" like uniform updates
  95471. */
  95472. setMatrix(name: string, value: Matrix): ShaderMaterial;
  95473. /**
  95474. * Set a float32Array in the shader from a matrix array.
  95475. * @param name Define the name of the uniform as defined in the shader
  95476. * @param value Define the value to give to the uniform
  95477. * @return the material itself allowing "fluent" like uniform updates
  95478. */
  95479. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  95480. /**
  95481. * Set a mat3 in the shader from a Float32Array.
  95482. * @param name Define the name of the uniform as defined in the shader
  95483. * @param value Define the value to give to the uniform
  95484. * @return the material itself allowing "fluent" like uniform updates
  95485. */
  95486. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95487. /**
  95488. * Set a mat2 in the shader from a Float32Array.
  95489. * @param name Define the name of the uniform as defined in the shader
  95490. * @param value Define the value to give to the uniform
  95491. * @return the material itself allowing "fluent" like uniform updates
  95492. */
  95493. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  95494. /**
  95495. * Set a vec2 array in the shader from a number array.
  95496. * @param name Define the name of the uniform as defined in the shader
  95497. * @param value Define the value to give to the uniform
  95498. * @return the material itself allowing "fluent" like uniform updates
  95499. */
  95500. setArray2(name: string, value: number[]): ShaderMaterial;
  95501. /**
  95502. * Set a vec3 array in the shader from a number array.
  95503. * @param name Define the name of the uniform as defined in the shader
  95504. * @param value Define the value to give to the uniform
  95505. * @return the material itself allowing "fluent" like uniform updates
  95506. */
  95507. setArray3(name: string, value: number[]): ShaderMaterial;
  95508. /**
  95509. * Set a vec4 array in the shader from a number array.
  95510. * @param name Define the name of the uniform as defined in the shader
  95511. * @param value Define the value to give to the uniform
  95512. * @return the material itself allowing "fluent" like uniform updates
  95513. */
  95514. setArray4(name: string, value: number[]): ShaderMaterial;
  95515. private _checkCache;
  95516. /**
  95517. * Specifies that the submesh is ready to be used
  95518. * @param mesh defines the mesh to check
  95519. * @param subMesh defines which submesh to check
  95520. * @param useInstances specifies that instances should be used
  95521. * @returns a boolean indicating that the submesh is ready or not
  95522. */
  95523. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95524. /**
  95525. * Checks if the material is ready to render the requested mesh
  95526. * @param mesh Define the mesh to render
  95527. * @param useInstances Define whether or not the material is used with instances
  95528. * @returns true if ready, otherwise false
  95529. */
  95530. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95531. /**
  95532. * Binds the world matrix to the material
  95533. * @param world defines the world transformation matrix
  95534. * @param effectOverride - If provided, use this effect instead of internal effect
  95535. */
  95536. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  95537. /**
  95538. * Binds the submesh to this material by preparing the effect and shader to draw
  95539. * @param world defines the world transformation matrix
  95540. * @param mesh defines the mesh containing the submesh
  95541. * @param subMesh defines the submesh to bind the material to
  95542. */
  95543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95544. /**
  95545. * Binds the material to the mesh
  95546. * @param world defines the world transformation matrix
  95547. * @param mesh defines the mesh to bind the material to
  95548. * @param effectOverride - If provided, use this effect instead of internal effect
  95549. */
  95550. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  95551. protected _afterBind(mesh?: Mesh): void;
  95552. /**
  95553. * Gets the active textures from the material
  95554. * @returns an array of textures
  95555. */
  95556. getActiveTextures(): BaseTexture[];
  95557. /**
  95558. * Specifies if the material uses a texture
  95559. * @param texture defines the texture to check against the material
  95560. * @returns a boolean specifying if the material uses the texture
  95561. */
  95562. hasTexture(texture: BaseTexture): boolean;
  95563. /**
  95564. * Makes a duplicate of the material, and gives it a new name
  95565. * @param name defines the new name for the duplicated material
  95566. * @returns the cloned material
  95567. */
  95568. clone(name: string): ShaderMaterial;
  95569. /**
  95570. * Disposes the material
  95571. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95572. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95573. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95574. */
  95575. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95576. /**
  95577. * Serializes this material in a JSON representation
  95578. * @returns the serialized material object
  95579. */
  95580. serialize(): any;
  95581. /**
  95582. * Creates a shader material from parsed shader material data
  95583. * @param source defines the JSON represnetation of the material
  95584. * @param scene defines the hosting scene
  95585. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95586. * @returns a new material
  95587. */
  95588. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  95589. /**
  95590. * Creates a new ShaderMaterial from a snippet saved in a remote file
  95591. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  95592. * @param url defines the url to load from
  95593. * @param scene defines the hosting scene
  95594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95595. * @returns a promise that will resolve to the new ShaderMaterial
  95596. */
  95597. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95598. /**
  95599. * Creates a ShaderMaterial from a snippet saved by the Inspector
  95600. * @param snippetId defines the snippet to load
  95601. * @param scene defines the hosting scene
  95602. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95603. * @returns a promise that will resolve to the new ShaderMaterial
  95604. */
  95605. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  95606. }
  95607. }
  95608. declare module BABYLON {
  95609. /** @hidden */
  95610. export var colorPixelShader: {
  95611. name: string;
  95612. shader: string;
  95613. };
  95614. }
  95615. declare module BABYLON {
  95616. /** @hidden */
  95617. export var colorVertexShader: {
  95618. name: string;
  95619. shader: string;
  95620. };
  95621. }
  95622. declare module BABYLON {
  95623. /**
  95624. * Line mesh
  95625. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  95626. */
  95627. export class LinesMesh extends Mesh {
  95628. /**
  95629. * If vertex color should be applied to the mesh
  95630. */
  95631. readonly useVertexColor?: boolean | undefined;
  95632. /**
  95633. * If vertex alpha should be applied to the mesh
  95634. */
  95635. readonly useVertexAlpha?: boolean | undefined;
  95636. /**
  95637. * Color of the line (Default: White)
  95638. */
  95639. color: Color3;
  95640. /**
  95641. * Alpha of the line (Default: 1)
  95642. */
  95643. alpha: number;
  95644. /**
  95645. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95646. * This margin is expressed in world space coordinates, so its value may vary.
  95647. * Default value is 0.1
  95648. */
  95649. intersectionThreshold: number;
  95650. private _colorShader;
  95651. private color4;
  95652. /**
  95653. * Creates a new LinesMesh
  95654. * @param name defines the name
  95655. * @param scene defines the hosting scene
  95656. * @param parent defines the parent mesh if any
  95657. * @param source defines the optional source LinesMesh used to clone data from
  95658. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95659. * When false, achieved by calling a clone(), also passing False.
  95660. * This will make creation of children, recursive.
  95661. * @param useVertexColor defines if this LinesMesh supports vertex color
  95662. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95663. */
  95664. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95665. /**
  95666. * If vertex color should be applied to the mesh
  95667. */
  95668. useVertexColor?: boolean | undefined,
  95669. /**
  95670. * If vertex alpha should be applied to the mesh
  95671. */
  95672. useVertexAlpha?: boolean | undefined);
  95673. private _addClipPlaneDefine;
  95674. private _removeClipPlaneDefine;
  95675. isReady(): boolean;
  95676. /**
  95677. * Returns the string "LineMesh"
  95678. */
  95679. getClassName(): string;
  95680. /**
  95681. * @hidden
  95682. */
  95683. get material(): Material;
  95684. /**
  95685. * @hidden
  95686. */
  95687. set material(value: Material);
  95688. /**
  95689. * @hidden
  95690. */
  95691. get checkCollisions(): boolean;
  95692. /** @hidden */
  95693. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95694. /** @hidden */
  95695. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95696. /**
  95697. * Disposes of the line mesh
  95698. * @param doNotRecurse If children should be disposed
  95699. */
  95700. dispose(doNotRecurse?: boolean): void;
  95701. /**
  95702. * Returns a new LineMesh object cloned from the current one.
  95703. */
  95704. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95705. /**
  95706. * Creates a new InstancedLinesMesh object from the mesh model.
  95707. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95708. * @param name defines the name of the new instance
  95709. * @returns a new InstancedLinesMesh
  95710. */
  95711. createInstance(name: string): InstancedLinesMesh;
  95712. }
  95713. /**
  95714. * Creates an instance based on a source LinesMesh
  95715. */
  95716. export class InstancedLinesMesh extends InstancedMesh {
  95717. /**
  95718. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95719. * This margin is expressed in world space coordinates, so its value may vary.
  95720. * Initilized with the intersectionThreshold value of the source LinesMesh
  95721. */
  95722. intersectionThreshold: number;
  95723. constructor(name: string, source: LinesMesh);
  95724. /**
  95725. * Returns the string "InstancedLinesMesh".
  95726. */
  95727. getClassName(): string;
  95728. }
  95729. }
  95730. declare module BABYLON {
  95731. /** @hidden */
  95732. export var linePixelShader: {
  95733. name: string;
  95734. shader: string;
  95735. };
  95736. }
  95737. declare module BABYLON {
  95738. /** @hidden */
  95739. export var lineVertexShader: {
  95740. name: string;
  95741. shader: string;
  95742. };
  95743. }
  95744. declare module BABYLON {
  95745. interface Scene {
  95746. /** @hidden */
  95747. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95748. }
  95749. interface AbstractMesh {
  95750. /**
  95751. * Gets the edgesRenderer associated with the mesh
  95752. */
  95753. edgesRenderer: Nullable<EdgesRenderer>;
  95754. }
  95755. interface LinesMesh {
  95756. /**
  95757. * Enables the edge rendering mode on the mesh.
  95758. * This mode makes the mesh edges visible
  95759. * @param epsilon defines the maximal distance between two angles to detect a face
  95760. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95761. * @returns the currentAbstractMesh
  95762. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95763. */
  95764. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95765. }
  95766. interface InstancedLinesMesh {
  95767. /**
  95768. * Enables the edge rendering mode on the mesh.
  95769. * This mode makes the mesh edges visible
  95770. * @param epsilon defines the maximal distance between two angles to detect a face
  95771. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95772. * @returns the current InstancedLinesMesh
  95773. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95774. */
  95775. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95776. }
  95777. /**
  95778. * Defines the minimum contract an Edges renderer should follow.
  95779. */
  95780. export interface IEdgesRenderer extends IDisposable {
  95781. /**
  95782. * Gets or sets a boolean indicating if the edgesRenderer is active
  95783. */
  95784. isEnabled: boolean;
  95785. /**
  95786. * Renders the edges of the attached mesh,
  95787. */
  95788. render(): void;
  95789. /**
  95790. * Checks wether or not the edges renderer is ready to render.
  95791. * @return true if ready, otherwise false.
  95792. */
  95793. isReady(): boolean;
  95794. /**
  95795. * List of instances to render in case the source mesh has instances
  95796. */
  95797. customInstances: SmartArray<Matrix>;
  95798. }
  95799. /**
  95800. * Defines the additional options of the edges renderer
  95801. */
  95802. export interface IEdgesRendererOptions {
  95803. /**
  95804. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95805. * If not defined, the default value is true
  95806. */
  95807. useAlternateEdgeFinder?: boolean;
  95808. /**
  95809. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95810. * If not defined, the default value is true.
  95811. * 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)
  95812. * This option is used only if useAlternateEdgeFinder = true
  95813. */
  95814. useFastVertexMerger?: boolean;
  95815. /**
  95816. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95817. * The default value is 1e-6
  95818. * This option is used only if useAlternateEdgeFinder = true
  95819. */
  95820. epsilonVertexMerge?: number;
  95821. /**
  95822. * 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
  95823. * 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.
  95824. * This option is used only if useAlternateEdgeFinder = true
  95825. */
  95826. applyTessellation?: boolean;
  95827. /**
  95828. * 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
  95829. * The default value is 1e-6
  95830. * This option is used only if useAlternateEdgeFinder = true
  95831. */
  95832. epsilonVertexAligned?: number;
  95833. }
  95834. /**
  95835. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  95836. */
  95837. export class EdgesRenderer implements IEdgesRenderer {
  95838. /**
  95839. * Define the size of the edges with an orthographic camera
  95840. */
  95841. edgesWidthScalerForOrthographic: number;
  95842. /**
  95843. * Define the size of the edges with a perspective camera
  95844. */
  95845. edgesWidthScalerForPerspective: number;
  95846. protected _source: AbstractMesh;
  95847. protected _linesPositions: number[];
  95848. protected _linesNormals: number[];
  95849. protected _linesIndices: number[];
  95850. protected _epsilon: number;
  95851. protected _indicesCount: number;
  95852. protected _lineShader: ShaderMaterial;
  95853. protected _ib: DataBuffer;
  95854. protected _buffers: {
  95855. [key: string]: Nullable<VertexBuffer>;
  95856. };
  95857. protected _buffersForInstances: {
  95858. [key: string]: Nullable<VertexBuffer>;
  95859. };
  95860. protected _checkVerticesInsteadOfIndices: boolean;
  95861. protected _options: Nullable<IEdgesRendererOptions>;
  95862. private _meshRebuildObserver;
  95863. private _meshDisposeObserver;
  95864. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95865. isEnabled: boolean;
  95866. /**
  95867. * List of instances to render in case the source mesh has instances
  95868. */
  95869. customInstances: SmartArray<Matrix>;
  95870. private static GetShader;
  95871. /**
  95872. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95873. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95874. * @param source Mesh used to create edges
  95875. * @param epsilon sum of angles in adjacency to check for edge
  95876. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  95877. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95878. * @param options The options to apply when generating the edges
  95879. */
  95880. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  95881. protected _prepareRessources(): void;
  95882. /** @hidden */
  95883. _rebuild(): void;
  95884. /**
  95885. * Releases the required resources for the edges renderer
  95886. */
  95887. dispose(): void;
  95888. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95889. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95890. /**
  95891. * Checks if the pair of p0 and p1 is en edge
  95892. * @param faceIndex
  95893. * @param edge
  95894. * @param faceNormals
  95895. * @param p0
  95896. * @param p1
  95897. * @private
  95898. */
  95899. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95900. /**
  95901. * push line into the position, normal and index buffer
  95902. * @protected
  95903. */
  95904. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95905. /**
  95906. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  95907. */
  95908. private _tessellateTriangle;
  95909. private _generateEdgesLinesAlternate;
  95910. /**
  95911. * Generates lines edges from adjacencjes
  95912. * @private
  95913. */
  95914. _generateEdgesLines(): void;
  95915. /**
  95916. * Checks wether or not the edges renderer is ready to render.
  95917. * @return true if ready, otherwise false.
  95918. */
  95919. isReady(): boolean;
  95920. /**
  95921. * Renders the edges of the attached mesh,
  95922. */
  95923. render(): void;
  95924. }
  95925. /**
  95926. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95927. */
  95928. export class LineEdgesRenderer extends EdgesRenderer {
  95929. /**
  95930. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95931. * @param source LineMesh used to generate edges
  95932. * @param epsilon not important (specified angle for edge detection)
  95933. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95934. */
  95935. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95936. /**
  95937. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95938. */
  95939. _generateEdgesLines(): void;
  95940. }
  95941. }
  95942. declare module BABYLON {
  95943. /**
  95944. * This represents the object necessary to create a rendering group.
  95945. * This is exclusively used and created by the rendering manager.
  95946. * To modify the behavior, you use the available helpers in your scene or meshes.
  95947. * @hidden
  95948. */
  95949. export class RenderingGroup {
  95950. index: number;
  95951. private static _zeroVector;
  95952. private _scene;
  95953. private _opaqueSubMeshes;
  95954. private _transparentSubMeshes;
  95955. private _alphaTestSubMeshes;
  95956. private _depthOnlySubMeshes;
  95957. private _particleSystems;
  95958. private _spriteManagers;
  95959. private _opaqueSortCompareFn;
  95960. private _alphaTestSortCompareFn;
  95961. private _transparentSortCompareFn;
  95962. private _renderOpaque;
  95963. private _renderAlphaTest;
  95964. private _renderTransparent;
  95965. /** @hidden */
  95966. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95967. onBeforeTransparentRendering: () => void;
  95968. /**
  95969. * Set the opaque sort comparison function.
  95970. * If null the sub meshes will be render in the order they were created
  95971. */
  95972. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95973. /**
  95974. * Set the alpha test sort comparison function.
  95975. * If null the sub meshes will be render in the order they were created
  95976. */
  95977. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95978. /**
  95979. * Set the transparent sort comparison function.
  95980. * If null the sub meshes will be render in the order they were created
  95981. */
  95982. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95983. /**
  95984. * Creates a new rendering group.
  95985. * @param index The rendering group index
  95986. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95987. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95988. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95989. */
  95990. 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>);
  95991. /**
  95992. * Render all the sub meshes contained in the group.
  95993. * @param customRenderFunction Used to override the default render behaviour of the group.
  95994. * @returns true if rendered some submeshes.
  95995. */
  95996. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95997. /**
  95998. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95999. * @param subMeshes The submeshes to render
  96000. */
  96001. private renderOpaqueSorted;
  96002. /**
  96003. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  96004. * @param subMeshes The submeshes to render
  96005. */
  96006. private renderAlphaTestSorted;
  96007. /**
  96008. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  96009. * @param subMeshes The submeshes to render
  96010. */
  96011. private renderTransparentSorted;
  96012. /**
  96013. * Renders the submeshes in a specified order.
  96014. * @param subMeshes The submeshes to sort before render
  96015. * @param sortCompareFn The comparison function use to sort
  96016. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  96017. * @param transparent Specifies to activate blending if true
  96018. */
  96019. private static renderSorted;
  96020. /**
  96021. * Renders the submeshes in the order they were dispatched (no sort applied).
  96022. * @param subMeshes The submeshes to render
  96023. */
  96024. private static renderUnsorted;
  96025. /**
  96026. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96027. * are rendered back to front if in the same alpha index.
  96028. *
  96029. * @param a The first submesh
  96030. * @param b The second submesh
  96031. * @returns The result of the comparison
  96032. */
  96033. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  96034. /**
  96035. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96036. * are rendered back to front.
  96037. *
  96038. * @param a The first submesh
  96039. * @param b The second submesh
  96040. * @returns The result of the comparison
  96041. */
  96042. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  96043. /**
  96044. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  96045. * are rendered front to back (prevent overdraw).
  96046. *
  96047. * @param a The first submesh
  96048. * @param b The second submesh
  96049. * @returns The result of the comparison
  96050. */
  96051. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  96052. /**
  96053. * Resets the different lists of submeshes to prepare a new frame.
  96054. */
  96055. prepare(): void;
  96056. dispose(): void;
  96057. /**
  96058. * Inserts the submesh in its correct queue depending on its material.
  96059. * @param subMesh The submesh to dispatch
  96060. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96061. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96062. */
  96063. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96064. dispatchSprites(spriteManager: ISpriteManager): void;
  96065. dispatchParticles(particleSystem: IParticleSystem): void;
  96066. private _renderParticles;
  96067. private _renderSprites;
  96068. }
  96069. }
  96070. declare module BABYLON {
  96071. /**
  96072. * Interface describing the different options available in the rendering manager
  96073. * regarding Auto Clear between groups.
  96074. */
  96075. export interface IRenderingManagerAutoClearSetup {
  96076. /**
  96077. * Defines whether or not autoclear is enable.
  96078. */
  96079. autoClear: boolean;
  96080. /**
  96081. * Defines whether or not to autoclear the depth buffer.
  96082. */
  96083. depth: boolean;
  96084. /**
  96085. * Defines whether or not to autoclear the stencil buffer.
  96086. */
  96087. stencil: boolean;
  96088. }
  96089. /**
  96090. * This class is used by the onRenderingGroupObservable
  96091. */
  96092. export class RenderingGroupInfo {
  96093. /**
  96094. * The Scene that being rendered
  96095. */
  96096. scene: Scene;
  96097. /**
  96098. * The camera currently used for the rendering pass
  96099. */
  96100. camera: Nullable<Camera>;
  96101. /**
  96102. * The ID of the renderingGroup being processed
  96103. */
  96104. renderingGroupId: number;
  96105. }
  96106. /**
  96107. * This is the manager responsible of all the rendering for meshes sprites and particles.
  96108. * It is enable to manage the different groups as well as the different necessary sort functions.
  96109. * This should not be used directly aside of the few static configurations
  96110. */
  96111. export class RenderingManager {
  96112. /**
  96113. * The max id used for rendering groups (not included)
  96114. */
  96115. static MAX_RENDERINGGROUPS: number;
  96116. /**
  96117. * The min id used for rendering groups (included)
  96118. */
  96119. static MIN_RENDERINGGROUPS: number;
  96120. /**
  96121. * Used to globally prevent autoclearing scenes.
  96122. */
  96123. static AUTOCLEAR: boolean;
  96124. /**
  96125. * @hidden
  96126. */
  96127. _useSceneAutoClearSetup: boolean;
  96128. private _scene;
  96129. private _renderingGroups;
  96130. private _depthStencilBufferAlreadyCleaned;
  96131. private _autoClearDepthStencil;
  96132. private _customOpaqueSortCompareFn;
  96133. private _customAlphaTestSortCompareFn;
  96134. private _customTransparentSortCompareFn;
  96135. private _renderingGroupInfo;
  96136. /**
  96137. * Instantiates a new rendering group for a particular scene
  96138. * @param scene Defines the scene the groups belongs to
  96139. */
  96140. constructor(scene: Scene);
  96141. private _clearDepthStencilBuffer;
  96142. /**
  96143. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  96144. * @hidden
  96145. */
  96146. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  96147. /**
  96148. * Resets the different information of the group to prepare a new frame
  96149. * @hidden
  96150. */
  96151. reset(): void;
  96152. /**
  96153. * Dispose and release the group and its associated resources.
  96154. * @hidden
  96155. */
  96156. dispose(): void;
  96157. /**
  96158. * Clear the info related to rendering groups preventing retention points during dispose.
  96159. */
  96160. freeRenderingGroups(): void;
  96161. private _prepareRenderingGroup;
  96162. /**
  96163. * Add a sprite manager to the rendering manager in order to render it this frame.
  96164. * @param spriteManager Define the sprite manager to render
  96165. */
  96166. dispatchSprites(spriteManager: ISpriteManager): void;
  96167. /**
  96168. * Add a particle system to the rendering manager in order to render it this frame.
  96169. * @param particleSystem Define the particle system to render
  96170. */
  96171. dispatchParticles(particleSystem: IParticleSystem): void;
  96172. /**
  96173. * Add a submesh to the manager in order to render it this frame
  96174. * @param subMesh The submesh to dispatch
  96175. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  96176. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  96177. */
  96178. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  96179. /**
  96180. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96181. * This allowed control for front to back rendering or reversly depending of the special needs.
  96182. *
  96183. * @param renderingGroupId The rendering group id corresponding to its index
  96184. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96185. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96186. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96187. */
  96188. 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;
  96189. /**
  96190. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96191. *
  96192. * @param renderingGroupId The rendering group id corresponding to its index
  96193. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96194. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96195. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96196. */
  96197. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96198. /**
  96199. * Gets the current auto clear configuration for one rendering group of the rendering
  96200. * manager.
  96201. * @param index the rendering group index to get the information for
  96202. * @returns The auto clear setup for the requested rendering group
  96203. */
  96204. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96205. }
  96206. }
  96207. declare module BABYLON {
  96208. /**
  96209. * Defines the options associated with the creation of a custom shader for a shadow generator.
  96210. */
  96211. export interface ICustomShaderOptions {
  96212. /**
  96213. * Gets or sets the custom shader name to use
  96214. */
  96215. shaderName: string;
  96216. /**
  96217. * The list of attribute names used in the shader
  96218. */
  96219. attributes?: string[];
  96220. /**
  96221. * The list of unifrom names used in the shader
  96222. */
  96223. uniforms?: string[];
  96224. /**
  96225. * The list of sampler names used in the shader
  96226. */
  96227. samplers?: string[];
  96228. /**
  96229. * The list of defines used in the shader
  96230. */
  96231. defines?: string[];
  96232. }
  96233. /**
  96234. * Interface to implement to create a shadow generator compatible with BJS.
  96235. */
  96236. export interface IShadowGenerator {
  96237. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96238. id: string;
  96239. /**
  96240. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96241. * @returns The render target texture if present otherwise, null
  96242. */
  96243. getShadowMap(): Nullable<RenderTargetTexture>;
  96244. /**
  96245. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96246. * @param subMesh The submesh we want to render in the shadow map
  96247. * @param useInstances Defines wether will draw in the map using instances
  96248. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96249. * @returns true if ready otherwise, false
  96250. */
  96251. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96252. /**
  96253. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96254. * @param defines Defines of the material we want to update
  96255. * @param lightIndex Index of the light in the enabled light list of the material
  96256. */
  96257. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  96258. /**
  96259. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96260. * defined in the generator but impacting the effect).
  96261. * It implies the unifroms available on the materials are the standard BJS ones.
  96262. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96263. * @param effect The effect we are binfing the information for
  96264. */
  96265. bindShadowLight(lightIndex: string, effect: Effect): void;
  96266. /**
  96267. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96268. * (eq to shadow prjection matrix * light transform matrix)
  96269. * @returns The transform matrix used to create the shadow map
  96270. */
  96271. getTransformMatrix(): Matrix;
  96272. /**
  96273. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96274. * Cube and 2D textures for instance.
  96275. */
  96276. recreateShadowMap(): void;
  96277. /**
  96278. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96279. * @param onCompiled Callback triggered at the and of the effects compilation
  96280. * @param options Sets of optional options forcing the compilation with different modes
  96281. */
  96282. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96283. useInstances: boolean;
  96284. }>): void;
  96285. /**
  96286. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96287. * @param options Sets of optional options forcing the compilation with different modes
  96288. * @returns A promise that resolves when the compilation completes
  96289. */
  96290. forceCompilationAsync(options?: Partial<{
  96291. useInstances: boolean;
  96292. }>): Promise<void>;
  96293. /**
  96294. * Serializes the shadow generator setup to a json object.
  96295. * @returns The serialized JSON object
  96296. */
  96297. serialize(): any;
  96298. /**
  96299. * Disposes the Shadow map and related Textures and effects.
  96300. */
  96301. dispose(): void;
  96302. }
  96303. /**
  96304. * Default implementation IShadowGenerator.
  96305. * This is the main object responsible of generating shadows in the framework.
  96306. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  96307. */
  96308. export class ShadowGenerator implements IShadowGenerator {
  96309. /**
  96310. * Name of the shadow generator class
  96311. */
  96312. static CLASSNAME: string;
  96313. /**
  96314. * Shadow generator mode None: no filtering applied.
  96315. */
  96316. static readonly FILTER_NONE: number;
  96317. /**
  96318. * Shadow generator mode ESM: Exponential Shadow Mapping.
  96319. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96320. */
  96321. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  96322. /**
  96323. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  96324. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  96325. */
  96326. static readonly FILTER_POISSONSAMPLING: number;
  96327. /**
  96328. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  96329. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96330. */
  96331. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  96332. /**
  96333. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  96334. * edge artifacts on steep falloff.
  96335. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96336. */
  96337. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  96338. /**
  96339. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  96340. * edge artifacts on steep falloff.
  96341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  96342. */
  96343. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  96344. /**
  96345. * Shadow generator mode PCF: Percentage Closer Filtering
  96346. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96347. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  96348. */
  96349. static readonly FILTER_PCF: number;
  96350. /**
  96351. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  96352. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  96353. * Contact Hardening
  96354. */
  96355. static readonly FILTER_PCSS: number;
  96356. /**
  96357. * Reserved for PCF and PCSS
  96358. * Highest Quality.
  96359. *
  96360. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  96361. *
  96362. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  96363. */
  96364. static readonly QUALITY_HIGH: number;
  96365. /**
  96366. * Reserved for PCF and PCSS
  96367. * Good tradeoff for quality/perf cross devices
  96368. *
  96369. * Execute PCF on a 3*3 kernel.
  96370. *
  96371. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  96372. */
  96373. static readonly QUALITY_MEDIUM: number;
  96374. /**
  96375. * Reserved for PCF and PCSS
  96376. * The lowest quality but the fastest.
  96377. *
  96378. * Execute PCF on a 1*1 kernel.
  96379. *
  96380. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  96381. */
  96382. static readonly QUALITY_LOW: number;
  96383. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  96384. id: string;
  96385. /** Gets or sets the custom shader name to use */
  96386. customShaderOptions: ICustomShaderOptions;
  96387. /**
  96388. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  96389. */
  96390. onBeforeShadowMapRenderObservable: Observable<Effect>;
  96391. /**
  96392. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  96393. */
  96394. onAfterShadowMapRenderObservable: Observable<Effect>;
  96395. /**
  96396. * Observable triggered before a mesh is rendered in the shadow map.
  96397. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  96398. */
  96399. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  96400. /**
  96401. * Observable triggered after a mesh is rendered in the shadow map.
  96402. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  96403. */
  96404. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  96405. protected _bias: number;
  96406. /**
  96407. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  96408. */
  96409. get bias(): number;
  96410. /**
  96411. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  96412. */
  96413. set bias(bias: number);
  96414. protected _normalBias: number;
  96415. /**
  96416. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96417. */
  96418. get normalBias(): number;
  96419. /**
  96420. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  96421. */
  96422. set normalBias(normalBias: number);
  96423. protected _blurBoxOffset: number;
  96424. /**
  96425. * Gets the blur box offset: offset applied during the blur pass.
  96426. * Only useful if useKernelBlur = false
  96427. */
  96428. get blurBoxOffset(): number;
  96429. /**
  96430. * Sets the blur box offset: offset applied during the blur pass.
  96431. * Only useful if useKernelBlur = false
  96432. */
  96433. set blurBoxOffset(value: number);
  96434. protected _blurScale: number;
  96435. /**
  96436. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  96437. * 2 means half of the size.
  96438. */
  96439. get blurScale(): number;
  96440. /**
  96441. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  96442. * 2 means half of the size.
  96443. */
  96444. set blurScale(value: number);
  96445. protected _blurKernel: number;
  96446. /**
  96447. * Gets the blur kernel: kernel size of the blur pass.
  96448. * Only useful if useKernelBlur = true
  96449. */
  96450. get blurKernel(): number;
  96451. /**
  96452. * Sets the blur kernel: kernel size of the blur pass.
  96453. * Only useful if useKernelBlur = true
  96454. */
  96455. set blurKernel(value: number);
  96456. protected _useKernelBlur: boolean;
  96457. /**
  96458. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  96459. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96460. */
  96461. get useKernelBlur(): boolean;
  96462. /**
  96463. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  96464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  96465. */
  96466. set useKernelBlur(value: boolean);
  96467. protected _depthScale: number;
  96468. /**
  96469. * Gets the depth scale used in ESM mode.
  96470. */
  96471. get depthScale(): number;
  96472. /**
  96473. * Sets the depth scale used in ESM mode.
  96474. * This can override the scale stored on the light.
  96475. */
  96476. set depthScale(value: number);
  96477. protected _validateFilter(filter: number): number;
  96478. protected _filter: number;
  96479. /**
  96480. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  96481. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96482. */
  96483. get filter(): number;
  96484. /**
  96485. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  96486. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  96487. */
  96488. set filter(value: number);
  96489. /**
  96490. * Gets if the current filter is set to Poisson Sampling.
  96491. */
  96492. get usePoissonSampling(): boolean;
  96493. /**
  96494. * Sets the current filter to Poisson Sampling.
  96495. */
  96496. set usePoissonSampling(value: boolean);
  96497. /**
  96498. * Gets if the current filter is set to ESM.
  96499. */
  96500. get useExponentialShadowMap(): boolean;
  96501. /**
  96502. * Sets the current filter is to ESM.
  96503. */
  96504. set useExponentialShadowMap(value: boolean);
  96505. /**
  96506. * Gets if the current filter is set to filtered ESM.
  96507. */
  96508. get useBlurExponentialShadowMap(): boolean;
  96509. /**
  96510. * Gets if the current filter is set to filtered ESM.
  96511. */
  96512. set useBlurExponentialShadowMap(value: boolean);
  96513. /**
  96514. * Gets if the current filter is set to "close ESM" (using the inverse of the
  96515. * exponential to prevent steep falloff artifacts).
  96516. */
  96517. get useCloseExponentialShadowMap(): boolean;
  96518. /**
  96519. * Sets the current filter to "close ESM" (using the inverse of the
  96520. * exponential to prevent steep falloff artifacts).
  96521. */
  96522. set useCloseExponentialShadowMap(value: boolean);
  96523. /**
  96524. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  96525. * exponential to prevent steep falloff artifacts).
  96526. */
  96527. get useBlurCloseExponentialShadowMap(): boolean;
  96528. /**
  96529. * Sets the current filter to filtered "close ESM" (using the inverse of the
  96530. * exponential to prevent steep falloff artifacts).
  96531. */
  96532. set useBlurCloseExponentialShadowMap(value: boolean);
  96533. /**
  96534. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  96535. */
  96536. get usePercentageCloserFiltering(): boolean;
  96537. /**
  96538. * Sets the current filter to "PCF" (percentage closer filtering).
  96539. */
  96540. set usePercentageCloserFiltering(value: boolean);
  96541. protected _filteringQuality: number;
  96542. /**
  96543. * Gets the PCF or PCSS Quality.
  96544. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96545. */
  96546. get filteringQuality(): number;
  96547. /**
  96548. * Sets the PCF or PCSS Quality.
  96549. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  96550. */
  96551. set filteringQuality(filteringQuality: number);
  96552. /**
  96553. * Gets if the current filter is set to "PCSS" (contact hardening).
  96554. */
  96555. get useContactHardeningShadow(): boolean;
  96556. /**
  96557. * Sets the current filter to "PCSS" (contact hardening).
  96558. */
  96559. set useContactHardeningShadow(value: boolean);
  96560. protected _contactHardeningLightSizeUVRatio: number;
  96561. /**
  96562. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96563. * Using a ratio helps keeping shape stability independently of the map size.
  96564. *
  96565. * It does not account for the light projection as it was having too much
  96566. * instability during the light setup or during light position changes.
  96567. *
  96568. * Only valid if useContactHardeningShadow is true.
  96569. */
  96570. get contactHardeningLightSizeUVRatio(): number;
  96571. /**
  96572. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  96573. * Using a ratio helps keeping shape stability independently of the map size.
  96574. *
  96575. * It does not account for the light projection as it was having too much
  96576. * instability during the light setup or during light position changes.
  96577. *
  96578. * Only valid if useContactHardeningShadow is true.
  96579. */
  96580. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  96581. protected _darkness: number;
  96582. /** Gets or sets the actual darkness of a shadow */
  96583. get darkness(): number;
  96584. set darkness(value: number);
  96585. /**
  96586. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  96587. * 0 means strongest and 1 would means no shadow.
  96588. * @returns the darkness.
  96589. */
  96590. getDarkness(): number;
  96591. /**
  96592. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  96593. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  96594. * @returns the shadow generator allowing fluent coding.
  96595. */
  96596. setDarkness(darkness: number): ShadowGenerator;
  96597. protected _transparencyShadow: boolean;
  96598. /** Gets or sets the ability to have transparent shadow */
  96599. get transparencyShadow(): boolean;
  96600. set transparencyShadow(value: boolean);
  96601. /**
  96602. * Sets the ability to have transparent shadow (boolean).
  96603. * @param transparent True if transparent else False
  96604. * @returns the shadow generator allowing fluent coding
  96605. */
  96606. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  96607. /**
  96608. * Enables or disables shadows with varying strength based on the transparency
  96609. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  96610. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  96611. * mesh.visibility * alphaTexture.a
  96612. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  96613. */
  96614. enableSoftTransparentShadow: boolean;
  96615. protected _shadowMap: Nullable<RenderTargetTexture>;
  96616. protected _shadowMap2: Nullable<RenderTargetTexture>;
  96617. /**
  96618. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  96619. * @returns The render target texture if present otherwise, null
  96620. */
  96621. getShadowMap(): Nullable<RenderTargetTexture>;
  96622. /**
  96623. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  96624. * @returns The render target texture if the shadow map is present otherwise, null
  96625. */
  96626. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  96627. /**
  96628. * Gets the class name of that object
  96629. * @returns "ShadowGenerator"
  96630. */
  96631. getClassName(): string;
  96632. /**
  96633. * Helper function to add a mesh and its descendants to the list of shadow casters.
  96634. * @param mesh Mesh to add
  96635. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  96636. * @returns the Shadow Generator itself
  96637. */
  96638. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96639. /**
  96640. * Helper function to remove a mesh and its descendants from the list of shadow casters
  96641. * @param mesh Mesh to remove
  96642. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  96643. * @returns the Shadow Generator itself
  96644. */
  96645. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  96646. /**
  96647. * Controls the extent to which the shadows fade out at the edge of the frustum
  96648. */
  96649. frustumEdgeFalloff: number;
  96650. protected _light: IShadowLight;
  96651. /**
  96652. * Returns the associated light object.
  96653. * @returns the light generating the shadow
  96654. */
  96655. getLight(): IShadowLight;
  96656. /**
  96657. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  96658. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  96659. * It might on the other hand introduce peter panning.
  96660. */
  96661. forceBackFacesOnly: boolean;
  96662. protected _scene: Scene;
  96663. protected _lightDirection: Vector3;
  96664. protected _effect: Effect;
  96665. protected _viewMatrix: Matrix;
  96666. protected _projectionMatrix: Matrix;
  96667. protected _transformMatrix: Matrix;
  96668. protected _cachedPosition: Vector3;
  96669. protected _cachedDirection: Vector3;
  96670. protected _cachedDefines: string;
  96671. protected _currentRenderID: number;
  96672. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96673. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96674. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96675. protected _blurPostProcesses: PostProcess[];
  96676. protected _mapSize: number;
  96677. protected _currentFaceIndex: number;
  96678. protected _currentFaceIndexCache: number;
  96679. protected _textureType: number;
  96680. protected _defaultTextureMatrix: Matrix;
  96681. protected _storedUniqueId: Nullable<number>;
  96682. /** @hidden */
  96683. static _SceneComponentInitialization: (scene: Scene) => void;
  96684. /**
  96685. * Creates a ShadowGenerator object.
  96686. * A ShadowGenerator is the required tool to use the shadows.
  96687. * Each light casting shadows needs to use its own ShadowGenerator.
  96688. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96689. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96690. * @param light The light object generating the shadows.
  96691. * @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.
  96692. */
  96693. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96694. protected _initializeGenerator(): void;
  96695. protected _createTargetRenderTexture(): void;
  96696. protected _initializeShadowMap(): void;
  96697. protected _initializeBlurRTTAndPostProcesses(): void;
  96698. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96699. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96700. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96701. protected _applyFilterValues(): void;
  96702. /**
  96703. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96704. * @param onCompiled Callback triggered at the and of the effects compilation
  96705. * @param options Sets of optional options forcing the compilation with different modes
  96706. */
  96707. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96708. useInstances: boolean;
  96709. }>): void;
  96710. /**
  96711. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96712. * @param options Sets of optional options forcing the compilation with different modes
  96713. * @returns A promise that resolves when the compilation completes
  96714. */
  96715. forceCompilationAsync(options?: Partial<{
  96716. useInstances: boolean;
  96717. }>): Promise<void>;
  96718. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96719. private _prepareShadowDefines;
  96720. /**
  96721. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96722. * @param subMesh The submesh we want to render in the shadow map
  96723. * @param useInstances Defines wether will draw in the map using instances
  96724. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96725. * @returns true if ready otherwise, false
  96726. */
  96727. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96728. /**
  96729. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96730. * @param defines Defines of the material we want to update
  96731. * @param lightIndex Index of the light in the enabled light list of the material
  96732. */
  96733. prepareDefines(defines: any, lightIndex: number): void;
  96734. /**
  96735. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96736. * defined in the generator but impacting the effect).
  96737. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96738. * @param effect The effect we are binfing the information for
  96739. */
  96740. bindShadowLight(lightIndex: string, effect: Effect): void;
  96741. /**
  96742. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96743. * (eq to shadow prjection matrix * light transform matrix)
  96744. * @returns The transform matrix used to create the shadow map
  96745. */
  96746. getTransformMatrix(): Matrix;
  96747. /**
  96748. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96749. * Cube and 2D textures for instance.
  96750. */
  96751. recreateShadowMap(): void;
  96752. protected _disposeBlurPostProcesses(): void;
  96753. protected _disposeRTTandPostProcesses(): void;
  96754. /**
  96755. * Disposes the ShadowGenerator.
  96756. * Returns nothing.
  96757. */
  96758. dispose(): void;
  96759. /**
  96760. * Serializes the shadow generator setup to a json object.
  96761. * @returns The serialized JSON object
  96762. */
  96763. serialize(): any;
  96764. /**
  96765. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96766. * @param parsedShadowGenerator The JSON object to parse
  96767. * @param scene The scene to create the shadow map for
  96768. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96769. * @returns The parsed shadow generator
  96770. */
  96771. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96772. }
  96773. }
  96774. declare module BABYLON {
  96775. /**
  96776. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96777. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96778. * 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.
  96779. */
  96780. export abstract class Light extends Node {
  96781. /**
  96782. * Falloff Default: light is falling off following the material specification:
  96783. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96784. */
  96785. static readonly FALLOFF_DEFAULT: number;
  96786. /**
  96787. * Falloff Physical: light is falling off following the inverse squared distance law.
  96788. */
  96789. static readonly FALLOFF_PHYSICAL: number;
  96790. /**
  96791. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96792. * to enhance interoperability with other engines.
  96793. */
  96794. static readonly FALLOFF_GLTF: number;
  96795. /**
  96796. * Falloff Standard: light is falling off like in the standard material
  96797. * to enhance interoperability with other materials.
  96798. */
  96799. static readonly FALLOFF_STANDARD: number;
  96800. /**
  96801. * If every light affecting the material is in this lightmapMode,
  96802. * material.lightmapTexture adds or multiplies
  96803. * (depends on material.useLightmapAsShadowmap)
  96804. * after every other light calculations.
  96805. */
  96806. static readonly LIGHTMAP_DEFAULT: number;
  96807. /**
  96808. * material.lightmapTexture as only diffuse lighting from this light
  96809. * adds only specular lighting from this light
  96810. * adds dynamic shadows
  96811. */
  96812. static readonly LIGHTMAP_SPECULAR: number;
  96813. /**
  96814. * material.lightmapTexture as only lighting
  96815. * no light calculation from this light
  96816. * only adds dynamic shadows from this light
  96817. */
  96818. static readonly LIGHTMAP_SHADOWSONLY: number;
  96819. /**
  96820. * Each light type uses the default quantity according to its type:
  96821. * point/spot lights use luminous intensity
  96822. * directional lights use illuminance
  96823. */
  96824. static readonly INTENSITYMODE_AUTOMATIC: number;
  96825. /**
  96826. * lumen (lm)
  96827. */
  96828. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  96829. /**
  96830. * candela (lm/sr)
  96831. */
  96832. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  96833. /**
  96834. * lux (lm/m^2)
  96835. */
  96836. static readonly INTENSITYMODE_ILLUMINANCE: number;
  96837. /**
  96838. * nit (cd/m^2)
  96839. */
  96840. static readonly INTENSITYMODE_LUMINANCE: number;
  96841. /**
  96842. * Light type const id of the point light.
  96843. */
  96844. static readonly LIGHTTYPEID_POINTLIGHT: number;
  96845. /**
  96846. * Light type const id of the directional light.
  96847. */
  96848. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96849. /**
  96850. * Light type const id of the spot light.
  96851. */
  96852. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96853. /**
  96854. * Light type const id of the hemispheric light.
  96855. */
  96856. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96857. /**
  96858. * Diffuse gives the basic color to an object.
  96859. */
  96860. diffuse: Color3;
  96861. /**
  96862. * Specular produces a highlight color on an object.
  96863. * Note: This is note affecting PBR materials.
  96864. */
  96865. specular: Color3;
  96866. /**
  96867. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96868. * falling off base on range or angle.
  96869. * This can be set to any values in Light.FALLOFF_x.
  96870. *
  96871. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96872. * other types of materials.
  96873. */
  96874. falloffType: number;
  96875. /**
  96876. * Strength of the light.
  96877. * Note: By default it is define in the framework own unit.
  96878. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96879. */
  96880. intensity: number;
  96881. private _range;
  96882. protected _inverseSquaredRange: number;
  96883. /**
  96884. * Defines how far from the source the light is impacting in scene units.
  96885. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96886. */
  96887. get range(): number;
  96888. /**
  96889. * Defines how far from the source the light is impacting in scene units.
  96890. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96891. */
  96892. set range(value: number);
  96893. /**
  96894. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96895. * of light.
  96896. */
  96897. private _photometricScale;
  96898. private _intensityMode;
  96899. /**
  96900. * Gets the photometric scale used to interpret the intensity.
  96901. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96902. */
  96903. get intensityMode(): number;
  96904. /**
  96905. * Sets the photometric scale used to interpret the intensity.
  96906. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96907. */
  96908. set intensityMode(value: number);
  96909. private _radius;
  96910. /**
  96911. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96912. */
  96913. get radius(): number;
  96914. /**
  96915. * sets the light radius used by PBR Materials to simulate soft area lights.
  96916. */
  96917. set radius(value: number);
  96918. private _renderPriority;
  96919. /**
  96920. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96921. * exceeding the number allowed of the materials.
  96922. */
  96923. renderPriority: number;
  96924. private _shadowEnabled;
  96925. /**
  96926. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96927. * the current shadow generator.
  96928. */
  96929. get shadowEnabled(): boolean;
  96930. /**
  96931. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96932. * the current shadow generator.
  96933. */
  96934. set shadowEnabled(value: boolean);
  96935. private _includedOnlyMeshes;
  96936. /**
  96937. * Gets the only meshes impacted by this light.
  96938. */
  96939. get includedOnlyMeshes(): AbstractMesh[];
  96940. /**
  96941. * Sets the only meshes impacted by this light.
  96942. */
  96943. set includedOnlyMeshes(value: AbstractMesh[]);
  96944. private _excludedMeshes;
  96945. /**
  96946. * Gets the meshes not impacted by this light.
  96947. */
  96948. get excludedMeshes(): AbstractMesh[];
  96949. /**
  96950. * Sets the meshes not impacted by this light.
  96951. */
  96952. set excludedMeshes(value: AbstractMesh[]);
  96953. private _excludeWithLayerMask;
  96954. /**
  96955. * Gets the layer id use to find what meshes are not impacted by the light.
  96956. * Inactive if 0
  96957. */
  96958. get excludeWithLayerMask(): number;
  96959. /**
  96960. * Sets the layer id use to find what meshes are not impacted by the light.
  96961. * Inactive if 0
  96962. */
  96963. set excludeWithLayerMask(value: number);
  96964. private _includeOnlyWithLayerMask;
  96965. /**
  96966. * Gets the layer id use to find what meshes are impacted by the light.
  96967. * Inactive if 0
  96968. */
  96969. get includeOnlyWithLayerMask(): number;
  96970. /**
  96971. * Sets the layer id use to find what meshes are impacted by the light.
  96972. * Inactive if 0
  96973. */
  96974. set includeOnlyWithLayerMask(value: number);
  96975. private _lightmapMode;
  96976. /**
  96977. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96978. */
  96979. get lightmapMode(): number;
  96980. /**
  96981. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96982. */
  96983. set lightmapMode(value: number);
  96984. /**
  96985. * Shadow generator associted to the light.
  96986. * @hidden Internal use only.
  96987. */
  96988. _shadowGenerator: Nullable<IShadowGenerator>;
  96989. /**
  96990. * @hidden Internal use only.
  96991. */
  96992. _excludedMeshesIds: string[];
  96993. /**
  96994. * @hidden Internal use only.
  96995. */
  96996. _includedOnlyMeshesIds: string[];
  96997. /**
  96998. * The current light unifom buffer.
  96999. * @hidden Internal use only.
  97000. */
  97001. _uniformBuffer: UniformBuffer;
  97002. /** @hidden */
  97003. _renderId: number;
  97004. /**
  97005. * Creates a Light object in the scene.
  97006. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97007. * @param name The firendly name of the light
  97008. * @param scene The scene the light belongs too
  97009. */
  97010. constructor(name: string, scene: Scene);
  97011. protected abstract _buildUniformLayout(): void;
  97012. /**
  97013. * Sets the passed Effect "effect" with the Light information.
  97014. * @param effect The effect to update
  97015. * @param lightIndex The index of the light in the effect to update
  97016. * @returns The light
  97017. */
  97018. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  97019. /**
  97020. * Sets the passed Effect "effect" with the Light textures.
  97021. * @param effect The effect to update
  97022. * @param lightIndex The index of the light in the effect to update
  97023. * @returns The light
  97024. */
  97025. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  97026. /**
  97027. * Binds the lights information from the scene to the effect for the given mesh.
  97028. * @param lightIndex Light index
  97029. * @param scene The scene where the light belongs to
  97030. * @param effect The effect we are binding the data to
  97031. * @param useSpecular Defines if specular is supported
  97032. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97033. */
  97034. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97035. /**
  97036. * Sets the passed Effect "effect" with the Light information.
  97037. * @param effect The effect to update
  97038. * @param lightDataUniformName The uniform used to store light data (position or direction)
  97039. * @returns The light
  97040. */
  97041. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  97042. /**
  97043. * Returns the string "Light".
  97044. * @returns the class name
  97045. */
  97046. getClassName(): string;
  97047. /** @hidden */
  97048. readonly _isLight: boolean;
  97049. /**
  97050. * Converts the light information to a readable string for debug purpose.
  97051. * @param fullDetails Supports for multiple levels of logging within scene loading
  97052. * @returns the human readable light info
  97053. */
  97054. toString(fullDetails?: boolean): string;
  97055. /** @hidden */
  97056. protected _syncParentEnabledState(): void;
  97057. /**
  97058. * Set the enabled state of this node.
  97059. * @param value - the new enabled state
  97060. */
  97061. setEnabled(value: boolean): void;
  97062. /**
  97063. * Returns the Light associated shadow generator if any.
  97064. * @return the associated shadow generator.
  97065. */
  97066. getShadowGenerator(): Nullable<IShadowGenerator>;
  97067. /**
  97068. * Returns a Vector3, the absolute light position in the World.
  97069. * @returns the world space position of the light
  97070. */
  97071. getAbsolutePosition(): Vector3;
  97072. /**
  97073. * Specifies if the light will affect the passed mesh.
  97074. * @param mesh The mesh to test against the light
  97075. * @return true the mesh is affected otherwise, false.
  97076. */
  97077. canAffectMesh(mesh: AbstractMesh): boolean;
  97078. /**
  97079. * Sort function to order lights for rendering.
  97080. * @param a First Light object to compare to second.
  97081. * @param b Second Light object to compare first.
  97082. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  97083. */
  97084. static CompareLightsPriority(a: Light, b: Light): number;
  97085. /**
  97086. * Releases resources associated with this node.
  97087. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97088. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97089. */
  97090. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97091. /**
  97092. * Returns the light type ID (integer).
  97093. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97094. */
  97095. getTypeID(): number;
  97096. /**
  97097. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  97098. * @returns the scaled intensity in intensity mode unit
  97099. */
  97100. getScaledIntensity(): number;
  97101. /**
  97102. * Returns a new Light object, named "name", from the current one.
  97103. * @param name The name of the cloned light
  97104. * @param newParent The parent of this light, if it has one
  97105. * @returns the new created light
  97106. */
  97107. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  97108. /**
  97109. * Serializes the current light into a Serialization object.
  97110. * @returns the serialized object.
  97111. */
  97112. serialize(): any;
  97113. /**
  97114. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  97115. * This new light is named "name" and added to the passed scene.
  97116. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  97117. * @param name The friendly name of the light
  97118. * @param scene The scene the new light will belong to
  97119. * @returns the constructor function
  97120. */
  97121. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  97122. /**
  97123. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  97124. * @param parsedLight The JSON representation of the light
  97125. * @param scene The scene to create the parsed light in
  97126. * @returns the created light after parsing
  97127. */
  97128. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  97129. private _hookArrayForExcluded;
  97130. private _hookArrayForIncludedOnly;
  97131. private _resyncMeshes;
  97132. /**
  97133. * Forces the meshes to update their light related information in their rendering used effects
  97134. * @hidden Internal Use Only
  97135. */
  97136. _markMeshesAsLightDirty(): void;
  97137. /**
  97138. * Recomputes the cached photometric scale if needed.
  97139. */
  97140. private _computePhotometricScale;
  97141. /**
  97142. * Returns the Photometric Scale according to the light type and intensity mode.
  97143. */
  97144. private _getPhotometricScale;
  97145. /**
  97146. * Reorder the light in the scene according to their defined priority.
  97147. * @hidden Internal Use Only
  97148. */
  97149. _reorderLightsInScene(): void;
  97150. /**
  97151. * Prepares the list of defines specific to the light type.
  97152. * @param defines the list of defines
  97153. * @param lightIndex defines the index of the light for the effect
  97154. */
  97155. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97156. }
  97157. }
  97158. declare module BABYLON {
  97159. /**
  97160. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  97161. * This is the base of the follow, arc rotate cameras and Free camera
  97162. * @see https://doc.babylonjs.com/features/cameras
  97163. */
  97164. export class TargetCamera extends Camera {
  97165. private static _RigCamTransformMatrix;
  97166. private static _TargetTransformMatrix;
  97167. private static _TargetFocalPoint;
  97168. private _tmpUpVector;
  97169. private _tmpTargetVector;
  97170. /**
  97171. * Define the current direction the camera is moving to
  97172. */
  97173. cameraDirection: Vector3;
  97174. /**
  97175. * Define the current rotation the camera is rotating to
  97176. */
  97177. cameraRotation: Vector2;
  97178. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  97179. ignoreParentScaling: boolean;
  97180. /**
  97181. * When set, the up vector of the camera will be updated by the rotation of the camera
  97182. */
  97183. updateUpVectorFromRotation: boolean;
  97184. private _tmpQuaternion;
  97185. /**
  97186. * Define the current rotation of the camera
  97187. */
  97188. rotation: Vector3;
  97189. /**
  97190. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  97191. */
  97192. rotationQuaternion: Quaternion;
  97193. /**
  97194. * Define the current speed of the camera
  97195. */
  97196. speed: number;
  97197. /**
  97198. * Add constraint to the camera to prevent it to move freely in all directions and
  97199. * around all axis.
  97200. */
  97201. noRotationConstraint: boolean;
  97202. /**
  97203. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  97204. * panning
  97205. */
  97206. invertRotation: boolean;
  97207. /**
  97208. * Speed multiplier for inverse camera panning
  97209. */
  97210. inverseRotationSpeed: number;
  97211. /**
  97212. * Define the current target of the camera as an object or a position.
  97213. */
  97214. lockedTarget: any;
  97215. /** @hidden */
  97216. _currentTarget: Vector3;
  97217. /** @hidden */
  97218. _initialFocalDistance: number;
  97219. /** @hidden */
  97220. _viewMatrix: Matrix;
  97221. /** @hidden */
  97222. _camMatrix: Matrix;
  97223. /** @hidden */
  97224. _cameraTransformMatrix: Matrix;
  97225. /** @hidden */
  97226. _cameraRotationMatrix: Matrix;
  97227. /** @hidden */
  97228. _referencePoint: Vector3;
  97229. /** @hidden */
  97230. _transformedReferencePoint: Vector3;
  97231. /** @hidden */
  97232. _reset: () => void;
  97233. private _defaultUp;
  97234. /**
  97235. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  97236. * This is the base of the follow, arc rotate cameras and Free camera
  97237. * @see https://doc.babylonjs.com/features/cameras
  97238. * @param name Defines the name of the camera in the scene
  97239. * @param position Defines the start position of the camera in the scene
  97240. * @param scene Defines the scene the camera belongs to
  97241. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97242. */
  97243. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97244. /**
  97245. * Gets the position in front of the camera at a given distance.
  97246. * @param distance The distance from the camera we want the position to be
  97247. * @returns the position
  97248. */
  97249. getFrontPosition(distance: number): Vector3;
  97250. /** @hidden */
  97251. _getLockedTargetPosition(): Nullable<Vector3>;
  97252. private _storedPosition;
  97253. private _storedRotation;
  97254. private _storedRotationQuaternion;
  97255. /**
  97256. * Store current camera state of the camera (fov, position, rotation, etc..)
  97257. * @returns the camera
  97258. */
  97259. storeState(): Camera;
  97260. /**
  97261. * Restored camera state. You must call storeState() first
  97262. * @returns whether it was successful or not
  97263. * @hidden
  97264. */
  97265. _restoreStateValues(): boolean;
  97266. /** @hidden */
  97267. _initCache(): void;
  97268. /** @hidden */
  97269. _updateCache(ignoreParentClass?: boolean): void;
  97270. /** @hidden */
  97271. _isSynchronizedViewMatrix(): boolean;
  97272. /** @hidden */
  97273. _computeLocalCameraSpeed(): number;
  97274. /**
  97275. * Defines the target the camera should look at.
  97276. * @param target Defines the new target as a Vector or a mesh
  97277. */
  97278. setTarget(target: Vector3): void;
  97279. /**
  97280. * Defines the target point of the camera.
  97281. * The camera looks towards it form the radius distance.
  97282. */
  97283. get target(): Vector3;
  97284. set target(value: Vector3);
  97285. /**
  97286. * Return the current target position of the camera. This value is expressed in local space.
  97287. * @returns the target position
  97288. */
  97289. getTarget(): Vector3;
  97290. /** @hidden */
  97291. _decideIfNeedsToMove(): boolean;
  97292. /** @hidden */
  97293. _updatePosition(): void;
  97294. /** @hidden */
  97295. _checkInputs(): void;
  97296. protected _updateCameraRotationMatrix(): void;
  97297. /**
  97298. * 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)
  97299. * @returns the current camera
  97300. */
  97301. private _rotateUpVectorWithCameraRotationMatrix;
  97302. private _cachedRotationZ;
  97303. private _cachedQuaternionRotationZ;
  97304. /** @hidden */
  97305. _getViewMatrix(): Matrix;
  97306. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  97307. /**
  97308. * @hidden
  97309. */
  97310. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97311. /**
  97312. * @hidden
  97313. */
  97314. _updateRigCameras(): void;
  97315. private _getRigCamPositionAndTarget;
  97316. /**
  97317. * Gets the current object class name.
  97318. * @return the class name
  97319. */
  97320. getClassName(): string;
  97321. }
  97322. }
  97323. declare module BABYLON {
  97324. /**
  97325. * Gather the list of keyboard event types as constants.
  97326. */
  97327. export class KeyboardEventTypes {
  97328. /**
  97329. * The keydown event is fired when a key becomes active (pressed).
  97330. */
  97331. static readonly KEYDOWN: number;
  97332. /**
  97333. * The keyup event is fired when a key has been released.
  97334. */
  97335. static readonly KEYUP: number;
  97336. }
  97337. /**
  97338. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97339. */
  97340. export class KeyboardInfo {
  97341. /**
  97342. * Defines the type of event (KeyboardEventTypes)
  97343. */
  97344. type: number;
  97345. /**
  97346. * Defines the related dom event
  97347. */
  97348. event: KeyboardEvent;
  97349. /**
  97350. * Instantiates a new keyboard info.
  97351. * This class is used to store keyboard related info for the onKeyboardObservable event.
  97352. * @param type Defines the type of event (KeyboardEventTypes)
  97353. * @param event Defines the related dom event
  97354. */
  97355. constructor(
  97356. /**
  97357. * Defines the type of event (KeyboardEventTypes)
  97358. */
  97359. type: number,
  97360. /**
  97361. * Defines the related dom event
  97362. */
  97363. event: KeyboardEvent);
  97364. }
  97365. /**
  97366. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97367. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  97368. */
  97369. export class KeyboardInfoPre extends KeyboardInfo {
  97370. /**
  97371. * Defines the type of event (KeyboardEventTypes)
  97372. */
  97373. type: number;
  97374. /**
  97375. * Defines the related dom event
  97376. */
  97377. event: KeyboardEvent;
  97378. /**
  97379. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  97380. */
  97381. skipOnPointerObservable: boolean;
  97382. /**
  97383. * Instantiates a new keyboard pre info.
  97384. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  97385. * @param type Defines the type of event (KeyboardEventTypes)
  97386. * @param event Defines the related dom event
  97387. */
  97388. constructor(
  97389. /**
  97390. * Defines the type of event (KeyboardEventTypes)
  97391. */
  97392. type: number,
  97393. /**
  97394. * Defines the related dom event
  97395. */
  97396. event: KeyboardEvent);
  97397. }
  97398. }
  97399. declare module BABYLON {
  97400. /**
  97401. * Manage the keyboard inputs to control the movement of a free camera.
  97402. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97403. */
  97404. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  97405. /**
  97406. * Defines the camera the input is attached to.
  97407. */
  97408. camera: FreeCamera;
  97409. /**
  97410. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97411. */
  97412. keysUp: number[];
  97413. /**
  97414. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97415. */
  97416. keysUpward: number[];
  97417. /**
  97418. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97419. */
  97420. keysDown: number[];
  97421. /**
  97422. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97423. */
  97424. keysDownward: number[];
  97425. /**
  97426. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97427. */
  97428. keysLeft: number[];
  97429. /**
  97430. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97431. */
  97432. keysRight: number[];
  97433. private _keys;
  97434. private _onCanvasBlurObserver;
  97435. private _onKeyboardObserver;
  97436. private _engine;
  97437. private _scene;
  97438. /**
  97439. * Attach the input controls to a specific dom element to get the input from.
  97440. * @param element Defines the element the controls should be listened from
  97441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97442. */
  97443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97444. /**
  97445. * Detach the current controls from the specified dom element.
  97446. * @param element Defines the element to stop listening the inputs from
  97447. */
  97448. detachControl(element: Nullable<HTMLElement>): void;
  97449. /**
  97450. * Update the current camera state depending on the inputs that have been used this frame.
  97451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97452. */
  97453. checkInputs(): void;
  97454. /**
  97455. * Gets the class name of the current intput.
  97456. * @returns the class name
  97457. */
  97458. getClassName(): string;
  97459. /** @hidden */
  97460. _onLostFocus(): void;
  97461. /**
  97462. * Get the friendly name associated with the input class.
  97463. * @returns the input friendly name
  97464. */
  97465. getSimpleName(): string;
  97466. }
  97467. }
  97468. declare module BABYLON {
  97469. /**
  97470. * Gather the list of pointer event types as constants.
  97471. */
  97472. export class PointerEventTypes {
  97473. /**
  97474. * 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.
  97475. */
  97476. static readonly POINTERDOWN: number;
  97477. /**
  97478. * The pointerup event is fired when a pointer is no longer active.
  97479. */
  97480. static readonly POINTERUP: number;
  97481. /**
  97482. * The pointermove event is fired when a pointer changes coordinates.
  97483. */
  97484. static readonly POINTERMOVE: number;
  97485. /**
  97486. * The pointerwheel event is fired when a mouse wheel has been rotated.
  97487. */
  97488. static readonly POINTERWHEEL: number;
  97489. /**
  97490. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  97491. */
  97492. static readonly POINTERPICK: number;
  97493. /**
  97494. * The pointertap event is fired when a the object has been touched and released without drag.
  97495. */
  97496. static readonly POINTERTAP: number;
  97497. /**
  97498. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  97499. */
  97500. static readonly POINTERDOUBLETAP: number;
  97501. }
  97502. /**
  97503. * Base class of pointer info types.
  97504. */
  97505. export class PointerInfoBase {
  97506. /**
  97507. * Defines the type of event (PointerEventTypes)
  97508. */
  97509. type: number;
  97510. /**
  97511. * Defines the related dom event
  97512. */
  97513. event: PointerEvent | MouseWheelEvent;
  97514. /**
  97515. * Instantiates the base class of pointers info.
  97516. * @param type Defines the type of event (PointerEventTypes)
  97517. * @param event Defines the related dom event
  97518. */
  97519. constructor(
  97520. /**
  97521. * Defines the type of event (PointerEventTypes)
  97522. */
  97523. type: number,
  97524. /**
  97525. * Defines the related dom event
  97526. */
  97527. event: PointerEvent | MouseWheelEvent);
  97528. }
  97529. /**
  97530. * This class is used to store pointer related info for the onPrePointerObservable event.
  97531. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  97532. */
  97533. export class PointerInfoPre extends PointerInfoBase {
  97534. /**
  97535. * Ray from a pointer if availible (eg. 6dof controller)
  97536. */
  97537. ray: Nullable<Ray>;
  97538. /**
  97539. * Defines the local position of the pointer on the canvas.
  97540. */
  97541. localPosition: Vector2;
  97542. /**
  97543. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  97544. */
  97545. skipOnPointerObservable: boolean;
  97546. /**
  97547. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  97548. * @param type Defines the type of event (PointerEventTypes)
  97549. * @param event Defines the related dom event
  97550. * @param localX Defines the local x coordinates of the pointer when the event occured
  97551. * @param localY Defines the local y coordinates of the pointer when the event occured
  97552. */
  97553. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  97554. }
  97555. /**
  97556. * This type contains all the data related to a pointer event in Babylon.js.
  97557. * 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.
  97558. */
  97559. export class PointerInfo extends PointerInfoBase {
  97560. /**
  97561. * Defines the picking info associated to the info (if any)\
  97562. */
  97563. pickInfo: Nullable<PickingInfo>;
  97564. /**
  97565. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  97566. * @param type Defines the type of event (PointerEventTypes)
  97567. * @param event Defines the related dom event
  97568. * @param pickInfo Defines the picking info associated to the info (if any)\
  97569. */
  97570. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  97571. /**
  97572. * Defines the picking info associated to the info (if any)\
  97573. */
  97574. pickInfo: Nullable<PickingInfo>);
  97575. }
  97576. /**
  97577. * Data relating to a touch event on the screen.
  97578. */
  97579. export interface PointerTouch {
  97580. /**
  97581. * X coordinate of touch.
  97582. */
  97583. x: number;
  97584. /**
  97585. * Y coordinate of touch.
  97586. */
  97587. y: number;
  97588. /**
  97589. * Id of touch. Unique for each finger.
  97590. */
  97591. pointerId: number;
  97592. /**
  97593. * Event type passed from DOM.
  97594. */
  97595. type: any;
  97596. }
  97597. }
  97598. declare module BABYLON {
  97599. /**
  97600. * Manage the mouse inputs to control the movement of a free camera.
  97601. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97602. */
  97603. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  97604. /**
  97605. * Define if touch is enabled in the mouse input
  97606. */
  97607. touchEnabled: boolean;
  97608. /**
  97609. * Defines the camera the input is attached to.
  97610. */
  97611. camera: FreeCamera;
  97612. /**
  97613. * Defines the buttons associated with the input to handle camera move.
  97614. */
  97615. buttons: number[];
  97616. /**
  97617. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  97618. */
  97619. angularSensibility: number;
  97620. private _pointerInput;
  97621. private _onMouseMove;
  97622. private _observer;
  97623. private previousPosition;
  97624. /**
  97625. * Observable for when a pointer move event occurs containing the move offset
  97626. */
  97627. onPointerMovedObservable: Observable<{
  97628. offsetX: number;
  97629. offsetY: number;
  97630. }>;
  97631. /**
  97632. * @hidden
  97633. * If the camera should be rotated automatically based on pointer movement
  97634. */
  97635. _allowCameraRotation: boolean;
  97636. /**
  97637. * Manage the mouse inputs to control the movement of a free camera.
  97638. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97639. * @param touchEnabled Defines if touch is enabled or not
  97640. */
  97641. constructor(
  97642. /**
  97643. * Define if touch is enabled in the mouse input
  97644. */
  97645. touchEnabled?: boolean);
  97646. /**
  97647. * Attach the input controls to a specific dom element to get the input from.
  97648. * @param element Defines the element the controls should be listened from
  97649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97650. */
  97651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97652. /**
  97653. * Called on JS contextmenu event.
  97654. * Override this method to provide functionality.
  97655. */
  97656. protected onContextMenu(evt: PointerEvent): void;
  97657. /**
  97658. * Detach the current controls from the specified dom element.
  97659. * @param element Defines the element to stop listening the inputs from
  97660. */
  97661. detachControl(element: Nullable<HTMLElement>): void;
  97662. /**
  97663. * Gets the class name of the current intput.
  97664. * @returns the class name
  97665. */
  97666. getClassName(): string;
  97667. /**
  97668. * Get the friendly name associated with the input class.
  97669. * @returns the input friendly name
  97670. */
  97671. getSimpleName(): string;
  97672. }
  97673. }
  97674. declare module BABYLON {
  97675. /**
  97676. * Manage the touch inputs to control the movement of a free camera.
  97677. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97678. */
  97679. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97680. /**
  97681. * Defines the camera the input is attached to.
  97682. */
  97683. camera: FreeCamera;
  97684. /**
  97685. * Defines the touch sensibility for rotation.
  97686. * The higher the faster.
  97687. */
  97688. touchAngularSensibility: number;
  97689. /**
  97690. * Defines the touch sensibility for move.
  97691. * The higher the faster.
  97692. */
  97693. touchMoveSensibility: number;
  97694. private _offsetX;
  97695. private _offsetY;
  97696. private _pointerPressed;
  97697. private _pointerInput;
  97698. private _observer;
  97699. private _onLostFocus;
  97700. /**
  97701. * Attach the input controls to a specific dom element to get the input from.
  97702. * @param element Defines the element the controls should be listened from
  97703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97704. */
  97705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97706. /**
  97707. * Detach the current controls from the specified dom element.
  97708. * @param element Defines the element to stop listening the inputs from
  97709. */
  97710. detachControl(element: Nullable<HTMLElement>): void;
  97711. /**
  97712. * Update the current camera state depending on the inputs that have been used this frame.
  97713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97714. */
  97715. checkInputs(): void;
  97716. /**
  97717. * Gets the class name of the current intput.
  97718. * @returns the class name
  97719. */
  97720. getClassName(): string;
  97721. /**
  97722. * Get the friendly name associated with the input class.
  97723. * @returns the input friendly name
  97724. */
  97725. getSimpleName(): string;
  97726. }
  97727. }
  97728. declare module BABYLON {
  97729. /**
  97730. * Default Inputs manager for the FreeCamera.
  97731. * It groups all the default supported inputs for ease of use.
  97732. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97733. */
  97734. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97735. /**
  97736. * @hidden
  97737. */
  97738. _mouseInput: Nullable<FreeCameraMouseInput>;
  97739. /**
  97740. * Instantiates a new FreeCameraInputsManager.
  97741. * @param camera Defines the camera the inputs belong to
  97742. */
  97743. constructor(camera: FreeCamera);
  97744. /**
  97745. * Add keyboard input support to the input manager.
  97746. * @returns the current input manager
  97747. */
  97748. addKeyboard(): FreeCameraInputsManager;
  97749. /**
  97750. * Add mouse input support to the input manager.
  97751. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97752. * @returns the current input manager
  97753. */
  97754. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97755. /**
  97756. * Removes the mouse input support from the manager
  97757. * @returns the current input manager
  97758. */
  97759. removeMouse(): FreeCameraInputsManager;
  97760. /**
  97761. * Add touch input support to the input manager.
  97762. * @returns the current input manager
  97763. */
  97764. addTouch(): FreeCameraInputsManager;
  97765. /**
  97766. * Remove all attached input methods from a camera
  97767. */
  97768. clear(): void;
  97769. }
  97770. }
  97771. declare module BABYLON {
  97772. /**
  97773. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97774. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97775. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97776. */
  97777. export class FreeCamera extends TargetCamera {
  97778. /**
  97779. * Define the collision ellipsoid of the camera.
  97780. * This is helpful to simulate a camera body like the player body around the camera
  97781. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97782. */
  97783. ellipsoid: Vector3;
  97784. /**
  97785. * Define an offset for the position of the ellipsoid around the camera.
  97786. * This can be helpful to determine the center of the body near the gravity center of the body
  97787. * instead of its head.
  97788. */
  97789. ellipsoidOffset: Vector3;
  97790. /**
  97791. * Enable or disable collisions of the camera with the rest of the scene objects.
  97792. */
  97793. checkCollisions: boolean;
  97794. /**
  97795. * Enable or disable gravity on the camera.
  97796. */
  97797. applyGravity: boolean;
  97798. /**
  97799. * Define the input manager associated to the camera.
  97800. */
  97801. inputs: FreeCameraInputsManager;
  97802. /**
  97803. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97804. * Higher values reduce sensitivity.
  97805. */
  97806. get angularSensibility(): number;
  97807. /**
  97808. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97809. * Higher values reduce sensitivity.
  97810. */
  97811. set angularSensibility(value: number);
  97812. /**
  97813. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97814. */
  97815. get keysUp(): number[];
  97816. set keysUp(value: number[]);
  97817. /**
  97818. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97819. */
  97820. get keysUpward(): number[];
  97821. set keysUpward(value: number[]);
  97822. /**
  97823. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97824. */
  97825. get keysDown(): number[];
  97826. set keysDown(value: number[]);
  97827. /**
  97828. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97829. */
  97830. get keysDownward(): number[];
  97831. set keysDownward(value: number[]);
  97832. /**
  97833. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97834. */
  97835. get keysLeft(): number[];
  97836. set keysLeft(value: number[]);
  97837. /**
  97838. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97839. */
  97840. get keysRight(): number[];
  97841. set keysRight(value: number[]);
  97842. /**
  97843. * Event raised when the camera collide with a mesh in the scene.
  97844. */
  97845. onCollide: (collidedMesh: AbstractMesh) => void;
  97846. private _collider;
  97847. private _needMoveForGravity;
  97848. private _oldPosition;
  97849. private _diffPosition;
  97850. private _newPosition;
  97851. /** @hidden */
  97852. _localDirection: Vector3;
  97853. /** @hidden */
  97854. _transformedDirection: Vector3;
  97855. /**
  97856. * Instantiates a Free Camera.
  97857. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97858. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97859. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97860. * @param name Define the name of the camera in the scene
  97861. * @param position Define the start position of the camera in the scene
  97862. * @param scene Define the scene the camera belongs to
  97863. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97864. */
  97865. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97866. /**
  97867. * Attached controls to the current camera.
  97868. * @param element Defines the element the controls should be listened from
  97869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97870. */
  97871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97872. /**
  97873. * Detach the current controls from the camera.
  97874. * The camera will stop reacting to inputs.
  97875. * @param element Defines the element to stop listening the inputs from
  97876. */
  97877. detachControl(element: HTMLElement): void;
  97878. private _collisionMask;
  97879. /**
  97880. * Define a collision mask to limit the list of object the camera can collide with
  97881. */
  97882. get collisionMask(): number;
  97883. set collisionMask(mask: number);
  97884. /** @hidden */
  97885. _collideWithWorld(displacement: Vector3): void;
  97886. private _onCollisionPositionChange;
  97887. /** @hidden */
  97888. _checkInputs(): void;
  97889. /** @hidden */
  97890. _decideIfNeedsToMove(): boolean;
  97891. /** @hidden */
  97892. _updatePosition(): void;
  97893. /**
  97894. * Destroy the camera and release the current resources hold by it.
  97895. */
  97896. dispose(): void;
  97897. /**
  97898. * Gets the current object class name.
  97899. * @return the class name
  97900. */
  97901. getClassName(): string;
  97902. }
  97903. }
  97904. declare module BABYLON {
  97905. /**
  97906. * Represents a gamepad control stick position
  97907. */
  97908. export class StickValues {
  97909. /**
  97910. * The x component of the control stick
  97911. */
  97912. x: number;
  97913. /**
  97914. * The y component of the control stick
  97915. */
  97916. y: number;
  97917. /**
  97918. * Initializes the gamepad x and y control stick values
  97919. * @param x The x component of the gamepad control stick value
  97920. * @param y The y component of the gamepad control stick value
  97921. */
  97922. constructor(
  97923. /**
  97924. * The x component of the control stick
  97925. */
  97926. x: number,
  97927. /**
  97928. * The y component of the control stick
  97929. */
  97930. y: number);
  97931. }
  97932. /**
  97933. * An interface which manages callbacks for gamepad button changes
  97934. */
  97935. export interface GamepadButtonChanges {
  97936. /**
  97937. * Called when a gamepad has been changed
  97938. */
  97939. changed: boolean;
  97940. /**
  97941. * Called when a gamepad press event has been triggered
  97942. */
  97943. pressChanged: boolean;
  97944. /**
  97945. * Called when a touch event has been triggered
  97946. */
  97947. touchChanged: boolean;
  97948. /**
  97949. * Called when a value has changed
  97950. */
  97951. valueChanged: boolean;
  97952. }
  97953. /**
  97954. * Represents a gamepad
  97955. */
  97956. export class Gamepad {
  97957. /**
  97958. * The id of the gamepad
  97959. */
  97960. id: string;
  97961. /**
  97962. * The index of the gamepad
  97963. */
  97964. index: number;
  97965. /**
  97966. * The browser gamepad
  97967. */
  97968. browserGamepad: any;
  97969. /**
  97970. * Specifies what type of gamepad this represents
  97971. */
  97972. type: number;
  97973. private _leftStick;
  97974. private _rightStick;
  97975. /** @hidden */
  97976. _isConnected: boolean;
  97977. private _leftStickAxisX;
  97978. private _leftStickAxisY;
  97979. private _rightStickAxisX;
  97980. private _rightStickAxisY;
  97981. /**
  97982. * Triggered when the left control stick has been changed
  97983. */
  97984. private _onleftstickchanged;
  97985. /**
  97986. * Triggered when the right control stick has been changed
  97987. */
  97988. private _onrightstickchanged;
  97989. /**
  97990. * Represents a gamepad controller
  97991. */
  97992. static GAMEPAD: number;
  97993. /**
  97994. * Represents a generic controller
  97995. */
  97996. static GENERIC: number;
  97997. /**
  97998. * Represents an XBox controller
  97999. */
  98000. static XBOX: number;
  98001. /**
  98002. * Represents a pose-enabled controller
  98003. */
  98004. static POSE_ENABLED: number;
  98005. /**
  98006. * Represents an Dual Shock controller
  98007. */
  98008. static DUALSHOCK: number;
  98009. /**
  98010. * Specifies whether the left control stick should be Y-inverted
  98011. */
  98012. protected _invertLeftStickY: boolean;
  98013. /**
  98014. * Specifies if the gamepad has been connected
  98015. */
  98016. get isConnected(): boolean;
  98017. /**
  98018. * Initializes the gamepad
  98019. * @param id The id of the gamepad
  98020. * @param index The index of the gamepad
  98021. * @param browserGamepad The browser gamepad
  98022. * @param leftStickX The x component of the left joystick
  98023. * @param leftStickY The y component of the left joystick
  98024. * @param rightStickX The x component of the right joystick
  98025. * @param rightStickY The y component of the right joystick
  98026. */
  98027. constructor(
  98028. /**
  98029. * The id of the gamepad
  98030. */
  98031. id: string,
  98032. /**
  98033. * The index of the gamepad
  98034. */
  98035. index: number,
  98036. /**
  98037. * The browser gamepad
  98038. */
  98039. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  98040. /**
  98041. * Callback triggered when the left joystick has changed
  98042. * @param callback
  98043. */
  98044. onleftstickchanged(callback: (values: StickValues) => void): void;
  98045. /**
  98046. * Callback triggered when the right joystick has changed
  98047. * @param callback
  98048. */
  98049. onrightstickchanged(callback: (values: StickValues) => void): void;
  98050. /**
  98051. * Gets the left joystick
  98052. */
  98053. get leftStick(): StickValues;
  98054. /**
  98055. * Sets the left joystick values
  98056. */
  98057. set leftStick(newValues: StickValues);
  98058. /**
  98059. * Gets the right joystick
  98060. */
  98061. get rightStick(): StickValues;
  98062. /**
  98063. * Sets the right joystick value
  98064. */
  98065. set rightStick(newValues: StickValues);
  98066. /**
  98067. * Updates the gamepad joystick positions
  98068. */
  98069. update(): void;
  98070. /**
  98071. * Disposes the gamepad
  98072. */
  98073. dispose(): void;
  98074. }
  98075. /**
  98076. * Represents a generic gamepad
  98077. */
  98078. export class GenericPad extends Gamepad {
  98079. private _buttons;
  98080. private _onbuttondown;
  98081. private _onbuttonup;
  98082. /**
  98083. * Observable triggered when a button has been pressed
  98084. */
  98085. onButtonDownObservable: Observable<number>;
  98086. /**
  98087. * Observable triggered when a button has been released
  98088. */
  98089. onButtonUpObservable: Observable<number>;
  98090. /**
  98091. * Callback triggered when a button has been pressed
  98092. * @param callback Called when a button has been pressed
  98093. */
  98094. onbuttondown(callback: (buttonPressed: number) => void): void;
  98095. /**
  98096. * Callback triggered when a button has been released
  98097. * @param callback Called when a button has been released
  98098. */
  98099. onbuttonup(callback: (buttonReleased: number) => void): void;
  98100. /**
  98101. * Initializes the generic gamepad
  98102. * @param id The id of the generic gamepad
  98103. * @param index The index of the generic gamepad
  98104. * @param browserGamepad The browser gamepad
  98105. */
  98106. constructor(id: string, index: number, browserGamepad: any);
  98107. private _setButtonValue;
  98108. /**
  98109. * Updates the generic gamepad
  98110. */
  98111. update(): void;
  98112. /**
  98113. * Disposes the generic gamepad
  98114. */
  98115. dispose(): void;
  98116. }
  98117. }
  98118. declare module BABYLON {
  98119. /**
  98120. * Defines the types of pose enabled controllers that are supported
  98121. */
  98122. export enum PoseEnabledControllerType {
  98123. /**
  98124. * HTC Vive
  98125. */
  98126. VIVE = 0,
  98127. /**
  98128. * Oculus Rift
  98129. */
  98130. OCULUS = 1,
  98131. /**
  98132. * Windows mixed reality
  98133. */
  98134. WINDOWS = 2,
  98135. /**
  98136. * Samsung gear VR
  98137. */
  98138. GEAR_VR = 3,
  98139. /**
  98140. * Google Daydream
  98141. */
  98142. DAYDREAM = 4,
  98143. /**
  98144. * Generic
  98145. */
  98146. GENERIC = 5
  98147. }
  98148. /**
  98149. * Defines the MutableGamepadButton interface for the state of a gamepad button
  98150. */
  98151. export interface MutableGamepadButton {
  98152. /**
  98153. * Value of the button/trigger
  98154. */
  98155. value: number;
  98156. /**
  98157. * If the button/trigger is currently touched
  98158. */
  98159. touched: boolean;
  98160. /**
  98161. * If the button/trigger is currently pressed
  98162. */
  98163. pressed: boolean;
  98164. }
  98165. /**
  98166. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  98167. * @hidden
  98168. */
  98169. export interface ExtendedGamepadButton extends GamepadButton {
  98170. /**
  98171. * If the button/trigger is currently pressed
  98172. */
  98173. readonly pressed: boolean;
  98174. /**
  98175. * If the button/trigger is currently touched
  98176. */
  98177. readonly touched: boolean;
  98178. /**
  98179. * Value of the button/trigger
  98180. */
  98181. readonly value: number;
  98182. }
  98183. /** @hidden */
  98184. export interface _GamePadFactory {
  98185. /**
  98186. * Returns whether or not the current gamepad can be created for this type of controller.
  98187. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98188. * @returns true if it can be created, otherwise false
  98189. */
  98190. canCreate(gamepadInfo: any): boolean;
  98191. /**
  98192. * Creates a new instance of the Gamepad.
  98193. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  98194. * @returns the new gamepad instance
  98195. */
  98196. create(gamepadInfo: any): Gamepad;
  98197. }
  98198. /**
  98199. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98200. */
  98201. export class PoseEnabledControllerHelper {
  98202. /** @hidden */
  98203. static _ControllerFactories: _GamePadFactory[];
  98204. /** @hidden */
  98205. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  98206. /**
  98207. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  98208. * @param vrGamepad the gamepad to initialized
  98209. * @returns a vr controller of the type the gamepad identified as
  98210. */
  98211. static InitiateController(vrGamepad: any): Gamepad;
  98212. }
  98213. /**
  98214. * Defines the PoseEnabledController object that contains state of a vr capable controller
  98215. */
  98216. export class PoseEnabledController extends Gamepad implements PoseControlled {
  98217. /**
  98218. * If the controller is used in a webXR session
  98219. */
  98220. isXR: boolean;
  98221. private _deviceRoomPosition;
  98222. private _deviceRoomRotationQuaternion;
  98223. /**
  98224. * The device position in babylon space
  98225. */
  98226. devicePosition: Vector3;
  98227. /**
  98228. * The device rotation in babylon space
  98229. */
  98230. deviceRotationQuaternion: Quaternion;
  98231. /**
  98232. * The scale factor of the device in babylon space
  98233. */
  98234. deviceScaleFactor: number;
  98235. /**
  98236. * (Likely devicePosition should be used instead) The device position in its room space
  98237. */
  98238. position: Vector3;
  98239. /**
  98240. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  98241. */
  98242. rotationQuaternion: Quaternion;
  98243. /**
  98244. * The type of controller (Eg. Windows mixed reality)
  98245. */
  98246. controllerType: PoseEnabledControllerType;
  98247. protected _calculatedPosition: Vector3;
  98248. private _calculatedRotation;
  98249. /**
  98250. * The raw pose from the device
  98251. */
  98252. rawPose: DevicePose;
  98253. private _trackPosition;
  98254. private _maxRotationDistFromHeadset;
  98255. private _draggedRoomRotation;
  98256. /**
  98257. * @hidden
  98258. */
  98259. _disableTrackPosition(fixedPosition: Vector3): void;
  98260. /**
  98261. * Internal, the mesh attached to the controller
  98262. * @hidden
  98263. */
  98264. _mesh: Nullable<AbstractMesh>;
  98265. private _poseControlledCamera;
  98266. private _leftHandSystemQuaternion;
  98267. /**
  98268. * Internal, matrix used to convert room space to babylon space
  98269. * @hidden
  98270. */
  98271. _deviceToWorld: Matrix;
  98272. /**
  98273. * Node to be used when casting a ray from the controller
  98274. * @hidden
  98275. */
  98276. _pointingPoseNode: Nullable<TransformNode>;
  98277. /**
  98278. * Name of the child mesh that can be used to cast a ray from the controller
  98279. */
  98280. static readonly POINTING_POSE: string;
  98281. /**
  98282. * Creates a new PoseEnabledController from a gamepad
  98283. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  98284. */
  98285. constructor(browserGamepad: any);
  98286. private _workingMatrix;
  98287. /**
  98288. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  98289. */
  98290. update(): void;
  98291. /**
  98292. * Updates only the pose device and mesh without doing any button event checking
  98293. */
  98294. protected _updatePoseAndMesh(): void;
  98295. /**
  98296. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  98297. * @param poseData raw pose fromthe device
  98298. */
  98299. updateFromDevice(poseData: DevicePose): void;
  98300. /**
  98301. * @hidden
  98302. */
  98303. _meshAttachedObservable: Observable<AbstractMesh>;
  98304. /**
  98305. * Attaches a mesh to the controller
  98306. * @param mesh the mesh to be attached
  98307. */
  98308. attachToMesh(mesh: AbstractMesh): void;
  98309. /**
  98310. * Attaches the controllers mesh to a camera
  98311. * @param camera the camera the mesh should be attached to
  98312. */
  98313. attachToPoseControlledCamera(camera: TargetCamera): void;
  98314. /**
  98315. * Disposes of the controller
  98316. */
  98317. dispose(): void;
  98318. /**
  98319. * The mesh that is attached to the controller
  98320. */
  98321. get mesh(): Nullable<AbstractMesh>;
  98322. /**
  98323. * Gets the ray of the controller in the direction the controller is pointing
  98324. * @param length the length the resulting ray should be
  98325. * @returns a ray in the direction the controller is pointing
  98326. */
  98327. getForwardRay(length?: number): Ray;
  98328. }
  98329. }
  98330. declare module BABYLON {
  98331. /**
  98332. * Defines the WebVRController object that represents controllers tracked in 3D space
  98333. */
  98334. export abstract class WebVRController extends PoseEnabledController {
  98335. /**
  98336. * Internal, the default controller model for the controller
  98337. */
  98338. protected _defaultModel: Nullable<AbstractMesh>;
  98339. /**
  98340. * Fired when the trigger state has changed
  98341. */
  98342. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  98343. /**
  98344. * Fired when the main button state has changed
  98345. */
  98346. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98347. /**
  98348. * Fired when the secondary button state has changed
  98349. */
  98350. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  98351. /**
  98352. * Fired when the pad state has changed
  98353. */
  98354. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  98355. /**
  98356. * Fired when controllers stick values have changed
  98357. */
  98358. onPadValuesChangedObservable: Observable<StickValues>;
  98359. /**
  98360. * Array of button availible on the controller
  98361. */
  98362. protected _buttons: Array<MutableGamepadButton>;
  98363. private _onButtonStateChange;
  98364. /**
  98365. * Fired when a controller button's state has changed
  98366. * @param callback the callback containing the button that was modified
  98367. */
  98368. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  98369. /**
  98370. * X and Y axis corresponding to the controllers joystick
  98371. */
  98372. pad: StickValues;
  98373. /**
  98374. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  98375. */
  98376. hand: string;
  98377. /**
  98378. * The default controller model for the controller
  98379. */
  98380. get defaultModel(): Nullable<AbstractMesh>;
  98381. /**
  98382. * Creates a new WebVRController from a gamepad
  98383. * @param vrGamepad the gamepad that the WebVRController should be created from
  98384. */
  98385. constructor(vrGamepad: any);
  98386. /**
  98387. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  98388. */
  98389. update(): void;
  98390. /**
  98391. * Function to be called when a button is modified
  98392. */
  98393. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  98394. /**
  98395. * Loads a mesh and attaches it to the controller
  98396. * @param scene the scene the mesh should be added to
  98397. * @param meshLoaded callback for when the mesh has been loaded
  98398. */
  98399. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  98400. private _setButtonValue;
  98401. private _changes;
  98402. private _checkChanges;
  98403. /**
  98404. * Disposes of th webVRCOntroller
  98405. */
  98406. dispose(): void;
  98407. }
  98408. }
  98409. declare module BABYLON {
  98410. /**
  98411. * The HemisphericLight simulates the ambient environment light,
  98412. * so the passed direction is the light reflection direction, not the incoming direction.
  98413. */
  98414. export class HemisphericLight extends Light {
  98415. /**
  98416. * The groundColor is the light in the opposite direction to the one specified during creation.
  98417. * 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.
  98418. */
  98419. groundColor: Color3;
  98420. /**
  98421. * The light reflection direction, not the incoming direction.
  98422. */
  98423. direction: Vector3;
  98424. /**
  98425. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  98426. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  98427. * The HemisphericLight can't cast shadows.
  98428. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98429. * @param name The friendly name of the light
  98430. * @param direction The direction of the light reflection
  98431. * @param scene The scene the light belongs to
  98432. */
  98433. constructor(name: string, direction: Vector3, scene: Scene);
  98434. protected _buildUniformLayout(): void;
  98435. /**
  98436. * Returns the string "HemisphericLight".
  98437. * @return The class name
  98438. */
  98439. getClassName(): string;
  98440. /**
  98441. * Sets the HemisphericLight direction towards the passed target (Vector3).
  98442. * Returns the updated direction.
  98443. * @param target The target the direction should point to
  98444. * @return The computed direction
  98445. */
  98446. setDirectionToTarget(target: Vector3): Vector3;
  98447. /**
  98448. * Returns the shadow generator associated to the light.
  98449. * @returns Always null for hemispheric lights because it does not support shadows.
  98450. */
  98451. getShadowGenerator(): Nullable<IShadowGenerator>;
  98452. /**
  98453. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  98454. * @param effect The effect to update
  98455. * @param lightIndex The index of the light in the effect to update
  98456. * @returns The hemispheric light
  98457. */
  98458. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  98459. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  98460. /**
  98461. * Computes the world matrix of the node
  98462. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  98463. * @param useWasUpdatedFlag defines a reserved property
  98464. * @returns the world matrix
  98465. */
  98466. computeWorldMatrix(): Matrix;
  98467. /**
  98468. * Returns the integer 3.
  98469. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98470. */
  98471. getTypeID(): number;
  98472. /**
  98473. * Prepares the list of defines specific to the light type.
  98474. * @param defines the list of defines
  98475. * @param lightIndex defines the index of the light for the effect
  98476. */
  98477. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98478. }
  98479. }
  98480. declare module BABYLON {
  98481. /** @hidden */
  98482. export var vrMultiviewToSingleviewPixelShader: {
  98483. name: string;
  98484. shader: string;
  98485. };
  98486. }
  98487. declare module BABYLON {
  98488. /**
  98489. * Renders to multiple views with a single draw call
  98490. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  98491. */
  98492. export class MultiviewRenderTarget extends RenderTargetTexture {
  98493. /**
  98494. * Creates a multiview render target
  98495. * @param scene scene used with the render target
  98496. * @param size the size of the render target (used for each view)
  98497. */
  98498. constructor(scene: Scene, size?: number | {
  98499. width: number;
  98500. height: number;
  98501. } | {
  98502. ratio: number;
  98503. });
  98504. /**
  98505. * @hidden
  98506. * @param faceIndex the face index, if its a cube texture
  98507. */
  98508. _bindFrameBuffer(faceIndex?: number): void;
  98509. /**
  98510. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  98511. * @returns the view count
  98512. */
  98513. getViewCount(): number;
  98514. }
  98515. }
  98516. declare module BABYLON {
  98517. interface Engine {
  98518. /**
  98519. * Creates a new multiview render target
  98520. * @param width defines the width of the texture
  98521. * @param height defines the height of the texture
  98522. * @returns the created multiview texture
  98523. */
  98524. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  98525. /**
  98526. * Binds a multiview framebuffer to be drawn to
  98527. * @param multiviewTexture texture to bind
  98528. */
  98529. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  98530. }
  98531. interface Camera {
  98532. /**
  98533. * @hidden
  98534. * 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)
  98535. */
  98536. _useMultiviewToSingleView: boolean;
  98537. /**
  98538. * @hidden
  98539. * 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)
  98540. */
  98541. _multiviewTexture: Nullable<RenderTargetTexture>;
  98542. /**
  98543. * @hidden
  98544. * ensures the multiview texture of the camera exists and has the specified width/height
  98545. * @param width height to set on the multiview texture
  98546. * @param height width to set on the multiview texture
  98547. */
  98548. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  98549. }
  98550. interface Scene {
  98551. /** @hidden */
  98552. _transformMatrixR: Matrix;
  98553. /** @hidden */
  98554. _multiviewSceneUbo: Nullable<UniformBuffer>;
  98555. /** @hidden */
  98556. _createMultiviewUbo(): void;
  98557. /** @hidden */
  98558. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  98559. /** @hidden */
  98560. _renderMultiviewToSingleView(camera: Camera): void;
  98561. }
  98562. }
  98563. declare module BABYLON {
  98564. /**
  98565. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  98566. * This will not be used for webXR as it supports displaying texture arrays directly
  98567. */
  98568. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  98569. /**
  98570. * Initializes a VRMultiviewToSingleview
  98571. * @param name name of the post process
  98572. * @param camera camera to be applied to
  98573. * @param scaleFactor scaling factor to the size of the output texture
  98574. */
  98575. constructor(name: string, camera: Camera, scaleFactor: number);
  98576. }
  98577. }
  98578. declare module BABYLON {
  98579. /**
  98580. * Interface used to define additional presentation attributes
  98581. */
  98582. export interface IVRPresentationAttributes {
  98583. /**
  98584. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  98585. */
  98586. highRefreshRate: boolean;
  98587. /**
  98588. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  98589. */
  98590. foveationLevel: number;
  98591. }
  98592. interface Engine {
  98593. /** @hidden */
  98594. _vrDisplay: any;
  98595. /** @hidden */
  98596. _vrSupported: boolean;
  98597. /** @hidden */
  98598. _oldSize: Size;
  98599. /** @hidden */
  98600. _oldHardwareScaleFactor: number;
  98601. /** @hidden */
  98602. _vrExclusivePointerMode: boolean;
  98603. /** @hidden */
  98604. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  98605. /** @hidden */
  98606. _onVRDisplayPointerRestricted: () => void;
  98607. /** @hidden */
  98608. _onVRDisplayPointerUnrestricted: () => void;
  98609. /** @hidden */
  98610. _onVrDisplayConnect: Nullable<(display: any) => void>;
  98611. /** @hidden */
  98612. _onVrDisplayDisconnect: Nullable<() => void>;
  98613. /** @hidden */
  98614. _onVrDisplayPresentChange: Nullable<() => void>;
  98615. /**
  98616. * Observable signaled when VR display mode changes
  98617. */
  98618. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  98619. /**
  98620. * Observable signaled when VR request present is complete
  98621. */
  98622. onVRRequestPresentComplete: Observable<boolean>;
  98623. /**
  98624. * Observable signaled when VR request present starts
  98625. */
  98626. onVRRequestPresentStart: Observable<Engine>;
  98627. /**
  98628. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  98629. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  98630. */
  98631. isInVRExclusivePointerMode: boolean;
  98632. /**
  98633. * Gets a boolean indicating if a webVR device was detected
  98634. * @returns true if a webVR device was detected
  98635. */
  98636. isVRDevicePresent(): boolean;
  98637. /**
  98638. * Gets the current webVR device
  98639. * @returns the current webVR device (or null)
  98640. */
  98641. getVRDevice(): any;
  98642. /**
  98643. * Initializes a webVR display and starts listening to display change events
  98644. * The onVRDisplayChangedObservable will be notified upon these changes
  98645. * @returns A promise containing a VRDisplay and if vr is supported
  98646. */
  98647. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  98648. /** @hidden */
  98649. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  98650. /**
  98651. * Gets or sets the presentation attributes used to configure VR rendering
  98652. */
  98653. vrPresentationAttributes?: IVRPresentationAttributes;
  98654. /**
  98655. * Call this function to switch to webVR mode
  98656. * Will do nothing if webVR is not supported or if there is no webVR device
  98657. * @param options the webvr options provided to the camera. mainly used for multiview
  98658. * @see https://doc.babylonjs.com/how_to/webvr_camera
  98659. */
  98660. enableVR(options: WebVROptions): void;
  98661. /** @hidden */
  98662. _onVRFullScreenTriggered(): void;
  98663. }
  98664. }
  98665. declare module BABYLON {
  98666. /**
  98667. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  98668. * IMPORTANT!! The data is right-hand data.
  98669. * @export
  98670. * @interface DevicePose
  98671. */
  98672. export interface DevicePose {
  98673. /**
  98674. * The position of the device, values in array are [x,y,z].
  98675. */
  98676. readonly position: Nullable<Float32Array>;
  98677. /**
  98678. * The linearVelocity of the device, values in array are [x,y,z].
  98679. */
  98680. readonly linearVelocity: Nullable<Float32Array>;
  98681. /**
  98682. * The linearAcceleration of the device, values in array are [x,y,z].
  98683. */
  98684. readonly linearAcceleration: Nullable<Float32Array>;
  98685. /**
  98686. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98687. */
  98688. readonly orientation: Nullable<Float32Array>;
  98689. /**
  98690. * The angularVelocity of the device, values in array are [x,y,z].
  98691. */
  98692. readonly angularVelocity: Nullable<Float32Array>;
  98693. /**
  98694. * The angularAcceleration of the device, values in array are [x,y,z].
  98695. */
  98696. readonly angularAcceleration: Nullable<Float32Array>;
  98697. }
  98698. /**
  98699. * Interface representing a pose controlled object in Babylon.
  98700. * A pose controlled object has both regular pose values as well as pose values
  98701. * from an external device such as a VR head mounted display
  98702. */
  98703. export interface PoseControlled {
  98704. /**
  98705. * The position of the object in babylon space.
  98706. */
  98707. position: Vector3;
  98708. /**
  98709. * The rotation quaternion of the object in babylon space.
  98710. */
  98711. rotationQuaternion: Quaternion;
  98712. /**
  98713. * The position of the device in babylon space.
  98714. */
  98715. devicePosition?: Vector3;
  98716. /**
  98717. * The rotation quaternion of the device in babylon space.
  98718. */
  98719. deviceRotationQuaternion: Quaternion;
  98720. /**
  98721. * The raw pose coming from the device.
  98722. */
  98723. rawPose: Nullable<DevicePose>;
  98724. /**
  98725. * The scale of the device to be used when translating from device space to babylon space.
  98726. */
  98727. deviceScaleFactor: number;
  98728. /**
  98729. * Updates the poseControlled values based on the input device pose.
  98730. * @param poseData the pose data to update the object with
  98731. */
  98732. updateFromDevice(poseData: DevicePose): void;
  98733. }
  98734. /**
  98735. * Set of options to customize the webVRCamera
  98736. */
  98737. export interface WebVROptions {
  98738. /**
  98739. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98740. */
  98741. trackPosition?: boolean;
  98742. /**
  98743. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98744. */
  98745. positionScale?: number;
  98746. /**
  98747. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98748. */
  98749. displayName?: string;
  98750. /**
  98751. * Should the native controller meshes be initialized. (default: true)
  98752. */
  98753. controllerMeshes?: boolean;
  98754. /**
  98755. * Creating a default HemiLight only on controllers. (default: true)
  98756. */
  98757. defaultLightingOnControllers?: boolean;
  98758. /**
  98759. * If you don't want to use the default VR button of the helper. (default: false)
  98760. */
  98761. useCustomVRButton?: boolean;
  98762. /**
  98763. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98764. */
  98765. customVRButton?: HTMLButtonElement;
  98766. /**
  98767. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98768. */
  98769. rayLength?: number;
  98770. /**
  98771. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98772. */
  98773. defaultHeight?: number;
  98774. /**
  98775. * If multiview should be used if availible (default: false)
  98776. */
  98777. useMultiview?: boolean;
  98778. }
  98779. /**
  98780. * This represents a WebVR camera.
  98781. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98782. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98783. */
  98784. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98785. private webVROptions;
  98786. /**
  98787. * @hidden
  98788. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98789. */
  98790. _vrDevice: any;
  98791. /**
  98792. * The rawPose of the vrDevice.
  98793. */
  98794. rawPose: Nullable<DevicePose>;
  98795. private _onVREnabled;
  98796. private _specsVersion;
  98797. private _attached;
  98798. private _frameData;
  98799. protected _descendants: Array<Node>;
  98800. private _deviceRoomPosition;
  98801. /** @hidden */
  98802. _deviceRoomRotationQuaternion: Quaternion;
  98803. private _standingMatrix;
  98804. /**
  98805. * Represents device position in babylon space.
  98806. */
  98807. devicePosition: Vector3;
  98808. /**
  98809. * Represents device rotation in babylon space.
  98810. */
  98811. deviceRotationQuaternion: Quaternion;
  98812. /**
  98813. * The scale of the device to be used when translating from device space to babylon space.
  98814. */
  98815. deviceScaleFactor: number;
  98816. private _deviceToWorld;
  98817. private _worldToDevice;
  98818. /**
  98819. * References to the webVR controllers for the vrDevice.
  98820. */
  98821. controllers: Array<WebVRController>;
  98822. /**
  98823. * Emits an event when a controller is attached.
  98824. */
  98825. onControllersAttachedObservable: Observable<WebVRController[]>;
  98826. /**
  98827. * Emits an event when a controller's mesh has been loaded;
  98828. */
  98829. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98830. /**
  98831. * Emits an event when the HMD's pose has been updated.
  98832. */
  98833. onPoseUpdatedFromDeviceObservable: Observable<any>;
  98834. private _poseSet;
  98835. /**
  98836. * If the rig cameras be used as parent instead of this camera.
  98837. */
  98838. rigParenting: boolean;
  98839. private _lightOnControllers;
  98840. private _defaultHeight?;
  98841. /**
  98842. * Instantiates a WebVRFreeCamera.
  98843. * @param name The name of the WebVRFreeCamera
  98844. * @param position The starting anchor position for the camera
  98845. * @param scene The scene the camera belongs to
  98846. * @param webVROptions a set of customizable options for the webVRCamera
  98847. */
  98848. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  98849. /**
  98850. * Gets the device distance from the ground in meters.
  98851. * @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.
  98852. */
  98853. deviceDistanceToRoomGround(): number;
  98854. /**
  98855. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98856. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98857. */
  98858. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98859. /**
  98860. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98861. * @returns A promise with a boolean set to if the standing matrix is supported.
  98862. */
  98863. useStandingMatrixAsync(): Promise<boolean>;
  98864. /**
  98865. * Disposes the camera
  98866. */
  98867. dispose(): void;
  98868. /**
  98869. * Gets a vrController by name.
  98870. * @param name The name of the controller to retreive
  98871. * @returns the controller matching the name specified or null if not found
  98872. */
  98873. getControllerByName(name: string): Nullable<WebVRController>;
  98874. private _leftController;
  98875. /**
  98876. * The controller corresponding to the users left hand.
  98877. */
  98878. get leftController(): Nullable<WebVRController>;
  98879. private _rightController;
  98880. /**
  98881. * The controller corresponding to the users right hand.
  98882. */
  98883. get rightController(): Nullable<WebVRController>;
  98884. /**
  98885. * Casts a ray forward from the vrCamera's gaze.
  98886. * @param length Length of the ray (default: 100)
  98887. * @returns the ray corresponding to the gaze
  98888. */
  98889. getForwardRay(length?: number): Ray;
  98890. /**
  98891. * @hidden
  98892. * Updates the camera based on device's frame data
  98893. */
  98894. _checkInputs(): void;
  98895. /**
  98896. * Updates the poseControlled values based on the input device pose.
  98897. * @param poseData Pose coming from the device
  98898. */
  98899. updateFromDevice(poseData: DevicePose): void;
  98900. private _htmlElementAttached;
  98901. private _detachIfAttached;
  98902. /**
  98903. * WebVR's attach control will start broadcasting frames to the device.
  98904. * Note that in certain browsers (chrome for example) this function must be called
  98905. * within a user-interaction callback. Example:
  98906. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98907. *
  98908. * @param element html element to attach the vrDevice to
  98909. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98910. */
  98911. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98912. /**
  98913. * Detaches the camera from the html element and disables VR
  98914. *
  98915. * @param element html element to detach from
  98916. */
  98917. detachControl(element: HTMLElement): void;
  98918. /**
  98919. * @returns the name of this class
  98920. */
  98921. getClassName(): string;
  98922. /**
  98923. * Calls resetPose on the vrDisplay
  98924. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98925. */
  98926. resetToCurrentRotation(): void;
  98927. /**
  98928. * @hidden
  98929. * Updates the rig cameras (left and right eye)
  98930. */
  98931. _updateRigCameras(): void;
  98932. private _workingVector;
  98933. private _oneVector;
  98934. private _workingMatrix;
  98935. private updateCacheCalled;
  98936. private _correctPositionIfNotTrackPosition;
  98937. /**
  98938. * @hidden
  98939. * Updates the cached values of the camera
  98940. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98941. */
  98942. _updateCache(ignoreParentClass?: boolean): void;
  98943. /**
  98944. * @hidden
  98945. * Get current device position in babylon world
  98946. */
  98947. _computeDevicePosition(): void;
  98948. /**
  98949. * Updates the current device position and rotation in the babylon world
  98950. */
  98951. update(): void;
  98952. /**
  98953. * @hidden
  98954. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98955. * @returns an identity matrix
  98956. */
  98957. _getViewMatrix(): Matrix;
  98958. private _tmpMatrix;
  98959. /**
  98960. * This function is called by the two RIG cameras.
  98961. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98962. * @hidden
  98963. */
  98964. _getWebVRViewMatrix(): Matrix;
  98965. /** @hidden */
  98966. _getWebVRProjectionMatrix(): Matrix;
  98967. private _onGamepadConnectedObserver;
  98968. private _onGamepadDisconnectedObserver;
  98969. private _updateCacheWhenTrackingDisabledObserver;
  98970. /**
  98971. * Initializes the controllers and their meshes
  98972. */
  98973. initControllers(): void;
  98974. }
  98975. }
  98976. declare module BABYLON {
  98977. /**
  98978. * "Static Class" containing the most commonly used helper while dealing with material for
  98979. * rendering purpose.
  98980. *
  98981. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98982. *
  98983. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98984. */
  98985. export class MaterialHelper {
  98986. /**
  98987. * Bind the current view position to an effect.
  98988. * @param effect The effect to be bound
  98989. * @param scene The scene the eyes position is used from
  98990. * @param variableName name of the shader variable that will hold the eye position
  98991. */
  98992. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98993. /**
  98994. * Helps preparing the defines values about the UVs in used in the effect.
  98995. * UVs are shared as much as we can accross channels in the shaders.
  98996. * @param texture The texture we are preparing the UVs for
  98997. * @param defines The defines to update
  98998. * @param key The channel key "diffuse", "specular"... used in the shader
  98999. */
  99000. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  99001. /**
  99002. * Binds a texture matrix value to its corrsponding uniform
  99003. * @param texture The texture to bind the matrix for
  99004. * @param uniformBuffer The uniform buffer receivin the data
  99005. * @param key The channel key "diffuse", "specular"... used in the shader
  99006. */
  99007. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  99008. /**
  99009. * Gets the current status of the fog (should it be enabled?)
  99010. * @param mesh defines the mesh to evaluate for fog support
  99011. * @param scene defines the hosting scene
  99012. * @returns true if fog must be enabled
  99013. */
  99014. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  99015. /**
  99016. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  99017. * @param mesh defines the current mesh
  99018. * @param scene defines the current scene
  99019. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  99020. * @param pointsCloud defines if point cloud rendering has to be turned on
  99021. * @param fogEnabled defines if fog has to be turned on
  99022. * @param alphaTest defines if alpha testing has to be turned on
  99023. * @param defines defines the current list of defines
  99024. */
  99025. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  99026. /**
  99027. * Helper used to prepare the list of defines associated with frame values for shader compilation
  99028. * @param scene defines the current scene
  99029. * @param engine defines the current engine
  99030. * @param defines specifies the list of active defines
  99031. * @param useInstances defines if instances have to be turned on
  99032. * @param useClipPlane defines if clip plane have to be turned on
  99033. * @param useInstances defines if instances have to be turned on
  99034. * @param useThinInstances defines if thin instances have to be turned on
  99035. */
  99036. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  99037. /**
  99038. * Prepares the defines for bones
  99039. * @param mesh The mesh containing the geometry data we will draw
  99040. * @param defines The defines to update
  99041. */
  99042. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  99043. /**
  99044. * Prepares the defines for morph targets
  99045. * @param mesh The mesh containing the geometry data we will draw
  99046. * @param defines The defines to update
  99047. */
  99048. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  99049. /**
  99050. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  99051. * @param mesh The mesh containing the geometry data we will draw
  99052. * @param defines The defines to update
  99053. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  99054. * @param useBones Precise whether bones should be used or not (override mesh info)
  99055. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  99056. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  99057. * @returns false if defines are considered not dirty and have not been checked
  99058. */
  99059. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  99060. /**
  99061. * Prepares the defines related to multiview
  99062. * @param scene The scene we are intending to draw
  99063. * @param defines The defines to update
  99064. */
  99065. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  99066. /**
  99067. * Prepares the defines related to the prepass
  99068. * @param scene The scene we are intending to draw
  99069. * @param defines The defines to update
  99070. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  99071. */
  99072. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  99073. /**
  99074. * Prepares the defines related to the light information passed in parameter
  99075. * @param scene The scene we are intending to draw
  99076. * @param mesh The mesh the effect is compiling for
  99077. * @param light The light the effect is compiling for
  99078. * @param lightIndex The index of the light
  99079. * @param defines The defines to update
  99080. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99081. * @param state Defines the current state regarding what is needed (normals, etc...)
  99082. */
  99083. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  99084. needNormals: boolean;
  99085. needRebuild: boolean;
  99086. shadowEnabled: boolean;
  99087. specularEnabled: boolean;
  99088. lightmapMode: boolean;
  99089. }): void;
  99090. /**
  99091. * Prepares the defines related to the light information passed in parameter
  99092. * @param scene The scene we are intending to draw
  99093. * @param mesh The mesh the effect is compiling for
  99094. * @param defines The defines to update
  99095. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  99096. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  99097. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  99098. * @returns true if normals will be required for the rest of the effect
  99099. */
  99100. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  99101. /**
  99102. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  99103. * @param lightIndex defines the light index
  99104. * @param uniformsList The uniform list
  99105. * @param samplersList The sampler list
  99106. * @param projectedLightTexture defines if projected texture must be used
  99107. * @param uniformBuffersList defines an optional list of uniform buffers
  99108. */
  99109. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  99110. /**
  99111. * Prepares the uniforms and samplers list to be used in the effect
  99112. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  99113. * @param samplersList The sampler list
  99114. * @param defines The defines helping in the list generation
  99115. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  99116. */
  99117. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  99118. /**
  99119. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  99120. * @param defines The defines to update while falling back
  99121. * @param fallbacks The authorized effect fallbacks
  99122. * @param maxSimultaneousLights The maximum number of lights allowed
  99123. * @param rank the current rank of the Effect
  99124. * @returns The newly affected rank
  99125. */
  99126. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  99127. private static _TmpMorphInfluencers;
  99128. /**
  99129. * Prepares the list of attributes required for morph targets according to the effect defines.
  99130. * @param attribs The current list of supported attribs
  99131. * @param mesh The mesh to prepare the morph targets attributes for
  99132. * @param influencers The number of influencers
  99133. */
  99134. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  99135. /**
  99136. * Prepares the list of attributes required for morph targets according to the effect defines.
  99137. * @param attribs The current list of supported attribs
  99138. * @param mesh The mesh to prepare the morph targets attributes for
  99139. * @param defines The current Defines of the effect
  99140. */
  99141. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  99142. /**
  99143. * Prepares the list of attributes required for bones according to the effect defines.
  99144. * @param attribs The current list of supported attribs
  99145. * @param mesh The mesh to prepare the bones attributes for
  99146. * @param defines The current Defines of the effect
  99147. * @param fallbacks The current efffect fallback strategy
  99148. */
  99149. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  99150. /**
  99151. * Check and prepare the list of attributes required for instances according to the effect defines.
  99152. * @param attribs The current list of supported attribs
  99153. * @param defines The current MaterialDefines of the effect
  99154. */
  99155. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  99156. /**
  99157. * Add the list of attributes required for instances to the attribs array.
  99158. * @param attribs The current list of supported attribs
  99159. */
  99160. static PushAttributesForInstances(attribs: string[]): void;
  99161. /**
  99162. * Binds the light information to the effect.
  99163. * @param light The light containing the generator
  99164. * @param effect The effect we are binding the data to
  99165. * @param lightIndex The light index in the effect used to render
  99166. */
  99167. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  99168. /**
  99169. * Binds the lights information from the scene to the effect for the given mesh.
  99170. * @param light Light to bind
  99171. * @param lightIndex Light index
  99172. * @param scene The scene where the light belongs to
  99173. * @param effect The effect we are binding the data to
  99174. * @param useSpecular Defines if specular is supported
  99175. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99176. */
  99177. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99178. /**
  99179. * Binds the lights information from the scene to the effect for the given mesh.
  99180. * @param scene The scene the lights belongs to
  99181. * @param mesh The mesh we are binding the information to render
  99182. * @param effect The effect we are binding the data to
  99183. * @param defines The generated defines for the effect
  99184. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  99185. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99186. */
  99187. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  99188. private static _tempFogColor;
  99189. /**
  99190. * Binds the fog information from the scene to the effect for the given mesh.
  99191. * @param scene The scene the lights belongs to
  99192. * @param mesh The mesh we are binding the information to render
  99193. * @param effect The effect we are binding the data to
  99194. * @param linearSpace Defines if the fog effect is applied in linear space
  99195. */
  99196. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  99197. /**
  99198. * Binds the bones information from the mesh to the effect.
  99199. * @param mesh The mesh we are binding the information to render
  99200. * @param effect The effect we are binding the data to
  99201. */
  99202. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  99203. /**
  99204. * Binds the morph targets information from the mesh to the effect.
  99205. * @param abstractMesh The mesh we are binding the information to render
  99206. * @param effect The effect we are binding the data to
  99207. */
  99208. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  99209. /**
  99210. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  99211. * @param defines The generated defines used in the effect
  99212. * @param effect The effect we are binding the data to
  99213. * @param scene The scene we are willing to render with logarithmic scale for
  99214. */
  99215. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  99216. /**
  99217. * Binds the clip plane information from the scene to the effect.
  99218. * @param scene The scene the clip plane information are extracted from
  99219. * @param effect The effect we are binding the data to
  99220. */
  99221. static BindClipPlane(effect: Effect, scene: Scene): void;
  99222. }
  99223. }
  99224. declare module BABYLON {
  99225. /**
  99226. * Block used to expose an input value
  99227. */
  99228. export class InputBlock extends NodeMaterialBlock {
  99229. private _mode;
  99230. private _associatedVariableName;
  99231. private _storedValue;
  99232. private _valueCallback;
  99233. private _type;
  99234. private _animationType;
  99235. /** Gets or set a value used to limit the range of float values */
  99236. min: number;
  99237. /** Gets or set a value used to limit the range of float values */
  99238. max: number;
  99239. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  99240. isBoolean: boolean;
  99241. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  99242. matrixMode: number;
  99243. /** @hidden */
  99244. _systemValue: Nullable<NodeMaterialSystemValues>;
  99245. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  99246. visibleInInspector: boolean;
  99247. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  99248. isConstant: boolean;
  99249. /** Gets or sets the group to use to display this block in the Inspector */
  99250. groupInInspector: string;
  99251. /** Gets an observable raised when the value is changed */
  99252. onValueChangedObservable: Observable<InputBlock>;
  99253. /**
  99254. * Gets or sets the connection point type (default is float)
  99255. */
  99256. get type(): NodeMaterialBlockConnectionPointTypes;
  99257. /**
  99258. * Creates a new InputBlock
  99259. * @param name defines the block name
  99260. * @param target defines the target of that block (Vertex by default)
  99261. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  99262. */
  99263. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  99264. /**
  99265. * Validates if a name is a reserve word.
  99266. * @param newName the new name to be given to the node.
  99267. * @returns false if the name is a reserve word, else true.
  99268. */
  99269. validateBlockName(newName: string): boolean;
  99270. /**
  99271. * Gets the output component
  99272. */
  99273. get output(): NodeMaterialConnectionPoint;
  99274. /**
  99275. * Set the source of this connection point to a vertex attribute
  99276. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  99277. * @returns the current connection point
  99278. */
  99279. setAsAttribute(attributeName?: string): InputBlock;
  99280. /**
  99281. * Set the source of this connection point to a system value
  99282. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  99283. * @returns the current connection point
  99284. */
  99285. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  99286. /**
  99287. * Gets or sets the value of that point.
  99288. * Please note that this value will be ignored if valueCallback is defined
  99289. */
  99290. get value(): any;
  99291. set value(value: any);
  99292. /**
  99293. * Gets or sets a callback used to get the value of that point.
  99294. * Please note that setting this value will force the connection point to ignore the value property
  99295. */
  99296. get valueCallback(): () => any;
  99297. set valueCallback(value: () => any);
  99298. /**
  99299. * Gets or sets the associated variable name in the shader
  99300. */
  99301. get associatedVariableName(): string;
  99302. set associatedVariableName(value: string);
  99303. /** Gets or sets the type of animation applied to the input */
  99304. get animationType(): AnimatedInputBlockTypes;
  99305. set animationType(value: AnimatedInputBlockTypes);
  99306. /**
  99307. * Gets a boolean indicating that this connection point not defined yet
  99308. */
  99309. get isUndefined(): boolean;
  99310. /**
  99311. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  99312. * In this case the connection point name must be the name of the uniform to use.
  99313. * Can only be set on inputs
  99314. */
  99315. get isUniform(): boolean;
  99316. set isUniform(value: boolean);
  99317. /**
  99318. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  99319. * In this case the connection point name must be the name of the attribute to use
  99320. * Can only be set on inputs
  99321. */
  99322. get isAttribute(): boolean;
  99323. set isAttribute(value: boolean);
  99324. /**
  99325. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  99326. * Can only be set on exit points
  99327. */
  99328. get isVarying(): boolean;
  99329. set isVarying(value: boolean);
  99330. /**
  99331. * Gets a boolean indicating that the current connection point is a system value
  99332. */
  99333. get isSystemValue(): boolean;
  99334. /**
  99335. * Gets or sets the current well known value or null if not defined as a system value
  99336. */
  99337. get systemValue(): Nullable<NodeMaterialSystemValues>;
  99338. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  99339. /**
  99340. * Gets the current class name
  99341. * @returns the class name
  99342. */
  99343. getClassName(): string;
  99344. /**
  99345. * Animate the input if animationType !== None
  99346. * @param scene defines the rendering scene
  99347. */
  99348. animate(scene: Scene): void;
  99349. private _emitDefine;
  99350. initialize(state: NodeMaterialBuildState): void;
  99351. /**
  99352. * Set the input block to its default value (based on its type)
  99353. */
  99354. setDefaultValue(): void;
  99355. private _emitConstant;
  99356. /** @hidden */
  99357. get _noContextSwitch(): boolean;
  99358. private _emit;
  99359. /** @hidden */
  99360. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  99361. /** @hidden */
  99362. _transmit(effect: Effect, scene: Scene): void;
  99363. protected _buildBlock(state: NodeMaterialBuildState): void;
  99364. protected _dumpPropertiesCode(): string;
  99365. dispose(): void;
  99366. serialize(): any;
  99367. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99368. }
  99369. }
  99370. declare module BABYLON {
  99371. /**
  99372. * Enum used to define the compatibility state between two connection points
  99373. */
  99374. export enum NodeMaterialConnectionPointCompatibilityStates {
  99375. /** Points are compatibles */
  99376. Compatible = 0,
  99377. /** Points are incompatible because of their types */
  99378. TypeIncompatible = 1,
  99379. /** Points are incompatible because of their targets (vertex vs fragment) */
  99380. TargetIncompatible = 2
  99381. }
  99382. /**
  99383. * Defines the direction of a connection point
  99384. */
  99385. export enum NodeMaterialConnectionPointDirection {
  99386. /** Input */
  99387. Input = 0,
  99388. /** Output */
  99389. Output = 1
  99390. }
  99391. /**
  99392. * Defines a connection point for a block
  99393. */
  99394. export class NodeMaterialConnectionPoint {
  99395. /** @hidden */
  99396. _ownerBlock: NodeMaterialBlock;
  99397. /** @hidden */
  99398. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  99399. private _endpoints;
  99400. private _associatedVariableName;
  99401. private _direction;
  99402. /** @hidden */
  99403. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99404. /** @hidden */
  99405. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  99406. private _type;
  99407. /** @hidden */
  99408. _enforceAssociatedVariableName: boolean;
  99409. /** Gets the direction of the point */
  99410. get direction(): NodeMaterialConnectionPointDirection;
  99411. /** Indicates that this connection point needs dual validation before being connected to another point */
  99412. needDualDirectionValidation: boolean;
  99413. /**
  99414. * Gets or sets the additional types supported by this connection point
  99415. */
  99416. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99417. /**
  99418. * Gets or sets the additional types excluded by this connection point
  99419. */
  99420. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  99421. /**
  99422. * Observable triggered when this point is connected
  99423. */
  99424. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  99425. /**
  99426. * Gets or sets the associated variable name in the shader
  99427. */
  99428. get associatedVariableName(): string;
  99429. set associatedVariableName(value: string);
  99430. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  99431. get innerType(): NodeMaterialBlockConnectionPointTypes;
  99432. /**
  99433. * Gets or sets the connection point type (default is float)
  99434. */
  99435. get type(): NodeMaterialBlockConnectionPointTypes;
  99436. set type(value: NodeMaterialBlockConnectionPointTypes);
  99437. /**
  99438. * Gets or sets the connection point name
  99439. */
  99440. name: string;
  99441. /**
  99442. * Gets or sets the connection point name
  99443. */
  99444. displayName: string;
  99445. /**
  99446. * Gets or sets a boolean indicating that this connection point can be omitted
  99447. */
  99448. isOptional: boolean;
  99449. /**
  99450. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  99451. */
  99452. isExposedOnFrame: boolean;
  99453. /**
  99454. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  99455. */
  99456. define: string;
  99457. /** @hidden */
  99458. _prioritizeVertex: boolean;
  99459. private _target;
  99460. /** Gets or sets the target of that connection point */
  99461. get target(): NodeMaterialBlockTargets;
  99462. set target(value: NodeMaterialBlockTargets);
  99463. /**
  99464. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  99465. */
  99466. get isConnected(): boolean;
  99467. /**
  99468. * Gets a boolean indicating that the current point is connected to an input block
  99469. */
  99470. get isConnectedToInputBlock(): boolean;
  99471. /**
  99472. * Gets a the connected input block (if any)
  99473. */
  99474. get connectInputBlock(): Nullable<InputBlock>;
  99475. /** Get the other side of the connection (if any) */
  99476. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  99477. /** Get the block that owns this connection point */
  99478. get ownerBlock(): NodeMaterialBlock;
  99479. /** Get the block connected on the other side of this connection (if any) */
  99480. get sourceBlock(): Nullable<NodeMaterialBlock>;
  99481. /** Get the block connected on the endpoints of this connection (if any) */
  99482. get connectedBlocks(): Array<NodeMaterialBlock>;
  99483. /** Gets the list of connected endpoints */
  99484. get endpoints(): NodeMaterialConnectionPoint[];
  99485. /** Gets a boolean indicating if that output point is connected to at least one input */
  99486. get hasEndpoints(): boolean;
  99487. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  99488. get isConnectedInVertexShader(): boolean;
  99489. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  99490. get isConnectedInFragmentShader(): boolean;
  99491. /**
  99492. * Creates a block suitable to be used as an input for this input point.
  99493. * If null is returned, a block based on the point type will be created.
  99494. * @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
  99495. */
  99496. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99497. /**
  99498. * Creates a new connection point
  99499. * @param name defines the connection point name
  99500. * @param ownerBlock defines the block hosting this connection point
  99501. * @param direction defines the direction of the connection point
  99502. */
  99503. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  99504. /**
  99505. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  99506. * @returns the class name
  99507. */
  99508. getClassName(): string;
  99509. /**
  99510. * Gets a boolean indicating if the current point can be connected to another point
  99511. * @param connectionPoint defines the other connection point
  99512. * @returns a boolean
  99513. */
  99514. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  99515. /**
  99516. * Gets a number indicating if the current point can be connected to another point
  99517. * @param connectionPoint defines the other connection point
  99518. * @returns a number defining the compatibility state
  99519. */
  99520. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99521. /**
  99522. * Connect this point to another connection point
  99523. * @param connectionPoint defines the other connection point
  99524. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  99525. * @returns the current connection point
  99526. */
  99527. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  99528. /**
  99529. * Disconnect this point from one of his endpoint
  99530. * @param endpoint defines the other connection point
  99531. * @returns the current connection point
  99532. */
  99533. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  99534. /**
  99535. * Serializes this point in a JSON representation
  99536. * @param isInput defines if the connection point is an input (default is true)
  99537. * @returns the serialized point object
  99538. */
  99539. serialize(isInput?: boolean): any;
  99540. /**
  99541. * Release resources
  99542. */
  99543. dispose(): void;
  99544. }
  99545. }
  99546. declare module BABYLON {
  99547. /**
  99548. * Enum used to define the material modes
  99549. */
  99550. export enum NodeMaterialModes {
  99551. /** Regular material */
  99552. Material = 0,
  99553. /** For post process */
  99554. PostProcess = 1,
  99555. /** For particle system */
  99556. Particle = 2
  99557. }
  99558. }
  99559. declare module BABYLON {
  99560. /**
  99561. * Block used to read a texture from a sampler
  99562. */
  99563. export class TextureBlock extends NodeMaterialBlock {
  99564. private _defineName;
  99565. private _linearDefineName;
  99566. private _gammaDefineName;
  99567. private _tempTextureRead;
  99568. private _samplerName;
  99569. private _transformedUVName;
  99570. private _textureTransformName;
  99571. private _textureInfoName;
  99572. private _mainUVName;
  99573. private _mainUVDefineName;
  99574. private _fragmentOnly;
  99575. /**
  99576. * Gets or sets the texture associated with the node
  99577. */
  99578. texture: Nullable<Texture>;
  99579. /**
  99580. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99581. */
  99582. convertToGammaSpace: boolean;
  99583. /**
  99584. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99585. */
  99586. convertToLinearSpace: boolean;
  99587. /**
  99588. * Create a new TextureBlock
  99589. * @param name defines the block name
  99590. */
  99591. constructor(name: string, fragmentOnly?: boolean);
  99592. /**
  99593. * Gets the current class name
  99594. * @returns the class name
  99595. */
  99596. getClassName(): string;
  99597. /**
  99598. * Gets the uv input component
  99599. */
  99600. get uv(): NodeMaterialConnectionPoint;
  99601. /**
  99602. * Gets the rgba output component
  99603. */
  99604. get rgba(): NodeMaterialConnectionPoint;
  99605. /**
  99606. * Gets the rgb output component
  99607. */
  99608. get rgb(): NodeMaterialConnectionPoint;
  99609. /**
  99610. * Gets the r output component
  99611. */
  99612. get r(): NodeMaterialConnectionPoint;
  99613. /**
  99614. * Gets the g output component
  99615. */
  99616. get g(): NodeMaterialConnectionPoint;
  99617. /**
  99618. * Gets the b output component
  99619. */
  99620. get b(): NodeMaterialConnectionPoint;
  99621. /**
  99622. * Gets the a output component
  99623. */
  99624. get a(): NodeMaterialConnectionPoint;
  99625. get target(): NodeMaterialBlockTargets;
  99626. autoConfigure(material: NodeMaterial): void;
  99627. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99629. isReady(): boolean;
  99630. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99631. private get _isMixed();
  99632. private _injectVertexCode;
  99633. private _writeTextureRead;
  99634. private _writeOutput;
  99635. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99636. protected _dumpPropertiesCode(): string;
  99637. serialize(): any;
  99638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99639. }
  99640. }
  99641. declare module BABYLON {
  99642. /** @hidden */
  99643. export var reflectionFunction: {
  99644. name: string;
  99645. shader: string;
  99646. };
  99647. }
  99648. declare module BABYLON {
  99649. /**
  99650. * Base block used to read a reflection texture from a sampler
  99651. */
  99652. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  99653. /** @hidden */
  99654. _define3DName: string;
  99655. /** @hidden */
  99656. _defineCubicName: string;
  99657. /** @hidden */
  99658. _defineExplicitName: string;
  99659. /** @hidden */
  99660. _defineProjectionName: string;
  99661. /** @hidden */
  99662. _defineLocalCubicName: string;
  99663. /** @hidden */
  99664. _defineSphericalName: string;
  99665. /** @hidden */
  99666. _definePlanarName: string;
  99667. /** @hidden */
  99668. _defineEquirectangularName: string;
  99669. /** @hidden */
  99670. _defineMirroredEquirectangularFixedName: string;
  99671. /** @hidden */
  99672. _defineEquirectangularFixedName: string;
  99673. /** @hidden */
  99674. _defineSkyboxName: string;
  99675. /** @hidden */
  99676. _defineOppositeZ: string;
  99677. /** @hidden */
  99678. _cubeSamplerName: string;
  99679. /** @hidden */
  99680. _2DSamplerName: string;
  99681. protected _positionUVWName: string;
  99682. protected _directionWName: string;
  99683. protected _reflectionVectorName: string;
  99684. /** @hidden */
  99685. _reflectionCoordsName: string;
  99686. /** @hidden */
  99687. _reflectionMatrixName: string;
  99688. protected _reflectionColorName: string;
  99689. /**
  99690. * Gets or sets the texture associated with the node
  99691. */
  99692. texture: Nullable<BaseTexture>;
  99693. /**
  99694. * Create a new ReflectionTextureBaseBlock
  99695. * @param name defines the block name
  99696. */
  99697. constructor(name: string);
  99698. /**
  99699. * Gets the current class name
  99700. * @returns the class name
  99701. */
  99702. getClassName(): string;
  99703. /**
  99704. * Gets the world position input component
  99705. */
  99706. abstract get position(): NodeMaterialConnectionPoint;
  99707. /**
  99708. * Gets the world position input component
  99709. */
  99710. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99711. /**
  99712. * Gets the world normal input component
  99713. */
  99714. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99715. /**
  99716. * Gets the world input component
  99717. */
  99718. abstract get world(): NodeMaterialConnectionPoint;
  99719. /**
  99720. * Gets the camera (or eye) position component
  99721. */
  99722. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99723. /**
  99724. * Gets the view input component
  99725. */
  99726. abstract get view(): NodeMaterialConnectionPoint;
  99727. protected _getTexture(): Nullable<BaseTexture>;
  99728. autoConfigure(material: NodeMaterial): void;
  99729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99730. isReady(): boolean;
  99731. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99732. /**
  99733. * Gets the code to inject in the vertex shader
  99734. * @param state current state of the node material building
  99735. * @returns the shader code
  99736. */
  99737. handleVertexSide(state: NodeMaterialBuildState): string;
  99738. /**
  99739. * Handles the inits for the fragment code path
  99740. * @param state node material build state
  99741. */
  99742. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99743. /**
  99744. * Generates the reflection coords code for the fragment code path
  99745. * @param worldNormalVarName name of the world normal variable
  99746. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99747. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99748. * @returns the shader code
  99749. */
  99750. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99751. /**
  99752. * Generates the reflection color code for the fragment code path
  99753. * @param lodVarName name of the lod variable
  99754. * @param swizzleLookupTexture swizzle to use for the final color variable
  99755. * @returns the shader code
  99756. */
  99757. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99758. /**
  99759. * Generates the code corresponding to the connected output points
  99760. * @param state node material build state
  99761. * @param varName name of the variable to output
  99762. * @returns the shader code
  99763. */
  99764. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99765. protected _buildBlock(state: NodeMaterialBuildState): this;
  99766. protected _dumpPropertiesCode(): string;
  99767. serialize(): any;
  99768. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99769. }
  99770. }
  99771. declare module BABYLON {
  99772. /**
  99773. * Defines a connection point to be used for points with a custom object type
  99774. */
  99775. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99776. private _blockType;
  99777. private _blockName;
  99778. private _nameForCheking?;
  99779. /**
  99780. * Creates a new connection point
  99781. * @param name defines the connection point name
  99782. * @param ownerBlock defines the block hosting this connection point
  99783. * @param direction defines the direction of the connection point
  99784. */
  99785. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99786. /**
  99787. * Gets a number indicating if the current point can be connected to another point
  99788. * @param connectionPoint defines the other connection point
  99789. * @returns a number defining the compatibility state
  99790. */
  99791. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99792. /**
  99793. * Creates a block suitable to be used as an input for this input point.
  99794. * If null is returned, a block based on the point type will be created.
  99795. * @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
  99796. */
  99797. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99798. }
  99799. }
  99800. declare module BABYLON {
  99801. /**
  99802. * Enum defining the type of properties that can be edited in the property pages in the NME
  99803. */
  99804. export enum PropertyTypeForEdition {
  99805. /** property is a boolean */
  99806. Boolean = 0,
  99807. /** property is a float */
  99808. Float = 1,
  99809. /** property is a Vector2 */
  99810. Vector2 = 2,
  99811. /** property is a list of values */
  99812. List = 3
  99813. }
  99814. /**
  99815. * Interface that defines an option in a variable of type list
  99816. */
  99817. export interface IEditablePropertyListOption {
  99818. /** label of the option */
  99819. "label": string;
  99820. /** value of the option */
  99821. "value": number;
  99822. }
  99823. /**
  99824. * Interface that defines the options available for an editable property
  99825. */
  99826. export interface IEditablePropertyOption {
  99827. /** min value */
  99828. "min"?: number;
  99829. /** max value */
  99830. "max"?: number;
  99831. /** notifiers: indicates which actions to take when the property is changed */
  99832. "notifiers"?: {
  99833. /** the material should be rebuilt */
  99834. "rebuild"?: boolean;
  99835. /** the preview should be updated */
  99836. "update"?: boolean;
  99837. };
  99838. /** list of the options for a variable of type list */
  99839. "options"?: IEditablePropertyListOption[];
  99840. }
  99841. /**
  99842. * Interface that describes an editable property
  99843. */
  99844. export interface IPropertyDescriptionForEdition {
  99845. /** name of the property */
  99846. "propertyName": string;
  99847. /** display name of the property */
  99848. "displayName": string;
  99849. /** type of the property */
  99850. "type": PropertyTypeForEdition;
  99851. /** group of the property - all properties with the same group value will be displayed in a specific section */
  99852. "groupName": string;
  99853. /** options for the property */
  99854. "options": IEditablePropertyOption;
  99855. }
  99856. /**
  99857. * Decorator that flags a property in a node material block as being editable
  99858. */
  99859. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  99860. }
  99861. declare module BABYLON {
  99862. /**
  99863. * Block used to implement the refraction part of the sub surface module of the PBR material
  99864. */
  99865. export class RefractionBlock extends NodeMaterialBlock {
  99866. /** @hidden */
  99867. _define3DName: string;
  99868. /** @hidden */
  99869. _refractionMatrixName: string;
  99870. /** @hidden */
  99871. _defineLODRefractionAlpha: string;
  99872. /** @hidden */
  99873. _defineLinearSpecularRefraction: string;
  99874. /** @hidden */
  99875. _defineOppositeZ: string;
  99876. /** @hidden */
  99877. _cubeSamplerName: string;
  99878. /** @hidden */
  99879. _2DSamplerName: string;
  99880. /** @hidden */
  99881. _vRefractionMicrosurfaceInfosName: string;
  99882. /** @hidden */
  99883. _vRefractionInfosName: string;
  99884. private _scene;
  99885. /**
  99886. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99887. * Materials half opaque for instance using refraction could benefit from this control.
  99888. */
  99889. linkRefractionWithTransparency: boolean;
  99890. /**
  99891. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99892. */
  99893. invertRefractionY: boolean;
  99894. /**
  99895. * Gets or sets the texture associated with the node
  99896. */
  99897. texture: Nullable<BaseTexture>;
  99898. /**
  99899. * Create a new RefractionBlock
  99900. * @param name defines the block name
  99901. */
  99902. constructor(name: string);
  99903. /**
  99904. * Gets the current class name
  99905. * @returns the class name
  99906. */
  99907. getClassName(): string;
  99908. /**
  99909. * Gets the intensity input component
  99910. */
  99911. get intensity(): NodeMaterialConnectionPoint;
  99912. /**
  99913. * Gets the index of refraction input component
  99914. */
  99915. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99916. /**
  99917. * Gets the tint at distance input component
  99918. */
  99919. get tintAtDistance(): NodeMaterialConnectionPoint;
  99920. /**
  99921. * Gets the view input component
  99922. */
  99923. get view(): NodeMaterialConnectionPoint;
  99924. /**
  99925. * Gets the refraction object output component
  99926. */
  99927. get refraction(): NodeMaterialConnectionPoint;
  99928. /**
  99929. * Returns true if the block has a texture
  99930. */
  99931. get hasTexture(): boolean;
  99932. protected _getTexture(): Nullable<BaseTexture>;
  99933. autoConfigure(material: NodeMaterial): void;
  99934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99935. isReady(): boolean;
  99936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99937. /**
  99938. * Gets the main code of the block (fragment side)
  99939. * @param state current state of the node material building
  99940. * @returns the shader code
  99941. */
  99942. getCode(state: NodeMaterialBuildState): string;
  99943. protected _buildBlock(state: NodeMaterialBuildState): this;
  99944. protected _dumpPropertiesCode(): string;
  99945. serialize(): any;
  99946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99947. }
  99948. }
  99949. declare module BABYLON {
  99950. /**
  99951. * Base block used as input for post process
  99952. */
  99953. export class CurrentScreenBlock extends NodeMaterialBlock {
  99954. private _samplerName;
  99955. private _linearDefineName;
  99956. private _gammaDefineName;
  99957. private _mainUVName;
  99958. private _tempTextureRead;
  99959. /**
  99960. * Gets or sets the texture associated with the node
  99961. */
  99962. texture: Nullable<BaseTexture>;
  99963. /**
  99964. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99965. */
  99966. convertToGammaSpace: boolean;
  99967. /**
  99968. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99969. */
  99970. convertToLinearSpace: boolean;
  99971. /**
  99972. * Create a new CurrentScreenBlock
  99973. * @param name defines the block name
  99974. */
  99975. constructor(name: string);
  99976. /**
  99977. * Gets the current class name
  99978. * @returns the class name
  99979. */
  99980. getClassName(): string;
  99981. /**
  99982. * Gets the uv input component
  99983. */
  99984. get uv(): NodeMaterialConnectionPoint;
  99985. /**
  99986. * Gets the rgba output component
  99987. */
  99988. get rgba(): NodeMaterialConnectionPoint;
  99989. /**
  99990. * Gets the rgb output component
  99991. */
  99992. get rgb(): NodeMaterialConnectionPoint;
  99993. /**
  99994. * Gets the r output component
  99995. */
  99996. get r(): NodeMaterialConnectionPoint;
  99997. /**
  99998. * Gets the g output component
  99999. */
  100000. get g(): NodeMaterialConnectionPoint;
  100001. /**
  100002. * Gets the b output component
  100003. */
  100004. get b(): NodeMaterialConnectionPoint;
  100005. /**
  100006. * Gets the a output component
  100007. */
  100008. get a(): NodeMaterialConnectionPoint;
  100009. /**
  100010. * Initialize the block and prepare the context for build
  100011. * @param state defines the state that will be used for the build
  100012. */
  100013. initialize(state: NodeMaterialBuildState): void;
  100014. get target(): NodeMaterialBlockTargets;
  100015. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100016. isReady(): boolean;
  100017. private _injectVertexCode;
  100018. private _writeTextureRead;
  100019. private _writeOutput;
  100020. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100021. serialize(): any;
  100022. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100023. }
  100024. }
  100025. declare module BABYLON {
  100026. /**
  100027. * Base block used for the particle texture
  100028. */
  100029. export class ParticleTextureBlock extends NodeMaterialBlock {
  100030. private _samplerName;
  100031. private _linearDefineName;
  100032. private _gammaDefineName;
  100033. private _tempTextureRead;
  100034. /**
  100035. * Gets or sets the texture associated with the node
  100036. */
  100037. texture: Nullable<BaseTexture>;
  100038. /**
  100039. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100040. */
  100041. convertToGammaSpace: boolean;
  100042. /**
  100043. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100044. */
  100045. convertToLinearSpace: boolean;
  100046. /**
  100047. * Create a new ParticleTextureBlock
  100048. * @param name defines the block name
  100049. */
  100050. constructor(name: string);
  100051. /**
  100052. * Gets the current class name
  100053. * @returns the class name
  100054. */
  100055. getClassName(): string;
  100056. /**
  100057. * Gets the uv input component
  100058. */
  100059. get uv(): NodeMaterialConnectionPoint;
  100060. /**
  100061. * Gets the rgba output component
  100062. */
  100063. get rgba(): NodeMaterialConnectionPoint;
  100064. /**
  100065. * Gets the rgb output component
  100066. */
  100067. get rgb(): NodeMaterialConnectionPoint;
  100068. /**
  100069. * Gets the r output component
  100070. */
  100071. get r(): NodeMaterialConnectionPoint;
  100072. /**
  100073. * Gets the g output component
  100074. */
  100075. get g(): NodeMaterialConnectionPoint;
  100076. /**
  100077. * Gets the b output component
  100078. */
  100079. get b(): NodeMaterialConnectionPoint;
  100080. /**
  100081. * Gets the a output component
  100082. */
  100083. get a(): NodeMaterialConnectionPoint;
  100084. /**
  100085. * Initialize the block and prepare the context for build
  100086. * @param state defines the state that will be used for the build
  100087. */
  100088. initialize(state: NodeMaterialBuildState): void;
  100089. autoConfigure(material: NodeMaterial): void;
  100090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100091. isReady(): boolean;
  100092. private _writeOutput;
  100093. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100094. serialize(): any;
  100095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100096. }
  100097. }
  100098. declare module BABYLON {
  100099. /**
  100100. * Class used to store shared data between 2 NodeMaterialBuildState
  100101. */
  100102. export class NodeMaterialBuildStateSharedData {
  100103. /**
  100104. * Gets the list of emitted varyings
  100105. */
  100106. temps: string[];
  100107. /**
  100108. * Gets the list of emitted varyings
  100109. */
  100110. varyings: string[];
  100111. /**
  100112. * Gets the varying declaration string
  100113. */
  100114. varyingDeclaration: string;
  100115. /**
  100116. * Input blocks
  100117. */
  100118. inputBlocks: InputBlock[];
  100119. /**
  100120. * Input blocks
  100121. */
  100122. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100123. /**
  100124. * Bindable blocks (Blocks that need to set data to the effect)
  100125. */
  100126. bindableBlocks: NodeMaterialBlock[];
  100127. /**
  100128. * List of blocks that can provide a compilation fallback
  100129. */
  100130. blocksWithFallbacks: NodeMaterialBlock[];
  100131. /**
  100132. * List of blocks that can provide a define update
  100133. */
  100134. blocksWithDefines: NodeMaterialBlock[];
  100135. /**
  100136. * List of blocks that can provide a repeatable content
  100137. */
  100138. repeatableContentBlocks: NodeMaterialBlock[];
  100139. /**
  100140. * List of blocks that can provide a dynamic list of uniforms
  100141. */
  100142. dynamicUniformBlocks: NodeMaterialBlock[];
  100143. /**
  100144. * List of blocks that can block the isReady function for the material
  100145. */
  100146. blockingBlocks: NodeMaterialBlock[];
  100147. /**
  100148. * Gets the list of animated inputs
  100149. */
  100150. animatedInputs: InputBlock[];
  100151. /**
  100152. * Build Id used to avoid multiple recompilations
  100153. */
  100154. buildId: number;
  100155. /** List of emitted variables */
  100156. variableNames: {
  100157. [key: string]: number;
  100158. };
  100159. /** List of emitted defines */
  100160. defineNames: {
  100161. [key: string]: number;
  100162. };
  100163. /** Should emit comments? */
  100164. emitComments: boolean;
  100165. /** Emit build activity */
  100166. verbose: boolean;
  100167. /** Gets or sets the hosting scene */
  100168. scene: Scene;
  100169. /**
  100170. * Gets the compilation hints emitted at compilation time
  100171. */
  100172. hints: {
  100173. needWorldViewMatrix: boolean;
  100174. needWorldViewProjectionMatrix: boolean;
  100175. needAlphaBlending: boolean;
  100176. needAlphaTesting: boolean;
  100177. };
  100178. /**
  100179. * List of compilation checks
  100180. */
  100181. checks: {
  100182. emitVertex: boolean;
  100183. emitFragment: boolean;
  100184. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  100185. };
  100186. /**
  100187. * Is vertex program allowed to be empty?
  100188. */
  100189. allowEmptyVertexProgram: boolean;
  100190. /** Creates a new shared data */
  100191. constructor();
  100192. /**
  100193. * Emits console errors and exceptions if there is a failing check
  100194. */
  100195. emitErrors(): void;
  100196. }
  100197. }
  100198. declare module BABYLON {
  100199. /**
  100200. * Class used to store node based material build state
  100201. */
  100202. export class NodeMaterialBuildState {
  100203. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  100204. supportUniformBuffers: boolean;
  100205. /**
  100206. * Gets the list of emitted attributes
  100207. */
  100208. attributes: string[];
  100209. /**
  100210. * Gets the list of emitted uniforms
  100211. */
  100212. uniforms: string[];
  100213. /**
  100214. * Gets the list of emitted constants
  100215. */
  100216. constants: string[];
  100217. /**
  100218. * Gets the list of emitted samplers
  100219. */
  100220. samplers: string[];
  100221. /**
  100222. * Gets the list of emitted functions
  100223. */
  100224. functions: {
  100225. [key: string]: string;
  100226. };
  100227. /**
  100228. * Gets the list of emitted extensions
  100229. */
  100230. extensions: {
  100231. [key: string]: string;
  100232. };
  100233. /**
  100234. * Gets the target of the compilation state
  100235. */
  100236. target: NodeMaterialBlockTargets;
  100237. /**
  100238. * Gets the list of emitted counters
  100239. */
  100240. counters: {
  100241. [key: string]: number;
  100242. };
  100243. /**
  100244. * Shared data between multiple NodeMaterialBuildState instances
  100245. */
  100246. sharedData: NodeMaterialBuildStateSharedData;
  100247. /** @hidden */
  100248. _vertexState: NodeMaterialBuildState;
  100249. /** @hidden */
  100250. _attributeDeclaration: string;
  100251. /** @hidden */
  100252. _uniformDeclaration: string;
  100253. /** @hidden */
  100254. _constantDeclaration: string;
  100255. /** @hidden */
  100256. _samplerDeclaration: string;
  100257. /** @hidden */
  100258. _varyingTransfer: string;
  100259. /** @hidden */
  100260. _injectAtEnd: string;
  100261. private _repeatableContentAnchorIndex;
  100262. /** @hidden */
  100263. _builtCompilationString: string;
  100264. /**
  100265. * Gets the emitted compilation strings
  100266. */
  100267. compilationString: string;
  100268. /**
  100269. * Finalize the compilation strings
  100270. * @param state defines the current compilation state
  100271. */
  100272. finalize(state: NodeMaterialBuildState): void;
  100273. /** @hidden */
  100274. get _repeatableContentAnchor(): string;
  100275. /** @hidden */
  100276. _getFreeVariableName(prefix: string): string;
  100277. /** @hidden */
  100278. _getFreeDefineName(prefix: string): string;
  100279. /** @hidden */
  100280. _excludeVariableName(name: string): void;
  100281. /** @hidden */
  100282. _emit2DSampler(name: string): void;
  100283. /** @hidden */
  100284. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  100285. /** @hidden */
  100286. _emitExtension(name: string, extension: string, define?: string): void;
  100287. /** @hidden */
  100288. _emitFunction(name: string, code: string, comments: string): void;
  100289. /** @hidden */
  100290. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  100291. replaceStrings?: {
  100292. search: RegExp;
  100293. replace: string;
  100294. }[];
  100295. repeatKey?: string;
  100296. }): string;
  100297. /** @hidden */
  100298. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  100299. repeatKey?: string;
  100300. removeAttributes?: boolean;
  100301. removeUniforms?: boolean;
  100302. removeVaryings?: boolean;
  100303. removeIfDef?: boolean;
  100304. replaceStrings?: {
  100305. search: RegExp;
  100306. replace: string;
  100307. }[];
  100308. }, storeKey?: string): void;
  100309. /** @hidden */
  100310. _registerTempVariable(name: string): boolean;
  100311. /** @hidden */
  100312. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  100313. /** @hidden */
  100314. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  100315. /** @hidden */
  100316. _emitFloat(value: number): string;
  100317. }
  100318. }
  100319. declare module BABYLON {
  100320. /**
  100321. * Helper class used to generate session unique ID
  100322. */
  100323. export class UniqueIdGenerator {
  100324. private static _UniqueIdCounter;
  100325. /**
  100326. * Gets an unique (relatively to the current scene) Id
  100327. */
  100328. static get UniqueId(): number;
  100329. }
  100330. }
  100331. declare module BABYLON {
  100332. /**
  100333. * Defines a block that can be used inside a node based material
  100334. */
  100335. export class NodeMaterialBlock {
  100336. private _buildId;
  100337. private _buildTarget;
  100338. private _target;
  100339. private _isFinalMerger;
  100340. private _isInput;
  100341. private _name;
  100342. protected _isUnique: boolean;
  100343. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  100344. inputsAreExclusive: boolean;
  100345. /** @hidden */
  100346. _codeVariableName: string;
  100347. /** @hidden */
  100348. _inputs: NodeMaterialConnectionPoint[];
  100349. /** @hidden */
  100350. _outputs: NodeMaterialConnectionPoint[];
  100351. /** @hidden */
  100352. _preparationId: number;
  100353. /**
  100354. * Gets the name of the block
  100355. */
  100356. get name(): string;
  100357. /**
  100358. * Sets the name of the block. Will check if the name is valid.
  100359. */
  100360. set name(newName: string);
  100361. /**
  100362. * Gets or sets the unique id of the node
  100363. */
  100364. uniqueId: number;
  100365. /**
  100366. * Gets or sets the comments associated with this block
  100367. */
  100368. comments: string;
  100369. /**
  100370. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  100371. */
  100372. get isUnique(): boolean;
  100373. /**
  100374. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  100375. */
  100376. get isFinalMerger(): boolean;
  100377. /**
  100378. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  100379. */
  100380. get isInput(): boolean;
  100381. /**
  100382. * Gets or sets the build Id
  100383. */
  100384. get buildId(): number;
  100385. set buildId(value: number);
  100386. /**
  100387. * Gets or sets the target of the block
  100388. */
  100389. get target(): NodeMaterialBlockTargets;
  100390. set target(value: NodeMaterialBlockTargets);
  100391. /**
  100392. * Gets the list of input points
  100393. */
  100394. get inputs(): NodeMaterialConnectionPoint[];
  100395. /** Gets the list of output points */
  100396. get outputs(): NodeMaterialConnectionPoint[];
  100397. /**
  100398. * Find an input by its name
  100399. * @param name defines the name of the input to look for
  100400. * @returns the input or null if not found
  100401. */
  100402. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100403. /**
  100404. * Find an output by its name
  100405. * @param name defines the name of the outputto look for
  100406. * @returns the output or null if not found
  100407. */
  100408. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  100409. /**
  100410. * Creates a new NodeMaterialBlock
  100411. * @param name defines the block name
  100412. * @param target defines the target of that block (Vertex by default)
  100413. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  100414. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  100415. */
  100416. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  100417. /**
  100418. * Initialize the block and prepare the context for build
  100419. * @param state defines the state that will be used for the build
  100420. */
  100421. initialize(state: NodeMaterialBuildState): void;
  100422. /**
  100423. * Bind data to effect. Will only be called for blocks with isBindable === true
  100424. * @param effect defines the effect to bind data to
  100425. * @param nodeMaterial defines the hosting NodeMaterial
  100426. * @param mesh defines the mesh that will be rendered
  100427. * @param subMesh defines the submesh that will be rendered
  100428. */
  100429. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100430. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  100431. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  100432. protected _writeFloat(value: number): string;
  100433. /**
  100434. * Gets the current class name e.g. "NodeMaterialBlock"
  100435. * @returns the class name
  100436. */
  100437. getClassName(): string;
  100438. /**
  100439. * Register a new input. Must be called inside a block constructor
  100440. * @param name defines the connection point name
  100441. * @param type defines the connection point type
  100442. * @param isOptional defines a boolean indicating that this input can be omitted
  100443. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100444. * @param point an already created connection point. If not provided, create a new one
  100445. * @returns the current block
  100446. */
  100447. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100448. /**
  100449. * Register a new output. Must be called inside a block constructor
  100450. * @param name defines the connection point name
  100451. * @param type defines the connection point type
  100452. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  100453. * @param point an already created connection point. If not provided, create a new one
  100454. * @returns the current block
  100455. */
  100456. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  100457. /**
  100458. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  100459. * @param forOutput defines an optional connection point to check compatibility with
  100460. * @returns the first available input or null
  100461. */
  100462. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  100463. /**
  100464. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  100465. * @param forBlock defines an optional block to check compatibility with
  100466. * @returns the first available input or null
  100467. */
  100468. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  100469. /**
  100470. * Gets the sibling of the given output
  100471. * @param current defines the current output
  100472. * @returns the next output in the list or null
  100473. */
  100474. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  100475. /**
  100476. * Connect current block with another block
  100477. * @param other defines the block to connect with
  100478. * @param options define the various options to help pick the right connections
  100479. * @returns the current block
  100480. */
  100481. connectTo(other: NodeMaterialBlock, options?: {
  100482. input?: string;
  100483. output?: string;
  100484. outputSwizzle?: string;
  100485. }): this | undefined;
  100486. protected _buildBlock(state: NodeMaterialBuildState): void;
  100487. /**
  100488. * Add uniforms, samplers and uniform buffers at compilation time
  100489. * @param state defines the state to update
  100490. * @param nodeMaterial defines the node material requesting the update
  100491. * @param defines defines the material defines to update
  100492. * @param uniformBuffers defines the list of uniform buffer names
  100493. */
  100494. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  100495. /**
  100496. * Add potential fallbacks if shader compilation fails
  100497. * @param mesh defines the mesh to be rendered
  100498. * @param fallbacks defines the current prioritized list of fallbacks
  100499. */
  100500. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  100501. /**
  100502. * Initialize defines for shader compilation
  100503. * @param mesh defines the mesh to be rendered
  100504. * @param nodeMaterial defines the node material requesting the update
  100505. * @param defines defines the material defines to update
  100506. * @param useInstances specifies that instances should be used
  100507. */
  100508. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100509. /**
  100510. * Update defines for shader compilation
  100511. * @param mesh defines the mesh to be rendered
  100512. * @param nodeMaterial defines the node material requesting the update
  100513. * @param defines defines the material defines to update
  100514. * @param useInstances specifies that instances should be used
  100515. * @param subMesh defines which submesh to render
  100516. */
  100517. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100518. /**
  100519. * Lets the block try to connect some inputs automatically
  100520. * @param material defines the hosting NodeMaterial
  100521. */
  100522. autoConfigure(material: NodeMaterial): void;
  100523. /**
  100524. * Function called when a block is declared as repeatable content generator
  100525. * @param vertexShaderState defines the current compilation state for the vertex shader
  100526. * @param fragmentShaderState defines the current compilation state for the fragment shader
  100527. * @param mesh defines the mesh to be rendered
  100528. * @param defines defines the material defines to update
  100529. */
  100530. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  100531. /**
  100532. * Checks if the block is ready
  100533. * @param mesh defines the mesh to be rendered
  100534. * @param nodeMaterial defines the node material requesting the update
  100535. * @param defines defines the material defines to update
  100536. * @param useInstances specifies that instances should be used
  100537. * @returns true if the block is ready
  100538. */
  100539. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  100540. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  100541. private _processBuild;
  100542. /**
  100543. * Validates the new name for the block node.
  100544. * @param newName the new name to be given to the node.
  100545. * @returns false if the name is a reserve word, else true.
  100546. */
  100547. validateBlockName(newName: string): boolean;
  100548. /**
  100549. * Compile the current node and generate the shader code
  100550. * @param state defines the current compilation state (uniforms, samplers, current string)
  100551. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  100552. * @returns true if already built
  100553. */
  100554. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  100555. protected _inputRename(name: string): string;
  100556. protected _outputRename(name: string): string;
  100557. protected _dumpPropertiesCode(): string;
  100558. /** @hidden */
  100559. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  100560. /** @hidden */
  100561. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  100562. /**
  100563. * Clone the current block to a new identical block
  100564. * @param scene defines the hosting scene
  100565. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100566. * @returns a copy of the current block
  100567. */
  100568. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  100569. /**
  100570. * Serializes this block in a JSON representation
  100571. * @returns the serialized block object
  100572. */
  100573. serialize(): any;
  100574. /** @hidden */
  100575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100576. private _deserializePortDisplayNamesAndExposedOnFrame;
  100577. /**
  100578. * Release resources
  100579. */
  100580. dispose(): void;
  100581. }
  100582. }
  100583. declare module BABYLON {
  100584. /**
  100585. * Base class of materials working in push mode in babylon JS
  100586. * @hidden
  100587. */
  100588. export class PushMaterial extends Material {
  100589. protected _activeEffect: Effect;
  100590. protected _normalMatrix: Matrix;
  100591. constructor(name: string, scene: Scene);
  100592. getEffect(): Effect;
  100593. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100594. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100595. /**
  100596. * Binds the given world matrix to the active effect
  100597. *
  100598. * @param world the matrix to bind
  100599. */
  100600. bindOnlyWorldMatrix(world: Matrix): void;
  100601. /**
  100602. * Binds the given normal matrix to the active effect
  100603. *
  100604. * @param normalMatrix the matrix to bind
  100605. */
  100606. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100607. bind(world: Matrix, mesh?: Mesh): void;
  100608. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100609. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100610. }
  100611. }
  100612. declare module BABYLON {
  100613. /**
  100614. * Root class for all node material optimizers
  100615. */
  100616. export class NodeMaterialOptimizer {
  100617. /**
  100618. * Function used to optimize a NodeMaterial graph
  100619. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  100620. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  100621. */
  100622. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  100623. }
  100624. }
  100625. declare module BABYLON {
  100626. /**
  100627. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  100628. */
  100629. export class TransformBlock extends NodeMaterialBlock {
  100630. /**
  100631. * Defines the value to use to complement W value to transform it to a Vector4
  100632. */
  100633. complementW: number;
  100634. /**
  100635. * Defines the value to use to complement z value to transform it to a Vector4
  100636. */
  100637. complementZ: number;
  100638. /**
  100639. * Creates a new TransformBlock
  100640. * @param name defines the block name
  100641. */
  100642. constructor(name: string);
  100643. /**
  100644. * Gets the current class name
  100645. * @returns the class name
  100646. */
  100647. getClassName(): string;
  100648. /**
  100649. * Gets the vector input
  100650. */
  100651. get vector(): NodeMaterialConnectionPoint;
  100652. /**
  100653. * Gets the output component
  100654. */
  100655. get output(): NodeMaterialConnectionPoint;
  100656. /**
  100657. * Gets the xyz output component
  100658. */
  100659. get xyz(): NodeMaterialConnectionPoint;
  100660. /**
  100661. * Gets the matrix transform input
  100662. */
  100663. get transform(): NodeMaterialConnectionPoint;
  100664. protected _buildBlock(state: NodeMaterialBuildState): this;
  100665. /**
  100666. * Update defines for shader compilation
  100667. * @param mesh defines the mesh to be rendered
  100668. * @param nodeMaterial defines the node material requesting the update
  100669. * @param defines defines the material defines to update
  100670. * @param useInstances specifies that instances should be used
  100671. * @param subMesh defines which submesh to render
  100672. */
  100673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  100674. serialize(): any;
  100675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100676. protected _dumpPropertiesCode(): string;
  100677. }
  100678. }
  100679. declare module BABYLON {
  100680. /**
  100681. * Block used to output the vertex position
  100682. */
  100683. export class VertexOutputBlock extends NodeMaterialBlock {
  100684. /**
  100685. * Creates a new VertexOutputBlock
  100686. * @param name defines the block name
  100687. */
  100688. constructor(name: string);
  100689. /**
  100690. * Gets the current class name
  100691. * @returns the class name
  100692. */
  100693. getClassName(): string;
  100694. /**
  100695. * Gets the vector input component
  100696. */
  100697. get vector(): NodeMaterialConnectionPoint;
  100698. protected _buildBlock(state: NodeMaterialBuildState): this;
  100699. }
  100700. }
  100701. declare module BABYLON {
  100702. /**
  100703. * Block used to output the final color
  100704. */
  100705. export class FragmentOutputBlock extends NodeMaterialBlock {
  100706. /**
  100707. * Create a new FragmentOutputBlock
  100708. * @param name defines the block name
  100709. */
  100710. constructor(name: string);
  100711. /**
  100712. * Gets the current class name
  100713. * @returns the class name
  100714. */
  100715. getClassName(): string;
  100716. /**
  100717. * Gets the rgba input component
  100718. */
  100719. get rgba(): NodeMaterialConnectionPoint;
  100720. /**
  100721. * Gets the rgb input component
  100722. */
  100723. get rgb(): NodeMaterialConnectionPoint;
  100724. /**
  100725. * Gets the a input component
  100726. */
  100727. get a(): NodeMaterialConnectionPoint;
  100728. protected _buildBlock(state: NodeMaterialBuildState): this;
  100729. }
  100730. }
  100731. declare module BABYLON {
  100732. /**
  100733. * Block used for the particle ramp gradient section
  100734. */
  100735. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100736. /**
  100737. * Create a new ParticleRampGradientBlock
  100738. * @param name defines the block name
  100739. */
  100740. constructor(name: string);
  100741. /**
  100742. * Gets the current class name
  100743. * @returns the class name
  100744. */
  100745. getClassName(): string;
  100746. /**
  100747. * Gets the color input component
  100748. */
  100749. get color(): NodeMaterialConnectionPoint;
  100750. /**
  100751. * Gets the rampColor output component
  100752. */
  100753. get rampColor(): NodeMaterialConnectionPoint;
  100754. /**
  100755. * Initialize the block and prepare the context for build
  100756. * @param state defines the state that will be used for the build
  100757. */
  100758. initialize(state: NodeMaterialBuildState): void;
  100759. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100760. }
  100761. }
  100762. declare module BABYLON {
  100763. /**
  100764. * Block used for the particle blend multiply section
  100765. */
  100766. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100767. /**
  100768. * Create a new ParticleBlendMultiplyBlock
  100769. * @param name defines the block name
  100770. */
  100771. constructor(name: string);
  100772. /**
  100773. * Gets the current class name
  100774. * @returns the class name
  100775. */
  100776. getClassName(): string;
  100777. /**
  100778. * Gets the color input component
  100779. */
  100780. get color(): NodeMaterialConnectionPoint;
  100781. /**
  100782. * Gets the alphaTexture input component
  100783. */
  100784. get alphaTexture(): NodeMaterialConnectionPoint;
  100785. /**
  100786. * Gets the alphaColor input component
  100787. */
  100788. get alphaColor(): NodeMaterialConnectionPoint;
  100789. /**
  100790. * Gets the blendColor output component
  100791. */
  100792. get blendColor(): NodeMaterialConnectionPoint;
  100793. /**
  100794. * Initialize the block and prepare the context for build
  100795. * @param state defines the state that will be used for the build
  100796. */
  100797. initialize(state: NodeMaterialBuildState): void;
  100798. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100799. }
  100800. }
  100801. declare module BABYLON {
  100802. /**
  100803. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100804. */
  100805. export class VectorMergerBlock extends NodeMaterialBlock {
  100806. /**
  100807. * Create a new VectorMergerBlock
  100808. * @param name defines the block name
  100809. */
  100810. constructor(name: string);
  100811. /**
  100812. * Gets the current class name
  100813. * @returns the class name
  100814. */
  100815. getClassName(): string;
  100816. /**
  100817. * Gets the xyz component (input)
  100818. */
  100819. get xyzIn(): NodeMaterialConnectionPoint;
  100820. /**
  100821. * Gets the xy component (input)
  100822. */
  100823. get xyIn(): NodeMaterialConnectionPoint;
  100824. /**
  100825. * Gets the x component (input)
  100826. */
  100827. get x(): NodeMaterialConnectionPoint;
  100828. /**
  100829. * Gets the y component (input)
  100830. */
  100831. get y(): NodeMaterialConnectionPoint;
  100832. /**
  100833. * Gets the z component (input)
  100834. */
  100835. get z(): NodeMaterialConnectionPoint;
  100836. /**
  100837. * Gets the w component (input)
  100838. */
  100839. get w(): NodeMaterialConnectionPoint;
  100840. /**
  100841. * Gets the xyzw component (output)
  100842. */
  100843. get xyzw(): NodeMaterialConnectionPoint;
  100844. /**
  100845. * Gets the xyz component (output)
  100846. */
  100847. get xyzOut(): NodeMaterialConnectionPoint;
  100848. /**
  100849. * Gets the xy component (output)
  100850. */
  100851. get xyOut(): NodeMaterialConnectionPoint;
  100852. /**
  100853. * Gets the xy component (output)
  100854. * @deprecated Please use xyOut instead.
  100855. */
  100856. get xy(): NodeMaterialConnectionPoint;
  100857. /**
  100858. * Gets the xyz component (output)
  100859. * @deprecated Please use xyzOut instead.
  100860. */
  100861. get xyz(): NodeMaterialConnectionPoint;
  100862. protected _buildBlock(state: NodeMaterialBuildState): this;
  100863. }
  100864. }
  100865. declare module BABYLON {
  100866. /**
  100867. * Block used to remap a float from a range to a new one
  100868. */
  100869. export class RemapBlock extends NodeMaterialBlock {
  100870. /**
  100871. * Gets or sets the source range
  100872. */
  100873. sourceRange: Vector2;
  100874. /**
  100875. * Gets or sets the target range
  100876. */
  100877. targetRange: Vector2;
  100878. /**
  100879. * Creates a new RemapBlock
  100880. * @param name defines the block name
  100881. */
  100882. constructor(name: string);
  100883. /**
  100884. * Gets the current class name
  100885. * @returns the class name
  100886. */
  100887. getClassName(): string;
  100888. /**
  100889. * Gets the input component
  100890. */
  100891. get input(): NodeMaterialConnectionPoint;
  100892. /**
  100893. * Gets the source min input component
  100894. */
  100895. get sourceMin(): NodeMaterialConnectionPoint;
  100896. /**
  100897. * Gets the source max input component
  100898. */
  100899. get sourceMax(): NodeMaterialConnectionPoint;
  100900. /**
  100901. * Gets the target min input component
  100902. */
  100903. get targetMin(): NodeMaterialConnectionPoint;
  100904. /**
  100905. * Gets the target max input component
  100906. */
  100907. get targetMax(): NodeMaterialConnectionPoint;
  100908. /**
  100909. * Gets the output component
  100910. */
  100911. get output(): NodeMaterialConnectionPoint;
  100912. protected _buildBlock(state: NodeMaterialBuildState): this;
  100913. protected _dumpPropertiesCode(): string;
  100914. serialize(): any;
  100915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100916. }
  100917. }
  100918. declare module BABYLON {
  100919. /**
  100920. * Block used to multiply 2 values
  100921. */
  100922. export class MultiplyBlock extends NodeMaterialBlock {
  100923. /**
  100924. * Creates a new MultiplyBlock
  100925. * @param name defines the block name
  100926. */
  100927. constructor(name: string);
  100928. /**
  100929. * Gets the current class name
  100930. * @returns the class name
  100931. */
  100932. getClassName(): string;
  100933. /**
  100934. * Gets the left operand input component
  100935. */
  100936. get left(): NodeMaterialConnectionPoint;
  100937. /**
  100938. * Gets the right operand input component
  100939. */
  100940. get right(): NodeMaterialConnectionPoint;
  100941. /**
  100942. * Gets the output component
  100943. */
  100944. get output(): NodeMaterialConnectionPoint;
  100945. protected _buildBlock(state: NodeMaterialBuildState): this;
  100946. }
  100947. }
  100948. declare module BABYLON {
  100949. /**
  100950. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100951. */
  100952. export class ColorSplitterBlock extends NodeMaterialBlock {
  100953. /**
  100954. * Create a new ColorSplitterBlock
  100955. * @param name defines the block name
  100956. */
  100957. constructor(name: string);
  100958. /**
  100959. * Gets the current class name
  100960. * @returns the class name
  100961. */
  100962. getClassName(): string;
  100963. /**
  100964. * Gets the rgba component (input)
  100965. */
  100966. get rgba(): NodeMaterialConnectionPoint;
  100967. /**
  100968. * Gets the rgb component (input)
  100969. */
  100970. get rgbIn(): NodeMaterialConnectionPoint;
  100971. /**
  100972. * Gets the rgb component (output)
  100973. */
  100974. get rgbOut(): NodeMaterialConnectionPoint;
  100975. /**
  100976. * Gets the r component (output)
  100977. */
  100978. get r(): NodeMaterialConnectionPoint;
  100979. /**
  100980. * Gets the g component (output)
  100981. */
  100982. get g(): NodeMaterialConnectionPoint;
  100983. /**
  100984. * Gets the b component (output)
  100985. */
  100986. get b(): NodeMaterialConnectionPoint;
  100987. /**
  100988. * Gets the a component (output)
  100989. */
  100990. get a(): NodeMaterialConnectionPoint;
  100991. protected _inputRename(name: string): string;
  100992. protected _outputRename(name: string): string;
  100993. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100994. }
  100995. }
  100996. declare module BABYLON {
  100997. /**
  100998. * Interface used to configure the node material editor
  100999. */
  101000. export interface INodeMaterialEditorOptions {
  101001. /** Define the URl to load node editor script */
  101002. editorURL?: string;
  101003. }
  101004. /** @hidden */
  101005. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101006. NORMAL: boolean;
  101007. TANGENT: boolean;
  101008. UV1: boolean;
  101009. /** BONES */
  101010. NUM_BONE_INFLUENCERS: number;
  101011. BonesPerMesh: number;
  101012. BONETEXTURE: boolean;
  101013. /** MORPH TARGETS */
  101014. MORPHTARGETS: boolean;
  101015. MORPHTARGETS_NORMAL: boolean;
  101016. MORPHTARGETS_TANGENT: boolean;
  101017. MORPHTARGETS_UV: boolean;
  101018. NUM_MORPH_INFLUENCERS: number;
  101019. /** IMAGE PROCESSING */
  101020. IMAGEPROCESSING: boolean;
  101021. VIGNETTE: boolean;
  101022. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101023. VIGNETTEBLENDMODEOPAQUE: boolean;
  101024. TONEMAPPING: boolean;
  101025. TONEMAPPING_ACES: boolean;
  101026. CONTRAST: boolean;
  101027. EXPOSURE: boolean;
  101028. COLORCURVES: boolean;
  101029. COLORGRADING: boolean;
  101030. COLORGRADING3D: boolean;
  101031. SAMPLER3DGREENDEPTH: boolean;
  101032. SAMPLER3DBGRMAP: boolean;
  101033. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101034. /** MISC. */
  101035. BUMPDIRECTUV: number;
  101036. constructor();
  101037. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  101038. }
  101039. /**
  101040. * Class used to configure NodeMaterial
  101041. */
  101042. export interface INodeMaterialOptions {
  101043. /**
  101044. * Defines if blocks should emit comments
  101045. */
  101046. emitComments: boolean;
  101047. }
  101048. /**
  101049. * Class used to create a node based material built by assembling shader blocks
  101050. */
  101051. export class NodeMaterial extends PushMaterial {
  101052. private static _BuildIdGenerator;
  101053. private _options;
  101054. private _vertexCompilationState;
  101055. private _fragmentCompilationState;
  101056. private _sharedData;
  101057. private _buildId;
  101058. private _buildWasSuccessful;
  101059. private _cachedWorldViewMatrix;
  101060. private _cachedWorldViewProjectionMatrix;
  101061. private _optimizers;
  101062. private _animationFrame;
  101063. /** Define the Url to load node editor script */
  101064. static EditorURL: string;
  101065. /** Define the Url to load snippets */
  101066. static SnippetUrl: string;
  101067. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  101068. static IgnoreTexturesAtLoadTime: boolean;
  101069. private BJSNODEMATERIALEDITOR;
  101070. /** Get the inspector from bundle or global */
  101071. private _getGlobalNodeMaterialEditor;
  101072. /**
  101073. * Snippet ID if the material was created from the snippet server
  101074. */
  101075. snippetId: string;
  101076. /**
  101077. * Gets or sets data used by visual editor
  101078. * @see https://nme.babylonjs.com
  101079. */
  101080. editorData: any;
  101081. /**
  101082. * 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)
  101083. */
  101084. ignoreAlpha: boolean;
  101085. /**
  101086. * Defines the maximum number of lights that can be used in the material
  101087. */
  101088. maxSimultaneousLights: number;
  101089. /**
  101090. * Observable raised when the material is built
  101091. */
  101092. onBuildObservable: Observable<NodeMaterial>;
  101093. /**
  101094. * Gets or sets the root nodes of the material vertex shader
  101095. */
  101096. _vertexOutputNodes: NodeMaterialBlock[];
  101097. /**
  101098. * Gets or sets the root nodes of the material fragment (pixel) shader
  101099. */
  101100. _fragmentOutputNodes: NodeMaterialBlock[];
  101101. /** Gets or sets options to control the node material overall behavior */
  101102. get options(): INodeMaterialOptions;
  101103. set options(options: INodeMaterialOptions);
  101104. /**
  101105. * Default configuration related to image processing available in the standard Material.
  101106. */
  101107. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101108. /**
  101109. * Gets the image processing configuration used either in this material.
  101110. */
  101111. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101112. /**
  101113. * Sets the Default image processing configuration used either in the this material.
  101114. *
  101115. * If sets to null, the scene one is in use.
  101116. */
  101117. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101118. /**
  101119. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  101120. */
  101121. attachedBlocks: NodeMaterialBlock[];
  101122. /**
  101123. * Specifies the mode of the node material
  101124. * @hidden
  101125. */
  101126. _mode: NodeMaterialModes;
  101127. /**
  101128. * Gets the mode property
  101129. */
  101130. get mode(): NodeMaterialModes;
  101131. /**
  101132. * Create a new node based material
  101133. * @param name defines the material name
  101134. * @param scene defines the hosting scene
  101135. * @param options defines creation option
  101136. */
  101137. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  101138. /**
  101139. * Gets the current class name of the material e.g. "NodeMaterial"
  101140. * @returns the class name
  101141. */
  101142. getClassName(): string;
  101143. /**
  101144. * Keep track of the image processing observer to allow dispose and replace.
  101145. */
  101146. private _imageProcessingObserver;
  101147. /**
  101148. * Attaches a new image processing configuration to the Standard Material.
  101149. * @param configuration
  101150. */
  101151. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101152. /**
  101153. * Get a block by its name
  101154. * @param name defines the name of the block to retrieve
  101155. * @returns the required block or null if not found
  101156. */
  101157. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  101158. /**
  101159. * Get a block by its name
  101160. * @param predicate defines the predicate used to find the good candidate
  101161. * @returns the required block or null if not found
  101162. */
  101163. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  101164. /**
  101165. * Get an input block by its name
  101166. * @param predicate defines the predicate used to find the good candidate
  101167. * @returns the required input block or null if not found
  101168. */
  101169. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  101170. /**
  101171. * Gets the list of input blocks attached to this material
  101172. * @returns an array of InputBlocks
  101173. */
  101174. getInputBlocks(): InputBlock[];
  101175. /**
  101176. * Adds a new optimizer to the list of optimizers
  101177. * @param optimizer defines the optimizers to add
  101178. * @returns the current material
  101179. */
  101180. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101181. /**
  101182. * Remove an optimizer from the list of optimizers
  101183. * @param optimizer defines the optimizers to remove
  101184. * @returns the current material
  101185. */
  101186. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  101187. /**
  101188. * Add a new block to the list of output nodes
  101189. * @param node defines the node to add
  101190. * @returns the current material
  101191. */
  101192. addOutputNode(node: NodeMaterialBlock): this;
  101193. /**
  101194. * Remove a block from the list of root nodes
  101195. * @param node defines the node to remove
  101196. * @returns the current material
  101197. */
  101198. removeOutputNode(node: NodeMaterialBlock): this;
  101199. private _addVertexOutputNode;
  101200. private _removeVertexOutputNode;
  101201. private _addFragmentOutputNode;
  101202. private _removeFragmentOutputNode;
  101203. /**
  101204. * Specifies if the material will require alpha blending
  101205. * @returns a boolean specifying if alpha blending is needed
  101206. */
  101207. needAlphaBlending(): boolean;
  101208. /**
  101209. * Specifies if this material should be rendered in alpha test mode
  101210. * @returns a boolean specifying if an alpha test is needed.
  101211. */
  101212. needAlphaTesting(): boolean;
  101213. private _initializeBlock;
  101214. private _resetDualBlocks;
  101215. /**
  101216. * Remove a block from the current node material
  101217. * @param block defines the block to remove
  101218. */
  101219. removeBlock(block: NodeMaterialBlock): void;
  101220. /**
  101221. * Build the material and generates the inner effect
  101222. * @param verbose defines if the build should log activity
  101223. */
  101224. build(verbose?: boolean): void;
  101225. /**
  101226. * Runs an otpimization phase to try to improve the shader code
  101227. */
  101228. optimize(): void;
  101229. private _prepareDefinesForAttributes;
  101230. /**
  101231. * Create a post process from the material
  101232. * @param camera The camera to apply the render pass to.
  101233. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101235. * @param engine The engine which the post process will be applied. (default: current engine)
  101236. * @param reusable If the post process can be reused on the same frame. (default: false)
  101237. * @param textureType Type of textures used when performing the post process. (default: 0)
  101238. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101239. * @returns the post process created
  101240. */
  101241. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  101242. /**
  101243. * Create the post process effect from the material
  101244. * @param postProcess The post process to create the effect for
  101245. */
  101246. createEffectForPostProcess(postProcess: PostProcess): void;
  101247. private _createEffectOrPostProcess;
  101248. private _createEffectForParticles;
  101249. /**
  101250. * Create the effect to be used as the custom effect for a particle system
  101251. * @param particleSystem Particle system to create the effect for
  101252. * @param onCompiled defines a function to call when the effect creation is successful
  101253. * @param onError defines a function to call when the effect creation has failed
  101254. */
  101255. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101256. private _processDefines;
  101257. /**
  101258. * Get if the submesh is ready to be used and all its information available.
  101259. * Child classes can use it to update shaders
  101260. * @param mesh defines the mesh to check
  101261. * @param subMesh defines which submesh to check
  101262. * @param useInstances specifies that instances should be used
  101263. * @returns a boolean indicating that the submesh is ready or not
  101264. */
  101265. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101266. /**
  101267. * Get a string representing the shaders built by the current node graph
  101268. */
  101269. get compiledShaders(): string;
  101270. /**
  101271. * Binds the world matrix to the material
  101272. * @param world defines the world transformation matrix
  101273. */
  101274. bindOnlyWorldMatrix(world: Matrix): void;
  101275. /**
  101276. * Binds the submesh to this material by preparing the effect and shader to draw
  101277. * @param world defines the world transformation matrix
  101278. * @param mesh defines the mesh containing the submesh
  101279. * @param subMesh defines the submesh to bind the material to
  101280. */
  101281. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101282. /**
  101283. * Gets the active textures from the material
  101284. * @returns an array of textures
  101285. */
  101286. getActiveTextures(): BaseTexture[];
  101287. /**
  101288. * Gets the list of texture blocks
  101289. * @returns an array of texture blocks
  101290. */
  101291. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101292. /**
  101293. * Specifies if the material uses a texture
  101294. * @param texture defines the texture to check against the material
  101295. * @returns a boolean specifying if the material uses the texture
  101296. */
  101297. hasTexture(texture: BaseTexture): boolean;
  101298. /**
  101299. * Disposes the material
  101300. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101301. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101302. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101303. */
  101304. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101305. /** Creates the node editor window. */
  101306. private _createNodeEditor;
  101307. /**
  101308. * Launch the node material editor
  101309. * @param config Define the configuration of the editor
  101310. * @return a promise fulfilled when the node editor is visible
  101311. */
  101312. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  101313. /**
  101314. * Clear the current material
  101315. */
  101316. clear(): void;
  101317. /**
  101318. * Clear the current material and set it to a default state
  101319. */
  101320. setToDefault(): void;
  101321. /**
  101322. * Clear the current material and set it to a default state for post process
  101323. */
  101324. setToDefaultPostProcess(): void;
  101325. /**
  101326. * Clear the current material and set it to a default state for particle
  101327. */
  101328. setToDefaultParticle(): void;
  101329. /**
  101330. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  101331. * @param url defines the url to load from
  101332. * @returns a promise that will fullfil when the material is fully loaded
  101333. */
  101334. loadAsync(url: string): Promise<void>;
  101335. private _gatherBlocks;
  101336. /**
  101337. * Generate a string containing the code declaration required to create an equivalent of this material
  101338. * @returns a string
  101339. */
  101340. generateCode(): string;
  101341. /**
  101342. * Serializes this material in a JSON representation
  101343. * @returns the serialized material object
  101344. */
  101345. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  101346. private _restoreConnections;
  101347. /**
  101348. * Clear the current graph and load a new one from a serialization object
  101349. * @param source defines the JSON representation of the material
  101350. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101351. * @param merge defines whether or not the source must be merged or replace the current content
  101352. */
  101353. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  101354. /**
  101355. * Makes a duplicate of the current material.
  101356. * @param name - name to use for the new material.
  101357. */
  101358. clone(name: string): NodeMaterial;
  101359. /**
  101360. * Creates a node material from parsed material data
  101361. * @param source defines the JSON representation of the material
  101362. * @param scene defines the hosting scene
  101363. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101364. * @returns a new node material
  101365. */
  101366. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  101367. /**
  101368. * Creates a node material from a snippet saved in a remote file
  101369. * @param name defines the name of the material to create
  101370. * @param url defines the url to load from
  101371. * @param scene defines the hosting scene
  101372. * @returns a promise that will resolve to the new node material
  101373. */
  101374. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  101375. /**
  101376. * Creates a node material from a snippet saved by the node material editor
  101377. * @param snippetId defines the snippet to load
  101378. * @param scene defines the hosting scene
  101379. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101380. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  101381. * @returns a promise that will resolve to the new node material
  101382. */
  101383. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  101384. /**
  101385. * Creates a new node material set to default basic configuration
  101386. * @param name defines the name of the material
  101387. * @param scene defines the hosting scene
  101388. * @returns a new NodeMaterial
  101389. */
  101390. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  101391. }
  101392. }
  101393. declare module BABYLON {
  101394. /**
  101395. * Size options for a post process
  101396. */
  101397. export type PostProcessOptions = {
  101398. width: number;
  101399. height: number;
  101400. };
  101401. /**
  101402. * PostProcess can be used to apply a shader to a texture after it has been rendered
  101403. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101404. */
  101405. export class PostProcess {
  101406. /** Name of the PostProcess. */
  101407. name: string;
  101408. /**
  101409. * Gets or sets the unique id of the post process
  101410. */
  101411. uniqueId: number;
  101412. /**
  101413. * Width of the texture to apply the post process on
  101414. */
  101415. width: number;
  101416. /**
  101417. * Height of the texture to apply the post process on
  101418. */
  101419. height: number;
  101420. /**
  101421. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  101422. */
  101423. nodeMaterialSource: Nullable<NodeMaterial>;
  101424. /**
  101425. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  101426. * @hidden
  101427. */
  101428. _outputTexture: Nullable<InternalTexture>;
  101429. /**
  101430. * Sampling mode used by the shader
  101431. * See https://doc.babylonjs.com/classes/3.1/texture
  101432. */
  101433. renderTargetSamplingMode: number;
  101434. /**
  101435. * Clear color to use when screen clearing
  101436. */
  101437. clearColor: Color4;
  101438. /**
  101439. * If the buffer needs to be cleared before applying the post process. (default: true)
  101440. * Should be set to false if shader will overwrite all previous pixels.
  101441. */
  101442. autoClear: boolean;
  101443. /**
  101444. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  101445. */
  101446. alphaMode: number;
  101447. /**
  101448. * Sets the setAlphaBlendConstants of the babylon engine
  101449. */
  101450. alphaConstants: Color4;
  101451. /**
  101452. * Animations to be used for the post processing
  101453. */
  101454. animations: Animation[];
  101455. /**
  101456. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  101457. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  101458. */
  101459. enablePixelPerfectMode: boolean;
  101460. /**
  101461. * Force the postprocess to be applied without taking in account viewport
  101462. */
  101463. forceFullscreenViewport: boolean;
  101464. /**
  101465. * List of inspectable custom properties (used by the Inspector)
  101466. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101467. */
  101468. inspectableCustomProperties: IInspectable[];
  101469. /**
  101470. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  101471. *
  101472. * | Value | Type | Description |
  101473. * | ----- | ----------------------------------- | ----------- |
  101474. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  101475. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  101476. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  101477. *
  101478. */
  101479. scaleMode: number;
  101480. /**
  101481. * Force textures to be a power of two (default: false)
  101482. */
  101483. alwaysForcePOT: boolean;
  101484. private _samples;
  101485. /**
  101486. * Number of sample textures (default: 1)
  101487. */
  101488. get samples(): number;
  101489. set samples(n: number);
  101490. /**
  101491. * Modify the scale of the post process to be the same as the viewport (default: false)
  101492. */
  101493. adaptScaleToCurrentViewport: boolean;
  101494. private _camera;
  101495. protected _scene: Scene;
  101496. private _engine;
  101497. private _options;
  101498. private _reusable;
  101499. private _textureType;
  101500. private _textureFormat;
  101501. /**
  101502. * Smart array of input and output textures for the post process.
  101503. * @hidden
  101504. */
  101505. _textures: SmartArray<InternalTexture>;
  101506. /**
  101507. * The index in _textures that corresponds to the output texture.
  101508. * @hidden
  101509. */
  101510. _currentRenderTextureInd: number;
  101511. private _effect;
  101512. private _samplers;
  101513. private _fragmentUrl;
  101514. private _vertexUrl;
  101515. private _parameters;
  101516. private _scaleRatio;
  101517. protected _indexParameters: any;
  101518. private _shareOutputWithPostProcess;
  101519. private _texelSize;
  101520. private _forcedOutputTexture;
  101521. /**
  101522. * Returns the fragment url or shader name used in the post process.
  101523. * @returns the fragment url or name in the shader store.
  101524. */
  101525. getEffectName(): string;
  101526. /**
  101527. * An event triggered when the postprocess is activated.
  101528. */
  101529. onActivateObservable: Observable<Camera>;
  101530. private _onActivateObserver;
  101531. /**
  101532. * A function that is added to the onActivateObservable
  101533. */
  101534. set onActivate(callback: Nullable<(camera: Camera) => void>);
  101535. /**
  101536. * An event triggered when the postprocess changes its size.
  101537. */
  101538. onSizeChangedObservable: Observable<PostProcess>;
  101539. private _onSizeChangedObserver;
  101540. /**
  101541. * A function that is added to the onSizeChangedObservable
  101542. */
  101543. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  101544. /**
  101545. * An event triggered when the postprocess applies its effect.
  101546. */
  101547. onApplyObservable: Observable<Effect>;
  101548. private _onApplyObserver;
  101549. /**
  101550. * A function that is added to the onApplyObservable
  101551. */
  101552. set onApply(callback: (effect: Effect) => void);
  101553. /**
  101554. * An event triggered before rendering the postprocess
  101555. */
  101556. onBeforeRenderObservable: Observable<Effect>;
  101557. private _onBeforeRenderObserver;
  101558. /**
  101559. * A function that is added to the onBeforeRenderObservable
  101560. */
  101561. set onBeforeRender(callback: (effect: Effect) => void);
  101562. /**
  101563. * An event triggered after rendering the postprocess
  101564. */
  101565. onAfterRenderObservable: Observable<Effect>;
  101566. private _onAfterRenderObserver;
  101567. /**
  101568. * A function that is added to the onAfterRenderObservable
  101569. */
  101570. set onAfterRender(callback: (efect: Effect) => void);
  101571. /**
  101572. * 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
  101573. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  101574. */
  101575. get inputTexture(): InternalTexture;
  101576. set inputTexture(value: InternalTexture);
  101577. /**
  101578. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  101579. * the only way to unset it is to use this function to restore its internal state
  101580. */
  101581. restoreDefaultInputTexture(): void;
  101582. /**
  101583. * Gets the camera which post process is applied to.
  101584. * @returns The camera the post process is applied to.
  101585. */
  101586. getCamera(): Camera;
  101587. /**
  101588. * Gets the texel size of the postprocess.
  101589. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  101590. */
  101591. get texelSize(): Vector2;
  101592. /**
  101593. * Creates a new instance PostProcess
  101594. * @param name The name of the PostProcess.
  101595. * @param fragmentUrl The url of the fragment shader to be used.
  101596. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  101597. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  101598. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101599. * @param camera The camera to apply the render pass to.
  101600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101601. * @param engine The engine which the post process will be applied. (default: current engine)
  101602. * @param reusable If the post process can be reused on the same frame. (default: false)
  101603. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  101604. * @param textureType Type of textures used when performing the post process. (default: 0)
  101605. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  101606. * @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
  101607. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  101608. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  101609. */
  101610. constructor(
  101611. /** Name of the PostProcess. */
  101612. 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);
  101613. /**
  101614. * Gets a string idenfifying the name of the class
  101615. * @returns "PostProcess" string
  101616. */
  101617. getClassName(): string;
  101618. /**
  101619. * Gets the engine which this post process belongs to.
  101620. * @returns The engine the post process was enabled with.
  101621. */
  101622. getEngine(): Engine;
  101623. /**
  101624. * The effect that is created when initializing the post process.
  101625. * @returns The created effect corresponding the the postprocess.
  101626. */
  101627. getEffect(): Effect;
  101628. /**
  101629. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  101630. * @param postProcess The post process to share the output with.
  101631. * @returns This post process.
  101632. */
  101633. shareOutputWith(postProcess: PostProcess): PostProcess;
  101634. /**
  101635. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  101636. * This should be called if the post process that shares output with this post process is disabled/disposed.
  101637. */
  101638. useOwnOutput(): void;
  101639. /**
  101640. * Updates the effect with the current post process compile time values and recompiles the shader.
  101641. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101642. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101643. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101644. * @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
  101645. * @param onCompiled Called when the shader has been compiled.
  101646. * @param onError Called if there is an error when compiling a shader.
  101647. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  101648. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  101649. */
  101650. 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;
  101651. /**
  101652. * The post process is reusable if it can be used multiple times within one frame.
  101653. * @returns If the post process is reusable
  101654. */
  101655. isReusable(): boolean;
  101656. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  101657. markTextureDirty(): void;
  101658. /**
  101659. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  101660. * 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.
  101661. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  101662. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  101663. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  101664. * @returns The target texture that was bound to be written to.
  101665. */
  101666. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  101667. /**
  101668. * If the post process is supported.
  101669. */
  101670. get isSupported(): boolean;
  101671. /**
  101672. * The aspect ratio of the output texture.
  101673. */
  101674. get aspectRatio(): number;
  101675. /**
  101676. * Get a value indicating if the post-process is ready to be used
  101677. * @returns true if the post-process is ready (shader is compiled)
  101678. */
  101679. isReady(): boolean;
  101680. /**
  101681. * Binds all textures and uniforms to the shader, this will be run on every pass.
  101682. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  101683. */
  101684. apply(): Nullable<Effect>;
  101685. private _disposeTextures;
  101686. /**
  101687. * Disposes the post process.
  101688. * @param camera The camera to dispose the post process on.
  101689. */
  101690. dispose(camera?: Camera): void;
  101691. }
  101692. }
  101693. declare module BABYLON {
  101694. /** @hidden */
  101695. export var kernelBlurVaryingDeclaration: {
  101696. name: string;
  101697. shader: string;
  101698. };
  101699. }
  101700. declare module BABYLON {
  101701. /** @hidden */
  101702. export var kernelBlurFragment: {
  101703. name: string;
  101704. shader: string;
  101705. };
  101706. }
  101707. declare module BABYLON {
  101708. /** @hidden */
  101709. export var kernelBlurFragment2: {
  101710. name: string;
  101711. shader: string;
  101712. };
  101713. }
  101714. declare module BABYLON {
  101715. /** @hidden */
  101716. export var kernelBlurPixelShader: {
  101717. name: string;
  101718. shader: string;
  101719. };
  101720. }
  101721. declare module BABYLON {
  101722. /** @hidden */
  101723. export var kernelBlurVertex: {
  101724. name: string;
  101725. shader: string;
  101726. };
  101727. }
  101728. declare module BABYLON {
  101729. /** @hidden */
  101730. export var kernelBlurVertexShader: {
  101731. name: string;
  101732. shader: string;
  101733. };
  101734. }
  101735. declare module BABYLON {
  101736. /**
  101737. * The Blur Post Process which blurs an image based on a kernel and direction.
  101738. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101739. */
  101740. export class BlurPostProcess extends PostProcess {
  101741. /** The direction in which to blur the image. */
  101742. direction: Vector2;
  101743. private blockCompilation;
  101744. protected _kernel: number;
  101745. protected _idealKernel: number;
  101746. protected _packedFloat: boolean;
  101747. private _staticDefines;
  101748. /**
  101749. * Sets the length in pixels of the blur sample region
  101750. */
  101751. set kernel(v: number);
  101752. /**
  101753. * Gets the length in pixels of the blur sample region
  101754. */
  101755. get kernel(): number;
  101756. /**
  101757. * Sets wether or not the blur needs to unpack/repack floats
  101758. */
  101759. set packedFloat(v: boolean);
  101760. /**
  101761. * Gets wether or not the blur is unpacking/repacking floats
  101762. */
  101763. get packedFloat(): boolean;
  101764. /**
  101765. * Creates a new instance BlurPostProcess
  101766. * @param name The name of the effect.
  101767. * @param direction The direction in which to blur the image.
  101768. * @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.
  101769. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101770. * @param camera The camera to apply the render pass to.
  101771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101772. * @param engine The engine which the post process will be applied. (default: current engine)
  101773. * @param reusable If the post process can be reused on the same frame. (default: false)
  101774. * @param textureType Type of textures used when performing the post process. (default: 0)
  101775. * @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)
  101776. */
  101777. constructor(name: string,
  101778. /** The direction in which to blur the image. */
  101779. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101780. /**
  101781. * Updates the effect with the current post process compile time values and recompiles the shader.
  101782. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101783. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101784. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101785. * @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
  101786. * @param onCompiled Called when the shader has been compiled.
  101787. * @param onError Called if there is an error when compiling a shader.
  101788. */
  101789. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101790. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101791. /**
  101792. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101793. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101794. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101795. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101796. * The gaps between physical kernels are compensated for in the weighting of the samples
  101797. * @param idealKernel Ideal blur kernel.
  101798. * @return Nearest best kernel.
  101799. */
  101800. protected _nearestBestKernel(idealKernel: number): number;
  101801. /**
  101802. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101803. * @param x The point on the Gaussian distribution to sample.
  101804. * @return the value of the Gaussian function at x.
  101805. */
  101806. protected _gaussianWeight(x: number): number;
  101807. /**
  101808. * Generates a string that can be used as a floating point number in GLSL.
  101809. * @param x Value to print.
  101810. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101811. * @return GLSL float string.
  101812. */
  101813. protected _glslFloat(x: number, decimalFigures?: number): string;
  101814. }
  101815. }
  101816. declare module BABYLON {
  101817. /**
  101818. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101819. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101820. * You can then easily use it as a reflectionTexture on a flat surface.
  101821. * In case the surface is not a plane, please consider relying on reflection probes.
  101822. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101823. */
  101824. export class MirrorTexture extends RenderTargetTexture {
  101825. private scene;
  101826. /**
  101827. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  101828. * 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.
  101829. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101830. */
  101831. mirrorPlane: Plane;
  101832. /**
  101833. * Define the blur ratio used to blur the reflection if needed.
  101834. */
  101835. set blurRatio(value: number);
  101836. get blurRatio(): number;
  101837. /**
  101838. * Define the adaptive blur kernel used to blur the reflection if needed.
  101839. * This will autocompute the closest best match for the `blurKernel`
  101840. */
  101841. set adaptiveBlurKernel(value: number);
  101842. /**
  101843. * Define the blur kernel used to blur the reflection if needed.
  101844. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101845. */
  101846. set blurKernel(value: number);
  101847. /**
  101848. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  101849. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101850. */
  101851. set blurKernelX(value: number);
  101852. get blurKernelX(): number;
  101853. /**
  101854. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  101855. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101856. */
  101857. set blurKernelY(value: number);
  101858. get blurKernelY(): number;
  101859. private _autoComputeBlurKernel;
  101860. protected _onRatioRescale(): void;
  101861. private _updateGammaSpace;
  101862. private _imageProcessingConfigChangeObserver;
  101863. private _transformMatrix;
  101864. private _mirrorMatrix;
  101865. private _savedViewMatrix;
  101866. private _blurX;
  101867. private _blurY;
  101868. private _adaptiveBlurKernel;
  101869. private _blurKernelX;
  101870. private _blurKernelY;
  101871. private _blurRatio;
  101872. /**
  101873. * Instantiates a Mirror Texture.
  101874. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101875. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101876. * You can then easily use it as a reflectionTexture on a flat surface.
  101877. * In case the surface is not a plane, please consider relying on reflection probes.
  101878. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101879. * @param name
  101880. * @param size
  101881. * @param scene
  101882. * @param generateMipMaps
  101883. * @param type
  101884. * @param samplingMode
  101885. * @param generateDepthBuffer
  101886. */
  101887. constructor(name: string, size: number | {
  101888. width: number;
  101889. height: number;
  101890. } | {
  101891. ratio: number;
  101892. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101893. private _preparePostProcesses;
  101894. /**
  101895. * Clone the mirror texture.
  101896. * @returns the cloned texture
  101897. */
  101898. clone(): MirrorTexture;
  101899. /**
  101900. * Serialize the texture to a JSON representation you could use in Parse later on
  101901. * @returns the serialized JSON representation
  101902. */
  101903. serialize(): any;
  101904. /**
  101905. * Dispose the texture and release its associated resources.
  101906. */
  101907. dispose(): void;
  101908. }
  101909. }
  101910. declare module BABYLON {
  101911. /**
  101912. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101913. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101914. */
  101915. export class Texture extends BaseTexture {
  101916. /**
  101917. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101918. */
  101919. static SerializeBuffers: boolean;
  101920. /** @hidden */
  101921. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101922. /** @hidden */
  101923. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101924. /** @hidden */
  101925. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101926. /** nearest is mag = nearest and min = nearest and mip = linear */
  101927. static readonly NEAREST_SAMPLINGMODE: number;
  101928. /** nearest is mag = nearest and min = nearest and mip = linear */
  101929. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101930. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101931. static readonly BILINEAR_SAMPLINGMODE: number;
  101932. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101933. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101934. /** Trilinear is mag = linear and min = linear and mip = linear */
  101935. static readonly TRILINEAR_SAMPLINGMODE: number;
  101936. /** Trilinear is mag = linear and min = linear and mip = linear */
  101937. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101938. /** mag = nearest and min = nearest and mip = nearest */
  101939. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101940. /** mag = nearest and min = linear and mip = nearest */
  101941. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101942. /** mag = nearest and min = linear and mip = linear */
  101943. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101944. /** mag = nearest and min = linear and mip = none */
  101945. static readonly NEAREST_LINEAR: number;
  101946. /** mag = nearest and min = nearest and mip = none */
  101947. static readonly NEAREST_NEAREST: number;
  101948. /** mag = linear and min = nearest and mip = nearest */
  101949. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101950. /** mag = linear and min = nearest and mip = linear */
  101951. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101952. /** mag = linear and min = linear and mip = none */
  101953. static readonly LINEAR_LINEAR: number;
  101954. /** mag = linear and min = nearest and mip = none */
  101955. static readonly LINEAR_NEAREST: number;
  101956. /** Explicit coordinates mode */
  101957. static readonly EXPLICIT_MODE: number;
  101958. /** Spherical coordinates mode */
  101959. static readonly SPHERICAL_MODE: number;
  101960. /** Planar coordinates mode */
  101961. static readonly PLANAR_MODE: number;
  101962. /** Cubic coordinates mode */
  101963. static readonly CUBIC_MODE: number;
  101964. /** Projection coordinates mode */
  101965. static readonly PROJECTION_MODE: number;
  101966. /** Inverse Cubic coordinates mode */
  101967. static readonly SKYBOX_MODE: number;
  101968. /** Inverse Cubic coordinates mode */
  101969. static readonly INVCUBIC_MODE: number;
  101970. /** Equirectangular coordinates mode */
  101971. static readonly EQUIRECTANGULAR_MODE: number;
  101972. /** Equirectangular Fixed coordinates mode */
  101973. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101974. /** Equirectangular Fixed Mirrored coordinates mode */
  101975. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101976. /** Texture is not repeating outside of 0..1 UVs */
  101977. static readonly CLAMP_ADDRESSMODE: number;
  101978. /** Texture is repeating outside of 0..1 UVs */
  101979. static readonly WRAP_ADDRESSMODE: number;
  101980. /** Texture is repeating and mirrored */
  101981. static readonly MIRROR_ADDRESSMODE: number;
  101982. /**
  101983. * 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
  101984. */
  101985. static UseSerializedUrlIfAny: boolean;
  101986. /**
  101987. * Define the url of the texture.
  101988. */
  101989. url: Nullable<string>;
  101990. /**
  101991. * Define an offset on the texture to offset the u coordinates of the UVs
  101992. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101993. */
  101994. uOffset: number;
  101995. /**
  101996. * Define an offset on the texture to offset the v coordinates of the UVs
  101997. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101998. */
  101999. vOffset: number;
  102000. /**
  102001. * Define an offset on the texture to scale the u coordinates of the UVs
  102002. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102003. */
  102004. uScale: number;
  102005. /**
  102006. * Define an offset on the texture to scale the v coordinates of the UVs
  102007. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  102008. */
  102009. vScale: number;
  102010. /**
  102011. * Define an offset on the texture to rotate around the u coordinates of the UVs
  102012. * @see https://doc.babylonjs.com/how_to/more_materials
  102013. */
  102014. uAng: number;
  102015. /**
  102016. * Define an offset on the texture to rotate around the v coordinates of the UVs
  102017. * @see https://doc.babylonjs.com/how_to/more_materials
  102018. */
  102019. vAng: number;
  102020. /**
  102021. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  102022. * @see https://doc.babylonjs.com/how_to/more_materials
  102023. */
  102024. wAng: number;
  102025. /**
  102026. * Defines the center of rotation (U)
  102027. */
  102028. uRotationCenter: number;
  102029. /**
  102030. * Defines the center of rotation (V)
  102031. */
  102032. vRotationCenter: number;
  102033. /**
  102034. * Defines the center of rotation (W)
  102035. */
  102036. wRotationCenter: number;
  102037. /**
  102038. * Are mip maps generated for this texture or not.
  102039. */
  102040. get noMipmap(): boolean;
  102041. /**
  102042. * List of inspectable custom properties (used by the Inspector)
  102043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102044. */
  102045. inspectableCustomProperties: Nullable<IInspectable[]>;
  102046. private _noMipmap;
  102047. /** @hidden */
  102048. _invertY: boolean;
  102049. private _rowGenerationMatrix;
  102050. private _cachedTextureMatrix;
  102051. private _projectionModeMatrix;
  102052. private _t0;
  102053. private _t1;
  102054. private _t2;
  102055. private _cachedUOffset;
  102056. private _cachedVOffset;
  102057. private _cachedUScale;
  102058. private _cachedVScale;
  102059. private _cachedUAng;
  102060. private _cachedVAng;
  102061. private _cachedWAng;
  102062. private _cachedProjectionMatrixId;
  102063. private _cachedCoordinatesMode;
  102064. /** @hidden */
  102065. protected _initialSamplingMode: number;
  102066. /** @hidden */
  102067. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102068. private _deleteBuffer;
  102069. protected _format: Nullable<number>;
  102070. private _delayedOnLoad;
  102071. private _delayedOnError;
  102072. private _mimeType?;
  102073. /**
  102074. * Observable triggered once the texture has been loaded.
  102075. */
  102076. onLoadObservable: Observable<Texture>;
  102077. protected _isBlocking: boolean;
  102078. /**
  102079. * Is the texture preventing material to render while loading.
  102080. * If false, a default texture will be used instead of the loading one during the preparation step.
  102081. */
  102082. set isBlocking(value: boolean);
  102083. get isBlocking(): boolean;
  102084. /**
  102085. * Get the current sampling mode associated with the texture.
  102086. */
  102087. get samplingMode(): number;
  102088. /**
  102089. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  102090. */
  102091. get invertY(): boolean;
  102092. /**
  102093. * Instantiates a new texture.
  102094. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102095. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102096. * @param url defines the url of the picture to load as a texture
  102097. * @param sceneOrEngine defines the scene or engine the texture will belong to
  102098. * @param noMipmap defines if the texture will require mip maps or not
  102099. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  102100. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102101. * @param onLoad defines a callback triggered when the texture has been loaded
  102102. * @param onError defines a callback triggered when an error occurred during the loading session
  102103. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  102104. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  102105. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102106. * @param mimeType defines an optional mime type information
  102107. */
  102108. 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);
  102109. /**
  102110. * Update the url (and optional buffer) of this texture if url was null during construction.
  102111. * @param url the url of the texture
  102112. * @param buffer the buffer of the texture (defaults to null)
  102113. * @param onLoad callback called when the texture is loaded (defaults to null)
  102114. */
  102115. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  102116. /**
  102117. * Finish the loading sequence of a texture flagged as delayed load.
  102118. * @hidden
  102119. */
  102120. delayLoad(): void;
  102121. private _prepareRowForTextureGeneration;
  102122. /**
  102123. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  102124. * @returns the transform matrix of the texture.
  102125. */
  102126. getTextureMatrix(uBase?: number): Matrix;
  102127. /**
  102128. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  102129. * @returns The reflection texture transform
  102130. */
  102131. getReflectionTextureMatrix(): Matrix;
  102132. /**
  102133. * Clones the texture.
  102134. * @returns the cloned texture
  102135. */
  102136. clone(): Texture;
  102137. /**
  102138. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102139. * @returns The JSON representation of the texture
  102140. */
  102141. serialize(): any;
  102142. /**
  102143. * Get the current class name of the texture useful for serialization or dynamic coding.
  102144. * @returns "Texture"
  102145. */
  102146. getClassName(): string;
  102147. /**
  102148. * Dispose the texture and release its associated resources.
  102149. */
  102150. dispose(): void;
  102151. /**
  102152. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  102153. * @param parsedTexture Define the JSON representation of the texture
  102154. * @param scene Define the scene the parsed texture should be instantiated in
  102155. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  102156. * @returns The parsed texture if successful
  102157. */
  102158. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  102159. /**
  102160. * Creates a texture from its base 64 representation.
  102161. * @param data Define the base64 payload without the data: prefix
  102162. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102163. * @param scene Define the scene the texture should belong to
  102164. * @param noMipmap Forces the texture to not create mip map information if true
  102165. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102166. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102167. * @param onLoad define a callback triggered when the texture has been loaded
  102168. * @param onError define a callback triggered when an error occurred during the loading session
  102169. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102170. * @returns the created texture
  102171. */
  102172. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  102173. /**
  102174. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  102175. * @param data Define the base64 payload without the data: prefix
  102176. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  102177. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  102178. * @param scene Define the scene the texture should belong to
  102179. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  102180. * @param noMipmap Forces the texture to not create mip map information if true
  102181. * @param invertY define if the texture needs to be inverted on the y axis during loading
  102182. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  102183. * @param onLoad define a callback triggered when the texture has been loaded
  102184. * @param onError define a callback triggered when an error occurred during the loading session
  102185. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  102186. * @returns the created texture
  102187. */
  102188. 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;
  102189. }
  102190. }
  102191. declare module BABYLON {
  102192. /**
  102193. * PostProcessManager is used to manage one or more post processes or post process pipelines
  102194. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102195. */
  102196. export class PostProcessManager {
  102197. private _scene;
  102198. private _indexBuffer;
  102199. private _vertexBuffers;
  102200. /**
  102201. * Creates a new instance PostProcess
  102202. * @param scene The scene that the post process is associated with.
  102203. */
  102204. constructor(scene: Scene);
  102205. private _prepareBuffers;
  102206. private _buildIndexBuffer;
  102207. /**
  102208. * Rebuilds the vertex buffers of the manager.
  102209. * @hidden
  102210. */
  102211. _rebuild(): void;
  102212. /**
  102213. * Prepares a frame to be run through a post process.
  102214. * @param sourceTexture The input texture to the post procesess. (default: null)
  102215. * @param postProcesses An array of post processes to be run. (default: null)
  102216. * @returns True if the post processes were able to be run.
  102217. * @hidden
  102218. */
  102219. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  102220. /**
  102221. * Manually render a set of post processes to a texture.
  102222. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  102223. * @param postProcesses An array of post processes to be run.
  102224. * @param targetTexture The target texture to render to.
  102225. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  102226. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  102227. * @param lodLevel defines which lod of the texture to render to
  102228. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  102229. */
  102230. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  102231. /**
  102232. * Finalize the result of the output of the postprocesses.
  102233. * @param doNotPresent If true the result will not be displayed to the screen.
  102234. * @param targetTexture The target texture to render to.
  102235. * @param faceIndex The index of the face to bind the target texture to.
  102236. * @param postProcesses The array of post processes to render.
  102237. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  102238. * @hidden
  102239. */
  102240. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  102241. /**
  102242. * Disposes of the post process manager.
  102243. */
  102244. dispose(): void;
  102245. }
  102246. }
  102247. declare module BABYLON {
  102248. /**
  102249. * This Helps creating a texture that will be created from a camera in your scene.
  102250. * It is basically a dynamic texture that could be used to create special effects for instance.
  102251. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  102252. */
  102253. export class RenderTargetTexture extends Texture {
  102254. isCube: boolean;
  102255. /**
  102256. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  102257. */
  102258. static readonly REFRESHRATE_RENDER_ONCE: number;
  102259. /**
  102260. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  102261. */
  102262. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  102263. /**
  102264. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  102265. * the central point of your effect and can save a lot of performances.
  102266. */
  102267. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  102268. /**
  102269. * Use this predicate to dynamically define the list of mesh you want to render.
  102270. * If set, the renderList property will be overwritten.
  102271. */
  102272. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  102273. private _renderList;
  102274. /**
  102275. * Use this list to define the list of mesh you want to render.
  102276. */
  102277. get renderList(): Nullable<Array<AbstractMesh>>;
  102278. set renderList(value: Nullable<Array<AbstractMesh>>);
  102279. /**
  102280. * Use this function to overload the renderList array at rendering time.
  102281. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  102282. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  102283. * the cube (if the RTT is a cube, else layerOrFace=0).
  102284. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  102285. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  102286. * hold dummy elements!
  102287. */
  102288. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  102289. private _hookArray;
  102290. /**
  102291. * Define if particles should be rendered in your texture.
  102292. */
  102293. renderParticles: boolean;
  102294. /**
  102295. * Define if sprites should be rendered in your texture.
  102296. */
  102297. renderSprites: boolean;
  102298. /**
  102299. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  102300. */
  102301. coordinatesMode: number;
  102302. /**
  102303. * Define the camera used to render the texture.
  102304. */
  102305. activeCamera: Nullable<Camera>;
  102306. /**
  102307. * Override the mesh isReady function with your own one.
  102308. */
  102309. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  102310. /**
  102311. * Override the render function of the texture with your own one.
  102312. */
  102313. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  102314. /**
  102315. * Define if camera post processes should be use while rendering the texture.
  102316. */
  102317. useCameraPostProcesses: boolean;
  102318. /**
  102319. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  102320. */
  102321. ignoreCameraViewport: boolean;
  102322. private _postProcessManager;
  102323. private _postProcesses;
  102324. private _resizeObserver;
  102325. /**
  102326. * An event triggered when the texture is unbind.
  102327. */
  102328. onBeforeBindObservable: Observable<RenderTargetTexture>;
  102329. /**
  102330. * An event triggered when the texture is unbind.
  102331. */
  102332. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  102333. private _onAfterUnbindObserver;
  102334. /**
  102335. * Set a after unbind callback in the texture.
  102336. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  102337. */
  102338. set onAfterUnbind(callback: () => void);
  102339. /**
  102340. * An event triggered before rendering the texture
  102341. */
  102342. onBeforeRenderObservable: Observable<number>;
  102343. private _onBeforeRenderObserver;
  102344. /**
  102345. * Set a before render callback in the texture.
  102346. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  102347. */
  102348. set onBeforeRender(callback: (faceIndex: number) => void);
  102349. /**
  102350. * An event triggered after rendering the texture
  102351. */
  102352. onAfterRenderObservable: Observable<number>;
  102353. private _onAfterRenderObserver;
  102354. /**
  102355. * Set a after render callback in the texture.
  102356. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  102357. */
  102358. set onAfterRender(callback: (faceIndex: number) => void);
  102359. /**
  102360. * An event triggered after the texture clear
  102361. */
  102362. onClearObservable: Observable<Engine>;
  102363. private _onClearObserver;
  102364. /**
  102365. * Set a clear callback in the texture.
  102366. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  102367. */
  102368. set onClear(callback: (Engine: Engine) => void);
  102369. /**
  102370. * An event triggered when the texture is resized.
  102371. */
  102372. onResizeObservable: Observable<RenderTargetTexture>;
  102373. /**
  102374. * Define the clear color of the Render Target if it should be different from the scene.
  102375. */
  102376. clearColor: Color4;
  102377. protected _size: number | {
  102378. width: number;
  102379. height: number;
  102380. layers?: number;
  102381. };
  102382. protected _initialSizeParameter: number | {
  102383. width: number;
  102384. height: number;
  102385. } | {
  102386. ratio: number;
  102387. };
  102388. protected _sizeRatio: Nullable<number>;
  102389. /** @hidden */
  102390. _generateMipMaps: boolean;
  102391. protected _renderingManager: RenderingManager;
  102392. /** @hidden */
  102393. _waitingRenderList: string[];
  102394. protected _doNotChangeAspectRatio: boolean;
  102395. protected _currentRefreshId: number;
  102396. protected _refreshRate: number;
  102397. protected _textureMatrix: Matrix;
  102398. protected _samples: number;
  102399. protected _renderTargetOptions: RenderTargetCreationOptions;
  102400. /**
  102401. * Gets render target creation options that were used.
  102402. */
  102403. get renderTargetOptions(): RenderTargetCreationOptions;
  102404. protected _onRatioRescale(): void;
  102405. /**
  102406. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  102407. * It must define where the camera used to render the texture is set
  102408. */
  102409. boundingBoxPosition: Vector3;
  102410. private _boundingBoxSize;
  102411. /**
  102412. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  102413. * When defined, the cubemap will switch to local mode
  102414. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  102415. * @example https://www.babylonjs-playground.com/#RNASML
  102416. */
  102417. set boundingBoxSize(value: Vector3);
  102418. get boundingBoxSize(): Vector3;
  102419. /**
  102420. * In case the RTT has been created with a depth texture, get the associated
  102421. * depth texture.
  102422. * Otherwise, return null.
  102423. */
  102424. get depthStencilTexture(): Nullable<InternalTexture>;
  102425. /**
  102426. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  102427. * or used a shadow, depth texture...
  102428. * @param name The friendly name of the texture
  102429. * @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)
  102430. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  102431. * @param generateMipMaps True if mip maps need to be generated after render.
  102432. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  102433. * @param type The type of the buffer in the RTT (int, half float, float...)
  102434. * @param isCube True if a cube texture needs to be created
  102435. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  102436. * @param generateDepthBuffer True to generate a depth buffer
  102437. * @param generateStencilBuffer True to generate a stencil buffer
  102438. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  102439. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  102440. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102441. */
  102442. constructor(name: string, size: number | {
  102443. width: number;
  102444. height: number;
  102445. layers?: number;
  102446. } | {
  102447. ratio: number;
  102448. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  102449. /**
  102450. * Creates a depth stencil texture.
  102451. * This is only available in WebGL 2 or with the depth texture extension available.
  102452. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  102453. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  102454. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  102455. */
  102456. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  102457. private _processSizeParameter;
  102458. /**
  102459. * Define the number of samples to use in case of MSAA.
  102460. * It defaults to one meaning no MSAA has been enabled.
  102461. */
  102462. get samples(): number;
  102463. set samples(value: number);
  102464. /**
  102465. * Resets the refresh counter of the texture and start bak from scratch.
  102466. * Could be useful to regenerate the texture if it is setup to render only once.
  102467. */
  102468. resetRefreshCounter(): void;
  102469. /**
  102470. * Define the refresh rate of the texture or the rendering frequency.
  102471. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  102472. */
  102473. get refreshRate(): number;
  102474. set refreshRate(value: number);
  102475. /**
  102476. * Adds a post process to the render target rendering passes.
  102477. * @param postProcess define the post process to add
  102478. */
  102479. addPostProcess(postProcess: PostProcess): void;
  102480. /**
  102481. * Clear all the post processes attached to the render target
  102482. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  102483. */
  102484. clearPostProcesses(dispose?: boolean): void;
  102485. /**
  102486. * Remove one of the post process from the list of attached post processes to the texture
  102487. * @param postProcess define the post process to remove from the list
  102488. */
  102489. removePostProcess(postProcess: PostProcess): void;
  102490. /** @hidden */
  102491. _shouldRender(): boolean;
  102492. /**
  102493. * Gets the actual render size of the texture.
  102494. * @returns the width of the render size
  102495. */
  102496. getRenderSize(): number;
  102497. /**
  102498. * Gets the actual render width of the texture.
  102499. * @returns the width of the render size
  102500. */
  102501. getRenderWidth(): number;
  102502. /**
  102503. * Gets the actual render height of the texture.
  102504. * @returns the height of the render size
  102505. */
  102506. getRenderHeight(): number;
  102507. /**
  102508. * Gets the actual number of layers of the texture.
  102509. * @returns the number of layers
  102510. */
  102511. getRenderLayers(): number;
  102512. /**
  102513. * Get if the texture can be rescaled or not.
  102514. */
  102515. get canRescale(): boolean;
  102516. /**
  102517. * Resize the texture using a ratio.
  102518. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  102519. */
  102520. scale(ratio: number): void;
  102521. /**
  102522. * Get the texture reflection matrix used to rotate/transform the reflection.
  102523. * @returns the reflection matrix
  102524. */
  102525. getReflectionTextureMatrix(): Matrix;
  102526. /**
  102527. * Resize the texture to a new desired size.
  102528. * Be carrefull as it will recreate all the data in the new texture.
  102529. * @param size Define the new size. It can be:
  102530. * - a number for squared texture,
  102531. * - an object containing { width: number, height: number }
  102532. * - or an object containing a ratio { ratio: number }
  102533. */
  102534. resize(size: number | {
  102535. width: number;
  102536. height: number;
  102537. } | {
  102538. ratio: number;
  102539. }): void;
  102540. private _defaultRenderListPrepared;
  102541. /**
  102542. * Renders all the objects from the render list into the texture.
  102543. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  102544. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  102545. */
  102546. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  102547. private _bestReflectionRenderTargetDimension;
  102548. private _prepareRenderingManager;
  102549. /**
  102550. * @hidden
  102551. * @param faceIndex face index to bind to if this is a cubetexture
  102552. * @param layer defines the index of the texture to bind in the array
  102553. */
  102554. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  102555. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102556. private renderToTarget;
  102557. /**
  102558. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  102559. * This allowed control for front to back rendering or reversly depending of the special needs.
  102560. *
  102561. * @param renderingGroupId The rendering group id corresponding to its index
  102562. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  102563. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  102564. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  102565. */
  102566. 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;
  102567. /**
  102568. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  102569. *
  102570. * @param renderingGroupId The rendering group id corresponding to its index
  102571. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  102572. */
  102573. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  102574. /**
  102575. * Clones the texture.
  102576. * @returns the cloned texture
  102577. */
  102578. clone(): RenderTargetTexture;
  102579. /**
  102580. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  102581. * @returns The JSON representation of the texture
  102582. */
  102583. serialize(): any;
  102584. /**
  102585. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  102586. */
  102587. disposeFramebufferObjects(): void;
  102588. /**
  102589. * Dispose the texture and release its associated resources.
  102590. */
  102591. dispose(): void;
  102592. /** @hidden */
  102593. _rebuild(): void;
  102594. /**
  102595. * Clear the info related to rendering groups preventing retention point in material dispose.
  102596. */
  102597. freeRenderingGroups(): void;
  102598. /**
  102599. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  102600. * @returns the view count
  102601. */
  102602. getViewCount(): number;
  102603. }
  102604. }
  102605. declare module BABYLON {
  102606. /**
  102607. * Class used to manipulate GUIDs
  102608. */
  102609. export class GUID {
  102610. /**
  102611. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102612. * Be aware Math.random() could cause collisions, but:
  102613. * "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"
  102614. * @returns a pseudo random id
  102615. */
  102616. static RandomId(): string;
  102617. }
  102618. }
  102619. declare module BABYLON {
  102620. /**
  102621. * Options to be used when creating a shadow depth material
  102622. */
  102623. export interface IIOptionShadowDepthMaterial {
  102624. /** Variables in the vertex shader code that need to have their names remapped.
  102625. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  102626. * "var_name" should be either: worldPos or vNormalW
  102627. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  102628. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  102629. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  102630. */
  102631. remappedVariables?: string[];
  102632. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  102633. standalone?: boolean;
  102634. }
  102635. /**
  102636. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  102637. */
  102638. export class ShadowDepthWrapper {
  102639. private _scene;
  102640. private _options?;
  102641. private _baseMaterial;
  102642. private _onEffectCreatedObserver;
  102643. private _subMeshToEffect;
  102644. private _subMeshToDepthEffect;
  102645. private _meshes;
  102646. /** @hidden */
  102647. _matriceNames: any;
  102648. /** Gets the standalone status of the wrapper */
  102649. get standalone(): boolean;
  102650. /** Gets the base material the wrapper is built upon */
  102651. get baseMaterial(): Material;
  102652. /**
  102653. * Instantiate a new shadow depth wrapper.
  102654. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  102655. * generate the shadow depth map. For more information, please refer to the documentation:
  102656. * https://doc.babylonjs.com/babylon101/shadows
  102657. * @param baseMaterial Material to wrap
  102658. * @param scene Define the scene the material belongs to
  102659. * @param options Options used to create the wrapper
  102660. */
  102661. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  102662. /**
  102663. * Gets the effect to use to generate the depth map
  102664. * @param subMesh subMesh to get the effect for
  102665. * @param shadowGenerator shadow generator to get the effect for
  102666. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  102667. */
  102668. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  102669. /**
  102670. * Specifies that the submesh is ready to be used for depth rendering
  102671. * @param subMesh submesh to check
  102672. * @param defines the list of defines to take into account when checking the effect
  102673. * @param shadowGenerator combined with subMesh, it defines the effect to check
  102674. * @param useInstances specifies that instances should be used
  102675. * @returns a boolean indicating that the submesh is ready or not
  102676. */
  102677. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  102678. /**
  102679. * Disposes the resources
  102680. */
  102681. dispose(): void;
  102682. private _makeEffect;
  102683. }
  102684. }
  102685. declare module BABYLON {
  102686. interface ThinEngine {
  102687. /**
  102688. * Unbind a list of render target textures from the webGL context
  102689. * This is used only when drawBuffer extension or webGL2 are active
  102690. * @param textures defines the render target textures to unbind
  102691. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102692. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102693. */
  102694. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  102695. /**
  102696. * Create a multi render target texture
  102697. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  102698. * @param size defines the size of the texture
  102699. * @param options defines the creation options
  102700. * @returns the cube texture as an InternalTexture
  102701. */
  102702. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  102703. /**
  102704. * Update the sample count for a given multiple render target texture
  102705. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102706. * @param textures defines the textures to update
  102707. * @param samples defines the sample count to set
  102708. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102709. */
  102710. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  102711. /**
  102712. * Select a subsets of attachments to draw to.
  102713. * @param attachments gl attachments
  102714. */
  102715. bindAttachments(attachments: number[]): void;
  102716. }
  102717. }
  102718. declare module BABYLON {
  102719. /**
  102720. * Creation options of the multi render target texture.
  102721. */
  102722. export interface IMultiRenderTargetOptions {
  102723. /**
  102724. * Define if the texture needs to create mip maps after render.
  102725. */
  102726. generateMipMaps?: boolean;
  102727. /**
  102728. * Define the types of all the draw buffers we want to create
  102729. */
  102730. types?: number[];
  102731. /**
  102732. * Define the sampling modes of all the draw buffers we want to create
  102733. */
  102734. samplingModes?: number[];
  102735. /**
  102736. * Define if a depth buffer is required
  102737. */
  102738. generateDepthBuffer?: boolean;
  102739. /**
  102740. * Define if a stencil buffer is required
  102741. */
  102742. generateStencilBuffer?: boolean;
  102743. /**
  102744. * Define if a depth texture is required instead of a depth buffer
  102745. */
  102746. generateDepthTexture?: boolean;
  102747. /**
  102748. * Define the number of desired draw buffers
  102749. */
  102750. textureCount?: number;
  102751. /**
  102752. * Define if aspect ratio should be adapted to the texture or stay the scene one
  102753. */
  102754. doNotChangeAspectRatio?: boolean;
  102755. /**
  102756. * Define the default type of the buffers we are creating
  102757. */
  102758. defaultType?: number;
  102759. }
  102760. /**
  102761. * A multi render target, like a render target provides the ability to render to a texture.
  102762. * Unlike the render target, it can render to several draw buffers in one draw.
  102763. * This is specially interesting in deferred rendering or for any effects requiring more than
  102764. * just one color from a single pass.
  102765. */
  102766. export class MultiRenderTarget extends RenderTargetTexture {
  102767. private _internalTextures;
  102768. private _textures;
  102769. private _multiRenderTargetOptions;
  102770. private _count;
  102771. /**
  102772. * Get if draw buffers are currently supported by the used hardware and browser.
  102773. */
  102774. get isSupported(): boolean;
  102775. /**
  102776. * Get the list of textures generated by the multi render target.
  102777. */
  102778. get textures(): Texture[];
  102779. /**
  102780. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  102781. */
  102782. get count(): number;
  102783. /**
  102784. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  102785. */
  102786. get depthTexture(): Texture;
  102787. /**
  102788. * Set the wrapping mode on U of all the textures we are rendering to.
  102789. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102790. */
  102791. set wrapU(wrap: number);
  102792. /**
  102793. * Set the wrapping mode on V of all the textures we are rendering to.
  102794. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  102795. */
  102796. set wrapV(wrap: number);
  102797. /**
  102798. * Instantiate a new multi render target texture.
  102799. * A multi render target, like a render target provides the ability to render to a texture.
  102800. * Unlike the render target, it can render to several draw buffers in one draw.
  102801. * This is specially interesting in deferred rendering or for any effects requiring more than
  102802. * just one color from a single pass.
  102803. * @param name Define the name of the texture
  102804. * @param size Define the size of the buffers to render to
  102805. * @param count Define the number of target we are rendering into
  102806. * @param scene Define the scene the texture belongs to
  102807. * @param options Define the options used to create the multi render target
  102808. */
  102809. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  102810. /** @hidden */
  102811. _rebuild(): void;
  102812. private _createInternalTextures;
  102813. private _createTextures;
  102814. /**
  102815. * Define the number of samples used if MSAA is enabled.
  102816. */
  102817. get samples(): number;
  102818. set samples(value: number);
  102819. /**
  102820. * Resize all the textures in the multi render target.
  102821. * Be carrefull as it will recreate all the data in the new texture.
  102822. * @param size Define the new size
  102823. */
  102824. resize(size: any): void;
  102825. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  102826. /**
  102827. * Dispose the render targets and their associated resources
  102828. */
  102829. dispose(): void;
  102830. /**
  102831. * Release all the underlying texture used as draw buffers.
  102832. */
  102833. releaseInternalTextures(): void;
  102834. }
  102835. }
  102836. declare module BABYLON {
  102837. /** @hidden */
  102838. export var imageProcessingPixelShader: {
  102839. name: string;
  102840. shader: string;
  102841. };
  102842. }
  102843. declare module BABYLON {
  102844. /**
  102845. * ImageProcessingPostProcess
  102846. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102847. */
  102848. export class ImageProcessingPostProcess extends PostProcess {
  102849. /**
  102850. * Default configuration related to image processing available in the PBR Material.
  102851. */
  102852. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102853. /**
  102854. * Gets the image processing configuration used either in this material.
  102855. */
  102856. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102857. /**
  102858. * Sets the Default image processing configuration used either in the this material.
  102859. *
  102860. * If sets to null, the scene one is in use.
  102861. */
  102862. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102863. /**
  102864. * Keep track of the image processing observer to allow dispose and replace.
  102865. */
  102866. private _imageProcessingObserver;
  102867. /**
  102868. * Attaches a new image processing configuration to the PBR Material.
  102869. * @param configuration
  102870. */
  102871. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102872. /**
  102873. * If the post process is supported.
  102874. */
  102875. get isSupported(): boolean;
  102876. /**
  102877. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102878. */
  102879. get colorCurves(): Nullable<ColorCurves>;
  102880. /**
  102881. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102882. */
  102883. set colorCurves(value: Nullable<ColorCurves>);
  102884. /**
  102885. * Gets wether the color curves effect is enabled.
  102886. */
  102887. get colorCurvesEnabled(): boolean;
  102888. /**
  102889. * Sets wether the color curves effect is enabled.
  102890. */
  102891. set colorCurvesEnabled(value: boolean);
  102892. /**
  102893. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102894. */
  102895. get colorGradingTexture(): Nullable<BaseTexture>;
  102896. /**
  102897. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102898. */
  102899. set colorGradingTexture(value: Nullable<BaseTexture>);
  102900. /**
  102901. * Gets wether the color grading effect is enabled.
  102902. */
  102903. get colorGradingEnabled(): boolean;
  102904. /**
  102905. * Gets wether the color grading effect is enabled.
  102906. */
  102907. set colorGradingEnabled(value: boolean);
  102908. /**
  102909. * Gets exposure used in the effect.
  102910. */
  102911. get exposure(): number;
  102912. /**
  102913. * Sets exposure used in the effect.
  102914. */
  102915. set exposure(value: number);
  102916. /**
  102917. * Gets wether tonemapping is enabled or not.
  102918. */
  102919. get toneMappingEnabled(): boolean;
  102920. /**
  102921. * Sets wether tonemapping is enabled or not
  102922. */
  102923. set toneMappingEnabled(value: boolean);
  102924. /**
  102925. * Gets the type of tone mapping effect.
  102926. */
  102927. get toneMappingType(): number;
  102928. /**
  102929. * Sets the type of tone mapping effect.
  102930. */
  102931. set toneMappingType(value: number);
  102932. /**
  102933. * Gets contrast used in the effect.
  102934. */
  102935. get contrast(): number;
  102936. /**
  102937. * Sets contrast used in the effect.
  102938. */
  102939. set contrast(value: number);
  102940. /**
  102941. * Gets Vignette stretch size.
  102942. */
  102943. get vignetteStretch(): number;
  102944. /**
  102945. * Sets Vignette stretch size.
  102946. */
  102947. set vignetteStretch(value: number);
  102948. /**
  102949. * Gets Vignette centre X Offset.
  102950. */
  102951. get vignetteCentreX(): number;
  102952. /**
  102953. * Sets Vignette centre X Offset.
  102954. */
  102955. set vignetteCentreX(value: number);
  102956. /**
  102957. * Gets Vignette centre Y Offset.
  102958. */
  102959. get vignetteCentreY(): number;
  102960. /**
  102961. * Sets Vignette centre Y Offset.
  102962. */
  102963. set vignetteCentreY(value: number);
  102964. /**
  102965. * Gets Vignette weight or intensity of the vignette effect.
  102966. */
  102967. get vignetteWeight(): number;
  102968. /**
  102969. * Sets Vignette weight or intensity of the vignette effect.
  102970. */
  102971. set vignetteWeight(value: number);
  102972. /**
  102973. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102974. * if vignetteEnabled is set to true.
  102975. */
  102976. get vignetteColor(): Color4;
  102977. /**
  102978. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102979. * if vignetteEnabled is set to true.
  102980. */
  102981. set vignetteColor(value: Color4);
  102982. /**
  102983. * Gets Camera field of view used by the Vignette effect.
  102984. */
  102985. get vignetteCameraFov(): number;
  102986. /**
  102987. * Sets Camera field of view used by the Vignette effect.
  102988. */
  102989. set vignetteCameraFov(value: number);
  102990. /**
  102991. * Gets the vignette blend mode allowing different kind of effect.
  102992. */
  102993. get vignetteBlendMode(): number;
  102994. /**
  102995. * Sets the vignette blend mode allowing different kind of effect.
  102996. */
  102997. set vignetteBlendMode(value: number);
  102998. /**
  102999. * Gets wether the vignette effect is enabled.
  103000. */
  103001. get vignetteEnabled(): boolean;
  103002. /**
  103003. * Sets wether the vignette effect is enabled.
  103004. */
  103005. set vignetteEnabled(value: boolean);
  103006. private _fromLinearSpace;
  103007. /**
  103008. * Gets wether the input of the processing is in Gamma or Linear Space.
  103009. */
  103010. get fromLinearSpace(): boolean;
  103011. /**
  103012. * Sets wether the input of the processing is in Gamma or Linear Space.
  103013. */
  103014. set fromLinearSpace(value: boolean);
  103015. /**
  103016. * Defines cache preventing GC.
  103017. */
  103018. private _defines;
  103019. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103020. /**
  103021. * "ImageProcessingPostProcess"
  103022. * @returns "ImageProcessingPostProcess"
  103023. */
  103024. getClassName(): string;
  103025. /**
  103026. * @hidden
  103027. */
  103028. _updateParameters(): void;
  103029. dispose(camera?: Camera): void;
  103030. }
  103031. }
  103032. declare module BABYLON {
  103033. /** @hidden */
  103034. export var fibonacci: {
  103035. name: string;
  103036. shader: string;
  103037. };
  103038. }
  103039. declare module BABYLON {
  103040. /** @hidden */
  103041. export var subSurfaceScatteringFunctions: {
  103042. name: string;
  103043. shader: string;
  103044. };
  103045. }
  103046. declare module BABYLON {
  103047. /** @hidden */
  103048. export var diffusionProfile: {
  103049. name: string;
  103050. shader: string;
  103051. };
  103052. }
  103053. declare module BABYLON {
  103054. /** @hidden */
  103055. export var subSurfaceScatteringPixelShader: {
  103056. name: string;
  103057. shader: string;
  103058. };
  103059. }
  103060. declare module BABYLON {
  103061. /**
  103062. * Sub surface scattering post process
  103063. */
  103064. export class SubSurfaceScatteringPostProcess extends PostProcess {
  103065. /** @hidden */
  103066. texelWidth: number;
  103067. /** @hidden */
  103068. texelHeight: number;
  103069. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  103070. }
  103071. }
  103072. declare module BABYLON {
  103073. /**
  103074. * Interface for defining prepass effects in the prepass post-process pipeline
  103075. */
  103076. export interface PrePassEffectConfiguration {
  103077. /**
  103078. * Post process to attach for this effect
  103079. */
  103080. postProcess: PostProcess;
  103081. /**
  103082. * Is the effect enabled
  103083. */
  103084. enabled: boolean;
  103085. /**
  103086. * Disposes the effect configuration
  103087. */
  103088. dispose(): void;
  103089. /**
  103090. * Disposes the effect configuration
  103091. */
  103092. createPostProcess: () => PostProcess;
  103093. }
  103094. }
  103095. declare module BABYLON {
  103096. /**
  103097. * Contains all parameters needed for the prepass to perform
  103098. * screen space subsurface scattering
  103099. */
  103100. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  103101. private _ssDiffusionS;
  103102. private _ssFilterRadii;
  103103. private _ssDiffusionD;
  103104. /**
  103105. * Post process to attach for screen space subsurface scattering
  103106. */
  103107. postProcess: SubSurfaceScatteringPostProcess;
  103108. /**
  103109. * Diffusion profile color for subsurface scattering
  103110. */
  103111. get ssDiffusionS(): number[];
  103112. /**
  103113. * Diffusion profile max color channel value for subsurface scattering
  103114. */
  103115. get ssDiffusionD(): number[];
  103116. /**
  103117. * Diffusion profile filter radius for subsurface scattering
  103118. */
  103119. get ssFilterRadii(): number[];
  103120. /**
  103121. * Is subsurface enabled
  103122. */
  103123. enabled: boolean;
  103124. /**
  103125. * Diffusion profile colors for subsurface scattering
  103126. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  103127. * See ...
  103128. * Note that you can only store up to 5 of them
  103129. */
  103130. ssDiffusionProfileColors: Color3[];
  103131. /**
  103132. * Defines the ratio real world => scene units.
  103133. * Used for subsurface scattering
  103134. */
  103135. metersPerUnit: number;
  103136. private _scene;
  103137. /**
  103138. * Builds a subsurface configuration object
  103139. * @param scene The scene
  103140. */
  103141. constructor(scene: Scene);
  103142. /**
  103143. * Adds a new diffusion profile.
  103144. * Useful for more realistic subsurface scattering on diverse materials.
  103145. * @param color The color of the diffusion profile. Should be the average color of the material.
  103146. * @return The index of the diffusion profile for the material subsurface configuration
  103147. */
  103148. addDiffusionProfile(color: Color3): number;
  103149. /**
  103150. * Creates the sss post process
  103151. * @return The created post process
  103152. */
  103153. createPostProcess(): SubSurfaceScatteringPostProcess;
  103154. /**
  103155. * Deletes all diffusion profiles.
  103156. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  103157. */
  103158. clearAllDiffusionProfiles(): void;
  103159. /**
  103160. * Disposes this object
  103161. */
  103162. dispose(): void;
  103163. /**
  103164. * @hidden
  103165. * https://zero-radiance.github.io/post/sampling-diffusion/
  103166. *
  103167. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  103168. * ------------------------------------------------------------------------------------
  103169. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  103170. * PDF[r, phi, s] = r * R[r, phi, s]
  103171. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  103172. * ------------------------------------------------------------------------------------
  103173. * We importance sample the color channel with the widest scattering distance.
  103174. */
  103175. getDiffusionProfileParameters(color: Color3): number;
  103176. /**
  103177. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  103178. * 'u' is the random number (the value of the CDF): [0, 1).
  103179. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  103180. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  103181. */
  103182. private _sampleBurleyDiffusionProfile;
  103183. }
  103184. }
  103185. declare module BABYLON {
  103186. /**
  103187. * Renders a pre pass of the scene
  103188. * This means every mesh in the scene will be rendered to a render target texture
  103189. * And then this texture will be composited to the rendering canvas with post processes
  103190. * It is necessary for effects like subsurface scattering or deferred shading
  103191. */
  103192. export class PrePassRenderer {
  103193. /** @hidden */
  103194. static _SceneComponentInitialization: (scene: Scene) => void;
  103195. private _scene;
  103196. private _engine;
  103197. private _isDirty;
  103198. /**
  103199. * Number of textures in the multi render target texture where the scene is directly rendered
  103200. */
  103201. readonly mrtCount: number;
  103202. /**
  103203. * The render target where the scene is directly rendered
  103204. */
  103205. prePassRT: MultiRenderTarget;
  103206. private _mrtTypes;
  103207. private _multiRenderAttachments;
  103208. private _defaultAttachments;
  103209. private _clearAttachments;
  103210. private _postProcesses;
  103211. private readonly _clearColor;
  103212. /**
  103213. * Image processing post process for composition
  103214. */
  103215. imageProcessingPostProcess: ImageProcessingPostProcess;
  103216. /**
  103217. * Configuration for sub surface scattering post process
  103218. */
  103219. subSurfaceConfiguration: SubSurfaceConfiguration;
  103220. /**
  103221. * Should materials render their geometry on the MRT
  103222. */
  103223. materialsShouldRenderGeometry: boolean;
  103224. /**
  103225. * Should materials render the irradiance information on the MRT
  103226. */
  103227. materialsShouldRenderIrradiance: boolean;
  103228. private _enabled;
  103229. /**
  103230. * Indicates if the prepass is enabled
  103231. */
  103232. get enabled(): boolean;
  103233. /**
  103234. * How many samples are used for MSAA of the scene render target
  103235. */
  103236. get samples(): number;
  103237. set samples(n: number);
  103238. /**
  103239. * Instanciates a prepass renderer
  103240. * @param scene The scene
  103241. */
  103242. constructor(scene: Scene);
  103243. private _initializeAttachments;
  103244. private _createCompositionEffect;
  103245. /**
  103246. * Indicates if rendering a prepass is supported
  103247. */
  103248. get isSupported(): boolean;
  103249. /**
  103250. * Sets the proper output textures to draw in the engine.
  103251. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103252. */
  103253. bindAttachmentsForEffect(effect: Effect): void;
  103254. /**
  103255. * @hidden
  103256. */
  103257. _beforeCameraDraw(): void;
  103258. /**
  103259. * @hidden
  103260. */
  103261. _afterCameraDraw(): void;
  103262. private _checkRTSize;
  103263. private _bindFrameBuffer;
  103264. /**
  103265. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103266. */
  103267. clear(): void;
  103268. private _setState;
  103269. private _enable;
  103270. private _disable;
  103271. private _resetPostProcessChain;
  103272. private _bindPostProcessChain;
  103273. /**
  103274. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103275. */
  103276. markAsDirty(): void;
  103277. private _update;
  103278. /**
  103279. * Disposes the prepass renderer.
  103280. */
  103281. dispose(): void;
  103282. }
  103283. }
  103284. declare module BABYLON {
  103285. /**
  103286. * Options for compiling materials.
  103287. */
  103288. export interface IMaterialCompilationOptions {
  103289. /**
  103290. * Defines whether clip planes are enabled.
  103291. */
  103292. clipPlane: boolean;
  103293. /**
  103294. * Defines whether instances are enabled.
  103295. */
  103296. useInstances: boolean;
  103297. }
  103298. /**
  103299. * Options passed when calling customShaderNameResolve
  103300. */
  103301. export interface ICustomShaderNameResolveOptions {
  103302. /**
  103303. * 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
  103304. */
  103305. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  103306. }
  103307. /**
  103308. * Base class for the main features of a material in Babylon.js
  103309. */
  103310. export class Material implements IAnimatable {
  103311. /**
  103312. * Returns the triangle fill mode
  103313. */
  103314. static readonly TriangleFillMode: number;
  103315. /**
  103316. * Returns the wireframe mode
  103317. */
  103318. static readonly WireFrameFillMode: number;
  103319. /**
  103320. * Returns the point fill mode
  103321. */
  103322. static readonly PointFillMode: number;
  103323. /**
  103324. * Returns the point list draw mode
  103325. */
  103326. static readonly PointListDrawMode: number;
  103327. /**
  103328. * Returns the line list draw mode
  103329. */
  103330. static readonly LineListDrawMode: number;
  103331. /**
  103332. * Returns the line loop draw mode
  103333. */
  103334. static readonly LineLoopDrawMode: number;
  103335. /**
  103336. * Returns the line strip draw mode
  103337. */
  103338. static readonly LineStripDrawMode: number;
  103339. /**
  103340. * Returns the triangle strip draw mode
  103341. */
  103342. static readonly TriangleStripDrawMode: number;
  103343. /**
  103344. * Returns the triangle fan draw mode
  103345. */
  103346. static readonly TriangleFanDrawMode: number;
  103347. /**
  103348. * Stores the clock-wise side orientation
  103349. */
  103350. static readonly ClockWiseSideOrientation: number;
  103351. /**
  103352. * Stores the counter clock-wise side orientation
  103353. */
  103354. static readonly CounterClockWiseSideOrientation: number;
  103355. /**
  103356. * The dirty texture flag value
  103357. */
  103358. static readonly TextureDirtyFlag: number;
  103359. /**
  103360. * The dirty light flag value
  103361. */
  103362. static readonly LightDirtyFlag: number;
  103363. /**
  103364. * The dirty fresnel flag value
  103365. */
  103366. static readonly FresnelDirtyFlag: number;
  103367. /**
  103368. * The dirty attribute flag value
  103369. */
  103370. static readonly AttributesDirtyFlag: number;
  103371. /**
  103372. * The dirty misc flag value
  103373. */
  103374. static readonly MiscDirtyFlag: number;
  103375. /**
  103376. * The all dirty flag value
  103377. */
  103378. static readonly AllDirtyFlag: number;
  103379. /**
  103380. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103381. */
  103382. static readonly MATERIAL_OPAQUE: number;
  103383. /**
  103384. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103385. */
  103386. static readonly MATERIAL_ALPHATEST: number;
  103387. /**
  103388. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103389. */
  103390. static readonly MATERIAL_ALPHABLEND: number;
  103391. /**
  103392. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103393. * They are also discarded below the alpha cutoff threshold to improve performances.
  103394. */
  103395. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  103396. /**
  103397. * The Whiteout method is used to blend normals.
  103398. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103399. */
  103400. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  103401. /**
  103402. * The Reoriented Normal Mapping method is used to blend normals.
  103403. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  103404. */
  103405. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  103406. /**
  103407. * Custom callback helping to override the default shader used in the material.
  103408. */
  103409. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  103410. /**
  103411. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  103412. */
  103413. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  103414. /**
  103415. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  103416. * This means that the material can keep using a previous shader while a new one is being compiled.
  103417. * This is mostly used when shader parallel compilation is supported (true by default)
  103418. */
  103419. allowShaderHotSwapping: boolean;
  103420. /**
  103421. * The ID of the material
  103422. */
  103423. id: string;
  103424. /**
  103425. * Gets or sets the unique id of the material
  103426. */
  103427. uniqueId: number;
  103428. /**
  103429. * The name of the material
  103430. */
  103431. name: string;
  103432. /**
  103433. * Gets or sets user defined metadata
  103434. */
  103435. metadata: any;
  103436. /**
  103437. * For internal use only. Please do not use.
  103438. */
  103439. reservedDataStore: any;
  103440. /**
  103441. * Specifies if the ready state should be checked on each call
  103442. */
  103443. checkReadyOnEveryCall: boolean;
  103444. /**
  103445. * Specifies if the ready state should be checked once
  103446. */
  103447. checkReadyOnlyOnce: boolean;
  103448. /**
  103449. * The state of the material
  103450. */
  103451. state: string;
  103452. /**
  103453. * If the material can be rendered to several textures with MRT extension
  103454. */
  103455. get canRenderToMRT(): boolean;
  103456. /**
  103457. * The alpha value of the material
  103458. */
  103459. protected _alpha: number;
  103460. /**
  103461. * List of inspectable custom properties (used by the Inspector)
  103462. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103463. */
  103464. inspectableCustomProperties: IInspectable[];
  103465. /**
  103466. * Sets the alpha value of the material
  103467. */
  103468. set alpha(value: number);
  103469. /**
  103470. * Gets the alpha value of the material
  103471. */
  103472. get alpha(): number;
  103473. /**
  103474. * Specifies if back face culling is enabled
  103475. */
  103476. protected _backFaceCulling: boolean;
  103477. /**
  103478. * Sets the back-face culling state
  103479. */
  103480. set backFaceCulling(value: boolean);
  103481. /**
  103482. * Gets the back-face culling state
  103483. */
  103484. get backFaceCulling(): boolean;
  103485. /**
  103486. * Stores the value for side orientation
  103487. */
  103488. sideOrientation: number;
  103489. /**
  103490. * Callback triggered when the material is compiled
  103491. */
  103492. onCompiled: Nullable<(effect: Effect) => void>;
  103493. /**
  103494. * Callback triggered when an error occurs
  103495. */
  103496. onError: Nullable<(effect: Effect, errors: string) => void>;
  103497. /**
  103498. * Callback triggered to get the render target textures
  103499. */
  103500. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  103501. /**
  103502. * Gets a boolean indicating that current material needs to register RTT
  103503. */
  103504. get hasRenderTargetTextures(): boolean;
  103505. /**
  103506. * Specifies if the material should be serialized
  103507. */
  103508. doNotSerialize: boolean;
  103509. /**
  103510. * @hidden
  103511. */
  103512. _storeEffectOnSubMeshes: boolean;
  103513. /**
  103514. * Stores the animations for the material
  103515. */
  103516. animations: Nullable<Array<Animation>>;
  103517. /**
  103518. * An event triggered when the material is disposed
  103519. */
  103520. onDisposeObservable: Observable<Material>;
  103521. /**
  103522. * An observer which watches for dispose events
  103523. */
  103524. private _onDisposeObserver;
  103525. private _onUnBindObservable;
  103526. /**
  103527. * Called during a dispose event
  103528. */
  103529. set onDispose(callback: () => void);
  103530. private _onBindObservable;
  103531. /**
  103532. * An event triggered when the material is bound
  103533. */
  103534. get onBindObservable(): Observable<AbstractMesh>;
  103535. /**
  103536. * An observer which watches for bind events
  103537. */
  103538. private _onBindObserver;
  103539. /**
  103540. * Called during a bind event
  103541. */
  103542. set onBind(callback: (Mesh: AbstractMesh) => void);
  103543. /**
  103544. * An event triggered when the material is unbound
  103545. */
  103546. get onUnBindObservable(): Observable<Material>;
  103547. protected _onEffectCreatedObservable: Nullable<Observable<{
  103548. effect: Effect;
  103549. subMesh: Nullable<SubMesh>;
  103550. }>>;
  103551. /**
  103552. * An event triggered when the effect is (re)created
  103553. */
  103554. get onEffectCreatedObservable(): Observable<{
  103555. effect: Effect;
  103556. subMesh: Nullable<SubMesh>;
  103557. }>;
  103558. /**
  103559. * Stores the value of the alpha mode
  103560. */
  103561. private _alphaMode;
  103562. /**
  103563. * Sets the value of the alpha mode.
  103564. *
  103565. * | Value | Type | Description |
  103566. * | --- | --- | --- |
  103567. * | 0 | ALPHA_DISABLE | |
  103568. * | 1 | ALPHA_ADD | |
  103569. * | 2 | ALPHA_COMBINE | |
  103570. * | 3 | ALPHA_SUBTRACT | |
  103571. * | 4 | ALPHA_MULTIPLY | |
  103572. * | 5 | ALPHA_MAXIMIZED | |
  103573. * | 6 | ALPHA_ONEONE | |
  103574. * | 7 | ALPHA_PREMULTIPLIED | |
  103575. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  103576. * | 9 | ALPHA_INTERPOLATE | |
  103577. * | 10 | ALPHA_SCREENMODE | |
  103578. *
  103579. */
  103580. set alphaMode(value: number);
  103581. /**
  103582. * Gets the value of the alpha mode
  103583. */
  103584. get alphaMode(): number;
  103585. /**
  103586. * Stores the state of the need depth pre-pass value
  103587. */
  103588. private _needDepthPrePass;
  103589. /**
  103590. * Sets the need depth pre-pass value
  103591. */
  103592. set needDepthPrePass(value: boolean);
  103593. /**
  103594. * Gets the depth pre-pass value
  103595. */
  103596. get needDepthPrePass(): boolean;
  103597. /**
  103598. * Specifies if depth writing should be disabled
  103599. */
  103600. disableDepthWrite: boolean;
  103601. /**
  103602. * Specifies if color writing should be disabled
  103603. */
  103604. disableColorWrite: boolean;
  103605. /**
  103606. * Specifies if depth writing should be forced
  103607. */
  103608. forceDepthWrite: boolean;
  103609. /**
  103610. * Specifies the depth function that should be used. 0 means the default engine function
  103611. */
  103612. depthFunction: number;
  103613. /**
  103614. * Specifies if there should be a separate pass for culling
  103615. */
  103616. separateCullingPass: boolean;
  103617. /**
  103618. * Stores the state specifing if fog should be enabled
  103619. */
  103620. private _fogEnabled;
  103621. /**
  103622. * Sets the state for enabling fog
  103623. */
  103624. set fogEnabled(value: boolean);
  103625. /**
  103626. * Gets the value of the fog enabled state
  103627. */
  103628. get fogEnabled(): boolean;
  103629. /**
  103630. * Stores the size of points
  103631. */
  103632. pointSize: number;
  103633. /**
  103634. * Stores the z offset value
  103635. */
  103636. zOffset: number;
  103637. get wireframe(): boolean;
  103638. /**
  103639. * Sets the state of wireframe mode
  103640. */
  103641. set wireframe(value: boolean);
  103642. /**
  103643. * Gets the value specifying if point clouds are enabled
  103644. */
  103645. get pointsCloud(): boolean;
  103646. /**
  103647. * Sets the state of point cloud mode
  103648. */
  103649. set pointsCloud(value: boolean);
  103650. /**
  103651. * Gets the material fill mode
  103652. */
  103653. get fillMode(): number;
  103654. /**
  103655. * Sets the material fill mode
  103656. */
  103657. set fillMode(value: number);
  103658. /**
  103659. * @hidden
  103660. * Stores the effects for the material
  103661. */
  103662. _effect: Nullable<Effect>;
  103663. /**
  103664. * Specifies if uniform buffers should be used
  103665. */
  103666. private _useUBO;
  103667. /**
  103668. * Stores a reference to the scene
  103669. */
  103670. private _scene;
  103671. /**
  103672. * Stores the fill mode state
  103673. */
  103674. private _fillMode;
  103675. /**
  103676. * Specifies if the depth write state should be cached
  103677. */
  103678. private _cachedDepthWriteState;
  103679. /**
  103680. * Specifies if the color write state should be cached
  103681. */
  103682. private _cachedColorWriteState;
  103683. /**
  103684. * Specifies if the depth function state should be cached
  103685. */
  103686. private _cachedDepthFunctionState;
  103687. /**
  103688. * Stores the uniform buffer
  103689. */
  103690. protected _uniformBuffer: UniformBuffer;
  103691. /** @hidden */
  103692. _indexInSceneMaterialArray: number;
  103693. /** @hidden */
  103694. meshMap: Nullable<{
  103695. [id: string]: AbstractMesh | undefined;
  103696. }>;
  103697. /**
  103698. * Creates a material instance
  103699. * @param name defines the name of the material
  103700. * @param scene defines the scene to reference
  103701. * @param doNotAdd specifies if the material should be added to the scene
  103702. */
  103703. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  103704. /**
  103705. * Returns a string representation of the current material
  103706. * @param fullDetails defines a boolean indicating which levels of logging is desired
  103707. * @returns a string with material information
  103708. */
  103709. toString(fullDetails?: boolean): string;
  103710. /**
  103711. * Gets the class name of the material
  103712. * @returns a string with the class name of the material
  103713. */
  103714. getClassName(): string;
  103715. /**
  103716. * Specifies if updates for the material been locked
  103717. */
  103718. get isFrozen(): boolean;
  103719. /**
  103720. * Locks updates for the material
  103721. */
  103722. freeze(): void;
  103723. /**
  103724. * Unlocks updates for the material
  103725. */
  103726. unfreeze(): void;
  103727. /**
  103728. * Specifies if the material is ready to be used
  103729. * @param mesh defines the mesh to check
  103730. * @param useInstances specifies if instances should be used
  103731. * @returns a boolean indicating if the material is ready to be used
  103732. */
  103733. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103734. /**
  103735. * Specifies that the submesh is ready to be used
  103736. * @param mesh defines the mesh to check
  103737. * @param subMesh defines which submesh to check
  103738. * @param useInstances specifies that instances should be used
  103739. * @returns a boolean indicating that the submesh is ready or not
  103740. */
  103741. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103742. /**
  103743. * Returns the material effect
  103744. * @returns the effect associated with the material
  103745. */
  103746. getEffect(): Nullable<Effect>;
  103747. /**
  103748. * Returns the current scene
  103749. * @returns a Scene
  103750. */
  103751. getScene(): Scene;
  103752. /**
  103753. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103754. */
  103755. protected _forceAlphaTest: boolean;
  103756. /**
  103757. * The transparency mode of the material.
  103758. */
  103759. protected _transparencyMode: Nullable<number>;
  103760. /**
  103761. * Gets the current transparency mode.
  103762. */
  103763. get transparencyMode(): Nullable<number>;
  103764. /**
  103765. * Sets the transparency mode of the material.
  103766. *
  103767. * | Value | Type | Description |
  103768. * | ----- | ----------------------------------- | ----------- |
  103769. * | 0 | OPAQUE | |
  103770. * | 1 | ALPHATEST | |
  103771. * | 2 | ALPHABLEND | |
  103772. * | 3 | ALPHATESTANDBLEND | |
  103773. *
  103774. */
  103775. set transparencyMode(value: Nullable<number>);
  103776. /**
  103777. * Returns true if alpha blending should be disabled.
  103778. */
  103779. protected get _disableAlphaBlending(): boolean;
  103780. /**
  103781. * Specifies whether or not this material should be rendered in alpha blend mode.
  103782. * @returns a boolean specifying if alpha blending is needed
  103783. */
  103784. needAlphaBlending(): boolean;
  103785. /**
  103786. * Specifies if the mesh will require alpha blending
  103787. * @param mesh defines the mesh to check
  103788. * @returns a boolean specifying if alpha blending is needed for the mesh
  103789. */
  103790. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  103791. /**
  103792. * Specifies whether or not this material should be rendered in alpha test mode.
  103793. * @returns a boolean specifying if an alpha test is needed.
  103794. */
  103795. needAlphaTesting(): boolean;
  103796. /**
  103797. * Specifies if material alpha testing should be turned on for the mesh
  103798. * @param mesh defines the mesh to check
  103799. */
  103800. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  103801. /**
  103802. * Gets the texture used for the alpha test
  103803. * @returns the texture to use for alpha testing
  103804. */
  103805. getAlphaTestTexture(): Nullable<BaseTexture>;
  103806. /**
  103807. * Marks the material to indicate that it needs to be re-calculated
  103808. */
  103809. markDirty(): void;
  103810. /** @hidden */
  103811. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  103812. /**
  103813. * Binds the material to the mesh
  103814. * @param world defines the world transformation matrix
  103815. * @param mesh defines the mesh to bind the material to
  103816. */
  103817. bind(world: Matrix, mesh?: Mesh): void;
  103818. /**
  103819. * Binds the submesh to the material
  103820. * @param world defines the world transformation matrix
  103821. * @param mesh defines the mesh containing the submesh
  103822. * @param subMesh defines the submesh to bind the material to
  103823. */
  103824. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103825. /**
  103826. * Binds the world matrix to the material
  103827. * @param world defines the world transformation matrix
  103828. */
  103829. bindOnlyWorldMatrix(world: Matrix): void;
  103830. /**
  103831. * Binds the scene's uniform buffer to the effect.
  103832. * @param effect defines the effect to bind to the scene uniform buffer
  103833. * @param sceneUbo defines the uniform buffer storing scene data
  103834. */
  103835. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  103836. /**
  103837. * Binds the view matrix to the effect
  103838. * @param effect defines the effect to bind the view matrix to
  103839. */
  103840. bindView(effect: Effect): void;
  103841. /**
  103842. * Binds the view projection matrix to the effect
  103843. * @param effect defines the effect to bind the view projection matrix to
  103844. */
  103845. bindViewProjection(effect: Effect): void;
  103846. /**
  103847. * Processes to execute after binding the material to a mesh
  103848. * @param mesh defines the rendered mesh
  103849. */
  103850. protected _afterBind(mesh?: Mesh): void;
  103851. /**
  103852. * Unbinds the material from the mesh
  103853. */
  103854. unbind(): void;
  103855. /**
  103856. * Gets the active textures from the material
  103857. * @returns an array of textures
  103858. */
  103859. getActiveTextures(): BaseTexture[];
  103860. /**
  103861. * Specifies if the material uses a texture
  103862. * @param texture defines the texture to check against the material
  103863. * @returns a boolean specifying if the material uses the texture
  103864. */
  103865. hasTexture(texture: BaseTexture): boolean;
  103866. /**
  103867. * Makes a duplicate of the material, and gives it a new name
  103868. * @param name defines the new name for the duplicated material
  103869. * @returns the cloned material
  103870. */
  103871. clone(name: string): Nullable<Material>;
  103872. /**
  103873. * Gets the meshes bound to the material
  103874. * @returns an array of meshes bound to the material
  103875. */
  103876. getBindedMeshes(): AbstractMesh[];
  103877. /**
  103878. * Force shader compilation
  103879. * @param mesh defines the mesh associated with this material
  103880. * @param onCompiled defines a function to execute once the material is compiled
  103881. * @param options defines the options to configure the compilation
  103882. * @param onError defines a function to execute if the material fails compiling
  103883. */
  103884. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  103885. /**
  103886. * Force shader compilation
  103887. * @param mesh defines the mesh that will use this material
  103888. * @param options defines additional options for compiling the shaders
  103889. * @returns a promise that resolves when the compilation completes
  103890. */
  103891. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  103892. private static readonly _AllDirtyCallBack;
  103893. private static readonly _ImageProcessingDirtyCallBack;
  103894. private static readonly _TextureDirtyCallBack;
  103895. private static readonly _FresnelDirtyCallBack;
  103896. private static readonly _MiscDirtyCallBack;
  103897. private static readonly _LightsDirtyCallBack;
  103898. private static readonly _AttributeDirtyCallBack;
  103899. private static _FresnelAndMiscDirtyCallBack;
  103900. private static _TextureAndMiscDirtyCallBack;
  103901. private static readonly _DirtyCallbackArray;
  103902. private static readonly _RunDirtyCallBacks;
  103903. /**
  103904. * Marks a define in the material to indicate that it needs to be re-computed
  103905. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  103906. */
  103907. markAsDirty(flag: number): void;
  103908. /**
  103909. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  103910. * @param func defines a function which checks material defines against the submeshes
  103911. */
  103912. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  103913. /**
  103914. * Indicates that the scene should check if the rendering now needs a prepass
  103915. */
  103916. protected _markScenePrePassDirty(): void;
  103917. /**
  103918. * Indicates that we need to re-calculated for all submeshes
  103919. */
  103920. protected _markAllSubMeshesAsAllDirty(): void;
  103921. /**
  103922. * Indicates that image processing needs to be re-calculated for all submeshes
  103923. */
  103924. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  103925. /**
  103926. * Indicates that textures need to be re-calculated for all submeshes
  103927. */
  103928. protected _markAllSubMeshesAsTexturesDirty(): void;
  103929. /**
  103930. * Indicates that fresnel needs to be re-calculated for all submeshes
  103931. */
  103932. protected _markAllSubMeshesAsFresnelDirty(): void;
  103933. /**
  103934. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  103935. */
  103936. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  103937. /**
  103938. * Indicates that lights need to be re-calculated for all submeshes
  103939. */
  103940. protected _markAllSubMeshesAsLightsDirty(): void;
  103941. /**
  103942. * Indicates that attributes need to be re-calculated for all submeshes
  103943. */
  103944. protected _markAllSubMeshesAsAttributesDirty(): void;
  103945. /**
  103946. * Indicates that misc needs to be re-calculated for all submeshes
  103947. */
  103948. protected _markAllSubMeshesAsMiscDirty(): void;
  103949. /**
  103950. * Indicates that textures and misc need to be re-calculated for all submeshes
  103951. */
  103952. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  103953. /**
  103954. * Sets the required values to the prepass renderer.
  103955. * @param prePassRenderer defines the prepass renderer to setup.
  103956. * @returns true if the pre pass is needed.
  103957. */
  103958. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103959. /**
  103960. * Disposes the material
  103961. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103962. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103963. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103964. */
  103965. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103966. /** @hidden */
  103967. private releaseVertexArrayObject;
  103968. /**
  103969. * Serializes this material
  103970. * @returns the serialized material object
  103971. */
  103972. serialize(): any;
  103973. /**
  103974. * Creates a material from parsed material data
  103975. * @param parsedMaterial defines parsed material data
  103976. * @param scene defines the hosting scene
  103977. * @param rootUrl defines the root URL to use to load textures
  103978. * @returns a new material
  103979. */
  103980. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  103981. }
  103982. }
  103983. declare module BABYLON {
  103984. /**
  103985. * A multi-material is used to apply different materials to different parts of the same object without the need of
  103986. * separate meshes. This can be use to improve performances.
  103987. * @see https://doc.babylonjs.com/how_to/multi_materials
  103988. */
  103989. export class MultiMaterial extends Material {
  103990. private _subMaterials;
  103991. /**
  103992. * Gets or Sets the list of Materials used within the multi material.
  103993. * They need to be ordered according to the submeshes order in the associated mesh
  103994. */
  103995. get subMaterials(): Nullable<Material>[];
  103996. set subMaterials(value: Nullable<Material>[]);
  103997. /**
  103998. * Function used to align with Node.getChildren()
  103999. * @returns the list of Materials used within the multi material
  104000. */
  104001. getChildren(): Nullable<Material>[];
  104002. /**
  104003. * Instantiates a new Multi Material
  104004. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104005. * separate meshes. This can be use to improve performances.
  104006. * @see https://doc.babylonjs.com/how_to/multi_materials
  104007. * @param name Define the name in the scene
  104008. * @param scene Define the scene the material belongs to
  104009. */
  104010. constructor(name: string, scene: Scene);
  104011. private _hookArray;
  104012. /**
  104013. * Get one of the submaterial by its index in the submaterials array
  104014. * @param index The index to look the sub material at
  104015. * @returns The Material if the index has been defined
  104016. */
  104017. getSubMaterial(index: number): Nullable<Material>;
  104018. /**
  104019. * Get the list of active textures for the whole sub materials list.
  104020. * @returns All the textures that will be used during the rendering
  104021. */
  104022. getActiveTextures(): BaseTexture[];
  104023. /**
  104024. * Gets the current class name of the material e.g. "MultiMaterial"
  104025. * Mainly use in serialization.
  104026. * @returns the class name
  104027. */
  104028. getClassName(): string;
  104029. /**
  104030. * Checks if the material is ready to render the requested sub mesh
  104031. * @param mesh Define the mesh the submesh belongs to
  104032. * @param subMesh Define the sub mesh to look readyness for
  104033. * @param useInstances Define whether or not the material is used with instances
  104034. * @returns true if ready, otherwise false
  104035. */
  104036. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104037. /**
  104038. * Clones the current material and its related sub materials
  104039. * @param name Define the name of the newly cloned material
  104040. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  104041. * @returns the cloned material
  104042. */
  104043. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  104044. /**
  104045. * Serializes the materials into a JSON representation.
  104046. * @returns the JSON representation
  104047. */
  104048. serialize(): any;
  104049. /**
  104050. * Dispose the material and release its associated resources
  104051. * @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)
  104052. * @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)
  104053. * @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)
  104054. */
  104055. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  104056. /**
  104057. * Creates a MultiMaterial from parsed MultiMaterial data.
  104058. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  104059. * @param scene defines the hosting scene
  104060. * @returns a new MultiMaterial
  104061. */
  104062. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  104063. }
  104064. }
  104065. declare module BABYLON {
  104066. /**
  104067. * Defines a subdivision inside a mesh
  104068. */
  104069. export class SubMesh implements ICullable {
  104070. /** the material index to use */
  104071. materialIndex: number;
  104072. /** vertex index start */
  104073. verticesStart: number;
  104074. /** vertices count */
  104075. verticesCount: number;
  104076. /** index start */
  104077. indexStart: number;
  104078. /** indices count */
  104079. indexCount: number;
  104080. /** @hidden */
  104081. _materialDefines: Nullable<MaterialDefines>;
  104082. /** @hidden */
  104083. _materialEffect: Nullable<Effect>;
  104084. /** @hidden */
  104085. _effectOverride: Nullable<Effect>;
  104086. /**
  104087. * Gets material defines used by the effect associated to the sub mesh
  104088. */
  104089. get materialDefines(): Nullable<MaterialDefines>;
  104090. /**
  104091. * Sets material defines used by the effect associated to the sub mesh
  104092. */
  104093. set materialDefines(defines: Nullable<MaterialDefines>);
  104094. /**
  104095. * Gets associated effect
  104096. */
  104097. get effect(): Nullable<Effect>;
  104098. /**
  104099. * Sets associated effect (effect used to render this submesh)
  104100. * @param effect defines the effect to associate with
  104101. * @param defines defines the set of defines used to compile this effect
  104102. */
  104103. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  104104. /** @hidden */
  104105. _linesIndexCount: number;
  104106. private _mesh;
  104107. private _renderingMesh;
  104108. private _boundingInfo;
  104109. private _linesIndexBuffer;
  104110. /** @hidden */
  104111. _lastColliderWorldVertices: Nullable<Vector3[]>;
  104112. /** @hidden */
  104113. _trianglePlanes: Plane[];
  104114. /** @hidden */
  104115. _lastColliderTransformMatrix: Nullable<Matrix>;
  104116. /** @hidden */
  104117. _renderId: number;
  104118. /** @hidden */
  104119. _alphaIndex: number;
  104120. /** @hidden */
  104121. _distanceToCamera: number;
  104122. /** @hidden */
  104123. _id: number;
  104124. private _currentMaterial;
  104125. /**
  104126. * Add a new submesh to a mesh
  104127. * @param materialIndex defines the material index to use
  104128. * @param verticesStart defines vertex index start
  104129. * @param verticesCount defines vertices count
  104130. * @param indexStart defines index start
  104131. * @param indexCount defines indices count
  104132. * @param mesh defines the parent mesh
  104133. * @param renderingMesh defines an optional rendering mesh
  104134. * @param createBoundingBox defines if bounding box should be created for this submesh
  104135. * @returns the new submesh
  104136. */
  104137. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  104138. /**
  104139. * Creates a new submesh
  104140. * @param materialIndex defines the material index to use
  104141. * @param verticesStart defines vertex index start
  104142. * @param verticesCount defines vertices count
  104143. * @param indexStart defines index start
  104144. * @param indexCount defines indices count
  104145. * @param mesh defines the parent mesh
  104146. * @param renderingMesh defines an optional rendering mesh
  104147. * @param createBoundingBox defines if bounding box should be created for this submesh
  104148. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  104149. */
  104150. constructor(
  104151. /** the material index to use */
  104152. materialIndex: number,
  104153. /** vertex index start */
  104154. verticesStart: number,
  104155. /** vertices count */
  104156. verticesCount: number,
  104157. /** index start */
  104158. indexStart: number,
  104159. /** indices count */
  104160. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  104161. /**
  104162. * Returns true if this submesh covers the entire parent mesh
  104163. * @ignorenaming
  104164. */
  104165. get IsGlobal(): boolean;
  104166. /**
  104167. * Returns the submesh BoudingInfo object
  104168. * @returns current bounding info (or mesh's one if the submesh is global)
  104169. */
  104170. getBoundingInfo(): BoundingInfo;
  104171. /**
  104172. * Sets the submesh BoundingInfo
  104173. * @param boundingInfo defines the new bounding info to use
  104174. * @returns the SubMesh
  104175. */
  104176. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  104177. /**
  104178. * Returns the mesh of the current submesh
  104179. * @return the parent mesh
  104180. */
  104181. getMesh(): AbstractMesh;
  104182. /**
  104183. * Returns the rendering mesh of the submesh
  104184. * @returns the rendering mesh (could be different from parent mesh)
  104185. */
  104186. getRenderingMesh(): Mesh;
  104187. /**
  104188. * Returns the replacement mesh of the submesh
  104189. * @returns the replacement mesh (could be different from parent mesh)
  104190. */
  104191. getReplacementMesh(): Nullable<AbstractMesh>;
  104192. /**
  104193. * Returns the effective mesh of the submesh
  104194. * @returns the effective mesh (could be different from parent mesh)
  104195. */
  104196. getEffectiveMesh(): AbstractMesh;
  104197. /**
  104198. * Returns the submesh material
  104199. * @returns null or the current material
  104200. */
  104201. getMaterial(): Nullable<Material>;
  104202. private _IsMultiMaterial;
  104203. /**
  104204. * Sets a new updated BoundingInfo object to the submesh
  104205. * @param data defines an optional position array to use to determine the bounding info
  104206. * @returns the SubMesh
  104207. */
  104208. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  104209. /** @hidden */
  104210. _checkCollision(collider: Collider): boolean;
  104211. /**
  104212. * Updates the submesh BoundingInfo
  104213. * @param world defines the world matrix to use to update the bounding info
  104214. * @returns the submesh
  104215. */
  104216. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  104217. /**
  104218. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  104219. * @param frustumPlanes defines the frustum planes
  104220. * @returns true if the submesh is intersecting with the frustum
  104221. */
  104222. isInFrustum(frustumPlanes: Plane[]): boolean;
  104223. /**
  104224. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  104225. * @param frustumPlanes defines the frustum planes
  104226. * @returns true if the submesh is inside the frustum
  104227. */
  104228. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  104229. /**
  104230. * Renders the submesh
  104231. * @param enableAlphaMode defines if alpha needs to be used
  104232. * @returns the submesh
  104233. */
  104234. render(enableAlphaMode: boolean): SubMesh;
  104235. /**
  104236. * @hidden
  104237. */
  104238. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  104239. /**
  104240. * Checks if the submesh intersects with a ray
  104241. * @param ray defines the ray to test
  104242. * @returns true is the passed ray intersects the submesh bounding box
  104243. */
  104244. canIntersects(ray: Ray): boolean;
  104245. /**
  104246. * Intersects current submesh with a ray
  104247. * @param ray defines the ray to test
  104248. * @param positions defines mesh's positions array
  104249. * @param indices defines mesh's indices array
  104250. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104251. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  104252. * @returns intersection info or null if no intersection
  104253. */
  104254. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  104255. /** @hidden */
  104256. private _intersectLines;
  104257. /** @hidden */
  104258. private _intersectUnIndexedLines;
  104259. /** @hidden */
  104260. private _intersectTriangles;
  104261. /** @hidden */
  104262. private _intersectUnIndexedTriangles;
  104263. /** @hidden */
  104264. _rebuild(): void;
  104265. /**
  104266. * Creates a new submesh from the passed mesh
  104267. * @param newMesh defines the new hosting mesh
  104268. * @param newRenderingMesh defines an optional rendering mesh
  104269. * @returns the new submesh
  104270. */
  104271. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  104272. /**
  104273. * Release associated resources
  104274. */
  104275. dispose(): void;
  104276. /**
  104277. * Gets the class name
  104278. * @returns the string "SubMesh".
  104279. */
  104280. getClassName(): string;
  104281. /**
  104282. * Creates a new submesh from indices data
  104283. * @param materialIndex the index of the main mesh material
  104284. * @param startIndex the index where to start the copy in the mesh indices array
  104285. * @param indexCount the number of indices to copy then from the startIndex
  104286. * @param mesh the main mesh to create the submesh from
  104287. * @param renderingMesh the optional rendering mesh
  104288. * @returns a new submesh
  104289. */
  104290. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  104291. }
  104292. }
  104293. declare module BABYLON {
  104294. /**
  104295. * Class used to represent data loading progression
  104296. */
  104297. export class SceneLoaderFlags {
  104298. private static _ForceFullSceneLoadingForIncremental;
  104299. private static _ShowLoadingScreen;
  104300. private static _CleanBoneMatrixWeights;
  104301. private static _loggingLevel;
  104302. /**
  104303. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104304. */
  104305. static get ForceFullSceneLoadingForIncremental(): boolean;
  104306. static set ForceFullSceneLoadingForIncremental(value: boolean);
  104307. /**
  104308. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104309. */
  104310. static get ShowLoadingScreen(): boolean;
  104311. static set ShowLoadingScreen(value: boolean);
  104312. /**
  104313. * Defines the current logging level (while loading the scene)
  104314. * @ignorenaming
  104315. */
  104316. static get loggingLevel(): number;
  104317. static set loggingLevel(value: number);
  104318. /**
  104319. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104320. */
  104321. static get CleanBoneMatrixWeights(): boolean;
  104322. static set CleanBoneMatrixWeights(value: boolean);
  104323. }
  104324. }
  104325. declare module BABYLON {
  104326. /**
  104327. * Class used to store geometry data (vertex buffers + index buffer)
  104328. */
  104329. export class Geometry implements IGetSetVerticesData {
  104330. /**
  104331. * Gets or sets the ID of the geometry
  104332. */
  104333. id: string;
  104334. /**
  104335. * Gets or sets the unique ID of the geometry
  104336. */
  104337. uniqueId: number;
  104338. /**
  104339. * Gets the delay loading state of the geometry (none by default which means not delayed)
  104340. */
  104341. delayLoadState: number;
  104342. /**
  104343. * Gets the file containing the data to load when running in delay load state
  104344. */
  104345. delayLoadingFile: Nullable<string>;
  104346. /**
  104347. * Callback called when the geometry is updated
  104348. */
  104349. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  104350. private _scene;
  104351. private _engine;
  104352. private _meshes;
  104353. private _totalVertices;
  104354. /** @hidden */
  104355. _indices: IndicesArray;
  104356. /** @hidden */
  104357. _vertexBuffers: {
  104358. [key: string]: VertexBuffer;
  104359. };
  104360. private _isDisposed;
  104361. private _extend;
  104362. private _boundingBias;
  104363. /** @hidden */
  104364. _delayInfo: Array<string>;
  104365. private _indexBuffer;
  104366. private _indexBufferIsUpdatable;
  104367. /** @hidden */
  104368. _boundingInfo: Nullable<BoundingInfo>;
  104369. /** @hidden */
  104370. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  104371. /** @hidden */
  104372. _softwareSkinningFrameId: number;
  104373. private _vertexArrayObjects;
  104374. private _updatable;
  104375. /** @hidden */
  104376. _positions: Nullable<Vector3[]>;
  104377. /**
  104378. * 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
  104379. */
  104380. get boundingBias(): Vector2;
  104381. /**
  104382. * 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
  104383. */
  104384. set boundingBias(value: Vector2);
  104385. /**
  104386. * Static function used to attach a new empty geometry to a mesh
  104387. * @param mesh defines the mesh to attach the geometry to
  104388. * @returns the new Geometry
  104389. */
  104390. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  104391. /** Get the list of meshes using this geometry */
  104392. get meshes(): Mesh[];
  104393. /**
  104394. * 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
  104395. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  104396. */
  104397. useBoundingInfoFromGeometry: boolean;
  104398. /**
  104399. * Creates a new geometry
  104400. * @param id defines the unique ID
  104401. * @param scene defines the hosting scene
  104402. * @param vertexData defines the VertexData used to get geometry data
  104403. * @param updatable defines if geometry must be updatable (false by default)
  104404. * @param mesh defines the mesh that will be associated with the geometry
  104405. */
  104406. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  104407. /**
  104408. * Gets the current extend of the geometry
  104409. */
  104410. get extend(): {
  104411. minimum: Vector3;
  104412. maximum: Vector3;
  104413. };
  104414. /**
  104415. * Gets the hosting scene
  104416. * @returns the hosting Scene
  104417. */
  104418. getScene(): Scene;
  104419. /**
  104420. * Gets the hosting engine
  104421. * @returns the hosting Engine
  104422. */
  104423. getEngine(): Engine;
  104424. /**
  104425. * Defines if the geometry is ready to use
  104426. * @returns true if the geometry is ready to be used
  104427. */
  104428. isReady(): boolean;
  104429. /**
  104430. * Gets a value indicating that the geometry should not be serialized
  104431. */
  104432. get doNotSerialize(): boolean;
  104433. /** @hidden */
  104434. _rebuild(): void;
  104435. /**
  104436. * Affects all geometry data in one call
  104437. * @param vertexData defines the geometry data
  104438. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  104439. */
  104440. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  104441. /**
  104442. * Set specific vertex data
  104443. * @param kind defines the data kind (Position, normal, etc...)
  104444. * @param data defines the vertex data to use
  104445. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104446. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104447. */
  104448. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  104449. /**
  104450. * Removes a specific vertex data
  104451. * @param kind defines the data kind (Position, normal, etc...)
  104452. */
  104453. removeVerticesData(kind: string): void;
  104454. /**
  104455. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  104456. * @param buffer defines the vertex buffer to use
  104457. * @param totalVertices defines the total number of vertices for position kind (could be null)
  104458. */
  104459. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  104460. /**
  104461. * Update a specific vertex buffer
  104462. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  104463. * It will do nothing if the buffer is not updatable
  104464. * @param kind defines the data kind (Position, normal, etc...)
  104465. * @param data defines the data to use
  104466. * @param offset defines the offset in the target buffer where to store the data
  104467. * @param useBytes set to true if the offset is in bytes
  104468. */
  104469. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  104470. /**
  104471. * Update a specific vertex buffer
  104472. * This function will create a new buffer if the current one is not updatable
  104473. * @param kind defines the data kind (Position, normal, etc...)
  104474. * @param data defines the data to use
  104475. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  104476. */
  104477. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  104478. private _updateBoundingInfo;
  104479. /** @hidden */
  104480. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  104481. /**
  104482. * Gets total number of vertices
  104483. * @returns the total number of vertices
  104484. */
  104485. getTotalVertices(): number;
  104486. /**
  104487. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104488. * @param kind defines the data kind (Position, normal, etc...)
  104489. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104490. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104491. * @returns a float array containing vertex data
  104492. */
  104493. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104494. /**
  104495. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  104496. * @param kind defines the data kind (Position, normal, etc...)
  104497. * @returns true if the vertex buffer with the specified kind is updatable
  104498. */
  104499. isVertexBufferUpdatable(kind: string): boolean;
  104500. /**
  104501. * Gets a specific vertex buffer
  104502. * @param kind defines the data kind (Position, normal, etc...)
  104503. * @returns a VertexBuffer
  104504. */
  104505. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  104506. /**
  104507. * Returns all vertex buffers
  104508. * @return an object holding all vertex buffers indexed by kind
  104509. */
  104510. getVertexBuffers(): Nullable<{
  104511. [key: string]: VertexBuffer;
  104512. }>;
  104513. /**
  104514. * Gets a boolean indicating if specific vertex buffer is present
  104515. * @param kind defines the data kind (Position, normal, etc...)
  104516. * @returns true if data is present
  104517. */
  104518. isVerticesDataPresent(kind: string): boolean;
  104519. /**
  104520. * Gets a list of all attached data kinds (Position, normal, etc...)
  104521. * @returns a list of string containing all kinds
  104522. */
  104523. getVerticesDataKinds(): string[];
  104524. /**
  104525. * Update index buffer
  104526. * @param indices defines the indices to store in the index buffer
  104527. * @param offset defines the offset in the target buffer where to store the data
  104528. * @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)
  104529. */
  104530. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  104531. /**
  104532. * Creates a new index buffer
  104533. * @param indices defines the indices to store in the index buffer
  104534. * @param totalVertices defines the total number of vertices (could be null)
  104535. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104536. */
  104537. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  104538. /**
  104539. * Return the total number of indices
  104540. * @returns the total number of indices
  104541. */
  104542. getTotalIndices(): number;
  104543. /**
  104544. * Gets the index buffer array
  104545. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104546. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104547. * @returns the index buffer array
  104548. */
  104549. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104550. /**
  104551. * Gets the index buffer
  104552. * @return the index buffer
  104553. */
  104554. getIndexBuffer(): Nullable<DataBuffer>;
  104555. /** @hidden */
  104556. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  104557. /**
  104558. * Release the associated resources for a specific mesh
  104559. * @param mesh defines the source mesh
  104560. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  104561. */
  104562. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  104563. /**
  104564. * Apply current geometry to a given mesh
  104565. * @param mesh defines the mesh to apply geometry to
  104566. */
  104567. applyToMesh(mesh: Mesh): void;
  104568. private _updateExtend;
  104569. private _applyToMesh;
  104570. private notifyUpdate;
  104571. /**
  104572. * Load the geometry if it was flagged as delay loaded
  104573. * @param scene defines the hosting scene
  104574. * @param onLoaded defines a callback called when the geometry is loaded
  104575. */
  104576. load(scene: Scene, onLoaded?: () => void): void;
  104577. private _queueLoad;
  104578. /**
  104579. * Invert the geometry to move from a right handed system to a left handed one.
  104580. */
  104581. toLeftHanded(): void;
  104582. /** @hidden */
  104583. _resetPointsArrayCache(): void;
  104584. /** @hidden */
  104585. _generatePointsArray(): boolean;
  104586. /**
  104587. * Gets a value indicating if the geometry is disposed
  104588. * @returns true if the geometry was disposed
  104589. */
  104590. isDisposed(): boolean;
  104591. private _disposeVertexArrayObjects;
  104592. /**
  104593. * Free all associated resources
  104594. */
  104595. dispose(): void;
  104596. /**
  104597. * Clone the current geometry into a new geometry
  104598. * @param id defines the unique ID of the new geometry
  104599. * @returns a new geometry object
  104600. */
  104601. copy(id: string): Geometry;
  104602. /**
  104603. * Serialize the current geometry info (and not the vertices data) into a JSON object
  104604. * @return a JSON representation of the current geometry data (without the vertices data)
  104605. */
  104606. serialize(): any;
  104607. private toNumberArray;
  104608. /**
  104609. * Serialize all vertices data into a JSON oject
  104610. * @returns a JSON representation of the current geometry data
  104611. */
  104612. serializeVerticeData(): any;
  104613. /**
  104614. * Extracts a clone of a mesh geometry
  104615. * @param mesh defines the source mesh
  104616. * @param id defines the unique ID of the new geometry object
  104617. * @returns the new geometry object
  104618. */
  104619. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  104620. /**
  104621. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  104622. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104623. * Be aware Math.random() could cause collisions, but:
  104624. * "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"
  104625. * @returns a string containing a new GUID
  104626. */
  104627. static RandomId(): string;
  104628. /** @hidden */
  104629. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  104630. private static _CleanMatricesWeights;
  104631. /**
  104632. * Create a new geometry from persisted data (Using .babylon file format)
  104633. * @param parsedVertexData defines the persisted data
  104634. * @param scene defines the hosting scene
  104635. * @param rootUrl defines the root url to use to load assets (like delayed data)
  104636. * @returns the new geometry object
  104637. */
  104638. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  104639. }
  104640. }
  104641. declare module BABYLON {
  104642. /**
  104643. * Define an interface for all classes that will get and set the data on vertices
  104644. */
  104645. export interface IGetSetVerticesData {
  104646. /**
  104647. * Gets a boolean indicating if specific vertex data is present
  104648. * @param kind defines the vertex data kind to use
  104649. * @returns true is data kind is present
  104650. */
  104651. isVerticesDataPresent(kind: string): boolean;
  104652. /**
  104653. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  104654. * @param kind defines the data kind (Position, normal, etc...)
  104655. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  104656. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104657. * @returns a float array containing vertex data
  104658. */
  104659. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  104660. /**
  104661. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  104662. * @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.
  104663. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  104664. * @returns the indices array or an empty array if the mesh has no geometry
  104665. */
  104666. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  104667. /**
  104668. * Set specific vertex data
  104669. * @param kind defines the data kind (Position, normal, etc...)
  104670. * @param data defines the vertex data to use
  104671. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  104672. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  104673. */
  104674. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  104675. /**
  104676. * Update a specific associated vertex buffer
  104677. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  104678. * - VertexBuffer.PositionKind
  104679. * - VertexBuffer.UVKind
  104680. * - VertexBuffer.UV2Kind
  104681. * - VertexBuffer.UV3Kind
  104682. * - VertexBuffer.UV4Kind
  104683. * - VertexBuffer.UV5Kind
  104684. * - VertexBuffer.UV6Kind
  104685. * - VertexBuffer.ColorKind
  104686. * - VertexBuffer.MatricesIndicesKind
  104687. * - VertexBuffer.MatricesIndicesExtraKind
  104688. * - VertexBuffer.MatricesWeightsKind
  104689. * - VertexBuffer.MatricesWeightsExtraKind
  104690. * @param data defines the data source
  104691. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  104692. * @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)
  104693. */
  104694. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  104695. /**
  104696. * Creates a new index buffer
  104697. * @param indices defines the indices to store in the index buffer
  104698. * @param totalVertices defines the total number of vertices (could be null)
  104699. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  104700. */
  104701. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  104702. }
  104703. /**
  104704. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  104705. */
  104706. export class VertexData {
  104707. /**
  104708. * Mesh side orientation : usually the external or front surface
  104709. */
  104710. static readonly FRONTSIDE: number;
  104711. /**
  104712. * Mesh side orientation : usually the internal or back surface
  104713. */
  104714. static readonly BACKSIDE: number;
  104715. /**
  104716. * Mesh side orientation : both internal and external or front and back surfaces
  104717. */
  104718. static readonly DOUBLESIDE: number;
  104719. /**
  104720. * Mesh side orientation : by default, `FRONTSIDE`
  104721. */
  104722. static readonly DEFAULTSIDE: number;
  104723. /**
  104724. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  104725. */
  104726. positions: Nullable<FloatArray>;
  104727. /**
  104728. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  104729. */
  104730. normals: Nullable<FloatArray>;
  104731. /**
  104732. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  104733. */
  104734. tangents: Nullable<FloatArray>;
  104735. /**
  104736. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104737. */
  104738. uvs: Nullable<FloatArray>;
  104739. /**
  104740. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104741. */
  104742. uvs2: Nullable<FloatArray>;
  104743. /**
  104744. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104745. */
  104746. uvs3: Nullable<FloatArray>;
  104747. /**
  104748. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104749. */
  104750. uvs4: Nullable<FloatArray>;
  104751. /**
  104752. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104753. */
  104754. uvs5: Nullable<FloatArray>;
  104755. /**
  104756. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  104757. */
  104758. uvs6: Nullable<FloatArray>;
  104759. /**
  104760. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  104761. */
  104762. colors: Nullable<FloatArray>;
  104763. /**
  104764. * 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).
  104765. */
  104766. matricesIndices: Nullable<FloatArray>;
  104767. /**
  104768. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  104769. */
  104770. matricesWeights: Nullable<FloatArray>;
  104771. /**
  104772. * An array extending the number of possible indices
  104773. */
  104774. matricesIndicesExtra: Nullable<FloatArray>;
  104775. /**
  104776. * An array extending the number of possible weights when the number of indices is extended
  104777. */
  104778. matricesWeightsExtra: Nullable<FloatArray>;
  104779. /**
  104780. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  104781. */
  104782. indices: Nullable<IndicesArray>;
  104783. /**
  104784. * Uses the passed data array to set the set the values for the specified kind of data
  104785. * @param data a linear array of floating numbers
  104786. * @param kind the type of data that is being set, eg positions, colors etc
  104787. */
  104788. set(data: FloatArray, kind: string): void;
  104789. /**
  104790. * Associates the vertexData to the passed Mesh.
  104791. * Sets it as updatable or not (default `false`)
  104792. * @param mesh the mesh the vertexData is applied to
  104793. * @param updatable when used and having the value true allows new data to update the vertexData
  104794. * @returns the VertexData
  104795. */
  104796. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  104797. /**
  104798. * Associates the vertexData to the passed Geometry.
  104799. * Sets it as updatable or not (default `false`)
  104800. * @param geometry the geometry the vertexData is applied to
  104801. * @param updatable when used and having the value true allows new data to update the vertexData
  104802. * @returns VertexData
  104803. */
  104804. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  104805. /**
  104806. * Updates the associated mesh
  104807. * @param mesh the mesh to be updated
  104808. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104809. * @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
  104810. * @returns VertexData
  104811. */
  104812. updateMesh(mesh: Mesh): VertexData;
  104813. /**
  104814. * Updates the associated geometry
  104815. * @param geometry the geometry to be updated
  104816. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  104817. * @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
  104818. * @returns VertexData.
  104819. */
  104820. updateGeometry(geometry: Geometry): VertexData;
  104821. private _applyTo;
  104822. private _update;
  104823. /**
  104824. * Transforms each position and each normal of the vertexData according to the passed Matrix
  104825. * @param matrix the transforming matrix
  104826. * @returns the VertexData
  104827. */
  104828. transform(matrix: Matrix): VertexData;
  104829. /**
  104830. * Merges the passed VertexData into the current one
  104831. * @param other the VertexData to be merged into the current one
  104832. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  104833. * @returns the modified VertexData
  104834. */
  104835. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  104836. private _mergeElement;
  104837. private _validate;
  104838. /**
  104839. * Serializes the VertexData
  104840. * @returns a serialized object
  104841. */
  104842. serialize(): any;
  104843. /**
  104844. * Extracts the vertexData from a mesh
  104845. * @param mesh the mesh from which to extract the VertexData
  104846. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  104847. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104848. * @returns the object VertexData associated to the passed mesh
  104849. */
  104850. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104851. /**
  104852. * Extracts the vertexData from the geometry
  104853. * @param geometry the geometry from which to extract the VertexData
  104854. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  104855. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  104856. * @returns the object VertexData associated to the passed mesh
  104857. */
  104858. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  104859. private static _ExtractFrom;
  104860. /**
  104861. * Creates the VertexData for a Ribbon
  104862. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  104863. * * pathArray array of paths, each of which an array of successive Vector3
  104864. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  104865. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  104866. * * 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
  104867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104868. * * 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)
  104869. * * 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)
  104870. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  104871. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  104872. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  104873. * @returns the VertexData of the ribbon
  104874. */
  104875. static CreateRibbon(options: {
  104876. pathArray: Vector3[][];
  104877. closeArray?: boolean;
  104878. closePath?: boolean;
  104879. offset?: number;
  104880. sideOrientation?: number;
  104881. frontUVs?: Vector4;
  104882. backUVs?: Vector4;
  104883. invertUV?: boolean;
  104884. uvs?: Vector2[];
  104885. colors?: Color4[];
  104886. }): VertexData;
  104887. /**
  104888. * Creates the VertexData for a box
  104889. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104890. * * size sets the width, height and depth of the box to the value of size, optional default 1
  104891. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  104892. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  104893. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  104894. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104895. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104896. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104897. * * 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)
  104898. * * 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)
  104899. * @returns the VertexData of the box
  104900. */
  104901. static CreateBox(options: {
  104902. size?: number;
  104903. width?: number;
  104904. height?: number;
  104905. depth?: number;
  104906. faceUV?: Vector4[];
  104907. faceColors?: Color4[];
  104908. sideOrientation?: number;
  104909. frontUVs?: Vector4;
  104910. backUVs?: Vector4;
  104911. }): VertexData;
  104912. /**
  104913. * Creates the VertexData for a tiled box
  104914. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104915. * * faceTiles sets the pattern, tile size and number of tiles for a face
  104916. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  104917. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  104918. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104919. * @returns the VertexData of the box
  104920. */
  104921. static CreateTiledBox(options: {
  104922. pattern?: number;
  104923. width?: number;
  104924. height?: number;
  104925. depth?: number;
  104926. tileSize?: number;
  104927. tileWidth?: number;
  104928. tileHeight?: number;
  104929. alignHorizontal?: number;
  104930. alignVertical?: number;
  104931. faceUV?: Vector4[];
  104932. faceColors?: Color4[];
  104933. sideOrientation?: number;
  104934. }): VertexData;
  104935. /**
  104936. * Creates the VertexData for a tiled plane
  104937. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104938. * * pattern a limited pattern arrangement depending on the number
  104939. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  104940. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  104941. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  104942. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104943. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  104944. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  104945. * @returns the VertexData of the tiled plane
  104946. */
  104947. static CreateTiledPlane(options: {
  104948. pattern?: number;
  104949. tileSize?: number;
  104950. tileWidth?: number;
  104951. tileHeight?: number;
  104952. size?: number;
  104953. width?: number;
  104954. height?: number;
  104955. alignHorizontal?: number;
  104956. alignVertical?: number;
  104957. sideOrientation?: number;
  104958. frontUVs?: Vector4;
  104959. backUVs?: Vector4;
  104960. }): VertexData;
  104961. /**
  104962. * Creates the VertexData for an ellipsoid, defaults to a sphere
  104963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104964. * * segments sets the number of horizontal strips optional, default 32
  104965. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  104966. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  104967. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  104968. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  104969. * * 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
  104970. * * 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
  104971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104972. * * 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)
  104973. * * 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)
  104974. * @returns the VertexData of the ellipsoid
  104975. */
  104976. static CreateSphere(options: {
  104977. segments?: number;
  104978. diameter?: number;
  104979. diameterX?: number;
  104980. diameterY?: number;
  104981. diameterZ?: number;
  104982. arc?: number;
  104983. slice?: number;
  104984. sideOrientation?: number;
  104985. frontUVs?: Vector4;
  104986. backUVs?: Vector4;
  104987. }): VertexData;
  104988. /**
  104989. * Creates the VertexData for a cylinder, cone or prism
  104990. * @param options an object used to set the following optional parameters for the box, required but can be empty
  104991. * * height sets the height (y direction) of the cylinder, optional, default 2
  104992. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  104993. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  104994. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  104995. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  104996. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  104997. * * 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
  104998. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  104999. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105000. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  105001. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  105002. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105003. * * 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)
  105004. * * 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)
  105005. * @returns the VertexData of the cylinder, cone or prism
  105006. */
  105007. static CreateCylinder(options: {
  105008. height?: number;
  105009. diameterTop?: number;
  105010. diameterBottom?: number;
  105011. diameter?: number;
  105012. tessellation?: number;
  105013. subdivisions?: number;
  105014. arc?: number;
  105015. faceColors?: Color4[];
  105016. faceUV?: Vector4[];
  105017. hasRings?: boolean;
  105018. enclose?: boolean;
  105019. sideOrientation?: number;
  105020. frontUVs?: Vector4;
  105021. backUVs?: Vector4;
  105022. }): VertexData;
  105023. /**
  105024. * Creates the VertexData for a torus
  105025. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105026. * * diameter the diameter of the torus, optional default 1
  105027. * * thickness the diameter of the tube forming the torus, optional default 0.5
  105028. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  105029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105030. * * 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)
  105031. * * 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)
  105032. * @returns the VertexData of the torus
  105033. */
  105034. static CreateTorus(options: {
  105035. diameter?: number;
  105036. thickness?: number;
  105037. tessellation?: number;
  105038. sideOrientation?: number;
  105039. frontUVs?: Vector4;
  105040. backUVs?: Vector4;
  105041. }): VertexData;
  105042. /**
  105043. * Creates the VertexData of the LineSystem
  105044. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  105045. * - lines an array of lines, each line being an array of successive Vector3
  105046. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  105047. * @returns the VertexData of the LineSystem
  105048. */
  105049. static CreateLineSystem(options: {
  105050. lines: Vector3[][];
  105051. colors?: Nullable<Color4[][]>;
  105052. }): VertexData;
  105053. /**
  105054. * Create the VertexData for a DashedLines
  105055. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  105056. * - points an array successive Vector3
  105057. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  105058. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  105059. * - dashNb the intended total number of dashes, optional, default 200
  105060. * @returns the VertexData for the DashedLines
  105061. */
  105062. static CreateDashedLines(options: {
  105063. points: Vector3[];
  105064. dashSize?: number;
  105065. gapSize?: number;
  105066. dashNb?: number;
  105067. }): VertexData;
  105068. /**
  105069. * Creates the VertexData for a Ground
  105070. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105071. * - width the width (x direction) of the ground, optional, default 1
  105072. * - height the height (z direction) of the ground, optional, default 1
  105073. * - subdivisions the number of subdivisions per side, optional, default 1
  105074. * @returns the VertexData of the Ground
  105075. */
  105076. static CreateGround(options: {
  105077. width?: number;
  105078. height?: number;
  105079. subdivisions?: number;
  105080. subdivisionsX?: number;
  105081. subdivisionsY?: number;
  105082. }): VertexData;
  105083. /**
  105084. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  105085. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  105086. * * xmin the ground minimum X coordinate, optional, default -1
  105087. * * zmin the ground minimum Z coordinate, optional, default -1
  105088. * * xmax the ground maximum X coordinate, optional, default 1
  105089. * * zmax the ground maximum Z coordinate, optional, default 1
  105090. * * 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}
  105091. * * 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}
  105092. * @returns the VertexData of the TiledGround
  105093. */
  105094. static CreateTiledGround(options: {
  105095. xmin: number;
  105096. zmin: number;
  105097. xmax: number;
  105098. zmax: number;
  105099. subdivisions?: {
  105100. w: number;
  105101. h: number;
  105102. };
  105103. precision?: {
  105104. w: number;
  105105. h: number;
  105106. };
  105107. }): VertexData;
  105108. /**
  105109. * Creates the VertexData of the Ground designed from a heightmap
  105110. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  105111. * * width the width (x direction) of the ground
  105112. * * height the height (z direction) of the ground
  105113. * * subdivisions the number of subdivisions per side
  105114. * * minHeight the minimum altitude on the ground, optional, default 0
  105115. * * maxHeight the maximum altitude on the ground, optional default 1
  105116. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  105117. * * buffer the array holding the image color data
  105118. * * bufferWidth the width of image
  105119. * * bufferHeight the height of image
  105120. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  105121. * @returns the VertexData of the Ground designed from a heightmap
  105122. */
  105123. static CreateGroundFromHeightMap(options: {
  105124. width: number;
  105125. height: number;
  105126. subdivisions: number;
  105127. minHeight: number;
  105128. maxHeight: number;
  105129. colorFilter: Color3;
  105130. buffer: Uint8Array;
  105131. bufferWidth: number;
  105132. bufferHeight: number;
  105133. alphaFilter: number;
  105134. }): VertexData;
  105135. /**
  105136. * Creates the VertexData for a Plane
  105137. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  105138. * * size sets the width and height of the plane to the value of size, optional default 1
  105139. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  105140. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  105141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105142. * * 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)
  105143. * * 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)
  105144. * @returns the VertexData of the box
  105145. */
  105146. static CreatePlane(options: {
  105147. size?: number;
  105148. width?: number;
  105149. height?: number;
  105150. sideOrientation?: number;
  105151. frontUVs?: Vector4;
  105152. backUVs?: Vector4;
  105153. }): VertexData;
  105154. /**
  105155. * Creates the VertexData of the Disc or regular Polygon
  105156. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  105157. * * radius the radius of the disc, optional default 0.5
  105158. * * tessellation the number of polygon sides, optional, default 64
  105159. * * 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
  105160. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105161. * * 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)
  105162. * * 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)
  105163. * @returns the VertexData of the box
  105164. */
  105165. static CreateDisc(options: {
  105166. radius?: number;
  105167. tessellation?: number;
  105168. arc?: number;
  105169. sideOrientation?: number;
  105170. frontUVs?: Vector4;
  105171. backUVs?: Vector4;
  105172. }): VertexData;
  105173. /**
  105174. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  105175. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  105176. * @param polygon a mesh built from polygonTriangulation.build()
  105177. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105178. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105179. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105180. * @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)
  105181. * @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)
  105182. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  105183. * @returns the VertexData of the Polygon
  105184. */
  105185. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  105186. /**
  105187. * Creates the VertexData of the IcoSphere
  105188. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  105189. * * radius the radius of the IcoSphere, optional default 1
  105190. * * radiusX allows stretching in the x direction, optional, default radius
  105191. * * radiusY allows stretching in the y direction, optional, default radius
  105192. * * radiusZ allows stretching in the z direction, optional, default radius
  105193. * * flat when true creates a flat shaded mesh, optional, default true
  105194. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105195. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105196. * * 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)
  105197. * * 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)
  105198. * @returns the VertexData of the IcoSphere
  105199. */
  105200. static CreateIcoSphere(options: {
  105201. radius?: number;
  105202. radiusX?: number;
  105203. radiusY?: number;
  105204. radiusZ?: number;
  105205. flat?: boolean;
  105206. subdivisions?: number;
  105207. sideOrientation?: number;
  105208. frontUVs?: Vector4;
  105209. backUVs?: Vector4;
  105210. }): VertexData;
  105211. /**
  105212. * Creates the VertexData for a Polyhedron
  105213. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  105214. * * type provided types are:
  105215. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  105216. * * 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)
  105217. * * size the size of the IcoSphere, optional default 1
  105218. * * sizeX allows stretching in the x direction, optional, default size
  105219. * * sizeY allows stretching in the y direction, optional, default size
  105220. * * sizeZ allows stretching in the z direction, optional, default size
  105221. * * 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
  105222. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  105223. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  105224. * * flat when true creates a flat shaded mesh, optional, default true
  105225. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  105226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105227. * * 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)
  105228. * * 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)
  105229. * @returns the VertexData of the Polyhedron
  105230. */
  105231. static CreatePolyhedron(options: {
  105232. type?: number;
  105233. size?: number;
  105234. sizeX?: number;
  105235. sizeY?: number;
  105236. sizeZ?: number;
  105237. custom?: any;
  105238. faceUV?: Vector4[];
  105239. faceColors?: Color4[];
  105240. flat?: boolean;
  105241. sideOrientation?: number;
  105242. frontUVs?: Vector4;
  105243. backUVs?: Vector4;
  105244. }): VertexData;
  105245. /**
  105246. * Creates the VertexData for a TorusKnot
  105247. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  105248. * * radius the radius of the torus knot, optional, default 2
  105249. * * tube the thickness of the tube, optional, default 0.5
  105250. * * radialSegments the number of sides on each tube segments, optional, default 32
  105251. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  105252. * * p the number of windings around the z axis, optional, default 2
  105253. * * q the number of windings around the x axis, optional, default 3
  105254. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105255. * * 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)
  105256. * * 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)
  105257. * @returns the VertexData of the Torus Knot
  105258. */
  105259. static CreateTorusKnot(options: {
  105260. radius?: number;
  105261. tube?: number;
  105262. radialSegments?: number;
  105263. tubularSegments?: number;
  105264. p?: number;
  105265. q?: number;
  105266. sideOrientation?: number;
  105267. frontUVs?: Vector4;
  105268. backUVs?: Vector4;
  105269. }): VertexData;
  105270. /**
  105271. * Compute normals for given positions and indices
  105272. * @param positions an array of vertex positions, [...., x, y, z, ......]
  105273. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  105274. * @param normals an array of vertex normals, [...., x, y, z, ......]
  105275. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  105276. * * facetNormals : optional array of facet normals (vector3)
  105277. * * facetPositions : optional array of facet positions (vector3)
  105278. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  105279. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  105280. * * bInfo : optional bounding info, required for facetPartitioning computation
  105281. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  105282. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  105283. * * useRightHandedSystem: optional boolean to for right handed system computation
  105284. * * depthSort : optional boolean to enable the facet depth sort computation
  105285. * * distanceTo : optional Vector3 to compute the facet depth from this location
  105286. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  105287. */
  105288. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  105289. facetNormals?: any;
  105290. facetPositions?: any;
  105291. facetPartitioning?: any;
  105292. ratio?: number;
  105293. bInfo?: any;
  105294. bbSize?: Vector3;
  105295. subDiv?: any;
  105296. useRightHandedSystem?: boolean;
  105297. depthSort?: boolean;
  105298. distanceTo?: Vector3;
  105299. depthSortedFacets?: any;
  105300. }): void;
  105301. /** @hidden */
  105302. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  105303. /**
  105304. * Applies VertexData created from the imported parameters to the geometry
  105305. * @param parsedVertexData the parsed data from an imported file
  105306. * @param geometry the geometry to apply the VertexData to
  105307. */
  105308. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  105309. }
  105310. }
  105311. declare module BABYLON {
  105312. /**
  105313. * Defines a target to use with MorphTargetManager
  105314. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105315. */
  105316. export class MorphTarget implements IAnimatable {
  105317. /** defines the name of the target */
  105318. name: string;
  105319. /**
  105320. * Gets or sets the list of animations
  105321. */
  105322. animations: Animation[];
  105323. private _scene;
  105324. private _positions;
  105325. private _normals;
  105326. private _tangents;
  105327. private _uvs;
  105328. private _influence;
  105329. private _uniqueId;
  105330. /**
  105331. * Observable raised when the influence changes
  105332. */
  105333. onInfluenceChanged: Observable<boolean>;
  105334. /** @hidden */
  105335. _onDataLayoutChanged: Observable<void>;
  105336. /**
  105337. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105338. */
  105339. get influence(): number;
  105340. set influence(influence: number);
  105341. /**
  105342. * Gets or sets the id of the morph Target
  105343. */
  105344. id: string;
  105345. private _animationPropertiesOverride;
  105346. /**
  105347. * Gets or sets the animation properties override
  105348. */
  105349. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105350. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105351. /**
  105352. * Creates a new MorphTarget
  105353. * @param name defines the name of the target
  105354. * @param influence defines the influence to use
  105355. * @param scene defines the scene the morphtarget belongs to
  105356. */
  105357. constructor(
  105358. /** defines the name of the target */
  105359. name: string, influence?: number, scene?: Nullable<Scene>);
  105360. /**
  105361. * Gets the unique ID of this manager
  105362. */
  105363. get uniqueId(): number;
  105364. /**
  105365. * Gets a boolean defining if the target contains position data
  105366. */
  105367. get hasPositions(): boolean;
  105368. /**
  105369. * Gets a boolean defining if the target contains normal data
  105370. */
  105371. get hasNormals(): boolean;
  105372. /**
  105373. * Gets a boolean defining if the target contains tangent data
  105374. */
  105375. get hasTangents(): boolean;
  105376. /**
  105377. * Gets a boolean defining if the target contains texture coordinates data
  105378. */
  105379. get hasUVs(): boolean;
  105380. /**
  105381. * Affects position data to this target
  105382. * @param data defines the position data to use
  105383. */
  105384. setPositions(data: Nullable<FloatArray>): void;
  105385. /**
  105386. * Gets the position data stored in this target
  105387. * @returns a FloatArray containing the position data (or null if not present)
  105388. */
  105389. getPositions(): Nullable<FloatArray>;
  105390. /**
  105391. * Affects normal data to this target
  105392. * @param data defines the normal data to use
  105393. */
  105394. setNormals(data: Nullable<FloatArray>): void;
  105395. /**
  105396. * Gets the normal data stored in this target
  105397. * @returns a FloatArray containing the normal data (or null if not present)
  105398. */
  105399. getNormals(): Nullable<FloatArray>;
  105400. /**
  105401. * Affects tangent data to this target
  105402. * @param data defines the tangent data to use
  105403. */
  105404. setTangents(data: Nullable<FloatArray>): void;
  105405. /**
  105406. * Gets the tangent data stored in this target
  105407. * @returns a FloatArray containing the tangent data (or null if not present)
  105408. */
  105409. getTangents(): Nullable<FloatArray>;
  105410. /**
  105411. * Affects texture coordinates data to this target
  105412. * @param data defines the texture coordinates data to use
  105413. */
  105414. setUVs(data: Nullable<FloatArray>): void;
  105415. /**
  105416. * Gets the texture coordinates data stored in this target
  105417. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  105418. */
  105419. getUVs(): Nullable<FloatArray>;
  105420. /**
  105421. * Clone the current target
  105422. * @returns a new MorphTarget
  105423. */
  105424. clone(): MorphTarget;
  105425. /**
  105426. * Serializes the current target into a Serialization object
  105427. * @returns the serialized object
  105428. */
  105429. serialize(): any;
  105430. /**
  105431. * Returns the string "MorphTarget"
  105432. * @returns "MorphTarget"
  105433. */
  105434. getClassName(): string;
  105435. /**
  105436. * Creates a new target from serialized data
  105437. * @param serializationObject defines the serialized data to use
  105438. * @returns a new MorphTarget
  105439. */
  105440. static Parse(serializationObject: any): MorphTarget;
  105441. /**
  105442. * Creates a MorphTarget from mesh data
  105443. * @param mesh defines the source mesh
  105444. * @param name defines the name to use for the new target
  105445. * @param influence defines the influence to attach to the target
  105446. * @returns a new MorphTarget
  105447. */
  105448. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  105449. }
  105450. }
  105451. declare module BABYLON {
  105452. /**
  105453. * This class is used to deform meshes using morphing between different targets
  105454. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105455. */
  105456. export class MorphTargetManager {
  105457. private _targets;
  105458. private _targetInfluenceChangedObservers;
  105459. private _targetDataLayoutChangedObservers;
  105460. private _activeTargets;
  105461. private _scene;
  105462. private _influences;
  105463. private _supportsNormals;
  105464. private _supportsTangents;
  105465. private _supportsUVs;
  105466. private _vertexCount;
  105467. private _uniqueId;
  105468. private _tempInfluences;
  105469. /**
  105470. * Gets or sets a boolean indicating if normals must be morphed
  105471. */
  105472. enableNormalMorphing: boolean;
  105473. /**
  105474. * Gets or sets a boolean indicating if tangents must be morphed
  105475. */
  105476. enableTangentMorphing: boolean;
  105477. /**
  105478. * Gets or sets a boolean indicating if UV must be morphed
  105479. */
  105480. enableUVMorphing: boolean;
  105481. /**
  105482. * Creates a new MorphTargetManager
  105483. * @param scene defines the current scene
  105484. */
  105485. constructor(scene?: Nullable<Scene>);
  105486. /**
  105487. * Gets the unique ID of this manager
  105488. */
  105489. get uniqueId(): number;
  105490. /**
  105491. * Gets the number of vertices handled by this manager
  105492. */
  105493. get vertexCount(): number;
  105494. /**
  105495. * Gets a boolean indicating if this manager supports morphing of normals
  105496. */
  105497. get supportsNormals(): boolean;
  105498. /**
  105499. * Gets a boolean indicating if this manager supports morphing of tangents
  105500. */
  105501. get supportsTangents(): boolean;
  105502. /**
  105503. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  105504. */
  105505. get supportsUVs(): boolean;
  105506. /**
  105507. * Gets the number of targets stored in this manager
  105508. */
  105509. get numTargets(): number;
  105510. /**
  105511. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105512. */
  105513. get numInfluencers(): number;
  105514. /**
  105515. * Gets the list of influences (one per target)
  105516. */
  105517. get influences(): Float32Array;
  105518. /**
  105519. * Gets the active target at specified index. An active target is a target with an influence > 0
  105520. * @param index defines the index to check
  105521. * @returns the requested target
  105522. */
  105523. getActiveTarget(index: number): MorphTarget;
  105524. /**
  105525. * Gets the target at specified index
  105526. * @param index defines the index to check
  105527. * @returns the requested target
  105528. */
  105529. getTarget(index: number): MorphTarget;
  105530. /**
  105531. * Add a new target to this manager
  105532. * @param target defines the target to add
  105533. */
  105534. addTarget(target: MorphTarget): void;
  105535. /**
  105536. * Removes a target from the manager
  105537. * @param target defines the target to remove
  105538. */
  105539. removeTarget(target: MorphTarget): void;
  105540. /**
  105541. * Clone the current manager
  105542. * @returns a new MorphTargetManager
  105543. */
  105544. clone(): MorphTargetManager;
  105545. /**
  105546. * Serializes the current manager into a Serialization object
  105547. * @returns the serialized object
  105548. */
  105549. serialize(): any;
  105550. private _syncActiveTargets;
  105551. /**
  105552. * Syncrhonize the targets with all the meshes using this morph target manager
  105553. */
  105554. synchronize(): void;
  105555. /**
  105556. * Creates a new MorphTargetManager from serialized data
  105557. * @param serializationObject defines the serialized data
  105558. * @param scene defines the hosting scene
  105559. * @returns the new MorphTargetManager
  105560. */
  105561. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  105562. }
  105563. }
  105564. declare module BABYLON {
  105565. /**
  105566. * Class used to represent a specific level of detail of a mesh
  105567. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105568. */
  105569. export class MeshLODLevel {
  105570. /** Defines the distance where this level should start being displayed */
  105571. distance: number;
  105572. /** Defines the mesh to use to render this level */
  105573. mesh: Nullable<Mesh>;
  105574. /**
  105575. * Creates a new LOD level
  105576. * @param distance defines the distance where this level should star being displayed
  105577. * @param mesh defines the mesh to use to render this level
  105578. */
  105579. constructor(
  105580. /** Defines the distance where this level should start being displayed */
  105581. distance: number,
  105582. /** Defines the mesh to use to render this level */
  105583. mesh: Nullable<Mesh>);
  105584. }
  105585. }
  105586. declare module BABYLON {
  105587. /**
  105588. * Helper class used to generate a canvas to manipulate images
  105589. */
  105590. export class CanvasGenerator {
  105591. /**
  105592. * Create a new canvas (or offscreen canvas depending on the context)
  105593. * @param width defines the expected width
  105594. * @param height defines the expected height
  105595. * @return a new canvas or offscreen canvas
  105596. */
  105597. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  105598. }
  105599. }
  105600. declare module BABYLON {
  105601. /**
  105602. * Mesh representing the gorund
  105603. */
  105604. export class GroundMesh extends Mesh {
  105605. /** If octree should be generated */
  105606. generateOctree: boolean;
  105607. private _heightQuads;
  105608. /** @hidden */
  105609. _subdivisionsX: number;
  105610. /** @hidden */
  105611. _subdivisionsY: number;
  105612. /** @hidden */
  105613. _width: number;
  105614. /** @hidden */
  105615. _height: number;
  105616. /** @hidden */
  105617. _minX: number;
  105618. /** @hidden */
  105619. _maxX: number;
  105620. /** @hidden */
  105621. _minZ: number;
  105622. /** @hidden */
  105623. _maxZ: number;
  105624. constructor(name: string, scene: Scene);
  105625. /**
  105626. * "GroundMesh"
  105627. * @returns "GroundMesh"
  105628. */
  105629. getClassName(): string;
  105630. /**
  105631. * The minimum of x and y subdivisions
  105632. */
  105633. get subdivisions(): number;
  105634. /**
  105635. * X subdivisions
  105636. */
  105637. get subdivisionsX(): number;
  105638. /**
  105639. * Y subdivisions
  105640. */
  105641. get subdivisionsY(): number;
  105642. /**
  105643. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  105644. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105645. * @param chunksCount the number of subdivisions for x and y
  105646. * @param octreeBlocksSize (Default: 32)
  105647. */
  105648. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  105649. /**
  105650. * Returns a height (y) value in the Worl system :
  105651. * the ground altitude at the coordinates (x, z) expressed in the World system.
  105652. * @param x x coordinate
  105653. * @param z z coordinate
  105654. * @returns the ground y position if (x, z) are outside the ground surface.
  105655. */
  105656. getHeightAtCoordinates(x: number, z: number): number;
  105657. /**
  105658. * Returns a normalized vector (Vector3) orthogonal to the ground
  105659. * at the ground coordinates (x, z) expressed in the World system.
  105660. * @param x x coordinate
  105661. * @param z z coordinate
  105662. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  105663. */
  105664. getNormalAtCoordinates(x: number, z: number): Vector3;
  105665. /**
  105666. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  105667. * at the ground coordinates (x, z) expressed in the World system.
  105668. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  105669. * @param x x coordinate
  105670. * @param z z coordinate
  105671. * @param ref vector to store the result
  105672. * @returns the GroundMesh.
  105673. */
  105674. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  105675. /**
  105676. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  105677. * if the ground has been updated.
  105678. * This can be used in the render loop.
  105679. * @returns the GroundMesh.
  105680. */
  105681. updateCoordinateHeights(): GroundMesh;
  105682. private _getFacetAt;
  105683. private _initHeightQuads;
  105684. private _computeHeightQuads;
  105685. /**
  105686. * Serializes this ground mesh
  105687. * @param serializationObject object to write serialization to
  105688. */
  105689. serialize(serializationObject: any): void;
  105690. /**
  105691. * Parses a serialized ground mesh
  105692. * @param parsedMesh the serialized mesh
  105693. * @param scene the scene to create the ground mesh in
  105694. * @returns the created ground mesh
  105695. */
  105696. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  105697. }
  105698. }
  105699. declare module BABYLON {
  105700. /**
  105701. * Interface for Physics-Joint data
  105702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105703. */
  105704. export interface PhysicsJointData {
  105705. /**
  105706. * The main pivot of the joint
  105707. */
  105708. mainPivot?: Vector3;
  105709. /**
  105710. * The connected pivot of the joint
  105711. */
  105712. connectedPivot?: Vector3;
  105713. /**
  105714. * The main axis of the joint
  105715. */
  105716. mainAxis?: Vector3;
  105717. /**
  105718. * The connected axis of the joint
  105719. */
  105720. connectedAxis?: Vector3;
  105721. /**
  105722. * The collision of the joint
  105723. */
  105724. collision?: boolean;
  105725. /**
  105726. * Native Oimo/Cannon/Energy data
  105727. */
  105728. nativeParams?: any;
  105729. }
  105730. /**
  105731. * This is a holder class for the physics joint created by the physics plugin
  105732. * It holds a set of functions to control the underlying joint
  105733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105734. */
  105735. export class PhysicsJoint {
  105736. /**
  105737. * The type of the physics joint
  105738. */
  105739. type: number;
  105740. /**
  105741. * The data for the physics joint
  105742. */
  105743. jointData: PhysicsJointData;
  105744. private _physicsJoint;
  105745. protected _physicsPlugin: IPhysicsEnginePlugin;
  105746. /**
  105747. * Initializes the physics joint
  105748. * @param type The type of the physics joint
  105749. * @param jointData The data for the physics joint
  105750. */
  105751. constructor(
  105752. /**
  105753. * The type of the physics joint
  105754. */
  105755. type: number,
  105756. /**
  105757. * The data for the physics joint
  105758. */
  105759. jointData: PhysicsJointData);
  105760. /**
  105761. * Gets the physics joint
  105762. */
  105763. get physicsJoint(): any;
  105764. /**
  105765. * Sets the physics joint
  105766. */
  105767. set physicsJoint(newJoint: any);
  105768. /**
  105769. * Sets the physics plugin
  105770. */
  105771. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  105772. /**
  105773. * Execute a function that is physics-plugin specific.
  105774. * @param {Function} func the function that will be executed.
  105775. * It accepts two parameters: the physics world and the physics joint
  105776. */
  105777. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  105778. /**
  105779. * Distance-Joint type
  105780. */
  105781. static DistanceJoint: number;
  105782. /**
  105783. * Hinge-Joint type
  105784. */
  105785. static HingeJoint: number;
  105786. /**
  105787. * Ball-and-Socket joint type
  105788. */
  105789. static BallAndSocketJoint: number;
  105790. /**
  105791. * Wheel-Joint type
  105792. */
  105793. static WheelJoint: number;
  105794. /**
  105795. * Slider-Joint type
  105796. */
  105797. static SliderJoint: number;
  105798. /**
  105799. * Prismatic-Joint type
  105800. */
  105801. static PrismaticJoint: number;
  105802. /**
  105803. * Universal-Joint type
  105804. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  105805. */
  105806. static UniversalJoint: number;
  105807. /**
  105808. * Hinge-Joint 2 type
  105809. */
  105810. static Hinge2Joint: number;
  105811. /**
  105812. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  105813. */
  105814. static PointToPointJoint: number;
  105815. /**
  105816. * Spring-Joint type
  105817. */
  105818. static SpringJoint: number;
  105819. /**
  105820. * Lock-Joint type
  105821. */
  105822. static LockJoint: number;
  105823. }
  105824. /**
  105825. * A class representing a physics distance joint
  105826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105827. */
  105828. export class DistanceJoint extends PhysicsJoint {
  105829. /**
  105830. *
  105831. * @param jointData The data for the Distance-Joint
  105832. */
  105833. constructor(jointData: DistanceJointData);
  105834. /**
  105835. * Update the predefined distance.
  105836. * @param maxDistance The maximum preferred distance
  105837. * @param minDistance The minimum preferred distance
  105838. */
  105839. updateDistance(maxDistance: number, minDistance?: number): void;
  105840. }
  105841. /**
  105842. * Represents a Motor-Enabled Joint
  105843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105844. */
  105845. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  105846. /**
  105847. * Initializes the Motor-Enabled Joint
  105848. * @param type The type of the joint
  105849. * @param jointData The physica joint data for the joint
  105850. */
  105851. constructor(type: number, jointData: PhysicsJointData);
  105852. /**
  105853. * Set the motor values.
  105854. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105855. * @param force the force to apply
  105856. * @param maxForce max force for this motor.
  105857. */
  105858. setMotor(force?: number, maxForce?: number): void;
  105859. /**
  105860. * Set the motor's limits.
  105861. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105862. * @param upperLimit The upper limit of the motor
  105863. * @param lowerLimit The lower limit of the motor
  105864. */
  105865. setLimit(upperLimit: number, lowerLimit?: number): void;
  105866. }
  105867. /**
  105868. * This class represents a single physics Hinge-Joint
  105869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105870. */
  105871. export class HingeJoint extends MotorEnabledJoint {
  105872. /**
  105873. * Initializes the Hinge-Joint
  105874. * @param jointData The joint data for the Hinge-Joint
  105875. */
  105876. constructor(jointData: PhysicsJointData);
  105877. /**
  105878. * Set the motor values.
  105879. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105880. * @param {number} force the force to apply
  105881. * @param {number} maxForce max force for this motor.
  105882. */
  105883. setMotor(force?: number, maxForce?: number): void;
  105884. /**
  105885. * Set the motor's limits.
  105886. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105887. * @param upperLimit The upper limit of the motor
  105888. * @param lowerLimit The lower limit of the motor
  105889. */
  105890. setLimit(upperLimit: number, lowerLimit?: number): void;
  105891. }
  105892. /**
  105893. * This class represents a dual hinge physics joint (same as wheel joint)
  105894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105895. */
  105896. export class Hinge2Joint extends MotorEnabledJoint {
  105897. /**
  105898. * Initializes the Hinge2-Joint
  105899. * @param jointData The joint data for the Hinge2-Joint
  105900. */
  105901. constructor(jointData: PhysicsJointData);
  105902. /**
  105903. * Set the motor values.
  105904. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105905. * @param {number} targetSpeed the speed the motor is to reach
  105906. * @param {number} maxForce max force for this motor.
  105907. * @param {motorIndex} the motor's index, 0 or 1.
  105908. */
  105909. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  105910. /**
  105911. * Set the motor limits.
  105912. * Attention, this function is plugin specific. Engines won't react 100% the same.
  105913. * @param {number} upperLimit the upper limit
  105914. * @param {number} lowerLimit lower limit
  105915. * @param {motorIndex} the motor's index, 0 or 1.
  105916. */
  105917. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105918. }
  105919. /**
  105920. * Interface for a motor enabled joint
  105921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105922. */
  105923. export interface IMotorEnabledJoint {
  105924. /**
  105925. * Physics joint
  105926. */
  105927. physicsJoint: any;
  105928. /**
  105929. * Sets the motor of the motor-enabled joint
  105930. * @param force The force of the motor
  105931. * @param maxForce The maximum force of the motor
  105932. * @param motorIndex The index of the motor
  105933. */
  105934. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  105935. /**
  105936. * Sets the limit of the motor
  105937. * @param upperLimit The upper limit of the motor
  105938. * @param lowerLimit The lower limit of the motor
  105939. * @param motorIndex The index of the motor
  105940. */
  105941. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105942. }
  105943. /**
  105944. * Joint data for a Distance-Joint
  105945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105946. */
  105947. export interface DistanceJointData extends PhysicsJointData {
  105948. /**
  105949. * Max distance the 2 joint objects can be apart
  105950. */
  105951. maxDistance: number;
  105952. }
  105953. /**
  105954. * Joint data from a spring joint
  105955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105956. */
  105957. export interface SpringJointData extends PhysicsJointData {
  105958. /**
  105959. * Length of the spring
  105960. */
  105961. length: number;
  105962. /**
  105963. * Stiffness of the spring
  105964. */
  105965. stiffness: number;
  105966. /**
  105967. * Damping of the spring
  105968. */
  105969. damping: number;
  105970. /** this callback will be called when applying the force to the impostors. */
  105971. forceApplicationCallback: () => void;
  105972. }
  105973. }
  105974. declare module BABYLON {
  105975. /**
  105976. * Holds the data for the raycast result
  105977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105978. */
  105979. export class PhysicsRaycastResult {
  105980. private _hasHit;
  105981. private _hitDistance;
  105982. private _hitNormalWorld;
  105983. private _hitPointWorld;
  105984. private _rayFromWorld;
  105985. private _rayToWorld;
  105986. /**
  105987. * Gets if there was a hit
  105988. */
  105989. get hasHit(): boolean;
  105990. /**
  105991. * Gets the distance from the hit
  105992. */
  105993. get hitDistance(): number;
  105994. /**
  105995. * Gets the hit normal/direction in the world
  105996. */
  105997. get hitNormalWorld(): Vector3;
  105998. /**
  105999. * Gets the hit point in the world
  106000. */
  106001. get hitPointWorld(): Vector3;
  106002. /**
  106003. * Gets the ray "start point" of the ray in the world
  106004. */
  106005. get rayFromWorld(): Vector3;
  106006. /**
  106007. * Gets the ray "end point" of the ray in the world
  106008. */
  106009. get rayToWorld(): Vector3;
  106010. /**
  106011. * Sets the hit data (normal & point in world space)
  106012. * @param hitNormalWorld defines the normal in world space
  106013. * @param hitPointWorld defines the point in world space
  106014. */
  106015. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  106016. /**
  106017. * Sets the distance from the start point to the hit point
  106018. * @param distance
  106019. */
  106020. setHitDistance(distance: number): void;
  106021. /**
  106022. * Calculates the distance manually
  106023. */
  106024. calculateHitDistance(): void;
  106025. /**
  106026. * Resets all the values to default
  106027. * @param from The from point on world space
  106028. * @param to The to point on world space
  106029. */
  106030. reset(from?: Vector3, to?: Vector3): void;
  106031. }
  106032. /**
  106033. * Interface for the size containing width and height
  106034. */
  106035. interface IXYZ {
  106036. /**
  106037. * X
  106038. */
  106039. x: number;
  106040. /**
  106041. * Y
  106042. */
  106043. y: number;
  106044. /**
  106045. * Z
  106046. */
  106047. z: number;
  106048. }
  106049. }
  106050. declare module BABYLON {
  106051. /**
  106052. * Interface used to describe a physics joint
  106053. */
  106054. export interface PhysicsImpostorJoint {
  106055. /** Defines the main impostor to which the joint is linked */
  106056. mainImpostor: PhysicsImpostor;
  106057. /** Defines the impostor that is connected to the main impostor using this joint */
  106058. connectedImpostor: PhysicsImpostor;
  106059. /** Defines the joint itself */
  106060. joint: PhysicsJoint;
  106061. }
  106062. /** @hidden */
  106063. export interface IPhysicsEnginePlugin {
  106064. world: any;
  106065. name: string;
  106066. setGravity(gravity: Vector3): void;
  106067. setTimeStep(timeStep: number): void;
  106068. getTimeStep(): number;
  106069. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  106070. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106071. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  106072. generatePhysicsBody(impostor: PhysicsImpostor): void;
  106073. removePhysicsBody(impostor: PhysicsImpostor): void;
  106074. generateJoint(joint: PhysicsImpostorJoint): void;
  106075. removeJoint(joint: PhysicsImpostorJoint): void;
  106076. isSupported(): boolean;
  106077. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  106078. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  106079. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106080. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  106081. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106082. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  106083. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  106084. getBodyMass(impostor: PhysicsImpostor): number;
  106085. getBodyFriction(impostor: PhysicsImpostor): number;
  106086. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  106087. getBodyRestitution(impostor: PhysicsImpostor): number;
  106088. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  106089. getBodyPressure?(impostor: PhysicsImpostor): number;
  106090. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  106091. getBodyStiffness?(impostor: PhysicsImpostor): number;
  106092. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  106093. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  106094. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  106095. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  106096. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  106097. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106098. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  106099. sleepBody(impostor: PhysicsImpostor): void;
  106100. wakeUpBody(impostor: PhysicsImpostor): void;
  106101. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106102. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  106103. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  106104. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106105. getRadius(impostor: PhysicsImpostor): number;
  106106. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  106107. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  106108. dispose(): void;
  106109. }
  106110. /**
  106111. * Interface used to define a physics engine
  106112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106113. */
  106114. export interface IPhysicsEngine {
  106115. /**
  106116. * Gets the gravity vector used by the simulation
  106117. */
  106118. gravity: Vector3;
  106119. /**
  106120. * Sets the gravity vector used by the simulation
  106121. * @param gravity defines the gravity vector to use
  106122. */
  106123. setGravity(gravity: Vector3): void;
  106124. /**
  106125. * Set the time step of the physics engine.
  106126. * Default is 1/60.
  106127. * To slow it down, enter 1/600 for example.
  106128. * To speed it up, 1/30
  106129. * @param newTimeStep the new timestep to apply to this world.
  106130. */
  106131. setTimeStep(newTimeStep: number): void;
  106132. /**
  106133. * Get the time step of the physics engine.
  106134. * @returns the current time step
  106135. */
  106136. getTimeStep(): number;
  106137. /**
  106138. * Set the sub time step of the physics engine.
  106139. * Default is 0 meaning there is no sub steps
  106140. * To increase physics resolution precision, set a small value (like 1 ms)
  106141. * @param subTimeStep defines the new sub timestep used for physics resolution.
  106142. */
  106143. setSubTimeStep(subTimeStep: number): void;
  106144. /**
  106145. * Get the sub time step of the physics engine.
  106146. * @returns the current sub time step
  106147. */
  106148. getSubTimeStep(): number;
  106149. /**
  106150. * Release all resources
  106151. */
  106152. dispose(): void;
  106153. /**
  106154. * Gets the name of the current physics plugin
  106155. * @returns the name of the plugin
  106156. */
  106157. getPhysicsPluginName(): string;
  106158. /**
  106159. * Adding a new impostor for the impostor tracking.
  106160. * This will be done by the impostor itself.
  106161. * @param impostor the impostor to add
  106162. */
  106163. addImpostor(impostor: PhysicsImpostor): void;
  106164. /**
  106165. * Remove an impostor from the engine.
  106166. * This impostor and its mesh will not longer be updated by the physics engine.
  106167. * @param impostor the impostor to remove
  106168. */
  106169. removeImpostor(impostor: PhysicsImpostor): void;
  106170. /**
  106171. * Add a joint to the physics engine
  106172. * @param mainImpostor defines the main impostor to which the joint is added.
  106173. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  106174. * @param joint defines the joint that will connect both impostors.
  106175. */
  106176. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106177. /**
  106178. * Removes a joint from the simulation
  106179. * @param mainImpostor defines the impostor used with the joint
  106180. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  106181. * @param joint defines the joint to remove
  106182. */
  106183. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  106184. /**
  106185. * Gets the current plugin used to run the simulation
  106186. * @returns current plugin
  106187. */
  106188. getPhysicsPlugin(): IPhysicsEnginePlugin;
  106189. /**
  106190. * Gets the list of physic impostors
  106191. * @returns an array of PhysicsImpostor
  106192. */
  106193. getImpostors(): Array<PhysicsImpostor>;
  106194. /**
  106195. * Gets the impostor for a physics enabled object
  106196. * @param object defines the object impersonated by the impostor
  106197. * @returns the PhysicsImpostor or null if not found
  106198. */
  106199. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106200. /**
  106201. * Gets the impostor for a physics body object
  106202. * @param body defines physics body used by the impostor
  106203. * @returns the PhysicsImpostor or null if not found
  106204. */
  106205. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  106206. /**
  106207. * Does a raycast in the physics world
  106208. * @param from when should the ray start?
  106209. * @param to when should the ray end?
  106210. * @returns PhysicsRaycastResult
  106211. */
  106212. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  106213. /**
  106214. * Called by the scene. No need to call it.
  106215. * @param delta defines the timespam between frames
  106216. */
  106217. _step(delta: number): void;
  106218. }
  106219. }
  106220. declare module BABYLON {
  106221. /**
  106222. * The interface for the physics imposter parameters
  106223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106224. */
  106225. export interface PhysicsImpostorParameters {
  106226. /**
  106227. * The mass of the physics imposter
  106228. */
  106229. mass: number;
  106230. /**
  106231. * The friction of the physics imposter
  106232. */
  106233. friction?: number;
  106234. /**
  106235. * The coefficient of restitution of the physics imposter
  106236. */
  106237. restitution?: number;
  106238. /**
  106239. * The native options of the physics imposter
  106240. */
  106241. nativeOptions?: any;
  106242. /**
  106243. * Specifies if the parent should be ignored
  106244. */
  106245. ignoreParent?: boolean;
  106246. /**
  106247. * Specifies if bi-directional transformations should be disabled
  106248. */
  106249. disableBidirectionalTransformation?: boolean;
  106250. /**
  106251. * The pressure inside the physics imposter, soft object only
  106252. */
  106253. pressure?: number;
  106254. /**
  106255. * The stiffness the physics imposter, soft object only
  106256. */
  106257. stiffness?: number;
  106258. /**
  106259. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  106260. */
  106261. velocityIterations?: number;
  106262. /**
  106263. * The number of iterations used in maintaining consistent vertex positions, soft object only
  106264. */
  106265. positionIterations?: number;
  106266. /**
  106267. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  106268. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  106269. * Add to fix multiple points
  106270. */
  106271. fixedPoints?: number;
  106272. /**
  106273. * The collision margin around a soft object
  106274. */
  106275. margin?: number;
  106276. /**
  106277. * The collision margin around a soft object
  106278. */
  106279. damping?: number;
  106280. /**
  106281. * The path for a rope based on an extrusion
  106282. */
  106283. path?: any;
  106284. /**
  106285. * The shape of an extrusion used for a rope based on an extrusion
  106286. */
  106287. shape?: any;
  106288. }
  106289. /**
  106290. * Interface for a physics-enabled object
  106291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106292. */
  106293. export interface IPhysicsEnabledObject {
  106294. /**
  106295. * The position of the physics-enabled object
  106296. */
  106297. position: Vector3;
  106298. /**
  106299. * The rotation of the physics-enabled object
  106300. */
  106301. rotationQuaternion: Nullable<Quaternion>;
  106302. /**
  106303. * The scale of the physics-enabled object
  106304. */
  106305. scaling: Vector3;
  106306. /**
  106307. * The rotation of the physics-enabled object
  106308. */
  106309. rotation?: Vector3;
  106310. /**
  106311. * The parent of the physics-enabled object
  106312. */
  106313. parent?: any;
  106314. /**
  106315. * The bounding info of the physics-enabled object
  106316. * @returns The bounding info of the physics-enabled object
  106317. */
  106318. getBoundingInfo(): BoundingInfo;
  106319. /**
  106320. * Computes the world matrix
  106321. * @param force Specifies if the world matrix should be computed by force
  106322. * @returns A world matrix
  106323. */
  106324. computeWorldMatrix(force: boolean): Matrix;
  106325. /**
  106326. * Gets the world matrix
  106327. * @returns A world matrix
  106328. */
  106329. getWorldMatrix?(): Matrix;
  106330. /**
  106331. * Gets the child meshes
  106332. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  106333. * @returns An array of abstract meshes
  106334. */
  106335. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  106336. /**
  106337. * Gets the vertex data
  106338. * @param kind The type of vertex data
  106339. * @returns A nullable array of numbers, or a float32 array
  106340. */
  106341. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  106342. /**
  106343. * Gets the indices from the mesh
  106344. * @returns A nullable array of index arrays
  106345. */
  106346. getIndices?(): Nullable<IndicesArray>;
  106347. /**
  106348. * Gets the scene from the mesh
  106349. * @returns the indices array or null
  106350. */
  106351. getScene?(): Scene;
  106352. /**
  106353. * Gets the absolute position from the mesh
  106354. * @returns the absolute position
  106355. */
  106356. getAbsolutePosition(): Vector3;
  106357. /**
  106358. * Gets the absolute pivot point from the mesh
  106359. * @returns the absolute pivot point
  106360. */
  106361. getAbsolutePivotPoint(): Vector3;
  106362. /**
  106363. * Rotates the mesh
  106364. * @param axis The axis of rotation
  106365. * @param amount The amount of rotation
  106366. * @param space The space of the rotation
  106367. * @returns The rotation transform node
  106368. */
  106369. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  106370. /**
  106371. * Translates the mesh
  106372. * @param axis The axis of translation
  106373. * @param distance The distance of translation
  106374. * @param space The space of the translation
  106375. * @returns The transform node
  106376. */
  106377. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  106378. /**
  106379. * Sets the absolute position of the mesh
  106380. * @param absolutePosition The absolute position of the mesh
  106381. * @returns The transform node
  106382. */
  106383. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  106384. /**
  106385. * Gets the class name of the mesh
  106386. * @returns The class name
  106387. */
  106388. getClassName(): string;
  106389. }
  106390. /**
  106391. * Represents a physics imposter
  106392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106393. */
  106394. export class PhysicsImpostor {
  106395. /**
  106396. * The physics-enabled object used as the physics imposter
  106397. */
  106398. object: IPhysicsEnabledObject;
  106399. /**
  106400. * The type of the physics imposter
  106401. */
  106402. type: number;
  106403. private _options;
  106404. private _scene?;
  106405. /**
  106406. * The default object size of the imposter
  106407. */
  106408. static DEFAULT_OBJECT_SIZE: Vector3;
  106409. /**
  106410. * The identity quaternion of the imposter
  106411. */
  106412. static IDENTITY_QUATERNION: Quaternion;
  106413. /** @hidden */
  106414. _pluginData: any;
  106415. private _physicsEngine;
  106416. private _physicsBody;
  106417. private _bodyUpdateRequired;
  106418. private _onBeforePhysicsStepCallbacks;
  106419. private _onAfterPhysicsStepCallbacks;
  106420. /** @hidden */
  106421. _onPhysicsCollideCallbacks: Array<{
  106422. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  106423. otherImpostors: Array<PhysicsImpostor>;
  106424. }>;
  106425. private _deltaPosition;
  106426. private _deltaRotation;
  106427. private _deltaRotationConjugated;
  106428. /** @hidden */
  106429. _isFromLine: boolean;
  106430. private _parent;
  106431. private _isDisposed;
  106432. private static _tmpVecs;
  106433. private static _tmpQuat;
  106434. /**
  106435. * Specifies if the physics imposter is disposed
  106436. */
  106437. get isDisposed(): boolean;
  106438. /**
  106439. * Gets the mass of the physics imposter
  106440. */
  106441. get mass(): number;
  106442. set mass(value: number);
  106443. /**
  106444. * Gets the coefficient of friction
  106445. */
  106446. get friction(): number;
  106447. /**
  106448. * Sets the coefficient of friction
  106449. */
  106450. set friction(value: number);
  106451. /**
  106452. * Gets the coefficient of restitution
  106453. */
  106454. get restitution(): number;
  106455. /**
  106456. * Sets the coefficient of restitution
  106457. */
  106458. set restitution(value: number);
  106459. /**
  106460. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  106461. */
  106462. get pressure(): number;
  106463. /**
  106464. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  106465. */
  106466. set pressure(value: number);
  106467. /**
  106468. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106469. */
  106470. get stiffness(): number;
  106471. /**
  106472. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  106473. */
  106474. set stiffness(value: number);
  106475. /**
  106476. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106477. */
  106478. get velocityIterations(): number;
  106479. /**
  106480. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  106481. */
  106482. set velocityIterations(value: number);
  106483. /**
  106484. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106485. */
  106486. get positionIterations(): number;
  106487. /**
  106488. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  106489. */
  106490. set positionIterations(value: number);
  106491. /**
  106492. * The unique id of the physics imposter
  106493. * set by the physics engine when adding this impostor to the array
  106494. */
  106495. uniqueId: number;
  106496. /**
  106497. * @hidden
  106498. */
  106499. soft: boolean;
  106500. /**
  106501. * @hidden
  106502. */
  106503. segments: number;
  106504. private _joints;
  106505. /**
  106506. * Initializes the physics imposter
  106507. * @param object The physics-enabled object used as the physics imposter
  106508. * @param type The type of the physics imposter
  106509. * @param _options The options for the physics imposter
  106510. * @param _scene The Babylon scene
  106511. */
  106512. constructor(
  106513. /**
  106514. * The physics-enabled object used as the physics imposter
  106515. */
  106516. object: IPhysicsEnabledObject,
  106517. /**
  106518. * The type of the physics imposter
  106519. */
  106520. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  106521. /**
  106522. * This function will completly initialize this impostor.
  106523. * It will create a new body - but only if this mesh has no parent.
  106524. * If it has, this impostor will not be used other than to define the impostor
  106525. * of the child mesh.
  106526. * @hidden
  106527. */
  106528. _init(): void;
  106529. private _getPhysicsParent;
  106530. /**
  106531. * Should a new body be generated.
  106532. * @returns boolean specifying if body initialization is required
  106533. */
  106534. isBodyInitRequired(): boolean;
  106535. /**
  106536. * Sets the updated scaling
  106537. * @param updated Specifies if the scaling is updated
  106538. */
  106539. setScalingUpdated(): void;
  106540. /**
  106541. * Force a regeneration of this or the parent's impostor's body.
  106542. * Use under cautious - This will remove all joints already implemented.
  106543. */
  106544. forceUpdate(): void;
  106545. /**
  106546. * Gets the body that holds this impostor. Either its own, or its parent.
  106547. */
  106548. get physicsBody(): any;
  106549. /**
  106550. * Get the parent of the physics imposter
  106551. * @returns Physics imposter or null
  106552. */
  106553. get parent(): Nullable<PhysicsImpostor>;
  106554. /**
  106555. * Sets the parent of the physics imposter
  106556. */
  106557. set parent(value: Nullable<PhysicsImpostor>);
  106558. /**
  106559. * Set the physics body. Used mainly by the physics engine/plugin
  106560. */
  106561. set physicsBody(physicsBody: any);
  106562. /**
  106563. * Resets the update flags
  106564. */
  106565. resetUpdateFlags(): void;
  106566. /**
  106567. * Gets the object extend size
  106568. * @returns the object extend size
  106569. */
  106570. getObjectExtendSize(): Vector3;
  106571. /**
  106572. * Gets the object center
  106573. * @returns The object center
  106574. */
  106575. getObjectCenter(): Vector3;
  106576. /**
  106577. * Get a specific parameter from the options parameters
  106578. * @param paramName The object parameter name
  106579. * @returns The object parameter
  106580. */
  106581. getParam(paramName: string): any;
  106582. /**
  106583. * Sets a specific parameter in the options given to the physics plugin
  106584. * @param paramName The parameter name
  106585. * @param value The value of the parameter
  106586. */
  106587. setParam(paramName: string, value: number): void;
  106588. /**
  106589. * Specifically change the body's mass option. Won't recreate the physics body object
  106590. * @param mass The mass of the physics imposter
  106591. */
  106592. setMass(mass: number): void;
  106593. /**
  106594. * Gets the linear velocity
  106595. * @returns linear velocity or null
  106596. */
  106597. getLinearVelocity(): Nullable<Vector3>;
  106598. /**
  106599. * Sets the linear velocity
  106600. * @param velocity linear velocity or null
  106601. */
  106602. setLinearVelocity(velocity: Nullable<Vector3>): void;
  106603. /**
  106604. * Gets the angular velocity
  106605. * @returns angular velocity or null
  106606. */
  106607. getAngularVelocity(): Nullable<Vector3>;
  106608. /**
  106609. * Sets the angular velocity
  106610. * @param velocity The velocity or null
  106611. */
  106612. setAngularVelocity(velocity: Nullable<Vector3>): void;
  106613. /**
  106614. * Execute a function with the physics plugin native code
  106615. * Provide a function the will have two variables - the world object and the physics body object
  106616. * @param func The function to execute with the physics plugin native code
  106617. */
  106618. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  106619. /**
  106620. * Register a function that will be executed before the physics world is stepping forward
  106621. * @param func The function to execute before the physics world is stepped forward
  106622. */
  106623. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106624. /**
  106625. * Unregister a function that will be executed before the physics world is stepping forward
  106626. * @param func The function to execute before the physics world is stepped forward
  106627. */
  106628. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106629. /**
  106630. * Register a function that will be executed after the physics step
  106631. * @param func The function to execute after physics step
  106632. */
  106633. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106634. /**
  106635. * Unregisters a function that will be executed after the physics step
  106636. * @param func The function to execute after physics step
  106637. */
  106638. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  106639. /**
  106640. * register a function that will be executed when this impostor collides against a different body
  106641. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  106642. * @param func Callback that is executed on collision
  106643. */
  106644. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  106645. /**
  106646. * Unregisters the physics imposter on contact
  106647. * @param collideAgainst The physics object to collide against
  106648. * @param func Callback to execute on collision
  106649. */
  106650. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  106651. private _tmpQuat;
  106652. private _tmpQuat2;
  106653. /**
  106654. * Get the parent rotation
  106655. * @returns The parent rotation
  106656. */
  106657. getParentsRotation(): Quaternion;
  106658. /**
  106659. * this function is executed by the physics engine.
  106660. */
  106661. beforeStep: () => void;
  106662. /**
  106663. * this function is executed by the physics engine
  106664. */
  106665. afterStep: () => void;
  106666. /**
  106667. * Legacy collision detection event support
  106668. */
  106669. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  106670. /**
  106671. * event and body object due to cannon's event-based architecture.
  106672. */
  106673. onCollide: (e: {
  106674. body: any;
  106675. }) => void;
  106676. /**
  106677. * Apply a force
  106678. * @param force The force to apply
  106679. * @param contactPoint The contact point for the force
  106680. * @returns The physics imposter
  106681. */
  106682. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106683. /**
  106684. * Apply an impulse
  106685. * @param force The impulse force
  106686. * @param contactPoint The contact point for the impulse force
  106687. * @returns The physics imposter
  106688. */
  106689. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  106690. /**
  106691. * A help function to create a joint
  106692. * @param otherImpostor A physics imposter used to create a joint
  106693. * @param jointType The type of joint
  106694. * @param jointData The data for the joint
  106695. * @returns The physics imposter
  106696. */
  106697. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  106698. /**
  106699. * Add a joint to this impostor with a different impostor
  106700. * @param otherImpostor A physics imposter used to add a joint
  106701. * @param joint The joint to add
  106702. * @returns The physics imposter
  106703. */
  106704. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  106705. /**
  106706. * Add an anchor to a cloth impostor
  106707. * @param otherImpostor rigid impostor to anchor to
  106708. * @param width ratio across width from 0 to 1
  106709. * @param height ratio up height from 0 to 1
  106710. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  106711. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  106712. * @returns impostor the soft imposter
  106713. */
  106714. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106715. /**
  106716. * Add a hook to a rope impostor
  106717. * @param otherImpostor rigid impostor to anchor to
  106718. * @param length ratio across rope from 0 to 1
  106719. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  106720. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  106721. * @returns impostor the rope imposter
  106722. */
  106723. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  106724. /**
  106725. * Will keep this body still, in a sleep mode.
  106726. * @returns the physics imposter
  106727. */
  106728. sleep(): PhysicsImpostor;
  106729. /**
  106730. * Wake the body up.
  106731. * @returns The physics imposter
  106732. */
  106733. wakeUp(): PhysicsImpostor;
  106734. /**
  106735. * Clones the physics imposter
  106736. * @param newObject The physics imposter clones to this physics-enabled object
  106737. * @returns A nullable physics imposter
  106738. */
  106739. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  106740. /**
  106741. * Disposes the physics imposter
  106742. */
  106743. dispose(): void;
  106744. /**
  106745. * Sets the delta position
  106746. * @param position The delta position amount
  106747. */
  106748. setDeltaPosition(position: Vector3): void;
  106749. /**
  106750. * Sets the delta rotation
  106751. * @param rotation The delta rotation amount
  106752. */
  106753. setDeltaRotation(rotation: Quaternion): void;
  106754. /**
  106755. * Gets the box size of the physics imposter and stores the result in the input parameter
  106756. * @param result Stores the box size
  106757. * @returns The physics imposter
  106758. */
  106759. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  106760. /**
  106761. * Gets the radius of the physics imposter
  106762. * @returns Radius of the physics imposter
  106763. */
  106764. getRadius(): number;
  106765. /**
  106766. * Sync a bone with this impostor
  106767. * @param bone The bone to sync to the impostor.
  106768. * @param boneMesh The mesh that the bone is influencing.
  106769. * @param jointPivot The pivot of the joint / bone in local space.
  106770. * @param distToJoint Optional distance from the impostor to the joint.
  106771. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106772. */
  106773. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  106774. /**
  106775. * Sync impostor to a bone
  106776. * @param bone The bone that the impostor will be synced to.
  106777. * @param boneMesh The mesh that the bone is influencing.
  106778. * @param jointPivot The pivot of the joint / bone in local space.
  106779. * @param distToJoint Optional distance from the impostor to the joint.
  106780. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  106781. * @param boneAxis Optional vector3 axis the bone is aligned with
  106782. */
  106783. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  106784. /**
  106785. * No-Imposter type
  106786. */
  106787. static NoImpostor: number;
  106788. /**
  106789. * Sphere-Imposter type
  106790. */
  106791. static SphereImpostor: number;
  106792. /**
  106793. * Box-Imposter type
  106794. */
  106795. static BoxImpostor: number;
  106796. /**
  106797. * Plane-Imposter type
  106798. */
  106799. static PlaneImpostor: number;
  106800. /**
  106801. * Mesh-imposter type
  106802. */
  106803. static MeshImpostor: number;
  106804. /**
  106805. * Capsule-Impostor type (Ammo.js plugin only)
  106806. */
  106807. static CapsuleImpostor: number;
  106808. /**
  106809. * Cylinder-Imposter type
  106810. */
  106811. static CylinderImpostor: number;
  106812. /**
  106813. * Particle-Imposter type
  106814. */
  106815. static ParticleImpostor: number;
  106816. /**
  106817. * Heightmap-Imposter type
  106818. */
  106819. static HeightmapImpostor: number;
  106820. /**
  106821. * ConvexHull-Impostor type (Ammo.js plugin only)
  106822. */
  106823. static ConvexHullImpostor: number;
  106824. /**
  106825. * Custom-Imposter type (Ammo.js plugin only)
  106826. */
  106827. static CustomImpostor: number;
  106828. /**
  106829. * Rope-Imposter type
  106830. */
  106831. static RopeImpostor: number;
  106832. /**
  106833. * Cloth-Imposter type
  106834. */
  106835. static ClothImpostor: number;
  106836. /**
  106837. * Softbody-Imposter type
  106838. */
  106839. static SoftbodyImpostor: number;
  106840. }
  106841. }
  106842. declare module BABYLON {
  106843. /**
  106844. * @hidden
  106845. **/
  106846. export class _CreationDataStorage {
  106847. closePath?: boolean;
  106848. closeArray?: boolean;
  106849. idx: number[];
  106850. dashSize: number;
  106851. gapSize: number;
  106852. path3D: Path3D;
  106853. pathArray: Vector3[][];
  106854. arc: number;
  106855. radius: number;
  106856. cap: number;
  106857. tessellation: number;
  106858. }
  106859. /**
  106860. * @hidden
  106861. **/
  106862. class _InstanceDataStorage {
  106863. visibleInstances: any;
  106864. batchCache: _InstancesBatch;
  106865. instancesBufferSize: number;
  106866. instancesBuffer: Nullable<Buffer>;
  106867. instancesData: Float32Array;
  106868. overridenInstanceCount: number;
  106869. isFrozen: boolean;
  106870. previousBatch: Nullable<_InstancesBatch>;
  106871. hardwareInstancedRendering: boolean;
  106872. sideOrientation: number;
  106873. manualUpdate: boolean;
  106874. }
  106875. /**
  106876. * @hidden
  106877. **/
  106878. export class _InstancesBatch {
  106879. mustReturn: boolean;
  106880. visibleInstances: Nullable<InstancedMesh[]>[];
  106881. renderSelf: boolean[];
  106882. hardwareInstancedRendering: boolean[];
  106883. }
  106884. /**
  106885. * @hidden
  106886. **/
  106887. class _ThinInstanceDataStorage {
  106888. instancesCount: number;
  106889. matrixBuffer: Nullable<Buffer>;
  106890. matrixBufferSize: number;
  106891. matrixData: Nullable<Float32Array>;
  106892. boundingVectors: Array<Vector3>;
  106893. worldMatrices: Nullable<Matrix[]>;
  106894. }
  106895. /**
  106896. * Class used to represent renderable models
  106897. */
  106898. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  106899. /**
  106900. * Mesh side orientation : usually the external or front surface
  106901. */
  106902. static readonly FRONTSIDE: number;
  106903. /**
  106904. * Mesh side orientation : usually the internal or back surface
  106905. */
  106906. static readonly BACKSIDE: number;
  106907. /**
  106908. * Mesh side orientation : both internal and external or front and back surfaces
  106909. */
  106910. static readonly DOUBLESIDE: number;
  106911. /**
  106912. * Mesh side orientation : by default, `FRONTSIDE`
  106913. */
  106914. static readonly DEFAULTSIDE: number;
  106915. /**
  106916. * Mesh cap setting : no cap
  106917. */
  106918. static readonly NO_CAP: number;
  106919. /**
  106920. * Mesh cap setting : one cap at the beginning of the mesh
  106921. */
  106922. static readonly CAP_START: number;
  106923. /**
  106924. * Mesh cap setting : one cap at the end of the mesh
  106925. */
  106926. static readonly CAP_END: number;
  106927. /**
  106928. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  106929. */
  106930. static readonly CAP_ALL: number;
  106931. /**
  106932. * Mesh pattern setting : no flip or rotate
  106933. */
  106934. static readonly NO_FLIP: number;
  106935. /**
  106936. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  106937. */
  106938. static readonly FLIP_TILE: number;
  106939. /**
  106940. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  106941. */
  106942. static readonly ROTATE_TILE: number;
  106943. /**
  106944. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  106945. */
  106946. static readonly FLIP_ROW: number;
  106947. /**
  106948. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  106949. */
  106950. static readonly ROTATE_ROW: number;
  106951. /**
  106952. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  106953. */
  106954. static readonly FLIP_N_ROTATE_TILE: number;
  106955. /**
  106956. * Mesh pattern setting : rotate pattern and rotate
  106957. */
  106958. static readonly FLIP_N_ROTATE_ROW: number;
  106959. /**
  106960. * Mesh tile positioning : part tiles same on left/right or top/bottom
  106961. */
  106962. static readonly CENTER: number;
  106963. /**
  106964. * Mesh tile positioning : part tiles on left
  106965. */
  106966. static readonly LEFT: number;
  106967. /**
  106968. * Mesh tile positioning : part tiles on right
  106969. */
  106970. static readonly RIGHT: number;
  106971. /**
  106972. * Mesh tile positioning : part tiles on top
  106973. */
  106974. static readonly TOP: number;
  106975. /**
  106976. * Mesh tile positioning : part tiles on bottom
  106977. */
  106978. static readonly BOTTOM: number;
  106979. /**
  106980. * Gets the default side orientation.
  106981. * @param orientation the orientation to value to attempt to get
  106982. * @returns the default orientation
  106983. * @hidden
  106984. */
  106985. static _GetDefaultSideOrientation(orientation?: number): number;
  106986. private _internalMeshDataInfo;
  106987. get computeBonesUsingShaders(): boolean;
  106988. set computeBonesUsingShaders(value: boolean);
  106989. /**
  106990. * An event triggered before rendering the mesh
  106991. */
  106992. get onBeforeRenderObservable(): Observable<Mesh>;
  106993. /**
  106994. * An event triggered before binding the mesh
  106995. */
  106996. get onBeforeBindObservable(): Observable<Mesh>;
  106997. /**
  106998. * An event triggered after rendering the mesh
  106999. */
  107000. get onAfterRenderObservable(): Observable<Mesh>;
  107001. /**
  107002. * An event triggered before drawing the mesh
  107003. */
  107004. get onBeforeDrawObservable(): Observable<Mesh>;
  107005. private _onBeforeDrawObserver;
  107006. /**
  107007. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  107008. */
  107009. set onBeforeDraw(callback: () => void);
  107010. get hasInstances(): boolean;
  107011. get hasThinInstances(): boolean;
  107012. /**
  107013. * Gets the delay loading state of the mesh (when delay loading is turned on)
  107014. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  107015. */
  107016. delayLoadState: number;
  107017. /**
  107018. * Gets the list of instances created from this mesh
  107019. * it is not supposed to be modified manually.
  107020. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  107021. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107022. */
  107023. instances: InstancedMesh[];
  107024. /**
  107025. * Gets the file containing delay loading data for this mesh
  107026. */
  107027. delayLoadingFile: string;
  107028. /** @hidden */
  107029. _binaryInfo: any;
  107030. /**
  107031. * User defined function used to change how LOD level selection is done
  107032. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107033. */
  107034. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  107035. /**
  107036. * Gets or sets the morph target manager
  107037. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107038. */
  107039. get morphTargetManager(): Nullable<MorphTargetManager>;
  107040. set morphTargetManager(value: Nullable<MorphTargetManager>);
  107041. /** @hidden */
  107042. _creationDataStorage: Nullable<_CreationDataStorage>;
  107043. /** @hidden */
  107044. _geometry: Nullable<Geometry>;
  107045. /** @hidden */
  107046. _delayInfo: Array<string>;
  107047. /** @hidden */
  107048. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  107049. /** @hidden */
  107050. _instanceDataStorage: _InstanceDataStorage;
  107051. /** @hidden */
  107052. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  107053. private _effectiveMaterial;
  107054. /** @hidden */
  107055. _shouldGenerateFlatShading: boolean;
  107056. /** @hidden */
  107057. _originalBuilderSideOrientation: number;
  107058. /**
  107059. * Use this property to change the original side orientation defined at construction time
  107060. */
  107061. overrideMaterialSideOrientation: Nullable<number>;
  107062. /**
  107063. * Gets the source mesh (the one used to clone this one from)
  107064. */
  107065. get source(): Nullable<Mesh>;
  107066. /**
  107067. * Gets or sets a boolean indicating that this mesh does not use index buffer
  107068. */
  107069. get isUnIndexed(): boolean;
  107070. set isUnIndexed(value: boolean);
  107071. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  107072. get worldMatrixInstancedBuffer(): Float32Array;
  107073. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  107074. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  107075. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  107076. /**
  107077. * @constructor
  107078. * @param name The value used by scene.getMeshByName() to do a lookup.
  107079. * @param scene The scene to add this mesh to.
  107080. * @param parent The parent of this mesh, if it has one
  107081. * @param source An optional Mesh from which geometry is shared, cloned.
  107082. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  107083. * When false, achieved by calling a clone(), also passing False.
  107084. * This will make creation of children, recursive.
  107085. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  107086. */
  107087. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  107088. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107089. doNotInstantiate: boolean;
  107090. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107091. /**
  107092. * Gets the class name
  107093. * @returns the string "Mesh".
  107094. */
  107095. getClassName(): string;
  107096. /** @hidden */
  107097. get _isMesh(): boolean;
  107098. /**
  107099. * Returns a description of this mesh
  107100. * @param fullDetails define if full details about this mesh must be used
  107101. * @returns a descriptive string representing this mesh
  107102. */
  107103. toString(fullDetails?: boolean): string;
  107104. /** @hidden */
  107105. _unBindEffect(): void;
  107106. /**
  107107. * Gets a boolean indicating if this mesh has LOD
  107108. */
  107109. get hasLODLevels(): boolean;
  107110. /**
  107111. * Gets the list of MeshLODLevel associated with the current mesh
  107112. * @returns an array of MeshLODLevel
  107113. */
  107114. getLODLevels(): MeshLODLevel[];
  107115. private _sortLODLevels;
  107116. /**
  107117. * Add a mesh as LOD level triggered at the given distance.
  107118. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107119. * @param distance The distance from the center of the object to show this level
  107120. * @param mesh The mesh to be added as LOD level (can be null)
  107121. * @return This mesh (for chaining)
  107122. */
  107123. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  107124. /**
  107125. * Returns the LOD level mesh at the passed distance or null if not found.
  107126. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107127. * @param distance The distance from the center of the object to show this level
  107128. * @returns a Mesh or `null`
  107129. */
  107130. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  107131. /**
  107132. * Remove a mesh from the LOD array
  107133. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107134. * @param mesh defines the mesh to be removed
  107135. * @return This mesh (for chaining)
  107136. */
  107137. removeLODLevel(mesh: Mesh): Mesh;
  107138. /**
  107139. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  107140. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107141. * @param camera defines the camera to use to compute distance
  107142. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  107143. * @return This mesh (for chaining)
  107144. */
  107145. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  107146. /**
  107147. * Gets the mesh internal Geometry object
  107148. */
  107149. get geometry(): Nullable<Geometry>;
  107150. /**
  107151. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  107152. * @returns the total number of vertices
  107153. */
  107154. getTotalVertices(): number;
  107155. /**
  107156. * Returns the content of an associated vertex buffer
  107157. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107158. * - VertexBuffer.PositionKind
  107159. * - VertexBuffer.UVKind
  107160. * - VertexBuffer.UV2Kind
  107161. * - VertexBuffer.UV3Kind
  107162. * - VertexBuffer.UV4Kind
  107163. * - VertexBuffer.UV5Kind
  107164. * - VertexBuffer.UV6Kind
  107165. * - VertexBuffer.ColorKind
  107166. * - VertexBuffer.MatricesIndicesKind
  107167. * - VertexBuffer.MatricesIndicesExtraKind
  107168. * - VertexBuffer.MatricesWeightsKind
  107169. * - VertexBuffer.MatricesWeightsExtraKind
  107170. * @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
  107171. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  107172. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  107173. */
  107174. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  107175. /**
  107176. * Returns the mesh VertexBuffer object from the requested `kind`
  107177. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107178. * - VertexBuffer.PositionKind
  107179. * - VertexBuffer.NormalKind
  107180. * - VertexBuffer.UVKind
  107181. * - VertexBuffer.UV2Kind
  107182. * - VertexBuffer.UV3Kind
  107183. * - VertexBuffer.UV4Kind
  107184. * - VertexBuffer.UV5Kind
  107185. * - VertexBuffer.UV6Kind
  107186. * - VertexBuffer.ColorKind
  107187. * - VertexBuffer.MatricesIndicesKind
  107188. * - VertexBuffer.MatricesIndicesExtraKind
  107189. * - VertexBuffer.MatricesWeightsKind
  107190. * - VertexBuffer.MatricesWeightsExtraKind
  107191. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  107192. */
  107193. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  107194. /**
  107195. * Tests if a specific vertex buffer is associated with this mesh
  107196. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107197. * - VertexBuffer.PositionKind
  107198. * - VertexBuffer.NormalKind
  107199. * - VertexBuffer.UVKind
  107200. * - VertexBuffer.UV2Kind
  107201. * - VertexBuffer.UV3Kind
  107202. * - VertexBuffer.UV4Kind
  107203. * - VertexBuffer.UV5Kind
  107204. * - VertexBuffer.UV6Kind
  107205. * - VertexBuffer.ColorKind
  107206. * - VertexBuffer.MatricesIndicesKind
  107207. * - VertexBuffer.MatricesIndicesExtraKind
  107208. * - VertexBuffer.MatricesWeightsKind
  107209. * - VertexBuffer.MatricesWeightsExtraKind
  107210. * @returns a boolean
  107211. */
  107212. isVerticesDataPresent(kind: string): boolean;
  107213. /**
  107214. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  107215. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  107216. * - VertexBuffer.PositionKind
  107217. * - VertexBuffer.UVKind
  107218. * - VertexBuffer.UV2Kind
  107219. * - VertexBuffer.UV3Kind
  107220. * - VertexBuffer.UV4Kind
  107221. * - VertexBuffer.UV5Kind
  107222. * - VertexBuffer.UV6Kind
  107223. * - VertexBuffer.ColorKind
  107224. * - VertexBuffer.MatricesIndicesKind
  107225. * - VertexBuffer.MatricesIndicesExtraKind
  107226. * - VertexBuffer.MatricesWeightsKind
  107227. * - VertexBuffer.MatricesWeightsExtraKind
  107228. * @returns a boolean
  107229. */
  107230. isVertexBufferUpdatable(kind: string): boolean;
  107231. /**
  107232. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  107233. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  107234. * - VertexBuffer.PositionKind
  107235. * - VertexBuffer.NormalKind
  107236. * - VertexBuffer.UVKind
  107237. * - VertexBuffer.UV2Kind
  107238. * - VertexBuffer.UV3Kind
  107239. * - VertexBuffer.UV4Kind
  107240. * - VertexBuffer.UV5Kind
  107241. * - VertexBuffer.UV6Kind
  107242. * - VertexBuffer.ColorKind
  107243. * - VertexBuffer.MatricesIndicesKind
  107244. * - VertexBuffer.MatricesIndicesExtraKind
  107245. * - VertexBuffer.MatricesWeightsKind
  107246. * - VertexBuffer.MatricesWeightsExtraKind
  107247. * @returns an array of strings
  107248. */
  107249. getVerticesDataKinds(): string[];
  107250. /**
  107251. * Returns a positive integer : the total number of indices in this mesh geometry.
  107252. * @returns the numner of indices or zero if the mesh has no geometry.
  107253. */
  107254. getTotalIndices(): number;
  107255. /**
  107256. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  107257. * @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.
  107258. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  107259. * @returns the indices array or an empty array if the mesh has no geometry
  107260. */
  107261. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  107262. get isBlocked(): boolean;
  107263. /**
  107264. * Determine if the current mesh is ready to be rendered
  107265. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  107266. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  107267. * @returns true if all associated assets are ready (material, textures, shaders)
  107268. */
  107269. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  107270. /**
  107271. * 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.
  107272. */
  107273. get areNormalsFrozen(): boolean;
  107274. /**
  107275. * 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.
  107276. * @returns the current mesh
  107277. */
  107278. freezeNormals(): Mesh;
  107279. /**
  107280. * 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
  107281. * @returns the current mesh
  107282. */
  107283. unfreezeNormals(): Mesh;
  107284. /**
  107285. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  107286. */
  107287. set overridenInstanceCount(count: number);
  107288. /** @hidden */
  107289. _preActivate(): Mesh;
  107290. /** @hidden */
  107291. _preActivateForIntermediateRendering(renderId: number): Mesh;
  107292. /** @hidden */
  107293. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  107294. protected _afterComputeWorldMatrix(): void;
  107295. /** @hidden */
  107296. _postActivate(): void;
  107297. /**
  107298. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  107299. * This means the mesh underlying bounding box and sphere are recomputed.
  107300. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  107301. * @returns the current mesh
  107302. */
  107303. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  107304. /** @hidden */
  107305. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  107306. /**
  107307. * This function will subdivide the mesh into multiple submeshes
  107308. * @param count defines the expected number of submeshes
  107309. */
  107310. subdivide(count: number): void;
  107311. /**
  107312. * Copy a FloatArray into a specific associated vertex buffer
  107313. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107314. * - VertexBuffer.PositionKind
  107315. * - VertexBuffer.UVKind
  107316. * - VertexBuffer.UV2Kind
  107317. * - VertexBuffer.UV3Kind
  107318. * - VertexBuffer.UV4Kind
  107319. * - VertexBuffer.UV5Kind
  107320. * - VertexBuffer.UV6Kind
  107321. * - VertexBuffer.ColorKind
  107322. * - VertexBuffer.MatricesIndicesKind
  107323. * - VertexBuffer.MatricesIndicesExtraKind
  107324. * - VertexBuffer.MatricesWeightsKind
  107325. * - VertexBuffer.MatricesWeightsExtraKind
  107326. * @param data defines the data source
  107327. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107328. * @param stride defines the data stride size (can be null)
  107329. * @returns the current mesh
  107330. */
  107331. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  107332. /**
  107333. * Delete a vertex buffer associated with this mesh
  107334. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  107335. * - VertexBuffer.PositionKind
  107336. * - VertexBuffer.UVKind
  107337. * - VertexBuffer.UV2Kind
  107338. * - VertexBuffer.UV3Kind
  107339. * - VertexBuffer.UV4Kind
  107340. * - VertexBuffer.UV5Kind
  107341. * - VertexBuffer.UV6Kind
  107342. * - VertexBuffer.ColorKind
  107343. * - VertexBuffer.MatricesIndicesKind
  107344. * - VertexBuffer.MatricesIndicesExtraKind
  107345. * - VertexBuffer.MatricesWeightsKind
  107346. * - VertexBuffer.MatricesWeightsExtraKind
  107347. */
  107348. removeVerticesData(kind: string): void;
  107349. /**
  107350. * Flags an associated vertex buffer as updatable
  107351. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  107352. * - VertexBuffer.PositionKind
  107353. * - VertexBuffer.UVKind
  107354. * - VertexBuffer.UV2Kind
  107355. * - VertexBuffer.UV3Kind
  107356. * - VertexBuffer.UV4Kind
  107357. * - VertexBuffer.UV5Kind
  107358. * - VertexBuffer.UV6Kind
  107359. * - VertexBuffer.ColorKind
  107360. * - VertexBuffer.MatricesIndicesKind
  107361. * - VertexBuffer.MatricesIndicesExtraKind
  107362. * - VertexBuffer.MatricesWeightsKind
  107363. * - VertexBuffer.MatricesWeightsExtraKind
  107364. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  107365. */
  107366. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  107367. /**
  107368. * Sets the mesh global Vertex Buffer
  107369. * @param buffer defines the buffer to use
  107370. * @returns the current mesh
  107371. */
  107372. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  107373. /**
  107374. * Update a specific associated vertex buffer
  107375. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  107376. * - VertexBuffer.PositionKind
  107377. * - VertexBuffer.UVKind
  107378. * - VertexBuffer.UV2Kind
  107379. * - VertexBuffer.UV3Kind
  107380. * - VertexBuffer.UV4Kind
  107381. * - VertexBuffer.UV5Kind
  107382. * - VertexBuffer.UV6Kind
  107383. * - VertexBuffer.ColorKind
  107384. * - VertexBuffer.MatricesIndicesKind
  107385. * - VertexBuffer.MatricesIndicesExtraKind
  107386. * - VertexBuffer.MatricesWeightsKind
  107387. * - VertexBuffer.MatricesWeightsExtraKind
  107388. * @param data defines the data source
  107389. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  107390. * @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)
  107391. * @returns the current mesh
  107392. */
  107393. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  107394. /**
  107395. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  107396. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  107397. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  107398. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  107399. * @returns the current mesh
  107400. */
  107401. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  107402. /**
  107403. * Creates a un-shared specific occurence of the geometry for the mesh.
  107404. * @returns the current mesh
  107405. */
  107406. makeGeometryUnique(): Mesh;
  107407. /**
  107408. * Set the index buffer of this mesh
  107409. * @param indices defines the source data
  107410. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  107411. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  107412. * @returns the current mesh
  107413. */
  107414. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  107415. /**
  107416. * Update the current index buffer
  107417. * @param indices defines the source data
  107418. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  107419. * @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)
  107420. * @returns the current mesh
  107421. */
  107422. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  107423. /**
  107424. * Invert the geometry to move from a right handed system to a left handed one.
  107425. * @returns the current mesh
  107426. */
  107427. toLeftHanded(): Mesh;
  107428. /** @hidden */
  107429. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  107430. /** @hidden */
  107431. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  107432. /**
  107433. * Registers for this mesh a javascript function called just before the rendering process
  107434. * @param func defines the function to call before rendering this mesh
  107435. * @returns the current mesh
  107436. */
  107437. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107438. /**
  107439. * Disposes a previously registered javascript function called before the rendering
  107440. * @param func defines the function to remove
  107441. * @returns the current mesh
  107442. */
  107443. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  107444. /**
  107445. * Registers for this mesh a javascript function called just after the rendering is complete
  107446. * @param func defines the function to call after rendering this mesh
  107447. * @returns the current mesh
  107448. */
  107449. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107450. /**
  107451. * Disposes a previously registered javascript function called after the rendering.
  107452. * @param func defines the function to remove
  107453. * @returns the current mesh
  107454. */
  107455. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  107456. /** @hidden */
  107457. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  107458. /** @hidden */
  107459. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  107460. /** @hidden */
  107461. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  107462. /** @hidden */
  107463. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  107464. /** @hidden */
  107465. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  107466. /** @hidden */
  107467. _rebuild(): void;
  107468. /** @hidden */
  107469. _freeze(): void;
  107470. /** @hidden */
  107471. _unFreeze(): void;
  107472. /**
  107473. * 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
  107474. * @param subMesh defines the subMesh to render
  107475. * @param enableAlphaMode defines if alpha mode can be changed
  107476. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  107477. * @returns the current mesh
  107478. */
  107479. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  107480. private _onBeforeDraw;
  107481. /**
  107482. * Renormalize the mesh and patch it up if there are no weights
  107483. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  107484. * However in the case of zero weights then we set just a single influence to 1.
  107485. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  107486. */
  107487. cleanMatrixWeights(): void;
  107488. private normalizeSkinFourWeights;
  107489. private normalizeSkinWeightsAndExtra;
  107490. /**
  107491. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  107492. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  107493. * the user know there was an issue with importing the mesh
  107494. * @returns a validation object with skinned, valid and report string
  107495. */
  107496. validateSkinning(): {
  107497. skinned: boolean;
  107498. valid: boolean;
  107499. report: string;
  107500. };
  107501. /** @hidden */
  107502. _checkDelayState(): Mesh;
  107503. private _queueLoad;
  107504. /**
  107505. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  107506. * A mesh is in the frustum if its bounding box intersects the frustum
  107507. * @param frustumPlanes defines the frustum to test
  107508. * @returns true if the mesh is in the frustum planes
  107509. */
  107510. isInFrustum(frustumPlanes: Plane[]): boolean;
  107511. /**
  107512. * Sets the mesh material by the material or multiMaterial `id` property
  107513. * @param id is a string identifying the material or the multiMaterial
  107514. * @returns the current mesh
  107515. */
  107516. setMaterialByID(id: string): Mesh;
  107517. /**
  107518. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  107519. * @returns an array of IAnimatable
  107520. */
  107521. getAnimatables(): IAnimatable[];
  107522. /**
  107523. * Modifies the mesh geometry according to the passed transformation matrix.
  107524. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  107525. * The mesh normals are modified using the same transformation.
  107526. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107527. * @param transform defines the transform matrix to use
  107528. * @see https://doc.babylonjs.com/resources/baking_transformations
  107529. * @returns the current mesh
  107530. */
  107531. bakeTransformIntoVertices(transform: Matrix): Mesh;
  107532. /**
  107533. * Modifies the mesh geometry according to its own current World Matrix.
  107534. * The mesh World Matrix is then reset.
  107535. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  107536. * Note that, under the hood, this method sets a new VertexBuffer each call.
  107537. * @see https://doc.babylonjs.com/resources/baking_transformations
  107538. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  107539. * @returns the current mesh
  107540. */
  107541. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  107542. /** @hidden */
  107543. get _positions(): Nullable<Vector3[]>;
  107544. /** @hidden */
  107545. _resetPointsArrayCache(): Mesh;
  107546. /** @hidden */
  107547. _generatePointsArray(): boolean;
  107548. /**
  107549. * Returns a new Mesh object generated from the current mesh properties.
  107550. * This method must not get confused with createInstance()
  107551. * @param name is a string, the name given to the new mesh
  107552. * @param newParent can be any Node object (default `null`)
  107553. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  107554. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  107555. * @returns a new mesh
  107556. */
  107557. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  107558. /**
  107559. * Releases resources associated with this mesh.
  107560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107562. */
  107563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107564. /** @hidden */
  107565. _disposeInstanceSpecificData(): void;
  107566. /** @hidden */
  107567. _disposeThinInstanceSpecificData(): void;
  107568. /**
  107569. * Modifies the mesh geometry according to a displacement map.
  107570. * 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.
  107571. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107572. * @param url is a string, the URL from the image file is to be downloaded.
  107573. * @param minHeight is the lower limit of the displacement.
  107574. * @param maxHeight is the upper limit of the displacement.
  107575. * @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.
  107576. * @param uvOffset is an optional vector2 used to offset UV.
  107577. * @param uvScale is an optional vector2 used to scale UV.
  107578. * @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.
  107579. * @returns the Mesh.
  107580. */
  107581. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107582. /**
  107583. * Modifies the mesh geometry according to a displacementMap buffer.
  107584. * 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.
  107585. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  107586. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  107587. * @param heightMapWidth is the width of the buffer image.
  107588. * @param heightMapHeight is the height of the buffer image.
  107589. * @param minHeight is the lower limit of the displacement.
  107590. * @param maxHeight is the upper limit of the displacement.
  107591. * @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.
  107592. * @param uvOffset is an optional vector2 used to offset UV.
  107593. * @param uvScale is an optional vector2 used to scale UV.
  107594. * @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.
  107595. * @returns the Mesh.
  107596. */
  107597. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  107598. /**
  107599. * Modify the mesh to get a flat shading rendering.
  107600. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  107601. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  107602. * @returns current mesh
  107603. */
  107604. convertToFlatShadedMesh(): Mesh;
  107605. /**
  107606. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  107607. * In other words, more vertices, no more indices and a single bigger VBO.
  107608. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  107609. * @returns current mesh
  107610. */
  107611. convertToUnIndexedMesh(): Mesh;
  107612. /**
  107613. * Inverses facet orientations.
  107614. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107615. * @param flipNormals will also inverts the normals
  107616. * @returns current mesh
  107617. */
  107618. flipFaces(flipNormals?: boolean): Mesh;
  107619. /**
  107620. * Increase the number of facets and hence vertices in a mesh
  107621. * Vertex normals are interpolated from existing vertex normals
  107622. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107623. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  107624. */
  107625. increaseVertices(numberPerEdge: number): void;
  107626. /**
  107627. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  107628. * This will undo any application of covertToFlatShadedMesh
  107629. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  107630. */
  107631. forceSharedVertices(): void;
  107632. /** @hidden */
  107633. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  107634. /** @hidden */
  107635. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  107636. /**
  107637. * Creates a new InstancedMesh object from the mesh model.
  107638. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  107639. * @param name defines the name of the new instance
  107640. * @returns a new InstancedMesh
  107641. */
  107642. createInstance(name: string): InstancedMesh;
  107643. /**
  107644. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  107645. * After this call, all the mesh instances have the same submeshes than the current mesh.
  107646. * @returns the current mesh
  107647. */
  107648. synchronizeInstances(): Mesh;
  107649. /**
  107650. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  107651. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  107652. * This should be used together with the simplification to avoid disappearing triangles.
  107653. * @param successCallback an optional success callback to be called after the optimization finished.
  107654. * @returns the current mesh
  107655. */
  107656. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  107657. /**
  107658. * Serialize current mesh
  107659. * @param serializationObject defines the object which will receive the serialization data
  107660. */
  107661. serialize(serializationObject: any): void;
  107662. /** @hidden */
  107663. _syncGeometryWithMorphTargetManager(): void;
  107664. /** @hidden */
  107665. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  107666. /**
  107667. * Returns a new Mesh object parsed from the source provided.
  107668. * @param parsedMesh is the source
  107669. * @param scene defines the hosting scene
  107670. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  107671. * @returns a new Mesh
  107672. */
  107673. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  107674. /**
  107675. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  107676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107677. * @param name defines the name of the mesh to create
  107678. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  107679. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  107680. * @param closePath creates a seam between the first and the last points of each path of the path array
  107681. * @param offset is taken in account only if the `pathArray` is containing a single path
  107682. * @param scene defines the hosting scene
  107683. * @param updatable defines if the mesh must be flagged as updatable
  107684. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107685. * @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)
  107686. * @returns a new Mesh
  107687. */
  107688. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107689. /**
  107690. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  107691. * @param name defines the name of the mesh to create
  107692. * @param radius sets the radius size (float) of the polygon (default 0.5)
  107693. * @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
  107694. * @param scene defines the hosting scene
  107695. * @param updatable defines if the mesh must be flagged as updatable
  107696. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107697. * @returns a new Mesh
  107698. */
  107699. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107700. /**
  107701. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  107702. * @param name defines the name of the mesh to create
  107703. * @param size sets the size (float) of each box side (default 1)
  107704. * @param scene defines the hosting scene
  107705. * @param updatable defines if the mesh must be flagged as updatable
  107706. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107707. * @returns a new Mesh
  107708. */
  107709. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  107710. /**
  107711. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  107712. * @param name defines the name of the mesh to create
  107713. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107714. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107715. * @param scene defines the hosting scene
  107716. * @param updatable defines if the mesh must be flagged as updatable
  107717. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107718. * @returns a new Mesh
  107719. */
  107720. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107721. /**
  107722. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  107723. * @param name defines the name of the mesh to create
  107724. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  107725. * @param diameter sets the diameter size (float) of the sphere (default 1)
  107726. * @param scene defines the hosting scene
  107727. * @returns a new Mesh
  107728. */
  107729. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  107730. /**
  107731. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  107732. * @param name defines the name of the mesh to create
  107733. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  107734. * @param diameterTop set the top cap diameter (floats, default 1)
  107735. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  107736. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  107737. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  107738. * @param scene defines the hosting scene
  107739. * @param updatable defines if the mesh must be flagged as updatable
  107740. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107741. * @returns a new Mesh
  107742. */
  107743. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  107744. /**
  107745. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  107746. * @param name defines the name of the mesh to create
  107747. * @param diameter sets the diameter size (float) of the torus (default 1)
  107748. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  107749. * @param tessellation sets the number of torus sides (postive integer, default 16)
  107750. * @param scene defines the hosting scene
  107751. * @param updatable defines if the mesh must be flagged as updatable
  107752. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107753. * @returns a new Mesh
  107754. */
  107755. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107756. /**
  107757. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  107758. * @param name defines the name of the mesh to create
  107759. * @param radius sets the global radius size (float) of the torus knot (default 2)
  107760. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  107761. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  107762. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  107763. * @param p the number of windings on X axis (positive integers, default 2)
  107764. * @param q the number of windings on Y axis (positive integers, default 3)
  107765. * @param scene defines the hosting scene
  107766. * @param updatable defines if the mesh must be flagged as updatable
  107767. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107768. * @returns a new Mesh
  107769. */
  107770. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107771. /**
  107772. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  107773. * @param name defines the name of the mesh to create
  107774. * @param points is an array successive Vector3
  107775. * @param scene defines the hosting scene
  107776. * @param updatable defines if the mesh must be flagged as updatable
  107777. * @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).
  107778. * @returns a new Mesh
  107779. */
  107780. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  107781. /**
  107782. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  107783. * @param name defines the name of the mesh to create
  107784. * @param points is an array successive Vector3
  107785. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  107786. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107787. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  107788. * @param scene defines the hosting scene
  107789. * @param updatable defines if the mesh must be flagged as updatable
  107790. * @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)
  107791. * @returns a new Mesh
  107792. */
  107793. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  107794. /**
  107795. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  107796. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  107797. * 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.
  107798. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107799. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107800. * Remember you can only change the shape positions, not their number when updating a polygon.
  107801. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  107802. * @param name defines the name of the mesh to create
  107803. * @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
  107804. * @param scene defines the hosting scene
  107805. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107806. * @param updatable defines if the mesh must be flagged as updatable
  107807. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107808. * @param earcutInjection can be used to inject your own earcut reference
  107809. * @returns a new Mesh
  107810. */
  107811. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107812. /**
  107813. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  107814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  107815. * @param name defines the name of the mesh to create
  107816. * @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
  107817. * @param depth defines the height of extrusion
  107818. * @param scene defines the hosting scene
  107819. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  107820. * @param updatable defines if the mesh must be flagged as updatable
  107821. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107822. * @param earcutInjection can be used to inject your own earcut reference
  107823. * @returns a new Mesh
  107824. */
  107825. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  107826. /**
  107827. * Creates an extruded shape mesh.
  107828. * 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
  107829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107831. * @param name defines the name of the mesh to create
  107832. * @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
  107833. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107834. * @param scale is the value to scale the shape
  107835. * @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
  107836. * @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
  107837. * @param scene defines the hosting scene
  107838. * @param updatable defines if the mesh must be flagged as updatable
  107839. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107840. * @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)
  107841. * @returns a new Mesh
  107842. */
  107843. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107844. /**
  107845. * Creates an custom extruded shape mesh.
  107846. * The custom extrusion is a parametric shape.
  107847. * It has no predefined shape. Its final shape will depend on the input parameters.
  107848. * Please consider using the same method from the MeshBuilder class instead
  107849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107850. * @param name defines the name of the mesh to create
  107851. * @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
  107852. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  107853. * @param scaleFunction is a custom Javascript function called on each path point
  107854. * @param rotationFunction is a custom Javascript function called on each path point
  107855. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107856. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  107857. * @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
  107858. * @param scene defines the hosting scene
  107859. * @param updatable defines if the mesh must be flagged as updatable
  107860. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107861. * @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)
  107862. * @returns a new Mesh
  107863. */
  107864. 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;
  107865. /**
  107866. * Creates lathe mesh.
  107867. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  107868. * Please consider using the same method from the MeshBuilder class instead
  107869. * @param name defines the name of the mesh to create
  107870. * @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
  107871. * @param radius is the radius value of the lathe
  107872. * @param tessellation is the side number of the lathe.
  107873. * @param scene defines the hosting scene
  107874. * @param updatable defines if the mesh must be flagged as updatable
  107875. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107876. * @returns a new Mesh
  107877. */
  107878. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107879. /**
  107880. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  107881. * @param name defines the name of the mesh to create
  107882. * @param size sets the size (float) of both sides of the plane at once (default 1)
  107883. * @param scene defines the hosting scene
  107884. * @param updatable defines if the mesh must be flagged as updatable
  107885. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107886. * @returns a new Mesh
  107887. */
  107888. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  107889. /**
  107890. * Creates a ground mesh.
  107891. * Please consider using the same method from the MeshBuilder class instead
  107892. * @param name defines the name of the mesh to create
  107893. * @param width set the width of the ground
  107894. * @param height set the height of the ground
  107895. * @param subdivisions sets the number of subdivisions per side
  107896. * @param scene defines the hosting scene
  107897. * @param updatable defines if the mesh must be flagged as updatable
  107898. * @returns a new Mesh
  107899. */
  107900. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  107901. /**
  107902. * Creates a tiled ground mesh.
  107903. * Please consider using the same method from the MeshBuilder class instead
  107904. * @param name defines the name of the mesh to create
  107905. * @param xmin set the ground minimum X coordinate
  107906. * @param zmin set the ground minimum Y coordinate
  107907. * @param xmax set the ground maximum X coordinate
  107908. * @param zmax set the ground maximum Z coordinate
  107909. * @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
  107910. * @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
  107911. * @param scene defines the hosting scene
  107912. * @param updatable defines if the mesh must be flagged as updatable
  107913. * @returns a new Mesh
  107914. */
  107915. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  107916. w: number;
  107917. h: number;
  107918. }, precision: {
  107919. w: number;
  107920. h: number;
  107921. }, scene: Scene, updatable?: boolean): Mesh;
  107922. /**
  107923. * Creates a ground mesh from a height map.
  107924. * Please consider using the same method from the MeshBuilder class instead
  107925. * @see https://doc.babylonjs.com/babylon101/height_map
  107926. * @param name defines the name of the mesh to create
  107927. * @param url sets the URL of the height map image resource
  107928. * @param width set the ground width size
  107929. * @param height set the ground height size
  107930. * @param subdivisions sets the number of subdivision per side
  107931. * @param minHeight is the minimum altitude on the ground
  107932. * @param maxHeight is the maximum altitude on the ground
  107933. * @param scene defines the hosting scene
  107934. * @param updatable defines if the mesh must be flagged as updatable
  107935. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  107936. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107937. * @returns a new Mesh
  107938. */
  107939. 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;
  107940. /**
  107941. * Creates a tube mesh.
  107942. * The tube is a parametric shape.
  107943. * It has no predefined shape. Its final shape will depend on the input parameters.
  107944. * Please consider using the same method from the MeshBuilder class instead
  107945. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107946. * @param name defines the name of the mesh to create
  107947. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  107948. * @param radius sets the tube radius size
  107949. * @param tessellation is the number of sides on the tubular surface
  107950. * @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
  107951. * @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
  107952. * @param scene defines the hosting scene
  107953. * @param updatable defines if the mesh must be flagged as updatable
  107954. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  107955. * @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)
  107956. * @returns a new Mesh
  107957. */
  107958. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  107959. (i: number, distance: number): number;
  107960. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  107961. /**
  107962. * Creates a polyhedron mesh.
  107963. * Please consider using the same method from the MeshBuilder class instead.
  107964. * * 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
  107965. * * The parameter `size` (positive float, default 1) sets the polygon size
  107966. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107967. * * 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`
  107968. * * 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
  107969. * * 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)`)
  107970. * * 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
  107971. * * 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
  107972. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107975. * @param name defines the name of the mesh to create
  107976. * @param options defines the options used to create the mesh
  107977. * @param scene defines the hosting scene
  107978. * @returns a new Mesh
  107979. */
  107980. static CreatePolyhedron(name: string, options: {
  107981. type?: number;
  107982. size?: number;
  107983. sizeX?: number;
  107984. sizeY?: number;
  107985. sizeZ?: number;
  107986. custom?: any;
  107987. faceUV?: Vector4[];
  107988. faceColors?: Color4[];
  107989. updatable?: boolean;
  107990. sideOrientation?: number;
  107991. }, scene: Scene): Mesh;
  107992. /**
  107993. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107994. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107995. * * 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`)
  107996. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107997. * * 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
  107998. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108001. * @param name defines the name of the mesh
  108002. * @param options defines the options used to create the mesh
  108003. * @param scene defines the hosting scene
  108004. * @returns a new Mesh
  108005. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  108006. */
  108007. static CreateIcoSphere(name: string, options: {
  108008. radius?: number;
  108009. flat?: boolean;
  108010. subdivisions?: number;
  108011. sideOrientation?: number;
  108012. updatable?: boolean;
  108013. }, scene: Scene): Mesh;
  108014. /**
  108015. * Creates a decal mesh.
  108016. * Please consider using the same method from the MeshBuilder class instead.
  108017. * A decal is a mesh usually applied as a model onto the surface of another mesh
  108018. * @param name defines the name of the mesh
  108019. * @param sourceMesh defines the mesh receiving the decal
  108020. * @param position sets the position of the decal in world coordinates
  108021. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  108022. * @param size sets the decal scaling
  108023. * @param angle sets the angle to rotate the decal
  108024. * @returns a new Mesh
  108025. */
  108026. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  108027. /**
  108028. * Prepare internal position array for software CPU skinning
  108029. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  108030. */
  108031. setPositionsForCPUSkinning(): Float32Array;
  108032. /**
  108033. * Prepare internal normal array for software CPU skinning
  108034. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  108035. */
  108036. setNormalsForCPUSkinning(): Float32Array;
  108037. /**
  108038. * Updates the vertex buffer by applying transformation from the bones
  108039. * @param skeleton defines the skeleton to apply to current mesh
  108040. * @returns the current mesh
  108041. */
  108042. applySkeleton(skeleton: Skeleton): Mesh;
  108043. /**
  108044. * 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
  108045. * @param meshes defines the list of meshes to scan
  108046. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  108047. */
  108048. static MinMax(meshes: AbstractMesh[]): {
  108049. min: Vector3;
  108050. max: Vector3;
  108051. };
  108052. /**
  108053. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  108054. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  108055. * @returns a vector3
  108056. */
  108057. static Center(meshesOrMinMaxVector: {
  108058. min: Vector3;
  108059. max: Vector3;
  108060. } | AbstractMesh[]): Vector3;
  108061. /**
  108062. * Merge the array of meshes into a single mesh for performance reasons.
  108063. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  108064. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  108065. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  108066. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  108067. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  108068. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  108069. * @returns a new mesh
  108070. */
  108071. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  108072. /** @hidden */
  108073. addInstance(instance: InstancedMesh): void;
  108074. /** @hidden */
  108075. removeInstance(instance: InstancedMesh): void;
  108076. }
  108077. }
  108078. declare module BABYLON {
  108079. /**
  108080. * This is the base class of all the camera used in the application.
  108081. * @see https://doc.babylonjs.com/features/cameras
  108082. */
  108083. export class Camera extends Node {
  108084. /** @hidden */
  108085. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  108086. /**
  108087. * This is the default projection mode used by the cameras.
  108088. * It helps recreating a feeling of perspective and better appreciate depth.
  108089. * This is the best way to simulate real life cameras.
  108090. */
  108091. static readonly PERSPECTIVE_CAMERA: number;
  108092. /**
  108093. * This helps creating camera with an orthographic mode.
  108094. * 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.
  108095. */
  108096. static readonly ORTHOGRAPHIC_CAMERA: number;
  108097. /**
  108098. * This is the default FOV mode for perspective cameras.
  108099. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  108100. */
  108101. static readonly FOVMODE_VERTICAL_FIXED: number;
  108102. /**
  108103. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  108104. */
  108105. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  108106. /**
  108107. * This specifies ther is no need for a camera rig.
  108108. * Basically only one eye is rendered corresponding to the camera.
  108109. */
  108110. static readonly RIG_MODE_NONE: number;
  108111. /**
  108112. * Simulates a camera Rig with one blue eye and one red eye.
  108113. * This can be use with 3d blue and red glasses.
  108114. */
  108115. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  108116. /**
  108117. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  108118. */
  108119. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  108120. /**
  108121. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  108122. */
  108123. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  108124. /**
  108125. * Defines that both eyes of the camera will be rendered over under each other.
  108126. */
  108127. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  108128. /**
  108129. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  108130. */
  108131. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  108132. /**
  108133. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  108134. */
  108135. static readonly RIG_MODE_VR: number;
  108136. /**
  108137. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  108138. */
  108139. static readonly RIG_MODE_WEBVR: number;
  108140. /**
  108141. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  108142. */
  108143. static readonly RIG_MODE_CUSTOM: number;
  108144. /**
  108145. * Defines if by default attaching controls should prevent the default javascript event to continue.
  108146. */
  108147. static ForceAttachControlToAlwaysPreventDefault: boolean;
  108148. /**
  108149. * Define the input manager associated with the camera.
  108150. */
  108151. inputs: CameraInputsManager<Camera>;
  108152. /** @hidden */
  108153. _position: Vector3;
  108154. /**
  108155. * Define the current local position of the camera in the scene
  108156. */
  108157. get position(): Vector3;
  108158. set position(newPosition: Vector3);
  108159. /**
  108160. * The vector the camera should consider as up.
  108161. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  108162. */
  108163. upVector: Vector3;
  108164. /**
  108165. * Define the current limit on the left side for an orthographic camera
  108166. * In scene unit
  108167. */
  108168. orthoLeft: Nullable<number>;
  108169. /**
  108170. * Define the current limit on the right side for an orthographic camera
  108171. * In scene unit
  108172. */
  108173. orthoRight: Nullable<number>;
  108174. /**
  108175. * Define the current limit on the bottom side for an orthographic camera
  108176. * In scene unit
  108177. */
  108178. orthoBottom: Nullable<number>;
  108179. /**
  108180. * Define the current limit on the top side for an orthographic camera
  108181. * In scene unit
  108182. */
  108183. orthoTop: Nullable<number>;
  108184. /**
  108185. * Field Of View is set in Radians. (default is 0.8)
  108186. */
  108187. fov: number;
  108188. /**
  108189. * Define the minimum distance the camera can see from.
  108190. * This is important to note that the depth buffer are not infinite and the closer it starts
  108191. * the more your scene might encounter depth fighting issue.
  108192. */
  108193. minZ: number;
  108194. /**
  108195. * Define the maximum distance the camera can see to.
  108196. * This is important to note that the depth buffer are not infinite and the further it end
  108197. * the more your scene might encounter depth fighting issue.
  108198. */
  108199. maxZ: number;
  108200. /**
  108201. * Define the default inertia of the camera.
  108202. * This helps giving a smooth feeling to the camera movement.
  108203. */
  108204. inertia: number;
  108205. /**
  108206. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  108207. */
  108208. mode: number;
  108209. /**
  108210. * Define whether the camera is intermediate.
  108211. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  108212. */
  108213. isIntermediate: boolean;
  108214. /**
  108215. * Define the viewport of the camera.
  108216. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  108217. */
  108218. viewport: Viewport;
  108219. /**
  108220. * Restricts the camera to viewing objects with the same layerMask.
  108221. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  108222. */
  108223. layerMask: number;
  108224. /**
  108225. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  108226. */
  108227. fovMode: number;
  108228. /**
  108229. * Rig mode of the camera.
  108230. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  108231. * This is normally controlled byt the camera themselves as internal use.
  108232. */
  108233. cameraRigMode: number;
  108234. /**
  108235. * Defines the distance between both "eyes" in case of a RIG
  108236. */
  108237. interaxialDistance: number;
  108238. /**
  108239. * Defines if stereoscopic rendering is done side by side or over under.
  108240. */
  108241. isStereoscopicSideBySide: boolean;
  108242. /**
  108243. * 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
  108244. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  108245. * else in the scene. (Eg. security camera)
  108246. *
  108247. * 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)
  108248. */
  108249. customRenderTargets: RenderTargetTexture[];
  108250. /**
  108251. * When set, the camera will render to this render target instead of the default canvas
  108252. *
  108253. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  108254. */
  108255. outputRenderTarget: Nullable<RenderTargetTexture>;
  108256. /**
  108257. * Observable triggered when the camera view matrix has changed.
  108258. */
  108259. onViewMatrixChangedObservable: Observable<Camera>;
  108260. /**
  108261. * Observable triggered when the camera Projection matrix has changed.
  108262. */
  108263. onProjectionMatrixChangedObservable: Observable<Camera>;
  108264. /**
  108265. * Observable triggered when the inputs have been processed.
  108266. */
  108267. onAfterCheckInputsObservable: Observable<Camera>;
  108268. /**
  108269. * Observable triggered when reset has been called and applied to the camera.
  108270. */
  108271. onRestoreStateObservable: Observable<Camera>;
  108272. /**
  108273. * Is this camera a part of a rig system?
  108274. */
  108275. isRigCamera: boolean;
  108276. /**
  108277. * If isRigCamera set to true this will be set with the parent camera.
  108278. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  108279. */
  108280. rigParent?: Camera;
  108281. /** @hidden */
  108282. _cameraRigParams: any;
  108283. /** @hidden */
  108284. _rigCameras: Camera[];
  108285. /** @hidden */
  108286. _rigPostProcess: Nullable<PostProcess>;
  108287. protected _webvrViewMatrix: Matrix;
  108288. /** @hidden */
  108289. _skipRendering: boolean;
  108290. /** @hidden */
  108291. _projectionMatrix: Matrix;
  108292. /** @hidden */
  108293. _postProcesses: Nullable<PostProcess>[];
  108294. /** @hidden */
  108295. _activeMeshes: SmartArray<AbstractMesh>;
  108296. protected _globalPosition: Vector3;
  108297. /** @hidden */
  108298. _computedViewMatrix: Matrix;
  108299. private _doNotComputeProjectionMatrix;
  108300. private _transformMatrix;
  108301. private _frustumPlanes;
  108302. private _refreshFrustumPlanes;
  108303. private _storedFov;
  108304. private _stateStored;
  108305. /**
  108306. * Instantiates a new camera object.
  108307. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  108308. * @see https://doc.babylonjs.com/features/cameras
  108309. * @param name Defines the name of the camera in the scene
  108310. * @param position Defines the position of the camera
  108311. * @param scene Defines the scene the camera belongs too
  108312. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  108313. */
  108314. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108315. /**
  108316. * Store current camera state (fov, position, etc..)
  108317. * @returns the camera
  108318. */
  108319. storeState(): Camera;
  108320. /**
  108321. * Restores the camera state values if it has been stored. You must call storeState() first
  108322. */
  108323. protected _restoreStateValues(): boolean;
  108324. /**
  108325. * Restored camera state. You must call storeState() first.
  108326. * @returns true if restored and false otherwise
  108327. */
  108328. restoreState(): boolean;
  108329. /**
  108330. * Gets the class name of the camera.
  108331. * @returns the class name
  108332. */
  108333. getClassName(): string;
  108334. /** @hidden */
  108335. readonly _isCamera: boolean;
  108336. /**
  108337. * Gets a string representation of the camera useful for debug purpose.
  108338. * @param fullDetails Defines that a more verboe level of logging is required
  108339. * @returns the string representation
  108340. */
  108341. toString(fullDetails?: boolean): string;
  108342. /**
  108343. * Gets the current world space position of the camera.
  108344. */
  108345. get globalPosition(): Vector3;
  108346. /**
  108347. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  108348. * @returns the active meshe list
  108349. */
  108350. getActiveMeshes(): SmartArray<AbstractMesh>;
  108351. /**
  108352. * Check whether a mesh is part of the current active mesh list of the camera
  108353. * @param mesh Defines the mesh to check
  108354. * @returns true if active, false otherwise
  108355. */
  108356. isActiveMesh(mesh: Mesh): boolean;
  108357. /**
  108358. * Is this camera ready to be used/rendered
  108359. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  108360. * @return true if the camera is ready
  108361. */
  108362. isReady(completeCheck?: boolean): boolean;
  108363. /** @hidden */
  108364. _initCache(): void;
  108365. /** @hidden */
  108366. _updateCache(ignoreParentClass?: boolean): void;
  108367. /** @hidden */
  108368. _isSynchronized(): boolean;
  108369. /** @hidden */
  108370. _isSynchronizedViewMatrix(): boolean;
  108371. /** @hidden */
  108372. _isSynchronizedProjectionMatrix(): boolean;
  108373. /**
  108374. * Attach the input controls to a specific dom element to get the input from.
  108375. * @param element Defines the element the controls should be listened from
  108376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108377. */
  108378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108379. /**
  108380. * Detach the current controls from the specified dom element.
  108381. * @param element Defines the element to stop listening the inputs from
  108382. */
  108383. detachControl(element: HTMLElement): void;
  108384. /**
  108385. * Update the camera state according to the different inputs gathered during the frame.
  108386. */
  108387. update(): void;
  108388. /** @hidden */
  108389. _checkInputs(): void;
  108390. /** @hidden */
  108391. get rigCameras(): Camera[];
  108392. /**
  108393. * Gets the post process used by the rig cameras
  108394. */
  108395. get rigPostProcess(): Nullable<PostProcess>;
  108396. /**
  108397. * Internal, gets the first post proces.
  108398. * @returns the first post process to be run on this camera.
  108399. */
  108400. _getFirstPostProcess(): Nullable<PostProcess>;
  108401. private _cascadePostProcessesToRigCams;
  108402. /**
  108403. * Attach a post process to the camera.
  108404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108405. * @param postProcess The post process to attach to the camera
  108406. * @param insertAt The position of the post process in case several of them are in use in the scene
  108407. * @returns the position the post process has been inserted at
  108408. */
  108409. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  108410. /**
  108411. * Detach a post process to the camera.
  108412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  108413. * @param postProcess The post process to detach from the camera
  108414. */
  108415. detachPostProcess(postProcess: PostProcess): void;
  108416. /**
  108417. * Gets the current world matrix of the camera
  108418. */
  108419. getWorldMatrix(): Matrix;
  108420. /** @hidden */
  108421. _getViewMatrix(): Matrix;
  108422. /**
  108423. * Gets the current view matrix of the camera.
  108424. * @param force forces the camera to recompute the matrix without looking at the cached state
  108425. * @returns the view matrix
  108426. */
  108427. getViewMatrix(force?: boolean): Matrix;
  108428. /**
  108429. * Freeze the projection matrix.
  108430. * It will prevent the cache check of the camera projection compute and can speed up perf
  108431. * if no parameter of the camera are meant to change
  108432. * @param projection Defines manually a projection if necessary
  108433. */
  108434. freezeProjectionMatrix(projection?: Matrix): void;
  108435. /**
  108436. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  108437. */
  108438. unfreezeProjectionMatrix(): void;
  108439. /**
  108440. * Gets the current projection matrix of the camera.
  108441. * @param force forces the camera to recompute the matrix without looking at the cached state
  108442. * @returns the projection matrix
  108443. */
  108444. getProjectionMatrix(force?: boolean): Matrix;
  108445. /**
  108446. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  108447. * @returns a Matrix
  108448. */
  108449. getTransformationMatrix(): Matrix;
  108450. private _updateFrustumPlanes;
  108451. /**
  108452. * Checks if a cullable object (mesh...) is in the camera frustum
  108453. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  108454. * @param target The object to check
  108455. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  108456. * @returns true if the object is in frustum otherwise false
  108457. */
  108458. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  108459. /**
  108460. * Checks if a cullable object (mesh...) is in the camera frustum
  108461. * Unlike isInFrustum this cheks the full bounding box
  108462. * @param target The object to check
  108463. * @returns true if the object is in frustum otherwise false
  108464. */
  108465. isCompletelyInFrustum(target: ICullable): boolean;
  108466. /**
  108467. * Gets a ray in the forward direction from the camera.
  108468. * @param length Defines the length of the ray to create
  108469. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108470. * @param origin Defines the start point of the ray which defaults to the camera position
  108471. * @returns the forward ray
  108472. */
  108473. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108474. /**
  108475. * Gets a ray in the forward direction from the camera.
  108476. * @param refRay the ray to (re)use when setting the values
  108477. * @param length Defines the length of the ray to create
  108478. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  108479. * @param origin Defines the start point of the ray which defaults to the camera position
  108480. * @returns the forward ray
  108481. */
  108482. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  108483. /**
  108484. * Releases resources associated with this node.
  108485. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108486. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108487. */
  108488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108489. /** @hidden */
  108490. _isLeftCamera: boolean;
  108491. /**
  108492. * Gets the left camera of a rig setup in case of Rigged Camera
  108493. */
  108494. get isLeftCamera(): boolean;
  108495. /** @hidden */
  108496. _isRightCamera: boolean;
  108497. /**
  108498. * Gets the right camera of a rig setup in case of Rigged Camera
  108499. */
  108500. get isRightCamera(): boolean;
  108501. /**
  108502. * Gets the left camera of a rig setup in case of Rigged Camera
  108503. */
  108504. get leftCamera(): Nullable<FreeCamera>;
  108505. /**
  108506. * Gets the right camera of a rig setup in case of Rigged Camera
  108507. */
  108508. get rightCamera(): Nullable<FreeCamera>;
  108509. /**
  108510. * Gets the left camera target of a rig setup in case of Rigged Camera
  108511. * @returns the target position
  108512. */
  108513. getLeftTarget(): Nullable<Vector3>;
  108514. /**
  108515. * Gets the right camera target of a rig setup in case of Rigged Camera
  108516. * @returns the target position
  108517. */
  108518. getRightTarget(): Nullable<Vector3>;
  108519. /**
  108520. * @hidden
  108521. */
  108522. setCameraRigMode(mode: number, rigParams: any): void;
  108523. /** @hidden */
  108524. static _setStereoscopicRigMode(camera: Camera): void;
  108525. /** @hidden */
  108526. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  108527. /** @hidden */
  108528. static _setVRRigMode(camera: Camera, rigParams: any): void;
  108529. /** @hidden */
  108530. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  108531. /** @hidden */
  108532. _getVRProjectionMatrix(): Matrix;
  108533. protected _updateCameraRotationMatrix(): void;
  108534. protected _updateWebVRCameraRotationMatrix(): void;
  108535. /**
  108536. * This function MUST be overwritten by the different WebVR cameras available.
  108537. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108538. * @hidden
  108539. */
  108540. _getWebVRProjectionMatrix(): Matrix;
  108541. /**
  108542. * This function MUST be overwritten by the different WebVR cameras available.
  108543. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  108544. * @hidden
  108545. */
  108546. _getWebVRViewMatrix(): Matrix;
  108547. /** @hidden */
  108548. setCameraRigParameter(name: string, value: any): void;
  108549. /**
  108550. * needs to be overridden by children so sub has required properties to be copied
  108551. * @hidden
  108552. */
  108553. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  108554. /**
  108555. * May need to be overridden by children
  108556. * @hidden
  108557. */
  108558. _updateRigCameras(): void;
  108559. /** @hidden */
  108560. _setupInputs(): void;
  108561. /**
  108562. * Serialiaze the camera setup to a json represention
  108563. * @returns the JSON representation
  108564. */
  108565. serialize(): any;
  108566. /**
  108567. * Clones the current camera.
  108568. * @param name The cloned camera name
  108569. * @returns the cloned camera
  108570. */
  108571. clone(name: string): Camera;
  108572. /**
  108573. * Gets the direction of the camera relative to a given local axis.
  108574. * @param localAxis Defines the reference axis to provide a relative direction.
  108575. * @return the direction
  108576. */
  108577. getDirection(localAxis: Vector3): Vector3;
  108578. /**
  108579. * Returns the current camera absolute rotation
  108580. */
  108581. get absoluteRotation(): Quaternion;
  108582. /**
  108583. * Gets the direction of the camera relative to a given local axis into a passed vector.
  108584. * @param localAxis Defines the reference axis to provide a relative direction.
  108585. * @param result Defines the vector to store the result in
  108586. */
  108587. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  108588. /**
  108589. * Gets a camera constructor for a given camera type
  108590. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  108591. * @param name The name of the camera the result will be able to instantiate
  108592. * @param scene The scene the result will construct the camera in
  108593. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  108594. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  108595. * @returns a factory method to construc the camera
  108596. */
  108597. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  108598. /**
  108599. * Compute the world matrix of the camera.
  108600. * @returns the camera world matrix
  108601. */
  108602. computeWorldMatrix(): Matrix;
  108603. /**
  108604. * Parse a JSON and creates the camera from the parsed information
  108605. * @param parsedCamera The JSON to parse
  108606. * @param scene The scene to instantiate the camera in
  108607. * @returns the newly constructed camera
  108608. */
  108609. static Parse(parsedCamera: any, scene: Scene): Camera;
  108610. }
  108611. }
  108612. declare module BABYLON {
  108613. /**
  108614. * Class containing static functions to help procedurally build meshes
  108615. */
  108616. export class DiscBuilder {
  108617. /**
  108618. * Creates a plane polygonal mesh. By default, this is a disc
  108619. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  108620. * * 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
  108621. * * 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
  108622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108625. * @param name defines the name of the mesh
  108626. * @param options defines the options used to create the mesh
  108627. * @param scene defines the hosting scene
  108628. * @returns the plane polygonal mesh
  108629. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  108630. */
  108631. static CreateDisc(name: string, options: {
  108632. radius?: number;
  108633. tessellation?: number;
  108634. arc?: number;
  108635. updatable?: boolean;
  108636. sideOrientation?: number;
  108637. frontUVs?: Vector4;
  108638. backUVs?: Vector4;
  108639. }, scene?: Nullable<Scene>): Mesh;
  108640. }
  108641. }
  108642. declare module BABYLON {
  108643. /**
  108644. * Options to be used when creating a FresnelParameters.
  108645. */
  108646. export type IFresnelParametersCreationOptions = {
  108647. /**
  108648. * Define the color used on edges (grazing angle)
  108649. */
  108650. leftColor?: Color3;
  108651. /**
  108652. * Define the color used on center
  108653. */
  108654. rightColor?: Color3;
  108655. /**
  108656. * Define bias applied to computed fresnel term
  108657. */
  108658. bias?: number;
  108659. /**
  108660. * Defined the power exponent applied to fresnel term
  108661. */
  108662. power?: number;
  108663. /**
  108664. * Define if the fresnel effect is enable or not.
  108665. */
  108666. isEnabled?: boolean;
  108667. };
  108668. /**
  108669. * Serialized format for FresnelParameters.
  108670. */
  108671. export type IFresnelParametersSerialized = {
  108672. /**
  108673. * Define the color used on edges (grazing angle) [as an array]
  108674. */
  108675. leftColor: number[];
  108676. /**
  108677. * Define the color used on center [as an array]
  108678. */
  108679. rightColor: number[];
  108680. /**
  108681. * Define bias applied to computed fresnel term
  108682. */
  108683. bias: number;
  108684. /**
  108685. * Defined the power exponent applied to fresnel term
  108686. */
  108687. power?: number;
  108688. /**
  108689. * Define if the fresnel effect is enable or not.
  108690. */
  108691. isEnabled: boolean;
  108692. };
  108693. /**
  108694. * This represents all the required information to add a fresnel effect on a material:
  108695. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108696. */
  108697. export class FresnelParameters {
  108698. private _isEnabled;
  108699. /**
  108700. * Define if the fresnel effect is enable or not.
  108701. */
  108702. get isEnabled(): boolean;
  108703. set isEnabled(value: boolean);
  108704. /**
  108705. * Define the color used on edges (grazing angle)
  108706. */
  108707. leftColor: Color3;
  108708. /**
  108709. * Define the color used on center
  108710. */
  108711. rightColor: Color3;
  108712. /**
  108713. * Define bias applied to computed fresnel term
  108714. */
  108715. bias: number;
  108716. /**
  108717. * Defined the power exponent applied to fresnel term
  108718. */
  108719. power: number;
  108720. /**
  108721. * Creates a new FresnelParameters object.
  108722. *
  108723. * @param options provide your own settings to optionally to override defaults
  108724. */
  108725. constructor(options?: IFresnelParametersCreationOptions);
  108726. /**
  108727. * Clones the current fresnel and its valuues
  108728. * @returns a clone fresnel configuration
  108729. */
  108730. clone(): FresnelParameters;
  108731. /**
  108732. * Determines equality between FresnelParameters objects
  108733. * @param otherFresnelParameters defines the second operand
  108734. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  108735. */
  108736. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  108737. /**
  108738. * Serializes the current fresnel parameters to a JSON representation.
  108739. * @return the JSON serialization
  108740. */
  108741. serialize(): IFresnelParametersSerialized;
  108742. /**
  108743. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  108744. * @param parsedFresnelParameters Define the JSON representation
  108745. * @returns the parsed parameters
  108746. */
  108747. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  108748. }
  108749. }
  108750. declare module BABYLON {
  108751. /**
  108752. * This groups all the flags used to control the materials channel.
  108753. */
  108754. export class MaterialFlags {
  108755. private static _DiffuseTextureEnabled;
  108756. /**
  108757. * Are diffuse textures enabled in the application.
  108758. */
  108759. static get DiffuseTextureEnabled(): boolean;
  108760. static set DiffuseTextureEnabled(value: boolean);
  108761. private static _DetailTextureEnabled;
  108762. /**
  108763. * Are detail textures enabled in the application.
  108764. */
  108765. static get DetailTextureEnabled(): boolean;
  108766. static set DetailTextureEnabled(value: boolean);
  108767. private static _AmbientTextureEnabled;
  108768. /**
  108769. * Are ambient textures enabled in the application.
  108770. */
  108771. static get AmbientTextureEnabled(): boolean;
  108772. static set AmbientTextureEnabled(value: boolean);
  108773. private static _OpacityTextureEnabled;
  108774. /**
  108775. * Are opacity textures enabled in the application.
  108776. */
  108777. static get OpacityTextureEnabled(): boolean;
  108778. static set OpacityTextureEnabled(value: boolean);
  108779. private static _ReflectionTextureEnabled;
  108780. /**
  108781. * Are reflection textures enabled in the application.
  108782. */
  108783. static get ReflectionTextureEnabled(): boolean;
  108784. static set ReflectionTextureEnabled(value: boolean);
  108785. private static _EmissiveTextureEnabled;
  108786. /**
  108787. * Are emissive textures enabled in the application.
  108788. */
  108789. static get EmissiveTextureEnabled(): boolean;
  108790. static set EmissiveTextureEnabled(value: boolean);
  108791. private static _SpecularTextureEnabled;
  108792. /**
  108793. * Are specular textures enabled in the application.
  108794. */
  108795. static get SpecularTextureEnabled(): boolean;
  108796. static set SpecularTextureEnabled(value: boolean);
  108797. private static _BumpTextureEnabled;
  108798. /**
  108799. * Are bump textures enabled in the application.
  108800. */
  108801. static get BumpTextureEnabled(): boolean;
  108802. static set BumpTextureEnabled(value: boolean);
  108803. private static _LightmapTextureEnabled;
  108804. /**
  108805. * Are lightmap textures enabled in the application.
  108806. */
  108807. static get LightmapTextureEnabled(): boolean;
  108808. static set LightmapTextureEnabled(value: boolean);
  108809. private static _RefractionTextureEnabled;
  108810. /**
  108811. * Are refraction textures enabled in the application.
  108812. */
  108813. static get RefractionTextureEnabled(): boolean;
  108814. static set RefractionTextureEnabled(value: boolean);
  108815. private static _ColorGradingTextureEnabled;
  108816. /**
  108817. * Are color grading textures enabled in the application.
  108818. */
  108819. static get ColorGradingTextureEnabled(): boolean;
  108820. static set ColorGradingTextureEnabled(value: boolean);
  108821. private static _FresnelEnabled;
  108822. /**
  108823. * Are fresnels enabled in the application.
  108824. */
  108825. static get FresnelEnabled(): boolean;
  108826. static set FresnelEnabled(value: boolean);
  108827. private static _ClearCoatTextureEnabled;
  108828. /**
  108829. * Are clear coat textures enabled in the application.
  108830. */
  108831. static get ClearCoatTextureEnabled(): boolean;
  108832. static set ClearCoatTextureEnabled(value: boolean);
  108833. private static _ClearCoatBumpTextureEnabled;
  108834. /**
  108835. * Are clear coat bump textures enabled in the application.
  108836. */
  108837. static get ClearCoatBumpTextureEnabled(): boolean;
  108838. static set ClearCoatBumpTextureEnabled(value: boolean);
  108839. private static _ClearCoatTintTextureEnabled;
  108840. /**
  108841. * Are clear coat tint textures enabled in the application.
  108842. */
  108843. static get ClearCoatTintTextureEnabled(): boolean;
  108844. static set ClearCoatTintTextureEnabled(value: boolean);
  108845. private static _SheenTextureEnabled;
  108846. /**
  108847. * Are sheen textures enabled in the application.
  108848. */
  108849. static get SheenTextureEnabled(): boolean;
  108850. static set SheenTextureEnabled(value: boolean);
  108851. private static _AnisotropicTextureEnabled;
  108852. /**
  108853. * Are anisotropic textures enabled in the application.
  108854. */
  108855. static get AnisotropicTextureEnabled(): boolean;
  108856. static set AnisotropicTextureEnabled(value: boolean);
  108857. private static _ThicknessTextureEnabled;
  108858. /**
  108859. * Are thickness textures enabled in the application.
  108860. */
  108861. static get ThicknessTextureEnabled(): boolean;
  108862. static set ThicknessTextureEnabled(value: boolean);
  108863. }
  108864. }
  108865. declare module BABYLON {
  108866. /** @hidden */
  108867. export var defaultFragmentDeclaration: {
  108868. name: string;
  108869. shader: string;
  108870. };
  108871. }
  108872. declare module BABYLON {
  108873. /** @hidden */
  108874. export var defaultUboDeclaration: {
  108875. name: string;
  108876. shader: string;
  108877. };
  108878. }
  108879. declare module BABYLON {
  108880. /** @hidden */
  108881. export var prePassDeclaration: {
  108882. name: string;
  108883. shader: string;
  108884. };
  108885. }
  108886. declare module BABYLON {
  108887. /** @hidden */
  108888. export var lightFragmentDeclaration: {
  108889. name: string;
  108890. shader: string;
  108891. };
  108892. }
  108893. declare module BABYLON {
  108894. /** @hidden */
  108895. export var lightUboDeclaration: {
  108896. name: string;
  108897. shader: string;
  108898. };
  108899. }
  108900. declare module BABYLON {
  108901. /** @hidden */
  108902. export var lightsFragmentFunctions: {
  108903. name: string;
  108904. shader: string;
  108905. };
  108906. }
  108907. declare module BABYLON {
  108908. /** @hidden */
  108909. export var shadowsFragmentFunctions: {
  108910. name: string;
  108911. shader: string;
  108912. };
  108913. }
  108914. declare module BABYLON {
  108915. /** @hidden */
  108916. export var fresnelFunction: {
  108917. name: string;
  108918. shader: string;
  108919. };
  108920. }
  108921. declare module BABYLON {
  108922. /** @hidden */
  108923. export var bumpFragmentMainFunctions: {
  108924. name: string;
  108925. shader: string;
  108926. };
  108927. }
  108928. declare module BABYLON {
  108929. /** @hidden */
  108930. export var bumpFragmentFunctions: {
  108931. name: string;
  108932. shader: string;
  108933. };
  108934. }
  108935. declare module BABYLON {
  108936. /** @hidden */
  108937. export var logDepthDeclaration: {
  108938. name: string;
  108939. shader: string;
  108940. };
  108941. }
  108942. declare module BABYLON {
  108943. /** @hidden */
  108944. export var bumpFragment: {
  108945. name: string;
  108946. shader: string;
  108947. };
  108948. }
  108949. declare module BABYLON {
  108950. /** @hidden */
  108951. export var depthPrePass: {
  108952. name: string;
  108953. shader: string;
  108954. };
  108955. }
  108956. declare module BABYLON {
  108957. /** @hidden */
  108958. export var lightFragment: {
  108959. name: string;
  108960. shader: string;
  108961. };
  108962. }
  108963. declare module BABYLON {
  108964. /** @hidden */
  108965. export var logDepthFragment: {
  108966. name: string;
  108967. shader: string;
  108968. };
  108969. }
  108970. declare module BABYLON {
  108971. /** @hidden */
  108972. export var defaultPixelShader: {
  108973. name: string;
  108974. shader: string;
  108975. };
  108976. }
  108977. declare module BABYLON {
  108978. /** @hidden */
  108979. export var defaultVertexDeclaration: {
  108980. name: string;
  108981. shader: string;
  108982. };
  108983. }
  108984. declare module BABYLON {
  108985. /** @hidden */
  108986. export var bumpVertexDeclaration: {
  108987. name: string;
  108988. shader: string;
  108989. };
  108990. }
  108991. declare module BABYLON {
  108992. /** @hidden */
  108993. export var bumpVertex: {
  108994. name: string;
  108995. shader: string;
  108996. };
  108997. }
  108998. declare module BABYLON {
  108999. /** @hidden */
  109000. export var fogVertex: {
  109001. name: string;
  109002. shader: string;
  109003. };
  109004. }
  109005. declare module BABYLON {
  109006. /** @hidden */
  109007. export var shadowsVertex: {
  109008. name: string;
  109009. shader: string;
  109010. };
  109011. }
  109012. declare module BABYLON {
  109013. /** @hidden */
  109014. export var pointCloudVertex: {
  109015. name: string;
  109016. shader: string;
  109017. };
  109018. }
  109019. declare module BABYLON {
  109020. /** @hidden */
  109021. export var logDepthVertex: {
  109022. name: string;
  109023. shader: string;
  109024. };
  109025. }
  109026. declare module BABYLON {
  109027. /** @hidden */
  109028. export var defaultVertexShader: {
  109029. name: string;
  109030. shader: string;
  109031. };
  109032. }
  109033. declare module BABYLON {
  109034. /**
  109035. * @hidden
  109036. */
  109037. export interface IMaterialDetailMapDefines {
  109038. DETAIL: boolean;
  109039. DETAILDIRECTUV: number;
  109040. DETAIL_NORMALBLENDMETHOD: number;
  109041. /** @hidden */
  109042. _areTexturesDirty: boolean;
  109043. }
  109044. /**
  109045. * Define the code related to the detail map parameters of a material
  109046. *
  109047. * Inspired from:
  109048. * 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
  109049. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  109050. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  109051. */
  109052. export class DetailMapConfiguration {
  109053. private _texture;
  109054. /**
  109055. * The detail texture of the material.
  109056. */
  109057. texture: Nullable<BaseTexture>;
  109058. /**
  109059. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  109060. * Bigger values mean stronger blending
  109061. */
  109062. diffuseBlendLevel: number;
  109063. /**
  109064. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  109065. * Bigger values mean stronger blending. Only used with PBR materials
  109066. */
  109067. roughnessBlendLevel: number;
  109068. /**
  109069. * Defines how strong the bump effect from the detail map is
  109070. * Bigger values mean stronger effect
  109071. */
  109072. bumpLevel: number;
  109073. private _normalBlendMethod;
  109074. /**
  109075. * The method used to blend the bump and detail normals together
  109076. */
  109077. normalBlendMethod: number;
  109078. private _isEnabled;
  109079. /**
  109080. * Enable or disable the detail map on this material
  109081. */
  109082. isEnabled: boolean;
  109083. /** @hidden */
  109084. private _internalMarkAllSubMeshesAsTexturesDirty;
  109085. /** @hidden */
  109086. _markAllSubMeshesAsTexturesDirty(): void;
  109087. /**
  109088. * Instantiate a new detail map
  109089. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109090. */
  109091. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109092. /**
  109093. * Gets whether the submesh is ready to be used or not.
  109094. * @param defines the list of "defines" to update.
  109095. * @param scene defines the scene the material belongs to.
  109096. * @returns - boolean indicating that the submesh is ready or not.
  109097. */
  109098. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  109099. /**
  109100. * Update the defines for detail map usage
  109101. * @param defines the list of "defines" to update.
  109102. * @param scene defines the scene the material belongs to.
  109103. */
  109104. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  109105. /**
  109106. * Binds the material data.
  109107. * @param uniformBuffer defines the Uniform buffer to fill in.
  109108. * @param scene defines the scene the material belongs to.
  109109. * @param isFrozen defines whether the material is frozen or not.
  109110. */
  109111. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109112. /**
  109113. * Checks to see if a texture is used in the material.
  109114. * @param texture - Base texture to use.
  109115. * @returns - Boolean specifying if a texture is used in the material.
  109116. */
  109117. hasTexture(texture: BaseTexture): boolean;
  109118. /**
  109119. * Returns an array of the actively used textures.
  109120. * @param activeTextures Array of BaseTextures
  109121. */
  109122. getActiveTextures(activeTextures: BaseTexture[]): void;
  109123. /**
  109124. * Returns the animatable textures.
  109125. * @param animatables Array of animatable textures.
  109126. */
  109127. getAnimatables(animatables: IAnimatable[]): void;
  109128. /**
  109129. * Disposes the resources of the material.
  109130. * @param forceDisposeTextures - Forces the disposal of all textures.
  109131. */
  109132. dispose(forceDisposeTextures?: boolean): void;
  109133. /**
  109134. * Get the current class name useful for serialization or dynamic coding.
  109135. * @returns "DetailMap"
  109136. */
  109137. getClassName(): string;
  109138. /**
  109139. * Add the required uniforms to the current list.
  109140. * @param uniforms defines the current uniform list.
  109141. */
  109142. static AddUniforms(uniforms: string[]): void;
  109143. /**
  109144. * Add the required samplers to the current list.
  109145. * @param samplers defines the current sampler list.
  109146. */
  109147. static AddSamplers(samplers: string[]): void;
  109148. /**
  109149. * Add the required uniforms to the current buffer.
  109150. * @param uniformBuffer defines the current uniform buffer.
  109151. */
  109152. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109153. /**
  109154. * Makes a duplicate of the current instance into another one.
  109155. * @param detailMap define the instance where to copy the info
  109156. */
  109157. copyTo(detailMap: DetailMapConfiguration): void;
  109158. /**
  109159. * Serializes this detail map instance
  109160. * @returns - An object with the serialized instance.
  109161. */
  109162. serialize(): any;
  109163. /**
  109164. * Parses a detail map setting from a serialized object.
  109165. * @param source - Serialized object.
  109166. * @param scene Defines the scene we are parsing for
  109167. * @param rootUrl Defines the rootUrl to load from
  109168. */
  109169. parse(source: any, scene: Scene, rootUrl: string): void;
  109170. }
  109171. }
  109172. declare module BABYLON {
  109173. /** @hidden */
  109174. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  109175. MAINUV1: boolean;
  109176. MAINUV2: boolean;
  109177. DIFFUSE: boolean;
  109178. DIFFUSEDIRECTUV: number;
  109179. DETAIL: boolean;
  109180. DETAILDIRECTUV: number;
  109181. DETAIL_NORMALBLENDMETHOD: number;
  109182. AMBIENT: boolean;
  109183. AMBIENTDIRECTUV: number;
  109184. OPACITY: boolean;
  109185. OPACITYDIRECTUV: number;
  109186. OPACITYRGB: boolean;
  109187. REFLECTION: boolean;
  109188. EMISSIVE: boolean;
  109189. EMISSIVEDIRECTUV: number;
  109190. SPECULAR: boolean;
  109191. SPECULARDIRECTUV: number;
  109192. BUMP: boolean;
  109193. BUMPDIRECTUV: number;
  109194. PARALLAX: boolean;
  109195. PARALLAXOCCLUSION: boolean;
  109196. SPECULAROVERALPHA: boolean;
  109197. CLIPPLANE: boolean;
  109198. CLIPPLANE2: boolean;
  109199. CLIPPLANE3: boolean;
  109200. CLIPPLANE4: boolean;
  109201. CLIPPLANE5: boolean;
  109202. CLIPPLANE6: boolean;
  109203. ALPHATEST: boolean;
  109204. DEPTHPREPASS: boolean;
  109205. ALPHAFROMDIFFUSE: boolean;
  109206. POINTSIZE: boolean;
  109207. FOG: boolean;
  109208. SPECULARTERM: boolean;
  109209. DIFFUSEFRESNEL: boolean;
  109210. OPACITYFRESNEL: boolean;
  109211. REFLECTIONFRESNEL: boolean;
  109212. REFRACTIONFRESNEL: boolean;
  109213. EMISSIVEFRESNEL: boolean;
  109214. FRESNEL: boolean;
  109215. NORMAL: boolean;
  109216. UV1: boolean;
  109217. UV2: boolean;
  109218. VERTEXCOLOR: boolean;
  109219. VERTEXALPHA: boolean;
  109220. NUM_BONE_INFLUENCERS: number;
  109221. BonesPerMesh: number;
  109222. BONETEXTURE: boolean;
  109223. INSTANCES: boolean;
  109224. THIN_INSTANCES: boolean;
  109225. GLOSSINESS: boolean;
  109226. ROUGHNESS: boolean;
  109227. EMISSIVEASILLUMINATION: boolean;
  109228. LINKEMISSIVEWITHDIFFUSE: boolean;
  109229. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109230. LIGHTMAP: boolean;
  109231. LIGHTMAPDIRECTUV: number;
  109232. OBJECTSPACE_NORMALMAP: boolean;
  109233. USELIGHTMAPASSHADOWMAP: boolean;
  109234. REFLECTIONMAP_3D: boolean;
  109235. REFLECTIONMAP_SPHERICAL: boolean;
  109236. REFLECTIONMAP_PLANAR: boolean;
  109237. REFLECTIONMAP_CUBIC: boolean;
  109238. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109239. REFLECTIONMAP_PROJECTION: boolean;
  109240. REFLECTIONMAP_SKYBOX: boolean;
  109241. REFLECTIONMAP_EXPLICIT: boolean;
  109242. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109243. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109244. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109245. INVERTCUBICMAP: boolean;
  109246. LOGARITHMICDEPTH: boolean;
  109247. REFRACTION: boolean;
  109248. REFRACTIONMAP_3D: boolean;
  109249. REFLECTIONOVERALPHA: boolean;
  109250. TWOSIDEDLIGHTING: boolean;
  109251. SHADOWFLOAT: boolean;
  109252. MORPHTARGETS: boolean;
  109253. MORPHTARGETS_NORMAL: boolean;
  109254. MORPHTARGETS_TANGENT: boolean;
  109255. MORPHTARGETS_UV: boolean;
  109256. NUM_MORPH_INFLUENCERS: number;
  109257. NONUNIFORMSCALING: boolean;
  109258. PREMULTIPLYALPHA: boolean;
  109259. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  109260. ALPHABLEND: boolean;
  109261. PREPASS: boolean;
  109262. SCENE_MRT_COUNT: number;
  109263. RGBDLIGHTMAP: boolean;
  109264. RGBDREFLECTION: boolean;
  109265. RGBDREFRACTION: boolean;
  109266. IMAGEPROCESSING: boolean;
  109267. VIGNETTE: boolean;
  109268. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109269. VIGNETTEBLENDMODEOPAQUE: boolean;
  109270. TONEMAPPING: boolean;
  109271. TONEMAPPING_ACES: boolean;
  109272. CONTRAST: boolean;
  109273. COLORCURVES: boolean;
  109274. COLORGRADING: boolean;
  109275. COLORGRADING3D: boolean;
  109276. SAMPLER3DGREENDEPTH: boolean;
  109277. SAMPLER3DBGRMAP: boolean;
  109278. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109279. MULTIVIEW: boolean;
  109280. /**
  109281. * If the reflection texture on this material is in linear color space
  109282. * @hidden
  109283. */
  109284. IS_REFLECTION_LINEAR: boolean;
  109285. /**
  109286. * If the refraction texture on this material is in linear color space
  109287. * @hidden
  109288. */
  109289. IS_REFRACTION_LINEAR: boolean;
  109290. EXPOSURE: boolean;
  109291. constructor();
  109292. setReflectionMode(modeToEnable: string): void;
  109293. }
  109294. /**
  109295. * This is the default material used in Babylon. It is the best trade off between quality
  109296. * and performances.
  109297. * @see https://doc.babylonjs.com/babylon101/materials
  109298. */
  109299. export class StandardMaterial extends PushMaterial {
  109300. private _diffuseTexture;
  109301. /**
  109302. * The basic texture of the material as viewed under a light.
  109303. */
  109304. diffuseTexture: Nullable<BaseTexture>;
  109305. private _ambientTexture;
  109306. /**
  109307. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109308. */
  109309. ambientTexture: Nullable<BaseTexture>;
  109310. private _opacityTexture;
  109311. /**
  109312. * Define the transparency of the material from a texture.
  109313. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109314. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109315. */
  109316. opacityTexture: Nullable<BaseTexture>;
  109317. private _reflectionTexture;
  109318. /**
  109319. * Define the texture used to display the reflection.
  109320. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109321. */
  109322. reflectionTexture: Nullable<BaseTexture>;
  109323. private _emissiveTexture;
  109324. /**
  109325. * Define texture of the material as if self lit.
  109326. * This will be mixed in the final result even in the absence of light.
  109327. */
  109328. emissiveTexture: Nullable<BaseTexture>;
  109329. private _specularTexture;
  109330. /**
  109331. * Define how the color and intensity of the highlight given by the light in the material.
  109332. */
  109333. specularTexture: Nullable<BaseTexture>;
  109334. private _bumpTexture;
  109335. /**
  109336. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109337. * 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.
  109338. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  109339. */
  109340. bumpTexture: Nullable<BaseTexture>;
  109341. private _lightmapTexture;
  109342. /**
  109343. * Complex lighting can be computationally expensive to compute at runtime.
  109344. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109345. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  109346. */
  109347. lightmapTexture: Nullable<BaseTexture>;
  109348. private _refractionTexture;
  109349. /**
  109350. * Define the texture used to display the refraction.
  109351. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109352. */
  109353. refractionTexture: Nullable<BaseTexture>;
  109354. /**
  109355. * The color of the material lit by the environmental background lighting.
  109356. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109357. */
  109358. ambientColor: Color3;
  109359. /**
  109360. * The basic color of the material as viewed under a light.
  109361. */
  109362. diffuseColor: Color3;
  109363. /**
  109364. * Define how the color and intensity of the highlight given by the light in the material.
  109365. */
  109366. specularColor: Color3;
  109367. /**
  109368. * Define the color of the material as if self lit.
  109369. * This will be mixed in the final result even in the absence of light.
  109370. */
  109371. emissiveColor: Color3;
  109372. /**
  109373. * Defines how sharp are the highlights in the material.
  109374. * The bigger the value the sharper giving a more glossy feeling to the result.
  109375. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109376. */
  109377. specularPower: number;
  109378. private _useAlphaFromDiffuseTexture;
  109379. /**
  109380. * Does the transparency come from the diffuse texture alpha channel.
  109381. */
  109382. useAlphaFromDiffuseTexture: boolean;
  109383. private _useEmissiveAsIllumination;
  109384. /**
  109385. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109386. */
  109387. useEmissiveAsIllumination: boolean;
  109388. private _linkEmissiveWithDiffuse;
  109389. /**
  109390. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109391. * the emissive level when the final color is close to one.
  109392. */
  109393. linkEmissiveWithDiffuse: boolean;
  109394. private _useSpecularOverAlpha;
  109395. /**
  109396. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109397. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109398. */
  109399. useSpecularOverAlpha: boolean;
  109400. private _useReflectionOverAlpha;
  109401. /**
  109402. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109403. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109404. */
  109405. useReflectionOverAlpha: boolean;
  109406. private _disableLighting;
  109407. /**
  109408. * Does lights from the scene impacts this material.
  109409. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109410. */
  109411. disableLighting: boolean;
  109412. private _useObjectSpaceNormalMap;
  109413. /**
  109414. * Allows using an object space normal map (instead of tangent space).
  109415. */
  109416. useObjectSpaceNormalMap: boolean;
  109417. private _useParallax;
  109418. /**
  109419. * Is parallax enabled or not.
  109420. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109421. */
  109422. useParallax: boolean;
  109423. private _useParallaxOcclusion;
  109424. /**
  109425. * Is parallax occlusion enabled or not.
  109426. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109427. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  109428. */
  109429. useParallaxOcclusion: boolean;
  109430. /**
  109431. * 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.
  109432. */
  109433. parallaxScaleBias: number;
  109434. private _roughness;
  109435. /**
  109436. * Helps to define how blurry the reflections should appears in the material.
  109437. */
  109438. roughness: number;
  109439. /**
  109440. * In case of refraction, define the value of the index of refraction.
  109441. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109442. */
  109443. indexOfRefraction: number;
  109444. /**
  109445. * Invert the refraction texture alongside the y axis.
  109446. * It can be useful with procedural textures or probe for instance.
  109447. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109448. */
  109449. invertRefractionY: boolean;
  109450. /**
  109451. * Defines the alpha limits in alpha test mode.
  109452. */
  109453. alphaCutOff: number;
  109454. private _useLightmapAsShadowmap;
  109455. /**
  109456. * In case of light mapping, define whether the map contains light or shadow informations.
  109457. */
  109458. useLightmapAsShadowmap: boolean;
  109459. private _diffuseFresnelParameters;
  109460. /**
  109461. * Define the diffuse fresnel parameters of the material.
  109462. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109463. */
  109464. diffuseFresnelParameters: FresnelParameters;
  109465. private _opacityFresnelParameters;
  109466. /**
  109467. * Define the opacity fresnel parameters of the material.
  109468. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109469. */
  109470. opacityFresnelParameters: FresnelParameters;
  109471. private _reflectionFresnelParameters;
  109472. /**
  109473. * Define the reflection fresnel parameters of the material.
  109474. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109475. */
  109476. reflectionFresnelParameters: FresnelParameters;
  109477. private _refractionFresnelParameters;
  109478. /**
  109479. * Define the refraction fresnel parameters of the material.
  109480. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109481. */
  109482. refractionFresnelParameters: FresnelParameters;
  109483. private _emissiveFresnelParameters;
  109484. /**
  109485. * Define the emissive fresnel parameters of the material.
  109486. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109487. */
  109488. emissiveFresnelParameters: FresnelParameters;
  109489. private _useReflectionFresnelFromSpecular;
  109490. /**
  109491. * If true automatically deducts the fresnels values from the material specularity.
  109492. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109493. */
  109494. useReflectionFresnelFromSpecular: boolean;
  109495. private _useGlossinessFromSpecularMapAlpha;
  109496. /**
  109497. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109498. */
  109499. useGlossinessFromSpecularMapAlpha: boolean;
  109500. private _maxSimultaneousLights;
  109501. /**
  109502. * Defines the maximum number of lights that can be used in the material
  109503. */
  109504. maxSimultaneousLights: number;
  109505. private _invertNormalMapX;
  109506. /**
  109507. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109508. */
  109509. invertNormalMapX: boolean;
  109510. private _invertNormalMapY;
  109511. /**
  109512. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109513. */
  109514. invertNormalMapY: boolean;
  109515. private _twoSidedLighting;
  109516. /**
  109517. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109518. */
  109519. twoSidedLighting: boolean;
  109520. /**
  109521. * Default configuration related to image processing available in the standard Material.
  109522. */
  109523. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109524. /**
  109525. * Gets the image processing configuration used either in this material.
  109526. */
  109527. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109528. /**
  109529. * Sets the Default image processing configuration used either in the this material.
  109530. *
  109531. * If sets to null, the scene one is in use.
  109532. */
  109533. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  109534. /**
  109535. * Keep track of the image processing observer to allow dispose and replace.
  109536. */
  109537. private _imageProcessingObserver;
  109538. /**
  109539. * Attaches a new image processing configuration to the Standard Material.
  109540. * @param configuration
  109541. */
  109542. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109543. /**
  109544. * Gets wether the color curves effect is enabled.
  109545. */
  109546. get cameraColorCurvesEnabled(): boolean;
  109547. /**
  109548. * Sets wether the color curves effect is enabled.
  109549. */
  109550. set cameraColorCurvesEnabled(value: boolean);
  109551. /**
  109552. * Gets wether the color grading effect is enabled.
  109553. */
  109554. get cameraColorGradingEnabled(): boolean;
  109555. /**
  109556. * Gets wether the color grading effect is enabled.
  109557. */
  109558. set cameraColorGradingEnabled(value: boolean);
  109559. /**
  109560. * Gets wether tonemapping is enabled or not.
  109561. */
  109562. get cameraToneMappingEnabled(): boolean;
  109563. /**
  109564. * Sets wether tonemapping is enabled or not
  109565. */
  109566. set cameraToneMappingEnabled(value: boolean);
  109567. /**
  109568. * The camera exposure used on this material.
  109569. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109570. * This corresponds to a photographic exposure.
  109571. */
  109572. get cameraExposure(): number;
  109573. /**
  109574. * The camera exposure used on this material.
  109575. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109576. * This corresponds to a photographic exposure.
  109577. */
  109578. set cameraExposure(value: number);
  109579. /**
  109580. * Gets The camera contrast used on this material.
  109581. */
  109582. get cameraContrast(): number;
  109583. /**
  109584. * Sets The camera contrast used on this material.
  109585. */
  109586. set cameraContrast(value: number);
  109587. /**
  109588. * Gets the Color Grading 2D Lookup Texture.
  109589. */
  109590. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  109591. /**
  109592. * Sets the Color Grading 2D Lookup Texture.
  109593. */
  109594. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  109595. /**
  109596. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109597. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109598. * 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;
  109599. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109600. */
  109601. get cameraColorCurves(): Nullable<ColorCurves>;
  109602. /**
  109603. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109604. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109605. * 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;
  109606. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109607. */
  109608. set cameraColorCurves(value: Nullable<ColorCurves>);
  109609. /**
  109610. * Can this material render to several textures at once
  109611. */
  109612. get canRenderToMRT(): boolean;
  109613. /**
  109614. * Defines the detail map parameters for the material.
  109615. */
  109616. readonly detailMap: DetailMapConfiguration;
  109617. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109618. protected _worldViewProjectionMatrix: Matrix;
  109619. protected _globalAmbientColor: Color3;
  109620. protected _useLogarithmicDepth: boolean;
  109621. protected _rebuildInParallel: boolean;
  109622. /**
  109623. * Instantiates a new standard material.
  109624. * This is the default material used in Babylon. It is the best trade off between quality
  109625. * and performances.
  109626. * @see https://doc.babylonjs.com/babylon101/materials
  109627. * @param name Define the name of the material in the scene
  109628. * @param scene Define the scene the material belong to
  109629. */
  109630. constructor(name: string, scene: Scene);
  109631. /**
  109632. * Gets a boolean indicating that current material needs to register RTT
  109633. */
  109634. get hasRenderTargetTextures(): boolean;
  109635. /**
  109636. * Gets the current class name of the material e.g. "StandardMaterial"
  109637. * Mainly use in serialization.
  109638. * @returns the class name
  109639. */
  109640. getClassName(): string;
  109641. /**
  109642. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109643. * You can try switching to logarithmic depth.
  109644. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109645. */
  109646. get useLogarithmicDepth(): boolean;
  109647. set useLogarithmicDepth(value: boolean);
  109648. /**
  109649. * Specifies if the material will require alpha blending
  109650. * @returns a boolean specifying if alpha blending is needed
  109651. */
  109652. needAlphaBlending(): boolean;
  109653. /**
  109654. * Specifies if this material should be rendered in alpha test mode
  109655. * @returns a boolean specifying if an alpha test is needed.
  109656. */
  109657. needAlphaTesting(): boolean;
  109658. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109659. /**
  109660. * Get the texture used for alpha test purpose.
  109661. * @returns the diffuse texture in case of the standard material.
  109662. */
  109663. getAlphaTestTexture(): Nullable<BaseTexture>;
  109664. /**
  109665. * Get if the submesh is ready to be used and all its information available.
  109666. * Child classes can use it to update shaders
  109667. * @param mesh defines the mesh to check
  109668. * @param subMesh defines which submesh to check
  109669. * @param useInstances specifies that instances should be used
  109670. * @returns a boolean indicating that the submesh is ready or not
  109671. */
  109672. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109673. /**
  109674. * Builds the material UBO layouts.
  109675. * Used internally during the effect preparation.
  109676. */
  109677. buildUniformLayout(): void;
  109678. /**
  109679. * Unbinds the material from the mesh
  109680. */
  109681. unbind(): void;
  109682. /**
  109683. * Binds the submesh to this material by preparing the effect and shader to draw
  109684. * @param world defines the world transformation matrix
  109685. * @param mesh defines the mesh containing the submesh
  109686. * @param subMesh defines the submesh to bind the material to
  109687. */
  109688. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109689. /**
  109690. * Get the list of animatables in the material.
  109691. * @returns the list of animatables object used in the material
  109692. */
  109693. getAnimatables(): IAnimatable[];
  109694. /**
  109695. * Gets the active textures from the material
  109696. * @returns an array of textures
  109697. */
  109698. getActiveTextures(): BaseTexture[];
  109699. /**
  109700. * Specifies if the material uses a texture
  109701. * @param texture defines the texture to check against the material
  109702. * @returns a boolean specifying if the material uses the texture
  109703. */
  109704. hasTexture(texture: BaseTexture): boolean;
  109705. /**
  109706. * Disposes the material
  109707. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109708. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109709. */
  109710. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109711. /**
  109712. * Makes a duplicate of the material, and gives it a new name
  109713. * @param name defines the new name for the duplicated material
  109714. * @returns the cloned material
  109715. */
  109716. clone(name: string): StandardMaterial;
  109717. /**
  109718. * Serializes this material in a JSON representation
  109719. * @returns the serialized material object
  109720. */
  109721. serialize(): any;
  109722. /**
  109723. * Creates a standard material from parsed material data
  109724. * @param source defines the JSON representation of the material
  109725. * @param scene defines the hosting scene
  109726. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109727. * @returns a new standard material
  109728. */
  109729. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109730. /**
  109731. * Are diffuse textures enabled in the application.
  109732. */
  109733. static get DiffuseTextureEnabled(): boolean;
  109734. static set DiffuseTextureEnabled(value: boolean);
  109735. /**
  109736. * Are detail textures enabled in the application.
  109737. */
  109738. static get DetailTextureEnabled(): boolean;
  109739. static set DetailTextureEnabled(value: boolean);
  109740. /**
  109741. * Are ambient textures enabled in the application.
  109742. */
  109743. static get AmbientTextureEnabled(): boolean;
  109744. static set AmbientTextureEnabled(value: boolean);
  109745. /**
  109746. * Are opacity textures enabled in the application.
  109747. */
  109748. static get OpacityTextureEnabled(): boolean;
  109749. static set OpacityTextureEnabled(value: boolean);
  109750. /**
  109751. * Are reflection textures enabled in the application.
  109752. */
  109753. static get ReflectionTextureEnabled(): boolean;
  109754. static set ReflectionTextureEnabled(value: boolean);
  109755. /**
  109756. * Are emissive textures enabled in the application.
  109757. */
  109758. static get EmissiveTextureEnabled(): boolean;
  109759. static set EmissiveTextureEnabled(value: boolean);
  109760. /**
  109761. * Are specular textures enabled in the application.
  109762. */
  109763. static get SpecularTextureEnabled(): boolean;
  109764. static set SpecularTextureEnabled(value: boolean);
  109765. /**
  109766. * Are bump textures enabled in the application.
  109767. */
  109768. static get BumpTextureEnabled(): boolean;
  109769. static set BumpTextureEnabled(value: boolean);
  109770. /**
  109771. * Are lightmap textures enabled in the application.
  109772. */
  109773. static get LightmapTextureEnabled(): boolean;
  109774. static set LightmapTextureEnabled(value: boolean);
  109775. /**
  109776. * Are refraction textures enabled in the application.
  109777. */
  109778. static get RefractionTextureEnabled(): boolean;
  109779. static set RefractionTextureEnabled(value: boolean);
  109780. /**
  109781. * Are color grading textures enabled in the application.
  109782. */
  109783. static get ColorGradingTextureEnabled(): boolean;
  109784. static set ColorGradingTextureEnabled(value: boolean);
  109785. /**
  109786. * Are fresnels enabled in the application.
  109787. */
  109788. static get FresnelEnabled(): boolean;
  109789. static set FresnelEnabled(value: boolean);
  109790. }
  109791. }
  109792. declare module BABYLON {
  109793. /**
  109794. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  109795. *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.
  109796. * The SPS is also a particle system. It provides some methods to manage the particles.
  109797. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  109798. *
  109799. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  109800. */
  109801. export class SolidParticleSystem implements IDisposable {
  109802. /**
  109803. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  109804. * Example : var p = SPS.particles[i];
  109805. */
  109806. particles: SolidParticle[];
  109807. /**
  109808. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  109809. */
  109810. nbParticles: number;
  109811. /**
  109812. * If the particles must ever face the camera (default false). Useful for planar particles.
  109813. */
  109814. billboard: boolean;
  109815. /**
  109816. * Recompute normals when adding a shape
  109817. */
  109818. recomputeNormals: boolean;
  109819. /**
  109820. * This a counter ofr your own usage. It's not set by any SPS functions.
  109821. */
  109822. counter: number;
  109823. /**
  109824. * The SPS name. This name is also given to the underlying mesh.
  109825. */
  109826. name: string;
  109827. /**
  109828. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  109829. */
  109830. mesh: Mesh;
  109831. /**
  109832. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  109833. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  109834. */
  109835. vars: any;
  109836. /**
  109837. * This array is populated when the SPS is set as 'pickable'.
  109838. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  109839. * Each element of this array is an object `{idx: int, faceId: int}`.
  109840. * `idx` is the picked particle index in the `SPS.particles` array
  109841. * `faceId` is the picked face index counted within this particle.
  109842. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  109843. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  109844. * Use the method SPS.pickedParticle(pickingInfo) instead.
  109845. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109846. */
  109847. pickedParticles: {
  109848. idx: number;
  109849. faceId: number;
  109850. }[];
  109851. /**
  109852. * This array is populated when the SPS is set as 'pickable'
  109853. * Each key of this array is a submesh index.
  109854. * Each element of this array is a second array defined like this :
  109855. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  109856. * Each element of this second array is an object `{idx: int, faceId: int}`.
  109857. * `idx` is the picked particle index in the `SPS.particles` array
  109858. * `faceId` is the picked face index counted within this particle.
  109859. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  109860. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  109861. */
  109862. pickedBySubMesh: {
  109863. idx: number;
  109864. faceId: number;
  109865. }[][];
  109866. /**
  109867. * This array is populated when `enableDepthSort` is set to true.
  109868. * Each element of this array is an instance of the class DepthSortedParticle.
  109869. */
  109870. depthSortedParticles: DepthSortedParticle[];
  109871. /**
  109872. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  109873. * @hidden
  109874. */
  109875. _bSphereOnly: boolean;
  109876. /**
  109877. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  109878. * @hidden
  109879. */
  109880. _bSphereRadiusFactor: number;
  109881. private _scene;
  109882. private _positions;
  109883. private _indices;
  109884. private _normals;
  109885. private _colors;
  109886. private _uvs;
  109887. private _indices32;
  109888. private _positions32;
  109889. private _normals32;
  109890. private _fixedNormal32;
  109891. private _colors32;
  109892. private _uvs32;
  109893. private _index;
  109894. private _updatable;
  109895. private _pickable;
  109896. private _isVisibilityBoxLocked;
  109897. private _alwaysVisible;
  109898. private _depthSort;
  109899. private _expandable;
  109900. private _shapeCounter;
  109901. private _copy;
  109902. private _color;
  109903. private _computeParticleColor;
  109904. private _computeParticleTexture;
  109905. private _computeParticleRotation;
  109906. private _computeParticleVertex;
  109907. private _computeBoundingBox;
  109908. private _depthSortParticles;
  109909. private _camera;
  109910. private _mustUnrotateFixedNormals;
  109911. private _particlesIntersect;
  109912. private _needs32Bits;
  109913. private _isNotBuilt;
  109914. private _lastParticleId;
  109915. private _idxOfId;
  109916. private _multimaterialEnabled;
  109917. private _useModelMaterial;
  109918. private _indicesByMaterial;
  109919. private _materialIndexes;
  109920. private _depthSortFunction;
  109921. private _materialSortFunction;
  109922. private _materials;
  109923. private _multimaterial;
  109924. private _materialIndexesById;
  109925. private _defaultMaterial;
  109926. private _autoUpdateSubMeshes;
  109927. private _tmpVertex;
  109928. /**
  109929. * Creates a SPS (Solid Particle System) object.
  109930. * @param name (String) is the SPS name, this will be the underlying mesh name.
  109931. * @param scene (Scene) is the scene in which the SPS is added.
  109932. * @param options defines the options of the sps e.g.
  109933. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  109934. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  109935. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  109936. * * 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.
  109937. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  109938. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  109939. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  109940. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  109941. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  109942. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  109943. */
  109944. constructor(name: string, scene: Scene, options?: {
  109945. updatable?: boolean;
  109946. isPickable?: boolean;
  109947. enableDepthSort?: boolean;
  109948. particleIntersection?: boolean;
  109949. boundingSphereOnly?: boolean;
  109950. bSphereRadiusFactor?: number;
  109951. expandable?: boolean;
  109952. useModelMaterial?: boolean;
  109953. enableMultiMaterial?: boolean;
  109954. });
  109955. /**
  109956. * Builds the SPS underlying mesh. Returns a standard Mesh.
  109957. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  109958. * @returns the created mesh
  109959. */
  109960. buildMesh(): Mesh;
  109961. /**
  109962. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  109963. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  109964. * Thus the particles generated from `digest()` have their property `position` set yet.
  109965. * @param mesh ( Mesh ) is the mesh to be digested
  109966. * @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
  109967. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  109968. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  109969. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  109970. * @returns the current SPS
  109971. */
  109972. digest(mesh: Mesh, options?: {
  109973. facetNb?: number;
  109974. number?: number;
  109975. delta?: number;
  109976. storage?: [];
  109977. }): SolidParticleSystem;
  109978. /**
  109979. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  109980. * @hidden
  109981. */
  109982. private _unrotateFixedNormals;
  109983. /**
  109984. * Resets the temporary working copy particle
  109985. * @hidden
  109986. */
  109987. private _resetCopy;
  109988. /**
  109989. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  109990. * @param p the current index in the positions array to be updated
  109991. * @param ind the current index in the indices array
  109992. * @param shape a Vector3 array, the shape geometry
  109993. * @param positions the positions array to be updated
  109994. * @param meshInd the shape indices array
  109995. * @param indices the indices array to be updated
  109996. * @param meshUV the shape uv array
  109997. * @param uvs the uv array to be updated
  109998. * @param meshCol the shape color array
  109999. * @param colors the color array to be updated
  110000. * @param meshNor the shape normals array
  110001. * @param normals the normals array to be updated
  110002. * @param idx the particle index
  110003. * @param idxInShape the particle index in its shape
  110004. * @param options the addShape() method passed options
  110005. * @model the particle model
  110006. * @hidden
  110007. */
  110008. private _meshBuilder;
  110009. /**
  110010. * Returns a shape Vector3 array from positions float array
  110011. * @param positions float array
  110012. * @returns a vector3 array
  110013. * @hidden
  110014. */
  110015. private _posToShape;
  110016. /**
  110017. * Returns a shapeUV array from a float uvs (array deep copy)
  110018. * @param uvs as a float array
  110019. * @returns a shapeUV array
  110020. * @hidden
  110021. */
  110022. private _uvsToShapeUV;
  110023. /**
  110024. * Adds a new particle object in the particles array
  110025. * @param idx particle index in particles array
  110026. * @param id particle id
  110027. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  110028. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  110029. * @param model particle ModelShape object
  110030. * @param shapeId model shape identifier
  110031. * @param idxInShape index of the particle in the current model
  110032. * @param bInfo model bounding info object
  110033. * @param storage target storage array, if any
  110034. * @hidden
  110035. */
  110036. private _addParticle;
  110037. /**
  110038. * Adds some particles to the SPS from the model shape. Returns the shape id.
  110039. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  110040. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  110041. * @param nb (positive integer) the number of particles to be created from this model
  110042. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  110043. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  110044. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110045. * @returns the number of shapes in the system
  110046. */
  110047. addShape(mesh: Mesh, nb: number, options?: {
  110048. positionFunction?: any;
  110049. vertexFunction?: any;
  110050. storage?: [];
  110051. }): number;
  110052. /**
  110053. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  110054. * @hidden
  110055. */
  110056. private _rebuildParticle;
  110057. /**
  110058. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  110059. * @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.
  110060. * @returns the SPS.
  110061. */
  110062. rebuildMesh(reset?: boolean): SolidParticleSystem;
  110063. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  110064. * Returns an array with the removed particles.
  110065. * 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.
  110066. * The SPS can't be empty so at least one particle needs to remain in place.
  110067. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  110068. * @param start index of the first particle to remove
  110069. * @param end index of the last particle to remove (included)
  110070. * @returns an array populated with the removed particles
  110071. */
  110072. removeParticles(start: number, end: number): SolidParticle[];
  110073. /**
  110074. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  110075. * @param solidParticleArray an array populated with Solid Particles objects
  110076. * @returns the SPS
  110077. */
  110078. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  110079. /**
  110080. * Creates a new particle and modifies the SPS mesh geometry :
  110081. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  110082. * - calls _addParticle() to populate the particle array
  110083. * factorized code from addShape() and insertParticlesFromArray()
  110084. * @param idx particle index in the particles array
  110085. * @param i particle index in its shape
  110086. * @param modelShape particle ModelShape object
  110087. * @param shape shape vertex array
  110088. * @param meshInd shape indices array
  110089. * @param meshUV shape uv array
  110090. * @param meshCol shape color array
  110091. * @param meshNor shape normals array
  110092. * @param bbInfo shape bounding info
  110093. * @param storage target particle storage
  110094. * @options addShape() passed options
  110095. * @hidden
  110096. */
  110097. private _insertNewParticle;
  110098. /**
  110099. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  110100. * This method calls `updateParticle()` for each particle of the SPS.
  110101. * For an animated SPS, it is usually called within the render loop.
  110102. * 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.
  110103. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  110104. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  110105. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  110106. * @returns the SPS.
  110107. */
  110108. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  110109. /**
  110110. * Disposes the SPS.
  110111. */
  110112. dispose(): void;
  110113. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  110114. * idx is the particle index in the SPS
  110115. * faceId is the picked face index counted within this particle.
  110116. * Returns null if the pickInfo can't identify a picked particle.
  110117. * @param pickingInfo (PickingInfo object)
  110118. * @returns {idx: number, faceId: number} or null
  110119. */
  110120. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  110121. idx: number;
  110122. faceId: number;
  110123. }>;
  110124. /**
  110125. * Returns a SolidParticle object from its identifier : particle.id
  110126. * @param id (integer) the particle Id
  110127. * @returns the searched particle or null if not found in the SPS.
  110128. */
  110129. getParticleById(id: number): Nullable<SolidParticle>;
  110130. /**
  110131. * Returns a new array populated with the particles having the passed shapeId.
  110132. * @param shapeId (integer) the shape identifier
  110133. * @returns a new solid particle array
  110134. */
  110135. getParticlesByShapeId(shapeId: number): SolidParticle[];
  110136. /**
  110137. * Populates the passed array "ref" with the particles having the passed shapeId.
  110138. * @param shapeId the shape identifier
  110139. * @returns the SPS
  110140. * @param ref
  110141. */
  110142. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  110143. /**
  110144. * Computes the required SubMeshes according the materials assigned to the particles.
  110145. * @returns the solid particle system.
  110146. * Does nothing if called before the SPS mesh is built.
  110147. */
  110148. computeSubMeshes(): SolidParticleSystem;
  110149. /**
  110150. * Sorts the solid particles by material when MultiMaterial is enabled.
  110151. * Updates the indices32 array.
  110152. * Updates the indicesByMaterial array.
  110153. * Updates the mesh indices array.
  110154. * @returns the SPS
  110155. * @hidden
  110156. */
  110157. private _sortParticlesByMaterial;
  110158. /**
  110159. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  110160. * @hidden
  110161. */
  110162. private _setMaterialIndexesById;
  110163. /**
  110164. * Returns an array with unique values of Materials from the passed array
  110165. * @param array the material array to be checked and filtered
  110166. * @hidden
  110167. */
  110168. private _filterUniqueMaterialId;
  110169. /**
  110170. * Sets a new Standard Material as _defaultMaterial if not already set.
  110171. * @hidden
  110172. */
  110173. private _setDefaultMaterial;
  110174. /**
  110175. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  110176. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110177. * @returns the SPS.
  110178. */
  110179. refreshVisibleSize(): SolidParticleSystem;
  110180. /**
  110181. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  110182. * @param size the size (float) of the visibility box
  110183. * note : this doesn't lock the SPS mesh bounding box.
  110184. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110185. */
  110186. setVisibilityBox(size: number): void;
  110187. /**
  110188. * Gets whether the SPS as always visible or not
  110189. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110190. */
  110191. get isAlwaysVisible(): boolean;
  110192. /**
  110193. * Sets the SPS as always visible or not
  110194. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110195. */
  110196. set isAlwaysVisible(val: boolean);
  110197. /**
  110198. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110199. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110200. */
  110201. set isVisibilityBoxLocked(val: boolean);
  110202. /**
  110203. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  110204. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  110205. */
  110206. get isVisibilityBoxLocked(): boolean;
  110207. /**
  110208. * Tells to `setParticles()` to compute the particle rotations or not.
  110209. * Default value : true. The SPS is faster when it's set to false.
  110210. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110211. */
  110212. set computeParticleRotation(val: boolean);
  110213. /**
  110214. * Tells to `setParticles()` to compute the particle colors or not.
  110215. * Default value : true. The SPS is faster when it's set to false.
  110216. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110217. */
  110218. set computeParticleColor(val: boolean);
  110219. set computeParticleTexture(val: boolean);
  110220. /**
  110221. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  110222. * Default value : false. The SPS is faster when it's set to false.
  110223. * Note : the particle custom vertex positions aren't stored values.
  110224. */
  110225. set computeParticleVertex(val: boolean);
  110226. /**
  110227. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  110228. */
  110229. set computeBoundingBox(val: boolean);
  110230. /**
  110231. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  110232. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110233. * Default : `true`
  110234. */
  110235. set depthSortParticles(val: boolean);
  110236. /**
  110237. * Gets if `setParticles()` computes the particle rotations or not.
  110238. * Default value : true. The SPS is faster when it's set to false.
  110239. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  110240. */
  110241. get computeParticleRotation(): boolean;
  110242. /**
  110243. * Gets if `setParticles()` computes the particle colors or not.
  110244. * Default value : true. The SPS is faster when it's set to false.
  110245. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  110246. */
  110247. get computeParticleColor(): boolean;
  110248. /**
  110249. * Gets if `setParticles()` computes the particle textures or not.
  110250. * Default value : true. The SPS is faster when it's set to false.
  110251. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  110252. */
  110253. get computeParticleTexture(): boolean;
  110254. /**
  110255. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  110256. * Default value : false. The SPS is faster when it's set to false.
  110257. * Note : the particle custom vertex positions aren't stored values.
  110258. */
  110259. get computeParticleVertex(): boolean;
  110260. /**
  110261. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  110262. */
  110263. get computeBoundingBox(): boolean;
  110264. /**
  110265. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  110266. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  110267. * Default : `true`
  110268. */
  110269. get depthSortParticles(): boolean;
  110270. /**
  110271. * Gets if the SPS is created as expandable at construction time.
  110272. * Default : `false`
  110273. */
  110274. get expandable(): boolean;
  110275. /**
  110276. * Gets if the SPS supports the Multi Materials
  110277. */
  110278. get multimaterialEnabled(): boolean;
  110279. /**
  110280. * Gets if the SPS uses the model materials for its own multimaterial.
  110281. */
  110282. get useModelMaterial(): boolean;
  110283. /**
  110284. * The SPS used material array.
  110285. */
  110286. get materials(): Material[];
  110287. /**
  110288. * Sets the SPS MultiMaterial from the passed materials.
  110289. * Note : the passed array is internally copied and not used then by reference.
  110290. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  110291. */
  110292. setMultiMaterial(materials: Material[]): void;
  110293. /**
  110294. * The SPS computed multimaterial object
  110295. */
  110296. get multimaterial(): MultiMaterial;
  110297. set multimaterial(mm: MultiMaterial);
  110298. /**
  110299. * If the subMeshes must be updated on the next call to setParticles()
  110300. */
  110301. get autoUpdateSubMeshes(): boolean;
  110302. set autoUpdateSubMeshes(val: boolean);
  110303. /**
  110304. * This function does nothing. It may be overwritten to set all the particle first values.
  110305. * The SPS doesn't call this function, you may have to call it by your own.
  110306. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110307. */
  110308. initParticles(): void;
  110309. /**
  110310. * This function does nothing. It may be overwritten to recycle a particle.
  110311. * The SPS doesn't call this function, you may have to call it by your own.
  110312. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110313. * @param particle The particle to recycle
  110314. * @returns the recycled particle
  110315. */
  110316. recycleParticle(particle: SolidParticle): SolidParticle;
  110317. /**
  110318. * Updates a particle : this function should be overwritten by the user.
  110319. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  110320. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  110321. * @example : just set a particle position or velocity and recycle conditions
  110322. * @param particle The particle to update
  110323. * @returns the updated particle
  110324. */
  110325. updateParticle(particle: SolidParticle): SolidParticle;
  110326. /**
  110327. * Updates a vertex of a particle : it can be overwritten by the user.
  110328. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  110329. * @param particle the current particle
  110330. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  110331. * @param pt the index of the current vertex in the particle shape
  110332. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  110333. * @example : just set a vertex particle position or color
  110334. * @returns the sps
  110335. */
  110336. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  110337. /**
  110338. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  110339. * This does nothing and may be overwritten by the user.
  110340. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110341. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110342. * @param update the boolean update value actually passed to setParticles()
  110343. */
  110344. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110345. /**
  110346. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  110347. * This will be passed three parameters.
  110348. * This does nothing and may be overwritten by the user.
  110349. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110350. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  110351. * @param update the boolean update value actually passed to setParticles()
  110352. */
  110353. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  110354. }
  110355. }
  110356. declare module BABYLON {
  110357. /**
  110358. * Represents one particle of a solid particle system.
  110359. */
  110360. export class SolidParticle {
  110361. /**
  110362. * particle global index
  110363. */
  110364. idx: number;
  110365. /**
  110366. * particle identifier
  110367. */
  110368. id: number;
  110369. /**
  110370. * The color of the particle
  110371. */
  110372. color: Nullable<Color4>;
  110373. /**
  110374. * The world space position of the particle.
  110375. */
  110376. position: Vector3;
  110377. /**
  110378. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  110379. */
  110380. rotation: Vector3;
  110381. /**
  110382. * The world space rotation quaternion of the particle.
  110383. */
  110384. rotationQuaternion: Nullable<Quaternion>;
  110385. /**
  110386. * The scaling of the particle.
  110387. */
  110388. scaling: Vector3;
  110389. /**
  110390. * The uvs of the particle.
  110391. */
  110392. uvs: Vector4;
  110393. /**
  110394. * The current speed of the particle.
  110395. */
  110396. velocity: Vector3;
  110397. /**
  110398. * The pivot point in the particle local space.
  110399. */
  110400. pivot: Vector3;
  110401. /**
  110402. * Must the particle be translated from its pivot point in its local space ?
  110403. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  110404. * Default : false
  110405. */
  110406. translateFromPivot: boolean;
  110407. /**
  110408. * Is the particle active or not ?
  110409. */
  110410. alive: boolean;
  110411. /**
  110412. * Is the particle visible or not ?
  110413. */
  110414. isVisible: boolean;
  110415. /**
  110416. * Index of this particle in the global "positions" array (Internal use)
  110417. * @hidden
  110418. */
  110419. _pos: number;
  110420. /**
  110421. * @hidden Index of this particle in the global "indices" array (Internal use)
  110422. */
  110423. _ind: number;
  110424. /**
  110425. * @hidden ModelShape of this particle (Internal use)
  110426. */
  110427. _model: ModelShape;
  110428. /**
  110429. * ModelShape id of this particle
  110430. */
  110431. shapeId: number;
  110432. /**
  110433. * Index of the particle in its shape id
  110434. */
  110435. idxInShape: number;
  110436. /**
  110437. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  110438. */
  110439. _modelBoundingInfo: BoundingInfo;
  110440. /**
  110441. * @hidden Particle BoundingInfo object (Internal use)
  110442. */
  110443. _boundingInfo: BoundingInfo;
  110444. /**
  110445. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  110446. */
  110447. _sps: SolidParticleSystem;
  110448. /**
  110449. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  110450. */
  110451. _stillInvisible: boolean;
  110452. /**
  110453. * @hidden Last computed particle rotation matrix
  110454. */
  110455. _rotationMatrix: number[];
  110456. /**
  110457. * Parent particle Id, if any.
  110458. * Default null.
  110459. */
  110460. parentId: Nullable<number>;
  110461. /**
  110462. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  110463. */
  110464. materialIndex: Nullable<number>;
  110465. /**
  110466. * Custom object or properties.
  110467. */
  110468. props: Nullable<any>;
  110469. /**
  110470. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  110471. * The possible values are :
  110472. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110473. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110474. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110475. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110476. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110477. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  110478. * */
  110479. cullingStrategy: number;
  110480. /**
  110481. * @hidden Internal global position in the SPS.
  110482. */
  110483. _globalPosition: Vector3;
  110484. /**
  110485. * Creates a Solid Particle object.
  110486. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  110487. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  110488. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  110489. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  110490. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  110491. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  110492. * @param shapeId (integer) is the model shape identifier in the SPS.
  110493. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  110494. * @param sps defines the sps it is associated to
  110495. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  110496. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  110497. */
  110498. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  110499. /**
  110500. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  110501. * @param target the particle target
  110502. * @returns the current particle
  110503. */
  110504. copyToRef(target: SolidParticle): SolidParticle;
  110505. /**
  110506. * Legacy support, changed scale to scaling
  110507. */
  110508. get scale(): Vector3;
  110509. /**
  110510. * Legacy support, changed scale to scaling
  110511. */
  110512. set scale(scale: Vector3);
  110513. /**
  110514. * Legacy support, changed quaternion to rotationQuaternion
  110515. */
  110516. get quaternion(): Nullable<Quaternion>;
  110517. /**
  110518. * Legacy support, changed quaternion to rotationQuaternion
  110519. */
  110520. set quaternion(q: Nullable<Quaternion>);
  110521. /**
  110522. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  110523. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  110524. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  110525. * @returns true if it intersects
  110526. */
  110527. intersectsMesh(target: Mesh | SolidParticle): boolean;
  110528. /**
  110529. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  110530. * A particle is in the frustum if its bounding box intersects the frustum
  110531. * @param frustumPlanes defines the frustum to test
  110532. * @returns true if the particle is in the frustum planes
  110533. */
  110534. isInFrustum(frustumPlanes: Plane[]): boolean;
  110535. /**
  110536. * get the rotation matrix of the particle
  110537. * @hidden
  110538. */
  110539. getRotationMatrix(m: Matrix): void;
  110540. }
  110541. /**
  110542. * Represents the shape of the model used by one particle of a solid particle system.
  110543. * SPS internal tool, don't use it manually.
  110544. */
  110545. export class ModelShape {
  110546. /**
  110547. * The shape id
  110548. * @hidden
  110549. */
  110550. shapeID: number;
  110551. /**
  110552. * flat array of model positions (internal use)
  110553. * @hidden
  110554. */
  110555. _shape: Vector3[];
  110556. /**
  110557. * flat array of model UVs (internal use)
  110558. * @hidden
  110559. */
  110560. _shapeUV: number[];
  110561. /**
  110562. * color array of the model
  110563. * @hidden
  110564. */
  110565. _shapeColors: number[];
  110566. /**
  110567. * indices array of the model
  110568. * @hidden
  110569. */
  110570. _indices: number[];
  110571. /**
  110572. * normals array of the model
  110573. * @hidden
  110574. */
  110575. _normals: number[];
  110576. /**
  110577. * length of the shape in the model indices array (internal use)
  110578. * @hidden
  110579. */
  110580. _indicesLength: number;
  110581. /**
  110582. * Custom position function (internal use)
  110583. * @hidden
  110584. */
  110585. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  110586. /**
  110587. * Custom vertex function (internal use)
  110588. * @hidden
  110589. */
  110590. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  110591. /**
  110592. * Model material (internal use)
  110593. * @hidden
  110594. */
  110595. _material: Nullable<Material>;
  110596. /**
  110597. * 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.
  110598. * SPS internal tool, don't use it manually.
  110599. * @hidden
  110600. */
  110601. 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>);
  110602. }
  110603. /**
  110604. * Represents a Depth Sorted Particle in the solid particle system.
  110605. * @hidden
  110606. */
  110607. export class DepthSortedParticle {
  110608. /**
  110609. * Particle index
  110610. */
  110611. idx: number;
  110612. /**
  110613. * Index of the particle in the "indices" array
  110614. */
  110615. ind: number;
  110616. /**
  110617. * Length of the particle shape in the "indices" array
  110618. */
  110619. indicesLength: number;
  110620. /**
  110621. * Squared distance from the particle to the camera
  110622. */
  110623. sqDistance: number;
  110624. /**
  110625. * Material index when used with MultiMaterials
  110626. */
  110627. materialIndex: number;
  110628. /**
  110629. * Creates a new sorted particle
  110630. * @param materialIndex
  110631. */
  110632. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  110633. }
  110634. /**
  110635. * Represents a solid particle vertex
  110636. */
  110637. export class SolidParticleVertex {
  110638. /**
  110639. * Vertex position
  110640. */
  110641. position: Vector3;
  110642. /**
  110643. * Vertex color
  110644. */
  110645. color: Color4;
  110646. /**
  110647. * Vertex UV
  110648. */
  110649. uv: Vector2;
  110650. /**
  110651. * Creates a new solid particle vertex
  110652. */
  110653. constructor();
  110654. /** Vertex x coordinate */
  110655. get x(): number;
  110656. set x(val: number);
  110657. /** Vertex y coordinate */
  110658. get y(): number;
  110659. set y(val: number);
  110660. /** Vertex z coordinate */
  110661. get z(): number;
  110662. set z(val: number);
  110663. }
  110664. }
  110665. declare module BABYLON {
  110666. /**
  110667. * @hidden
  110668. */
  110669. export class _MeshCollisionData {
  110670. _checkCollisions: boolean;
  110671. _collisionMask: number;
  110672. _collisionGroup: number;
  110673. _surroundingMeshes: Nullable<AbstractMesh[]>;
  110674. _collider: Nullable<Collider>;
  110675. _oldPositionForCollisions: Vector3;
  110676. _diffPositionForCollisions: Vector3;
  110677. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  110678. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  110679. }
  110680. }
  110681. declare module BABYLON {
  110682. /** @hidden */
  110683. class _FacetDataStorage {
  110684. facetPositions: Vector3[];
  110685. facetNormals: Vector3[];
  110686. facetPartitioning: number[][];
  110687. facetNb: number;
  110688. partitioningSubdivisions: number;
  110689. partitioningBBoxRatio: number;
  110690. facetDataEnabled: boolean;
  110691. facetParameters: any;
  110692. bbSize: Vector3;
  110693. subDiv: {
  110694. max: number;
  110695. X: number;
  110696. Y: number;
  110697. Z: number;
  110698. };
  110699. facetDepthSort: boolean;
  110700. facetDepthSortEnabled: boolean;
  110701. depthSortedIndices: IndicesArray;
  110702. depthSortedFacets: {
  110703. ind: number;
  110704. sqDistance: number;
  110705. }[];
  110706. facetDepthSortFunction: (f1: {
  110707. ind: number;
  110708. sqDistance: number;
  110709. }, f2: {
  110710. ind: number;
  110711. sqDistance: number;
  110712. }) => number;
  110713. facetDepthSortFrom: Vector3;
  110714. facetDepthSortOrigin: Vector3;
  110715. invertedMatrix: Matrix;
  110716. }
  110717. /**
  110718. * @hidden
  110719. **/
  110720. class _InternalAbstractMeshDataInfo {
  110721. _hasVertexAlpha: boolean;
  110722. _useVertexColors: boolean;
  110723. _numBoneInfluencers: number;
  110724. _applyFog: boolean;
  110725. _receiveShadows: boolean;
  110726. _facetData: _FacetDataStorage;
  110727. _visibility: number;
  110728. _skeleton: Nullable<Skeleton>;
  110729. _layerMask: number;
  110730. _computeBonesUsingShaders: boolean;
  110731. _isActive: boolean;
  110732. _onlyForInstances: boolean;
  110733. _isActiveIntermediate: boolean;
  110734. _onlyForInstancesIntermediate: boolean;
  110735. _actAsRegularMesh: boolean;
  110736. }
  110737. /**
  110738. * Class used to store all common mesh properties
  110739. */
  110740. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  110741. /** No occlusion */
  110742. static OCCLUSION_TYPE_NONE: number;
  110743. /** Occlusion set to optimisitic */
  110744. static OCCLUSION_TYPE_OPTIMISTIC: number;
  110745. /** Occlusion set to strict */
  110746. static OCCLUSION_TYPE_STRICT: number;
  110747. /** Use an accurante occlusion algorithm */
  110748. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  110749. /** Use a conservative occlusion algorithm */
  110750. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  110751. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  110752. * Test order :
  110753. * Is the bounding sphere outside the frustum ?
  110754. * If not, are the bounding box vertices outside the frustum ?
  110755. * It not, then the cullable object is in the frustum.
  110756. */
  110757. static readonly CULLINGSTRATEGY_STANDARD: number;
  110758. /** Culling strategy : Bounding Sphere Only.
  110759. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  110760. * It's also less accurate than the standard because some not visible objects can still be selected.
  110761. * Test : is the bounding sphere outside the frustum ?
  110762. * If not, then the cullable object is in the frustum.
  110763. */
  110764. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  110765. /** Culling strategy : Optimistic Inclusion.
  110766. * This in an inclusion test first, then the standard exclusion test.
  110767. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  110768. * 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.
  110769. * Anyway, it's as accurate as the standard strategy.
  110770. * Test :
  110771. * Is the cullable object bounding sphere center in the frustum ?
  110772. * If not, apply the default culling strategy.
  110773. */
  110774. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  110775. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  110776. * This in an inclusion test first, then the bounding sphere only exclusion test.
  110777. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  110778. * 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.
  110779. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  110780. * Test :
  110781. * Is the cullable object bounding sphere center in the frustum ?
  110782. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  110783. */
  110784. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  110785. /**
  110786. * No billboard
  110787. */
  110788. static get BILLBOARDMODE_NONE(): number;
  110789. /** Billboard on X axis */
  110790. static get BILLBOARDMODE_X(): number;
  110791. /** Billboard on Y axis */
  110792. static get BILLBOARDMODE_Y(): number;
  110793. /** Billboard on Z axis */
  110794. static get BILLBOARDMODE_Z(): number;
  110795. /** Billboard on all axes */
  110796. static get BILLBOARDMODE_ALL(): number;
  110797. /** Billboard on using position instead of orientation */
  110798. static get BILLBOARDMODE_USE_POSITION(): number;
  110799. /** @hidden */
  110800. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  110801. /**
  110802. * The culling strategy to use to check whether the mesh must be rendered or not.
  110803. * This value can be changed at any time and will be used on the next render mesh selection.
  110804. * The possible values are :
  110805. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  110806. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  110807. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  110808. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  110809. * Please read each static variable documentation to get details about the culling process.
  110810. * */
  110811. cullingStrategy: number;
  110812. /**
  110813. * Gets the number of facets in the mesh
  110814. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110815. */
  110816. get facetNb(): number;
  110817. /**
  110818. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  110819. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110820. */
  110821. get partitioningSubdivisions(): number;
  110822. set partitioningSubdivisions(nb: number);
  110823. /**
  110824. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  110825. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  110826. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  110827. */
  110828. get partitioningBBoxRatio(): number;
  110829. set partitioningBBoxRatio(ratio: number);
  110830. /**
  110831. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  110832. * Works only for updatable meshes.
  110833. * Doesn't work with multi-materials
  110834. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110835. */
  110836. get mustDepthSortFacets(): boolean;
  110837. set mustDepthSortFacets(sort: boolean);
  110838. /**
  110839. * The location (Vector3) where the facet depth sort must be computed from.
  110840. * By default, the active camera position.
  110841. * Used only when facet depth sort is enabled
  110842. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  110843. */
  110844. get facetDepthSortFrom(): Vector3;
  110845. set facetDepthSortFrom(location: Vector3);
  110846. /**
  110847. * gets a boolean indicating if facetData is enabled
  110848. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  110849. */
  110850. get isFacetDataEnabled(): boolean;
  110851. /** @hidden */
  110852. _updateNonUniformScalingState(value: boolean): boolean;
  110853. /**
  110854. * An event triggered when this mesh collides with another one
  110855. */
  110856. onCollideObservable: Observable<AbstractMesh>;
  110857. /** Set a function to call when this mesh collides with another one */
  110858. set onCollide(callback: () => void);
  110859. /**
  110860. * An event triggered when the collision's position changes
  110861. */
  110862. onCollisionPositionChangeObservable: Observable<Vector3>;
  110863. /** Set a function to call when the collision's position changes */
  110864. set onCollisionPositionChange(callback: () => void);
  110865. /**
  110866. * An event triggered when material is changed
  110867. */
  110868. onMaterialChangedObservable: Observable<AbstractMesh>;
  110869. /**
  110870. * Gets or sets the orientation for POV movement & rotation
  110871. */
  110872. definedFacingForward: boolean;
  110873. /** @hidden */
  110874. _occlusionQuery: Nullable<WebGLQuery>;
  110875. /** @hidden */
  110876. _renderingGroup: Nullable<RenderingGroup>;
  110877. /**
  110878. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110879. */
  110880. get visibility(): number;
  110881. /**
  110882. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  110883. */
  110884. set visibility(value: number);
  110885. /** Gets or sets the alpha index used to sort transparent meshes
  110886. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  110887. */
  110888. alphaIndex: number;
  110889. /**
  110890. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  110891. */
  110892. isVisible: boolean;
  110893. /**
  110894. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  110895. */
  110896. isPickable: boolean;
  110897. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  110898. showSubMeshesBoundingBox: boolean;
  110899. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  110900. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110901. */
  110902. isBlocker: boolean;
  110903. /**
  110904. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  110905. */
  110906. enablePointerMoveEvents: boolean;
  110907. /**
  110908. * Specifies the rendering group id for this mesh (0 by default)
  110909. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  110910. */
  110911. renderingGroupId: number;
  110912. private _material;
  110913. /** Gets or sets current material */
  110914. get material(): Nullable<Material>;
  110915. set material(value: Nullable<Material>);
  110916. /**
  110917. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  110918. * @see https://doc.babylonjs.com/babylon101/shadows
  110919. */
  110920. get receiveShadows(): boolean;
  110921. set receiveShadows(value: boolean);
  110922. /** Defines color to use when rendering outline */
  110923. outlineColor: Color3;
  110924. /** Define width to use when rendering outline */
  110925. outlineWidth: number;
  110926. /** Defines color to use when rendering overlay */
  110927. overlayColor: Color3;
  110928. /** Defines alpha to use when rendering overlay */
  110929. overlayAlpha: number;
  110930. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  110931. get hasVertexAlpha(): boolean;
  110932. set hasVertexAlpha(value: boolean);
  110933. /** 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) */
  110934. get useVertexColors(): boolean;
  110935. set useVertexColors(value: boolean);
  110936. /**
  110937. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  110938. */
  110939. get computeBonesUsingShaders(): boolean;
  110940. set computeBonesUsingShaders(value: boolean);
  110941. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  110942. get numBoneInfluencers(): number;
  110943. set numBoneInfluencers(value: number);
  110944. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  110945. get applyFog(): boolean;
  110946. set applyFog(value: boolean);
  110947. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  110948. useOctreeForRenderingSelection: boolean;
  110949. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  110950. useOctreeForPicking: boolean;
  110951. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  110952. useOctreeForCollisions: boolean;
  110953. /**
  110954. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  110955. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  110956. */
  110957. get layerMask(): number;
  110958. set layerMask(value: number);
  110959. /**
  110960. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  110961. */
  110962. alwaysSelectAsActiveMesh: boolean;
  110963. /**
  110964. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  110965. */
  110966. doNotSyncBoundingInfo: boolean;
  110967. /**
  110968. * Gets or sets the current action manager
  110969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110970. */
  110971. actionManager: Nullable<AbstractActionManager>;
  110972. private _meshCollisionData;
  110973. /**
  110974. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  110975. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110976. */
  110977. ellipsoid: Vector3;
  110978. /**
  110979. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  110980. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110981. */
  110982. ellipsoidOffset: Vector3;
  110983. /**
  110984. * Gets or sets a collision mask used to mask collisions (default is -1).
  110985. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110986. */
  110987. get collisionMask(): number;
  110988. set collisionMask(mask: number);
  110989. /**
  110990. * Gets or sets the current collision group mask (-1 by default).
  110991. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  110992. */
  110993. get collisionGroup(): number;
  110994. set collisionGroup(mask: number);
  110995. /**
  110996. * Gets or sets current surrounding meshes (null by default).
  110997. *
  110998. * By default collision detection is tested against every mesh in the scene.
  110999. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  111000. * meshes will be tested for the collision.
  111001. *
  111002. * Note: if set to an empty array no collision will happen when this mesh is moved.
  111003. */
  111004. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  111005. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  111006. /**
  111007. * Defines edge width used when edgesRenderer is enabled
  111008. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111009. */
  111010. edgesWidth: number;
  111011. /**
  111012. * Defines edge color used when edgesRenderer is enabled
  111013. * @see https://www.babylonjs-playground.com/#10OJSG#13
  111014. */
  111015. edgesColor: Color4;
  111016. /** @hidden */
  111017. _edgesRenderer: Nullable<IEdgesRenderer>;
  111018. /** @hidden */
  111019. _masterMesh: Nullable<AbstractMesh>;
  111020. /** @hidden */
  111021. _boundingInfo: Nullable<BoundingInfo>;
  111022. /** @hidden */
  111023. _renderId: number;
  111024. /**
  111025. * Gets or sets the list of subMeshes
  111026. * @see https://doc.babylonjs.com/how_to/multi_materials
  111027. */
  111028. subMeshes: SubMesh[];
  111029. /** @hidden */
  111030. _intersectionsInProgress: AbstractMesh[];
  111031. /** @hidden */
  111032. _unIndexed: boolean;
  111033. /** @hidden */
  111034. _lightSources: Light[];
  111035. /** Gets the list of lights affecting that mesh */
  111036. get lightSources(): Light[];
  111037. /** @hidden */
  111038. get _positions(): Nullable<Vector3[]>;
  111039. /** @hidden */
  111040. _waitingData: {
  111041. lods: Nullable<any>;
  111042. actions: Nullable<any>;
  111043. freezeWorldMatrix: Nullable<boolean>;
  111044. };
  111045. /** @hidden */
  111046. _bonesTransformMatrices: Nullable<Float32Array>;
  111047. /** @hidden */
  111048. _transformMatrixTexture: Nullable<RawTexture>;
  111049. /**
  111050. * Gets or sets a skeleton to apply skining transformations
  111051. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111052. */
  111053. set skeleton(value: Nullable<Skeleton>);
  111054. get skeleton(): Nullable<Skeleton>;
  111055. /**
  111056. * An event triggered when the mesh is rebuilt.
  111057. */
  111058. onRebuildObservable: Observable<AbstractMesh>;
  111059. /**
  111060. * Creates a new AbstractMesh
  111061. * @param name defines the name of the mesh
  111062. * @param scene defines the hosting scene
  111063. */
  111064. constructor(name: string, scene?: Nullable<Scene>);
  111065. /**
  111066. * Returns the string "AbstractMesh"
  111067. * @returns "AbstractMesh"
  111068. */
  111069. getClassName(): string;
  111070. /**
  111071. * Gets a string representation of the current mesh
  111072. * @param fullDetails defines a boolean indicating if full details must be included
  111073. * @returns a string representation of the current mesh
  111074. */
  111075. toString(fullDetails?: boolean): string;
  111076. /**
  111077. * @hidden
  111078. */
  111079. protected _getEffectiveParent(): Nullable<Node>;
  111080. /** @hidden */
  111081. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111082. /** @hidden */
  111083. _rebuild(): void;
  111084. /** @hidden */
  111085. _resyncLightSources(): void;
  111086. /** @hidden */
  111087. _resyncLightSource(light: Light): void;
  111088. /** @hidden */
  111089. _unBindEffect(): void;
  111090. /** @hidden */
  111091. _removeLightSource(light: Light, dispose: boolean): void;
  111092. private _markSubMeshesAsDirty;
  111093. /** @hidden */
  111094. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  111095. /** @hidden */
  111096. _markSubMeshesAsAttributesDirty(): void;
  111097. /** @hidden */
  111098. _markSubMeshesAsMiscDirty(): void;
  111099. /**
  111100. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  111101. */
  111102. get scaling(): Vector3;
  111103. set scaling(newScaling: Vector3);
  111104. /**
  111105. * Returns true if the mesh is blocked. Implemented by child classes
  111106. */
  111107. get isBlocked(): boolean;
  111108. /**
  111109. * Returns the mesh itself by default. Implemented by child classes
  111110. * @param camera defines the camera to use to pick the right LOD level
  111111. * @returns the currentAbstractMesh
  111112. */
  111113. getLOD(camera: Camera): Nullable<AbstractMesh>;
  111114. /**
  111115. * Returns 0 by default. Implemented by child classes
  111116. * @returns an integer
  111117. */
  111118. getTotalVertices(): number;
  111119. /**
  111120. * Returns a positive integer : the total number of indices in this mesh geometry.
  111121. * @returns the numner of indices or zero if the mesh has no geometry.
  111122. */
  111123. getTotalIndices(): number;
  111124. /**
  111125. * Returns null by default. Implemented by child classes
  111126. * @returns null
  111127. */
  111128. getIndices(): Nullable<IndicesArray>;
  111129. /**
  111130. * Returns the array of the requested vertex data kind. Implemented by child classes
  111131. * @param kind defines the vertex data kind to use
  111132. * @returns null
  111133. */
  111134. getVerticesData(kind: string): Nullable<FloatArray>;
  111135. /**
  111136. * Sets the vertex data of the mesh geometry for the requested `kind`.
  111137. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  111138. * Note that a new underlying VertexBuffer object is created each call.
  111139. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  111140. * @param kind defines vertex data kind:
  111141. * * VertexBuffer.PositionKind
  111142. * * VertexBuffer.UVKind
  111143. * * VertexBuffer.UV2Kind
  111144. * * VertexBuffer.UV3Kind
  111145. * * VertexBuffer.UV4Kind
  111146. * * VertexBuffer.UV5Kind
  111147. * * VertexBuffer.UV6Kind
  111148. * * VertexBuffer.ColorKind
  111149. * * VertexBuffer.MatricesIndicesKind
  111150. * * VertexBuffer.MatricesIndicesExtraKind
  111151. * * VertexBuffer.MatricesWeightsKind
  111152. * * VertexBuffer.MatricesWeightsExtraKind
  111153. * @param data defines the data source
  111154. * @param updatable defines if the data must be flagged as updatable (or static)
  111155. * @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
  111156. * @returns the current mesh
  111157. */
  111158. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  111159. /**
  111160. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  111161. * If the mesh has no geometry, it is simply returned as it is.
  111162. * @param kind defines vertex data kind:
  111163. * * VertexBuffer.PositionKind
  111164. * * VertexBuffer.UVKind
  111165. * * VertexBuffer.UV2Kind
  111166. * * VertexBuffer.UV3Kind
  111167. * * VertexBuffer.UV4Kind
  111168. * * VertexBuffer.UV5Kind
  111169. * * VertexBuffer.UV6Kind
  111170. * * VertexBuffer.ColorKind
  111171. * * VertexBuffer.MatricesIndicesKind
  111172. * * VertexBuffer.MatricesIndicesExtraKind
  111173. * * VertexBuffer.MatricesWeightsKind
  111174. * * VertexBuffer.MatricesWeightsExtraKind
  111175. * @param data defines the data source
  111176. * @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
  111177. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  111178. * @returns the current mesh
  111179. */
  111180. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  111181. /**
  111182. * Sets the mesh indices,
  111183. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  111184. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  111185. * @param totalVertices Defines the total number of vertices
  111186. * @returns the current mesh
  111187. */
  111188. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  111189. /**
  111190. * Gets a boolean indicating if specific vertex data is present
  111191. * @param kind defines the vertex data kind to use
  111192. * @returns true is data kind is present
  111193. */
  111194. isVerticesDataPresent(kind: string): boolean;
  111195. /**
  111196. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  111197. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  111198. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  111199. * @returns a BoundingInfo
  111200. */
  111201. getBoundingInfo(): BoundingInfo;
  111202. /**
  111203. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  111204. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  111205. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  111206. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  111207. * @returns the current mesh
  111208. */
  111209. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  111210. /**
  111211. * Overwrite the current bounding info
  111212. * @param boundingInfo defines the new bounding info
  111213. * @returns the current mesh
  111214. */
  111215. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  111216. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  111217. get useBones(): boolean;
  111218. /** @hidden */
  111219. _preActivate(): void;
  111220. /** @hidden */
  111221. _preActivateForIntermediateRendering(renderId: number): void;
  111222. /** @hidden */
  111223. _activate(renderId: number, intermediateRendering: boolean): boolean;
  111224. /** @hidden */
  111225. _postActivate(): void;
  111226. /** @hidden */
  111227. _freeze(): void;
  111228. /** @hidden */
  111229. _unFreeze(): void;
  111230. /**
  111231. * Gets the current world matrix
  111232. * @returns a Matrix
  111233. */
  111234. getWorldMatrix(): Matrix;
  111235. /** @hidden */
  111236. _getWorldMatrixDeterminant(): number;
  111237. /**
  111238. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  111239. */
  111240. get isAnInstance(): boolean;
  111241. /**
  111242. * Gets a boolean indicating if this mesh has instances
  111243. */
  111244. get hasInstances(): boolean;
  111245. /**
  111246. * Gets a boolean indicating if this mesh has thin instances
  111247. */
  111248. get hasThinInstances(): boolean;
  111249. /**
  111250. * Perform relative position change from the point of view of behind the front of the mesh.
  111251. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111252. * Supports definition of mesh facing forward or backward
  111253. * @param amountRight defines the distance on the right axis
  111254. * @param amountUp defines the distance on the up axis
  111255. * @param amountForward defines the distance on the forward axis
  111256. * @returns the current mesh
  111257. */
  111258. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  111259. /**
  111260. * Calculate relative position change from the point of view of behind the front of the mesh.
  111261. * This is performed taking into account the meshes current rotation, so you do not have to care.
  111262. * Supports definition of mesh facing forward or backward
  111263. * @param amountRight defines the distance on the right axis
  111264. * @param amountUp defines the distance on the up axis
  111265. * @param amountForward defines the distance on the forward axis
  111266. * @returns the new displacement vector
  111267. */
  111268. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  111269. /**
  111270. * Perform relative rotation change from the point of view of behind the front of the mesh.
  111271. * Supports definition of mesh facing forward or backward
  111272. * @param flipBack defines the flip
  111273. * @param twirlClockwise defines the twirl
  111274. * @param tiltRight defines the tilt
  111275. * @returns the current mesh
  111276. */
  111277. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  111278. /**
  111279. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  111280. * Supports definition of mesh facing forward or backward.
  111281. * @param flipBack defines the flip
  111282. * @param twirlClockwise defines the twirl
  111283. * @param tiltRight defines the tilt
  111284. * @returns the new rotation vector
  111285. */
  111286. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  111287. /**
  111288. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  111289. * This means the mesh underlying bounding box and sphere are recomputed.
  111290. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  111291. * @returns the current mesh
  111292. */
  111293. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  111294. /** @hidden */
  111295. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  111296. /** @hidden */
  111297. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  111298. /** @hidden */
  111299. _updateBoundingInfo(): AbstractMesh;
  111300. /** @hidden */
  111301. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  111302. /** @hidden */
  111303. protected _afterComputeWorldMatrix(): void;
  111304. /** @hidden */
  111305. get _effectiveMesh(): AbstractMesh;
  111306. /**
  111307. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  111308. * A mesh is in the frustum if its bounding box intersects the frustum
  111309. * @param frustumPlanes defines the frustum to test
  111310. * @returns true if the mesh is in the frustum planes
  111311. */
  111312. isInFrustum(frustumPlanes: Plane[]): boolean;
  111313. /**
  111314. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  111315. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  111316. * @param frustumPlanes defines the frustum to test
  111317. * @returns true if the mesh is completely in the frustum planes
  111318. */
  111319. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111320. /**
  111321. * True if the mesh intersects another mesh or a SolidParticle object
  111322. * @param mesh defines a target mesh or SolidParticle to test
  111323. * @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)
  111324. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  111325. * @returns true if there is an intersection
  111326. */
  111327. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  111328. /**
  111329. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  111330. * @param point defines the point to test
  111331. * @returns true if there is an intersection
  111332. */
  111333. intersectsPoint(point: Vector3): boolean;
  111334. /**
  111335. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  111336. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111337. */
  111338. get checkCollisions(): boolean;
  111339. set checkCollisions(collisionEnabled: boolean);
  111340. /**
  111341. * Gets Collider object used to compute collisions (not physics)
  111342. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111343. */
  111344. get collider(): Nullable<Collider>;
  111345. /**
  111346. * Move the mesh using collision engine
  111347. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111348. * @param displacement defines the requested displacement vector
  111349. * @returns the current mesh
  111350. */
  111351. moveWithCollisions(displacement: Vector3): AbstractMesh;
  111352. private _onCollisionPositionChange;
  111353. /** @hidden */
  111354. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  111355. /** @hidden */
  111356. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  111357. /** @hidden */
  111358. _checkCollision(collider: Collider): AbstractMesh;
  111359. /** @hidden */
  111360. _generatePointsArray(): boolean;
  111361. /**
  111362. * Checks if the passed Ray intersects with the mesh
  111363. * @param ray defines the ray to use
  111364. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  111365. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111366. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  111367. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  111368. * @returns the picking info
  111369. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  111370. */
  111371. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  111372. /**
  111373. * Clones the current mesh
  111374. * @param name defines the mesh name
  111375. * @param newParent defines the new mesh parent
  111376. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  111377. * @returns the new mesh
  111378. */
  111379. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  111380. /**
  111381. * Disposes all the submeshes of the current meshnp
  111382. * @returns the current mesh
  111383. */
  111384. releaseSubMeshes(): AbstractMesh;
  111385. /**
  111386. * Releases resources associated with this abstract mesh.
  111387. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111388. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111389. */
  111390. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111391. /**
  111392. * Adds the passed mesh as a child to the current mesh
  111393. * @param mesh defines the child mesh
  111394. * @returns the current mesh
  111395. */
  111396. addChild(mesh: AbstractMesh): AbstractMesh;
  111397. /**
  111398. * Removes the passed mesh from the current mesh children list
  111399. * @param mesh defines the child mesh
  111400. * @returns the current mesh
  111401. */
  111402. removeChild(mesh: AbstractMesh): AbstractMesh;
  111403. /** @hidden */
  111404. private _initFacetData;
  111405. /**
  111406. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  111407. * This method can be called within the render loop.
  111408. * 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
  111409. * @returns the current mesh
  111410. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111411. */
  111412. updateFacetData(): AbstractMesh;
  111413. /**
  111414. * Returns the facetLocalNormals array.
  111415. * The normals are expressed in the mesh local spac
  111416. * @returns an array of Vector3
  111417. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111418. */
  111419. getFacetLocalNormals(): Vector3[];
  111420. /**
  111421. * Returns the facetLocalPositions array.
  111422. * The facet positions are expressed in the mesh local space
  111423. * @returns an array of Vector3
  111424. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111425. */
  111426. getFacetLocalPositions(): Vector3[];
  111427. /**
  111428. * Returns the facetLocalPartioning array
  111429. * @returns an array of array of numbers
  111430. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111431. */
  111432. getFacetLocalPartitioning(): number[][];
  111433. /**
  111434. * Returns the i-th facet position in the world system.
  111435. * This method allocates a new Vector3 per call
  111436. * @param i defines the facet index
  111437. * @returns a new Vector3
  111438. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111439. */
  111440. getFacetPosition(i: number): Vector3;
  111441. /**
  111442. * Sets the reference Vector3 with the i-th facet position in the world system
  111443. * @param i defines the facet index
  111444. * @param ref defines the target vector
  111445. * @returns the current mesh
  111446. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111447. */
  111448. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  111449. /**
  111450. * Returns the i-th facet normal in the world system.
  111451. * This method allocates a new Vector3 per call
  111452. * @param i defines the facet index
  111453. * @returns a new Vector3
  111454. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111455. */
  111456. getFacetNormal(i: number): Vector3;
  111457. /**
  111458. * Sets the reference Vector3 with the i-th facet normal in the world system
  111459. * @param i defines the facet index
  111460. * @param ref defines the target vector
  111461. * @returns the current mesh
  111462. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111463. */
  111464. getFacetNormalToRef(i: number, ref: Vector3): this;
  111465. /**
  111466. * 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)
  111467. * @param x defines x coordinate
  111468. * @param y defines y coordinate
  111469. * @param z defines z coordinate
  111470. * @returns the array of facet indexes
  111471. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111472. */
  111473. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  111474. /**
  111475. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  111476. * @param projected sets as the (x,y,z) world projection on the facet
  111477. * @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
  111478. * @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
  111479. * @param x defines x coordinate
  111480. * @param y defines y coordinate
  111481. * @param z defines z coordinate
  111482. * @returns the face index if found (or null instead)
  111483. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111484. */
  111485. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111486. /**
  111487. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  111488. * @param projected sets as the (x,y,z) local projection on the facet
  111489. * @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
  111490. * @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
  111491. * @param x defines x coordinate
  111492. * @param y defines y coordinate
  111493. * @param z defines z coordinate
  111494. * @returns the face index if found (or null instead)
  111495. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111496. */
  111497. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  111498. /**
  111499. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  111500. * @returns the parameters
  111501. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111502. */
  111503. getFacetDataParameters(): any;
  111504. /**
  111505. * Disables the feature FacetData and frees the related memory
  111506. * @returns the current mesh
  111507. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  111508. */
  111509. disableFacetData(): AbstractMesh;
  111510. /**
  111511. * Updates the AbstractMesh indices array
  111512. * @param indices defines the data source
  111513. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  111514. * @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)
  111515. * @returns the current mesh
  111516. */
  111517. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  111518. /**
  111519. * Creates new normals data for the mesh
  111520. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  111521. * @returns the current mesh
  111522. */
  111523. createNormals(updatable: boolean): AbstractMesh;
  111524. /**
  111525. * Align the mesh with a normal
  111526. * @param normal defines the normal to use
  111527. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  111528. * @returns the current mesh
  111529. */
  111530. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  111531. /** @hidden */
  111532. _checkOcclusionQuery(): boolean;
  111533. /**
  111534. * Disables the mesh edge rendering mode
  111535. * @returns the currentAbstractMesh
  111536. */
  111537. disableEdgesRendering(): AbstractMesh;
  111538. /**
  111539. * Enables the edge rendering mode on the mesh.
  111540. * This mode makes the mesh edges visible
  111541. * @param epsilon defines the maximal distance between two angles to detect a face
  111542. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  111543. * @returns the currentAbstractMesh
  111544. * @see https://www.babylonjs-playground.com/#19O9TU#0
  111545. */
  111546. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  111547. /**
  111548. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  111549. * @returns an array of particle systems in the scene that use the mesh as an emitter
  111550. */
  111551. getConnectedParticleSystems(): IParticleSystem[];
  111552. }
  111553. }
  111554. declare module BABYLON {
  111555. /**
  111556. * Interface used to define ActionEvent
  111557. */
  111558. export interface IActionEvent {
  111559. /** The mesh or sprite that triggered the action */
  111560. source: any;
  111561. /** The X mouse cursor position at the time of the event */
  111562. pointerX: number;
  111563. /** The Y mouse cursor position at the time of the event */
  111564. pointerY: number;
  111565. /** The mesh that is currently pointed at (can be null) */
  111566. meshUnderPointer: Nullable<AbstractMesh>;
  111567. /** the original (browser) event that triggered the ActionEvent */
  111568. sourceEvent?: any;
  111569. /** additional data for the event */
  111570. additionalData?: any;
  111571. }
  111572. /**
  111573. * ActionEvent is the event being sent when an action is triggered.
  111574. */
  111575. export class ActionEvent implements IActionEvent {
  111576. /** The mesh or sprite that triggered the action */
  111577. source: any;
  111578. /** The X mouse cursor position at the time of the event */
  111579. pointerX: number;
  111580. /** The Y mouse cursor position at the time of the event */
  111581. pointerY: number;
  111582. /** The mesh that is currently pointed at (can be null) */
  111583. meshUnderPointer: Nullable<AbstractMesh>;
  111584. /** the original (browser) event that triggered the ActionEvent */
  111585. sourceEvent?: any;
  111586. /** additional data for the event */
  111587. additionalData?: any;
  111588. /**
  111589. * Creates a new ActionEvent
  111590. * @param source The mesh or sprite that triggered the action
  111591. * @param pointerX The X mouse cursor position at the time of the event
  111592. * @param pointerY The Y mouse cursor position at the time of the event
  111593. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  111594. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  111595. * @param additionalData additional data for the event
  111596. */
  111597. constructor(
  111598. /** The mesh or sprite that triggered the action */
  111599. source: any,
  111600. /** The X mouse cursor position at the time of the event */
  111601. pointerX: number,
  111602. /** The Y mouse cursor position at the time of the event */
  111603. pointerY: number,
  111604. /** The mesh that is currently pointed at (can be null) */
  111605. meshUnderPointer: Nullable<AbstractMesh>,
  111606. /** the original (browser) event that triggered the ActionEvent */
  111607. sourceEvent?: any,
  111608. /** additional data for the event */
  111609. additionalData?: any);
  111610. /**
  111611. * Helper function to auto-create an ActionEvent from a source mesh.
  111612. * @param source The source mesh that triggered the event
  111613. * @param evt The original (browser) event
  111614. * @param additionalData additional data for the event
  111615. * @returns the new ActionEvent
  111616. */
  111617. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  111618. /**
  111619. * Helper function to auto-create an ActionEvent from a source sprite
  111620. * @param source The source sprite that triggered the event
  111621. * @param scene Scene associated with the sprite
  111622. * @param evt The original (browser) event
  111623. * @param additionalData additional data for the event
  111624. * @returns the new ActionEvent
  111625. */
  111626. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  111627. /**
  111628. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  111629. * @param scene the scene where the event occurred
  111630. * @param evt The original (browser) event
  111631. * @returns the new ActionEvent
  111632. */
  111633. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  111634. /**
  111635. * Helper function to auto-create an ActionEvent from a primitive
  111636. * @param prim defines the target primitive
  111637. * @param pointerPos defines the pointer position
  111638. * @param evt The original (browser) event
  111639. * @param additionalData additional data for the event
  111640. * @returns the new ActionEvent
  111641. */
  111642. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  111643. }
  111644. }
  111645. declare module BABYLON {
  111646. /**
  111647. * Abstract class used to decouple action Manager from scene and meshes.
  111648. * Do not instantiate.
  111649. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111650. */
  111651. export abstract class AbstractActionManager implements IDisposable {
  111652. /** Gets the list of active triggers */
  111653. static Triggers: {
  111654. [key: string]: number;
  111655. };
  111656. /** Gets the cursor to use when hovering items */
  111657. hoverCursor: string;
  111658. /** Gets the list of actions */
  111659. actions: IAction[];
  111660. /**
  111661. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  111662. */
  111663. isRecursive: boolean;
  111664. /**
  111665. * Releases all associated resources
  111666. */
  111667. abstract dispose(): void;
  111668. /**
  111669. * Does this action manager has pointer triggers
  111670. */
  111671. abstract get hasPointerTriggers(): boolean;
  111672. /**
  111673. * Does this action manager has pick triggers
  111674. */
  111675. abstract get hasPickTriggers(): boolean;
  111676. /**
  111677. * Process a specific trigger
  111678. * @param trigger defines the trigger to process
  111679. * @param evt defines the event details to be processed
  111680. */
  111681. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  111682. /**
  111683. * Does this action manager handles actions of any of the given triggers
  111684. * @param triggers defines the triggers to be tested
  111685. * @return a boolean indicating whether one (or more) of the triggers is handled
  111686. */
  111687. abstract hasSpecificTriggers(triggers: number[]): boolean;
  111688. /**
  111689. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  111690. * speed.
  111691. * @param triggerA defines the trigger to be tested
  111692. * @param triggerB defines the trigger to be tested
  111693. * @return a boolean indicating whether one (or more) of the triggers is handled
  111694. */
  111695. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  111696. /**
  111697. * Does this action manager handles actions of a given trigger
  111698. * @param trigger defines the trigger to be tested
  111699. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  111700. * @return whether the trigger is handled
  111701. */
  111702. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  111703. /**
  111704. * Serialize this manager to a JSON object
  111705. * @param name defines the property name to store this manager
  111706. * @returns a JSON representation of this manager
  111707. */
  111708. abstract serialize(name: string): any;
  111709. /**
  111710. * Registers an action to this action manager
  111711. * @param action defines the action to be registered
  111712. * @return the action amended (prepared) after registration
  111713. */
  111714. abstract registerAction(action: IAction): Nullable<IAction>;
  111715. /**
  111716. * Unregisters an action to this action manager
  111717. * @param action defines the action to be unregistered
  111718. * @return a boolean indicating whether the action has been unregistered
  111719. */
  111720. abstract unregisterAction(action: IAction): Boolean;
  111721. /**
  111722. * Does exist one action manager with at least one trigger
  111723. **/
  111724. static get HasTriggers(): boolean;
  111725. /**
  111726. * Does exist one action manager with at least one pick trigger
  111727. **/
  111728. static get HasPickTriggers(): boolean;
  111729. /**
  111730. * Does exist one action manager that handles actions of a given trigger
  111731. * @param trigger defines the trigger to be tested
  111732. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  111733. **/
  111734. static HasSpecificTrigger(trigger: number): boolean;
  111735. }
  111736. }
  111737. declare module BABYLON {
  111738. /**
  111739. * Defines how a node can be built from a string name.
  111740. */
  111741. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  111742. /**
  111743. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  111744. */
  111745. export class Node implements IBehaviorAware<Node> {
  111746. /** @hidden */
  111747. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  111748. private static _NodeConstructors;
  111749. /**
  111750. * Add a new node constructor
  111751. * @param type defines the type name of the node to construct
  111752. * @param constructorFunc defines the constructor function
  111753. */
  111754. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  111755. /**
  111756. * Returns a node constructor based on type name
  111757. * @param type defines the type name
  111758. * @param name defines the new node name
  111759. * @param scene defines the hosting scene
  111760. * @param options defines optional options to transmit to constructors
  111761. * @returns the new constructor or null
  111762. */
  111763. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  111764. /**
  111765. * Gets or sets the name of the node
  111766. */
  111767. name: string;
  111768. /**
  111769. * Gets or sets the id of the node
  111770. */
  111771. id: string;
  111772. /**
  111773. * Gets or sets the unique id of the node
  111774. */
  111775. uniqueId: number;
  111776. /**
  111777. * Gets or sets a string used to store user defined state for the node
  111778. */
  111779. state: string;
  111780. /**
  111781. * Gets or sets an object used to store user defined information for the node
  111782. */
  111783. metadata: any;
  111784. /**
  111785. * For internal use only. Please do not use.
  111786. */
  111787. reservedDataStore: any;
  111788. /**
  111789. * List of inspectable custom properties (used by the Inspector)
  111790. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111791. */
  111792. inspectableCustomProperties: IInspectable[];
  111793. private _doNotSerialize;
  111794. /**
  111795. * Gets or sets a boolean used to define if the node must be serialized
  111796. */
  111797. get doNotSerialize(): boolean;
  111798. set doNotSerialize(value: boolean);
  111799. /** @hidden */
  111800. _isDisposed: boolean;
  111801. /**
  111802. * Gets a list of Animations associated with the node
  111803. */
  111804. animations: Animation[];
  111805. protected _ranges: {
  111806. [name: string]: Nullable<AnimationRange>;
  111807. };
  111808. /**
  111809. * Callback raised when the node is ready to be used
  111810. */
  111811. onReady: Nullable<(node: Node) => void>;
  111812. private _isEnabled;
  111813. private _isParentEnabled;
  111814. private _isReady;
  111815. /** @hidden */
  111816. _currentRenderId: number;
  111817. private _parentUpdateId;
  111818. /** @hidden */
  111819. _childUpdateId: number;
  111820. /** @hidden */
  111821. _waitingParentId: Nullable<string>;
  111822. /** @hidden */
  111823. _scene: Scene;
  111824. /** @hidden */
  111825. _cache: any;
  111826. private _parentNode;
  111827. private _children;
  111828. /** @hidden */
  111829. _worldMatrix: Matrix;
  111830. /** @hidden */
  111831. _worldMatrixDeterminant: number;
  111832. /** @hidden */
  111833. _worldMatrixDeterminantIsDirty: boolean;
  111834. /** @hidden */
  111835. private _sceneRootNodesIndex;
  111836. /**
  111837. * Gets a boolean indicating if the node has been disposed
  111838. * @returns true if the node was disposed
  111839. */
  111840. isDisposed(): boolean;
  111841. /**
  111842. * Gets or sets the parent of the node (without keeping the current position in the scene)
  111843. * @see https://doc.babylonjs.com/how_to/parenting
  111844. */
  111845. set parent(parent: Nullable<Node>);
  111846. get parent(): Nullable<Node>;
  111847. /** @hidden */
  111848. _addToSceneRootNodes(): void;
  111849. /** @hidden */
  111850. _removeFromSceneRootNodes(): void;
  111851. private _animationPropertiesOverride;
  111852. /**
  111853. * Gets or sets the animation properties override
  111854. */
  111855. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  111856. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  111857. /**
  111858. * Gets a string idenfifying the name of the class
  111859. * @returns "Node" string
  111860. */
  111861. getClassName(): string;
  111862. /** @hidden */
  111863. readonly _isNode: boolean;
  111864. /**
  111865. * An event triggered when the mesh is disposed
  111866. */
  111867. onDisposeObservable: Observable<Node>;
  111868. private _onDisposeObserver;
  111869. /**
  111870. * Sets a callback that will be raised when the node will be disposed
  111871. */
  111872. set onDispose(callback: () => void);
  111873. /**
  111874. * Creates a new Node
  111875. * @param name the name and id to be given to this node
  111876. * @param scene the scene this node will be added to
  111877. */
  111878. constructor(name: string, scene?: Nullable<Scene>);
  111879. /**
  111880. * Gets the scene of the node
  111881. * @returns a scene
  111882. */
  111883. getScene(): Scene;
  111884. /**
  111885. * Gets the engine of the node
  111886. * @returns a Engine
  111887. */
  111888. getEngine(): Engine;
  111889. private _behaviors;
  111890. /**
  111891. * Attach a behavior to the node
  111892. * @see https://doc.babylonjs.com/features/behaviour
  111893. * @param behavior defines the behavior to attach
  111894. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  111895. * @returns the current Node
  111896. */
  111897. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  111898. /**
  111899. * Remove an attached behavior
  111900. * @see https://doc.babylonjs.com/features/behaviour
  111901. * @param behavior defines the behavior to attach
  111902. * @returns the current Node
  111903. */
  111904. removeBehavior(behavior: Behavior<Node>): Node;
  111905. /**
  111906. * Gets the list of attached behaviors
  111907. * @see https://doc.babylonjs.com/features/behaviour
  111908. */
  111909. get behaviors(): Behavior<Node>[];
  111910. /**
  111911. * Gets an attached behavior by name
  111912. * @param name defines the name of the behavior to look for
  111913. * @see https://doc.babylonjs.com/features/behaviour
  111914. * @returns null if behavior was not found else the requested behavior
  111915. */
  111916. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  111917. /**
  111918. * Returns the latest update of the World matrix
  111919. * @returns a Matrix
  111920. */
  111921. getWorldMatrix(): Matrix;
  111922. /** @hidden */
  111923. _getWorldMatrixDeterminant(): number;
  111924. /**
  111925. * Returns directly the latest state of the mesh World matrix.
  111926. * A Matrix is returned.
  111927. */
  111928. get worldMatrixFromCache(): Matrix;
  111929. /** @hidden */
  111930. _initCache(): void;
  111931. /** @hidden */
  111932. updateCache(force?: boolean): void;
  111933. /** @hidden */
  111934. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  111935. /** @hidden */
  111936. _updateCache(ignoreParentClass?: boolean): void;
  111937. /** @hidden */
  111938. _isSynchronized(): boolean;
  111939. /** @hidden */
  111940. _markSyncedWithParent(): void;
  111941. /** @hidden */
  111942. isSynchronizedWithParent(): boolean;
  111943. /** @hidden */
  111944. isSynchronized(): boolean;
  111945. /**
  111946. * Is this node ready to be used/rendered
  111947. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  111948. * @return true if the node is ready
  111949. */
  111950. isReady(completeCheck?: boolean): boolean;
  111951. /**
  111952. * Is this node enabled?
  111953. * 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
  111954. * @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
  111955. * @return whether this node (and its parent) is enabled
  111956. */
  111957. isEnabled(checkAncestors?: boolean): boolean;
  111958. /** @hidden */
  111959. protected _syncParentEnabledState(): void;
  111960. /**
  111961. * Set the enabled state of this node
  111962. * @param value defines the new enabled state
  111963. */
  111964. setEnabled(value: boolean): void;
  111965. /**
  111966. * Is this node a descendant of the given node?
  111967. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  111968. * @param ancestor defines the parent node to inspect
  111969. * @returns a boolean indicating if this node is a descendant of the given node
  111970. */
  111971. isDescendantOf(ancestor: Node): boolean;
  111972. /** @hidden */
  111973. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  111974. /**
  111975. * Will return all nodes that have this node as ascendant
  111976. * @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
  111977. * @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
  111978. * @return all children nodes of all types
  111979. */
  111980. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  111981. /**
  111982. * Get all child-meshes of this node
  111983. * @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)
  111984. * @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
  111985. * @returns an array of AbstractMesh
  111986. */
  111987. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  111988. /**
  111989. * Get all direct children of this node
  111990. * @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
  111991. * @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)
  111992. * @returns an array of Node
  111993. */
  111994. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  111995. /** @hidden */
  111996. _setReady(state: boolean): void;
  111997. /**
  111998. * Get an animation by name
  111999. * @param name defines the name of the animation to look for
  112000. * @returns null if not found else the requested animation
  112001. */
  112002. getAnimationByName(name: string): Nullable<Animation>;
  112003. /**
  112004. * Creates an animation range for this node
  112005. * @param name defines the name of the range
  112006. * @param from defines the starting key
  112007. * @param to defines the end key
  112008. */
  112009. createAnimationRange(name: string, from: number, to: number): void;
  112010. /**
  112011. * Delete a specific animation range
  112012. * @param name defines the name of the range to delete
  112013. * @param deleteFrames defines if animation frames from the range must be deleted as well
  112014. */
  112015. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  112016. /**
  112017. * Get an animation range by name
  112018. * @param name defines the name of the animation range to look for
  112019. * @returns null if not found else the requested animation range
  112020. */
  112021. getAnimationRange(name: string): Nullable<AnimationRange>;
  112022. /**
  112023. * Gets the list of all animation ranges defined on this node
  112024. * @returns an array
  112025. */
  112026. getAnimationRanges(): Nullable<AnimationRange>[];
  112027. /**
  112028. * Will start the animation sequence
  112029. * @param name defines the range frames for animation sequence
  112030. * @param loop defines if the animation should loop (false by default)
  112031. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  112032. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  112033. * @returns the object created for this animation. If range does not exist, it will return null
  112034. */
  112035. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  112036. /**
  112037. * Serialize animation ranges into a JSON compatible object
  112038. * @returns serialization object
  112039. */
  112040. serializeAnimationRanges(): any;
  112041. /**
  112042. * Computes the world matrix of the node
  112043. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  112044. * @returns the world matrix
  112045. */
  112046. computeWorldMatrix(force?: boolean): Matrix;
  112047. /**
  112048. * Releases resources associated with this node.
  112049. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112050. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112051. */
  112052. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112053. /**
  112054. * Parse animation range data from a serialization object and store them into a given node
  112055. * @param node defines where to store the animation ranges
  112056. * @param parsedNode defines the serialization object to read data from
  112057. * @param scene defines the hosting scene
  112058. */
  112059. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  112060. /**
  112061. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  112062. * @param includeDescendants Include bounding info from descendants as well (true by default)
  112063. * @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
  112064. * @returns the new bounding vectors
  112065. */
  112066. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  112067. min: Vector3;
  112068. max: Vector3;
  112069. };
  112070. }
  112071. }
  112072. declare module BABYLON {
  112073. /**
  112074. * @hidden
  112075. */
  112076. export class _IAnimationState {
  112077. key: number;
  112078. repeatCount: number;
  112079. workValue?: any;
  112080. loopMode?: number;
  112081. offsetValue?: any;
  112082. highLimitValue?: any;
  112083. }
  112084. /**
  112085. * Class used to store any kind of animation
  112086. */
  112087. export class Animation {
  112088. /**Name of the animation */
  112089. name: string;
  112090. /**Property to animate */
  112091. targetProperty: string;
  112092. /**The frames per second of the animation */
  112093. framePerSecond: number;
  112094. /**The data type of the animation */
  112095. dataType: number;
  112096. /**The loop mode of the animation */
  112097. loopMode?: number | undefined;
  112098. /**Specifies if blending should be enabled */
  112099. enableBlending?: boolean | undefined;
  112100. /**
  112101. * Use matrix interpolation instead of using direct key value when animating matrices
  112102. */
  112103. static AllowMatricesInterpolation: boolean;
  112104. /**
  112105. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  112106. */
  112107. static AllowMatrixDecomposeForInterpolation: boolean;
  112108. /** Define the Url to load snippets */
  112109. static SnippetUrl: string;
  112110. /** Snippet ID if the animation was created from the snippet server */
  112111. snippetId: string;
  112112. /**
  112113. * Stores the key frames of the animation
  112114. */
  112115. private _keys;
  112116. /**
  112117. * Stores the easing function of the animation
  112118. */
  112119. private _easingFunction;
  112120. /**
  112121. * @hidden Internal use only
  112122. */
  112123. _runtimeAnimations: RuntimeAnimation[];
  112124. /**
  112125. * The set of event that will be linked to this animation
  112126. */
  112127. private _events;
  112128. /**
  112129. * Stores an array of target property paths
  112130. */
  112131. targetPropertyPath: string[];
  112132. /**
  112133. * Stores the blending speed of the animation
  112134. */
  112135. blendingSpeed: number;
  112136. /**
  112137. * Stores the animation ranges for the animation
  112138. */
  112139. private _ranges;
  112140. /**
  112141. * @hidden Internal use
  112142. */
  112143. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  112144. /**
  112145. * Sets up an animation
  112146. * @param property The property to animate
  112147. * @param animationType The animation type to apply
  112148. * @param framePerSecond The frames per second of the animation
  112149. * @param easingFunction The easing function used in the animation
  112150. * @returns The created animation
  112151. */
  112152. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  112153. /**
  112154. * Create and start an animation on a node
  112155. * @param name defines the name of the global animation that will be run on all nodes
  112156. * @param node defines the root node where the animation will take place
  112157. * @param targetProperty defines property to animate
  112158. * @param framePerSecond defines the number of frame per second yo use
  112159. * @param totalFrame defines the number of frames in total
  112160. * @param from defines the initial value
  112161. * @param to defines the final value
  112162. * @param loopMode defines which loop mode you want to use (off by default)
  112163. * @param easingFunction defines the easing function to use (linear by default)
  112164. * @param onAnimationEnd defines the callback to call when animation end
  112165. * @returns the animatable created for this animation
  112166. */
  112167. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112168. /**
  112169. * Create and start an animation on a node and its descendants
  112170. * @param name defines the name of the global animation that will be run on all nodes
  112171. * @param node defines the root node where the animation will take place
  112172. * @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
  112173. * @param targetProperty defines property to animate
  112174. * @param framePerSecond defines the number of frame per second to use
  112175. * @param totalFrame defines the number of frames in total
  112176. * @param from defines the initial value
  112177. * @param to defines the final value
  112178. * @param loopMode defines which loop mode you want to use (off by default)
  112179. * @param easingFunction defines the easing function to use (linear by default)
  112180. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  112181. * @returns the list of animatables created for all nodes
  112182. * @example https://www.babylonjs-playground.com/#MH0VLI
  112183. */
  112184. 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[]>;
  112185. /**
  112186. * Creates a new animation, merges it with the existing animations and starts it
  112187. * @param name Name of the animation
  112188. * @param node Node which contains the scene that begins the animations
  112189. * @param targetProperty Specifies which property to animate
  112190. * @param framePerSecond The frames per second of the animation
  112191. * @param totalFrame The total number of frames
  112192. * @param from The frame at the beginning of the animation
  112193. * @param to The frame at the end of the animation
  112194. * @param loopMode Specifies the loop mode of the animation
  112195. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  112196. * @param onAnimationEnd Callback to run once the animation is complete
  112197. * @returns Nullable animation
  112198. */
  112199. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  112200. /**
  112201. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  112202. * @param sourceAnimation defines the Animation containing keyframes to convert
  112203. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  112204. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  112205. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  112206. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  112207. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  112208. */
  112209. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  112210. /**
  112211. * Transition property of an host to the target Value
  112212. * @param property The property to transition
  112213. * @param targetValue The target Value of the property
  112214. * @param host The object where the property to animate belongs
  112215. * @param scene Scene used to run the animation
  112216. * @param frameRate Framerate (in frame/s) to use
  112217. * @param transition The transition type we want to use
  112218. * @param duration The duration of the animation, in milliseconds
  112219. * @param onAnimationEnd Callback trigger at the end of the animation
  112220. * @returns Nullable animation
  112221. */
  112222. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  112223. /**
  112224. * Return the array of runtime animations currently using this animation
  112225. */
  112226. get runtimeAnimations(): RuntimeAnimation[];
  112227. /**
  112228. * Specifies if any of the runtime animations are currently running
  112229. */
  112230. get hasRunningRuntimeAnimations(): boolean;
  112231. /**
  112232. * Initializes the animation
  112233. * @param name Name of the animation
  112234. * @param targetProperty Property to animate
  112235. * @param framePerSecond The frames per second of the animation
  112236. * @param dataType The data type of the animation
  112237. * @param loopMode The loop mode of the animation
  112238. * @param enableBlending Specifies if blending should be enabled
  112239. */
  112240. constructor(
  112241. /**Name of the animation */
  112242. name: string,
  112243. /**Property to animate */
  112244. targetProperty: string,
  112245. /**The frames per second of the animation */
  112246. framePerSecond: number,
  112247. /**The data type of the animation */
  112248. dataType: number,
  112249. /**The loop mode of the animation */
  112250. loopMode?: number | undefined,
  112251. /**Specifies if blending should be enabled */
  112252. enableBlending?: boolean | undefined);
  112253. /**
  112254. * Converts the animation to a string
  112255. * @param fullDetails support for multiple levels of logging within scene loading
  112256. * @returns String form of the animation
  112257. */
  112258. toString(fullDetails?: boolean): string;
  112259. /**
  112260. * Add an event to this animation
  112261. * @param event Event to add
  112262. */
  112263. addEvent(event: AnimationEvent): void;
  112264. /**
  112265. * Remove all events found at the given frame
  112266. * @param frame The frame to remove events from
  112267. */
  112268. removeEvents(frame: number): void;
  112269. /**
  112270. * Retrieves all the events from the animation
  112271. * @returns Events from the animation
  112272. */
  112273. getEvents(): AnimationEvent[];
  112274. /**
  112275. * Creates an animation range
  112276. * @param name Name of the animation range
  112277. * @param from Starting frame of the animation range
  112278. * @param to Ending frame of the animation
  112279. */
  112280. createRange(name: string, from: number, to: number): void;
  112281. /**
  112282. * Deletes an animation range by name
  112283. * @param name Name of the animation range to delete
  112284. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  112285. */
  112286. deleteRange(name: string, deleteFrames?: boolean): void;
  112287. /**
  112288. * Gets the animation range by name, or null if not defined
  112289. * @param name Name of the animation range
  112290. * @returns Nullable animation range
  112291. */
  112292. getRange(name: string): Nullable<AnimationRange>;
  112293. /**
  112294. * Gets the key frames from the animation
  112295. * @returns The key frames of the animation
  112296. */
  112297. getKeys(): Array<IAnimationKey>;
  112298. /**
  112299. * Gets the highest frame rate of the animation
  112300. * @returns Highest frame rate of the animation
  112301. */
  112302. getHighestFrame(): number;
  112303. /**
  112304. * Gets the easing function of the animation
  112305. * @returns Easing function of the animation
  112306. */
  112307. getEasingFunction(): IEasingFunction;
  112308. /**
  112309. * Sets the easing function of the animation
  112310. * @param easingFunction A custom mathematical formula for animation
  112311. */
  112312. setEasingFunction(easingFunction: EasingFunction): void;
  112313. /**
  112314. * Interpolates a scalar linearly
  112315. * @param startValue Start value of the animation curve
  112316. * @param endValue End value of the animation curve
  112317. * @param gradient Scalar amount to interpolate
  112318. * @returns Interpolated scalar value
  112319. */
  112320. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  112321. /**
  112322. * Interpolates a scalar cubically
  112323. * @param startValue Start value of the animation curve
  112324. * @param outTangent End tangent of the animation
  112325. * @param endValue End value of the animation curve
  112326. * @param inTangent Start tangent of the animation curve
  112327. * @param gradient Scalar amount to interpolate
  112328. * @returns Interpolated scalar value
  112329. */
  112330. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  112331. /**
  112332. * Interpolates a quaternion using a spherical linear interpolation
  112333. * @param startValue Start value of the animation curve
  112334. * @param endValue End value of the animation curve
  112335. * @param gradient Scalar amount to interpolate
  112336. * @returns Interpolated quaternion value
  112337. */
  112338. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  112339. /**
  112340. * Interpolates a quaternion cubically
  112341. * @param startValue Start value of the animation curve
  112342. * @param outTangent End tangent of the animation curve
  112343. * @param endValue End value of the animation curve
  112344. * @param inTangent Start tangent of the animation curve
  112345. * @param gradient Scalar amount to interpolate
  112346. * @returns Interpolated quaternion value
  112347. */
  112348. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  112349. /**
  112350. * Interpolates a Vector3 linearl
  112351. * @param startValue Start value of the animation curve
  112352. * @param endValue End value of the animation curve
  112353. * @param gradient Scalar amount to interpolate
  112354. * @returns Interpolated scalar value
  112355. */
  112356. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  112357. /**
  112358. * Interpolates a Vector3 cubically
  112359. * @param startValue Start value of the animation curve
  112360. * @param outTangent End tangent of the animation
  112361. * @param endValue End value of the animation curve
  112362. * @param inTangent Start tangent of the animation curve
  112363. * @param gradient Scalar amount to interpolate
  112364. * @returns InterpolatedVector3 value
  112365. */
  112366. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  112367. /**
  112368. * Interpolates a Vector2 linearly
  112369. * @param startValue Start value of the animation curve
  112370. * @param endValue End value of the animation curve
  112371. * @param gradient Scalar amount to interpolate
  112372. * @returns Interpolated Vector2 value
  112373. */
  112374. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  112375. /**
  112376. * Interpolates a Vector2 cubically
  112377. * @param startValue Start value of the animation curve
  112378. * @param outTangent End tangent of the animation
  112379. * @param endValue End value of the animation curve
  112380. * @param inTangent Start tangent of the animation curve
  112381. * @param gradient Scalar amount to interpolate
  112382. * @returns Interpolated Vector2 value
  112383. */
  112384. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  112385. /**
  112386. * Interpolates a size linearly
  112387. * @param startValue Start value of the animation curve
  112388. * @param endValue End value of the animation curve
  112389. * @param gradient Scalar amount to interpolate
  112390. * @returns Interpolated Size value
  112391. */
  112392. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  112393. /**
  112394. * Interpolates a Color3 linearly
  112395. * @param startValue Start value of the animation curve
  112396. * @param endValue End value of the animation curve
  112397. * @param gradient Scalar amount to interpolate
  112398. * @returns Interpolated Color3 value
  112399. */
  112400. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  112401. /**
  112402. * Interpolates a Color4 linearly
  112403. * @param startValue Start value of the animation curve
  112404. * @param endValue End value of the animation curve
  112405. * @param gradient Scalar amount to interpolate
  112406. * @returns Interpolated Color3 value
  112407. */
  112408. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  112409. /**
  112410. * @hidden Internal use only
  112411. */
  112412. _getKeyValue(value: any): any;
  112413. /**
  112414. * @hidden Internal use only
  112415. */
  112416. _interpolate(currentFrame: number, state: _IAnimationState): any;
  112417. /**
  112418. * Defines the function to use to interpolate matrices
  112419. * @param startValue defines the start matrix
  112420. * @param endValue defines the end matrix
  112421. * @param gradient defines the gradient between both matrices
  112422. * @param result defines an optional target matrix where to store the interpolation
  112423. * @returns the interpolated matrix
  112424. */
  112425. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  112426. /**
  112427. * Makes a copy of the animation
  112428. * @returns Cloned animation
  112429. */
  112430. clone(): Animation;
  112431. /**
  112432. * Sets the key frames of the animation
  112433. * @param values The animation key frames to set
  112434. */
  112435. setKeys(values: Array<IAnimationKey>): void;
  112436. /**
  112437. * Serializes the animation to an object
  112438. * @returns Serialized object
  112439. */
  112440. serialize(): any;
  112441. /**
  112442. * Float animation type
  112443. */
  112444. static readonly ANIMATIONTYPE_FLOAT: number;
  112445. /**
  112446. * Vector3 animation type
  112447. */
  112448. static readonly ANIMATIONTYPE_VECTOR3: number;
  112449. /**
  112450. * Quaternion animation type
  112451. */
  112452. static readonly ANIMATIONTYPE_QUATERNION: number;
  112453. /**
  112454. * Matrix animation type
  112455. */
  112456. static readonly ANIMATIONTYPE_MATRIX: number;
  112457. /**
  112458. * Color3 animation type
  112459. */
  112460. static readonly ANIMATIONTYPE_COLOR3: number;
  112461. /**
  112462. * Color3 animation type
  112463. */
  112464. static readonly ANIMATIONTYPE_COLOR4: number;
  112465. /**
  112466. * Vector2 animation type
  112467. */
  112468. static readonly ANIMATIONTYPE_VECTOR2: number;
  112469. /**
  112470. * Size animation type
  112471. */
  112472. static readonly ANIMATIONTYPE_SIZE: number;
  112473. /**
  112474. * Relative Loop Mode
  112475. */
  112476. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  112477. /**
  112478. * Cycle Loop Mode
  112479. */
  112480. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  112481. /**
  112482. * Constant Loop Mode
  112483. */
  112484. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  112485. /** @hidden */
  112486. static _UniversalLerp(left: any, right: any, amount: number): any;
  112487. /**
  112488. * Parses an animation object and creates an animation
  112489. * @param parsedAnimation Parsed animation object
  112490. * @returns Animation object
  112491. */
  112492. static Parse(parsedAnimation: any): Animation;
  112493. /**
  112494. * Appends the serialized animations from the source animations
  112495. * @param source Source containing the animations
  112496. * @param destination Target to store the animations
  112497. */
  112498. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112499. /**
  112500. * Creates a new animation or an array of animations from a snippet saved in a remote file
  112501. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  112502. * @param url defines the url to load from
  112503. * @returns a promise that will resolve to the new animation or an array of animations
  112504. */
  112505. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  112506. /**
  112507. * Creates an animation or an array of animations from a snippet saved by the Inspector
  112508. * @param snippetId defines the snippet to load
  112509. * @returns a promise that will resolve to the new animation or a new array of animations
  112510. */
  112511. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  112512. }
  112513. }
  112514. declare module BABYLON {
  112515. /**
  112516. * Interface containing an array of animations
  112517. */
  112518. export interface IAnimatable {
  112519. /**
  112520. * Array of animations
  112521. */
  112522. animations: Nullable<Array<Animation>>;
  112523. }
  112524. }
  112525. declare module BABYLON {
  112526. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  112527. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112528. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112529. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112530. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112531. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112532. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112533. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112534. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112535. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112536. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112537. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112538. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112539. /**
  112540. * Decorator used to define property that can be serialized as reference to a camera
  112541. * @param sourceName defines the name of the property to decorate
  112542. */
  112543. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  112544. /**
  112545. * Class used to help serialization objects
  112546. */
  112547. export class SerializationHelper {
  112548. /** @hidden */
  112549. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  112550. /** @hidden */
  112551. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  112552. /** @hidden */
  112553. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  112554. /** @hidden */
  112555. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  112556. /**
  112557. * Appends the serialized animations from the source animations
  112558. * @param source Source containing the animations
  112559. * @param destination Target to store the animations
  112560. */
  112561. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  112562. /**
  112563. * Static function used to serialized a specific entity
  112564. * @param entity defines the entity to serialize
  112565. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  112566. * @returns a JSON compatible object representing the serialization of the entity
  112567. */
  112568. static Serialize<T>(entity: T, serializationObject?: any): any;
  112569. /**
  112570. * Creates a new entity from a serialization data object
  112571. * @param creationFunction defines a function used to instanciated the new entity
  112572. * @param source defines the source serialization data
  112573. * @param scene defines the hosting scene
  112574. * @param rootUrl defines the root url for resources
  112575. * @returns a new entity
  112576. */
  112577. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  112578. /**
  112579. * Clones an object
  112580. * @param creationFunction defines the function used to instanciate the new object
  112581. * @param source defines the source object
  112582. * @returns the cloned object
  112583. */
  112584. static Clone<T>(creationFunction: () => T, source: T): T;
  112585. /**
  112586. * Instanciates a new object based on a source one (some data will be shared between both object)
  112587. * @param creationFunction defines the function used to instanciate the new object
  112588. * @param source defines the source object
  112589. * @returns the new object
  112590. */
  112591. static Instanciate<T>(creationFunction: () => T, source: T): T;
  112592. }
  112593. }
  112594. declare module BABYLON {
  112595. /**
  112596. * Base class of all the textures in babylon.
  112597. * It groups all the common properties the materials, post process, lights... might need
  112598. * in order to make a correct use of the texture.
  112599. */
  112600. export class BaseTexture implements IAnimatable {
  112601. /**
  112602. * Default anisotropic filtering level for the application.
  112603. * It is set to 4 as a good tradeoff between perf and quality.
  112604. */
  112605. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  112606. /**
  112607. * Gets or sets the unique id of the texture
  112608. */
  112609. uniqueId: number;
  112610. /**
  112611. * Define the name of the texture.
  112612. */
  112613. name: string;
  112614. /**
  112615. * Gets or sets an object used to store user defined information.
  112616. */
  112617. metadata: any;
  112618. /**
  112619. * For internal use only. Please do not use.
  112620. */
  112621. reservedDataStore: any;
  112622. private _hasAlpha;
  112623. /**
  112624. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  112625. */
  112626. set hasAlpha(value: boolean);
  112627. get hasAlpha(): boolean;
  112628. /**
  112629. * Defines if the alpha value should be determined via the rgb values.
  112630. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  112631. */
  112632. getAlphaFromRGB: boolean;
  112633. /**
  112634. * Intensity or strength of the texture.
  112635. * It is commonly used by materials to fine tune the intensity of the texture
  112636. */
  112637. level: number;
  112638. /**
  112639. * Define the UV chanel to use starting from 0 and defaulting to 0.
  112640. * This is part of the texture as textures usually maps to one uv set.
  112641. */
  112642. coordinatesIndex: number;
  112643. private _coordinatesMode;
  112644. /**
  112645. * How a texture is mapped.
  112646. *
  112647. * | Value | Type | Description |
  112648. * | ----- | ----------------------------------- | ----------- |
  112649. * | 0 | EXPLICIT_MODE | |
  112650. * | 1 | SPHERICAL_MODE | |
  112651. * | 2 | PLANAR_MODE | |
  112652. * | 3 | CUBIC_MODE | |
  112653. * | 4 | PROJECTION_MODE | |
  112654. * | 5 | SKYBOX_MODE | |
  112655. * | 6 | INVCUBIC_MODE | |
  112656. * | 7 | EQUIRECTANGULAR_MODE | |
  112657. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  112658. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  112659. */
  112660. set coordinatesMode(value: number);
  112661. get coordinatesMode(): number;
  112662. /**
  112663. * | Value | Type | Description |
  112664. * | ----- | ------------------ | ----------- |
  112665. * | 0 | CLAMP_ADDRESSMODE | |
  112666. * | 1 | WRAP_ADDRESSMODE | |
  112667. * | 2 | MIRROR_ADDRESSMODE | |
  112668. */
  112669. wrapU: number;
  112670. /**
  112671. * | Value | Type | Description |
  112672. * | ----- | ------------------ | ----------- |
  112673. * | 0 | CLAMP_ADDRESSMODE | |
  112674. * | 1 | WRAP_ADDRESSMODE | |
  112675. * | 2 | MIRROR_ADDRESSMODE | |
  112676. */
  112677. wrapV: number;
  112678. /**
  112679. * | Value | Type | Description |
  112680. * | ----- | ------------------ | ----------- |
  112681. * | 0 | CLAMP_ADDRESSMODE | |
  112682. * | 1 | WRAP_ADDRESSMODE | |
  112683. * | 2 | MIRROR_ADDRESSMODE | |
  112684. */
  112685. wrapR: number;
  112686. /**
  112687. * With compliant hardware and browser (supporting anisotropic filtering)
  112688. * this defines the level of anisotropic filtering in the texture.
  112689. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  112690. */
  112691. anisotropicFilteringLevel: number;
  112692. /**
  112693. * Define if the texture is a cube texture or if false a 2d texture.
  112694. */
  112695. get isCube(): boolean;
  112696. set isCube(value: boolean);
  112697. /**
  112698. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  112699. */
  112700. get is3D(): boolean;
  112701. set is3D(value: boolean);
  112702. /**
  112703. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  112704. */
  112705. get is2DArray(): boolean;
  112706. set is2DArray(value: boolean);
  112707. /**
  112708. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  112709. * HDR texture are usually stored in linear space.
  112710. * This only impacts the PBR and Background materials
  112711. */
  112712. gammaSpace: boolean;
  112713. /**
  112714. * Gets or sets whether or not the texture contains RGBD data.
  112715. */
  112716. get isRGBD(): boolean;
  112717. set isRGBD(value: boolean);
  112718. /**
  112719. * Is Z inverted in the texture (useful in a cube texture).
  112720. */
  112721. invertZ: boolean;
  112722. /**
  112723. * Are mip maps generated for this texture or not.
  112724. */
  112725. get noMipmap(): boolean;
  112726. /**
  112727. * @hidden
  112728. */
  112729. lodLevelInAlpha: boolean;
  112730. /**
  112731. * With prefiltered texture, defined the offset used during the prefiltering steps.
  112732. */
  112733. get lodGenerationOffset(): number;
  112734. set lodGenerationOffset(value: number);
  112735. /**
  112736. * With prefiltered texture, defined the scale used during the prefiltering steps.
  112737. */
  112738. get lodGenerationScale(): number;
  112739. set lodGenerationScale(value: number);
  112740. /**
  112741. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  112742. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  112743. * average roughness values.
  112744. */
  112745. get linearSpecularLOD(): boolean;
  112746. set linearSpecularLOD(value: boolean);
  112747. /**
  112748. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  112749. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  112750. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  112751. */
  112752. get irradianceTexture(): Nullable<BaseTexture>;
  112753. set irradianceTexture(value: Nullable<BaseTexture>);
  112754. /**
  112755. * Define if the texture is a render target.
  112756. */
  112757. isRenderTarget: boolean;
  112758. /**
  112759. * Define the unique id of the texture in the scene.
  112760. */
  112761. get uid(): string;
  112762. /** @hidden */
  112763. _prefiltered: boolean;
  112764. /**
  112765. * Return a string representation of the texture.
  112766. * @returns the texture as a string
  112767. */
  112768. toString(): string;
  112769. /**
  112770. * Get the class name of the texture.
  112771. * @returns "BaseTexture"
  112772. */
  112773. getClassName(): string;
  112774. /**
  112775. * Define the list of animation attached to the texture.
  112776. */
  112777. animations: Animation[];
  112778. /**
  112779. * An event triggered when the texture is disposed.
  112780. */
  112781. onDisposeObservable: Observable<BaseTexture>;
  112782. private _onDisposeObserver;
  112783. /**
  112784. * Callback triggered when the texture has been disposed.
  112785. * Kept for back compatibility, you can use the onDisposeObservable instead.
  112786. */
  112787. set onDispose(callback: () => void);
  112788. /**
  112789. * Define the current state of the loading sequence when in delayed load mode.
  112790. */
  112791. delayLoadState: number;
  112792. protected _scene: Nullable<Scene>;
  112793. protected _engine: Nullable<ThinEngine>;
  112794. /** @hidden */
  112795. _texture: Nullable<InternalTexture>;
  112796. private _uid;
  112797. /**
  112798. * Define if the texture is preventinga material to render or not.
  112799. * If not and the texture is not ready, the engine will use a default black texture instead.
  112800. */
  112801. get isBlocking(): boolean;
  112802. /**
  112803. * Instantiates a new BaseTexture.
  112804. * Base class of all the textures in babylon.
  112805. * It groups all the common properties the materials, post process, lights... might need
  112806. * in order to make a correct use of the texture.
  112807. * @param sceneOrEngine Define the scene or engine the texture blongs to
  112808. */
  112809. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  112810. /**
  112811. * Get the scene the texture belongs to.
  112812. * @returns the scene or null if undefined
  112813. */
  112814. getScene(): Nullable<Scene>;
  112815. /** @hidden */
  112816. protected _getEngine(): Nullable<ThinEngine>;
  112817. /**
  112818. * Get the texture transform matrix used to offset tile the texture for istance.
  112819. * @returns the transformation matrix
  112820. */
  112821. getTextureMatrix(): Matrix;
  112822. /**
  112823. * Get the texture reflection matrix used to rotate/transform the reflection.
  112824. * @returns the reflection matrix
  112825. */
  112826. getReflectionTextureMatrix(): Matrix;
  112827. /**
  112828. * Get the underlying lower level texture from Babylon.
  112829. * @returns the insternal texture
  112830. */
  112831. getInternalTexture(): Nullable<InternalTexture>;
  112832. /**
  112833. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  112834. * @returns true if ready or not blocking
  112835. */
  112836. isReadyOrNotBlocking(): boolean;
  112837. /**
  112838. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  112839. * @returns true if fully ready
  112840. */
  112841. isReady(): boolean;
  112842. private _cachedSize;
  112843. /**
  112844. * Get the size of the texture.
  112845. * @returns the texture size.
  112846. */
  112847. getSize(): ISize;
  112848. /**
  112849. * Get the base size of the texture.
  112850. * It can be different from the size if the texture has been resized for POT for instance
  112851. * @returns the base size
  112852. */
  112853. getBaseSize(): ISize;
  112854. /**
  112855. * Update the sampling mode of the texture.
  112856. * Default is Trilinear mode.
  112857. *
  112858. * | Value | Type | Description |
  112859. * | ----- | ------------------ | ----------- |
  112860. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  112861. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  112862. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  112863. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  112864. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  112865. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  112866. * | 7 | NEAREST_LINEAR | |
  112867. * | 8 | NEAREST_NEAREST | |
  112868. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  112869. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  112870. * | 11 | LINEAR_LINEAR | |
  112871. * | 12 | LINEAR_NEAREST | |
  112872. *
  112873. * > _mag_: magnification filter (close to the viewer)
  112874. * > _min_: minification filter (far from the viewer)
  112875. * > _mip_: filter used between mip map levels
  112876. *@param samplingMode Define the new sampling mode of the texture
  112877. */
  112878. updateSamplingMode(samplingMode: number): void;
  112879. /**
  112880. * Scales the texture if is `canRescale()`
  112881. * @param ratio the resize factor we want to use to rescale
  112882. */
  112883. scale(ratio: number): void;
  112884. /**
  112885. * Get if the texture can rescale.
  112886. */
  112887. get canRescale(): boolean;
  112888. /** @hidden */
  112889. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  112890. /** @hidden */
  112891. _rebuild(): void;
  112892. /**
  112893. * Triggers the load sequence in delayed load mode.
  112894. */
  112895. delayLoad(): void;
  112896. /**
  112897. * Clones the texture.
  112898. * @returns the cloned texture
  112899. */
  112900. clone(): Nullable<BaseTexture>;
  112901. /**
  112902. * Get the texture underlying type (INT, FLOAT...)
  112903. */
  112904. get textureType(): number;
  112905. /**
  112906. * Get the texture underlying format (RGB, RGBA...)
  112907. */
  112908. get textureFormat(): number;
  112909. /**
  112910. * Indicates that textures need to be re-calculated for all materials
  112911. */
  112912. protected _markAllSubMeshesAsTexturesDirty(): void;
  112913. /**
  112914. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  112915. * This will returns an RGBA array buffer containing either in values (0-255) or
  112916. * float values (0-1) depending of the underlying buffer type.
  112917. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  112918. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  112919. * @param buffer defines a user defined buffer to fill with data (can be null)
  112920. * @returns The Array buffer containing the pixels data.
  112921. */
  112922. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  112923. /**
  112924. * Release and destroy the underlying lower level texture aka internalTexture.
  112925. */
  112926. releaseInternalTexture(): void;
  112927. /** @hidden */
  112928. get _lodTextureHigh(): Nullable<BaseTexture>;
  112929. /** @hidden */
  112930. get _lodTextureMid(): Nullable<BaseTexture>;
  112931. /** @hidden */
  112932. get _lodTextureLow(): Nullable<BaseTexture>;
  112933. /**
  112934. * Dispose the texture and release its associated resources.
  112935. */
  112936. dispose(): void;
  112937. /**
  112938. * Serialize the texture into a JSON representation that can be parsed later on.
  112939. * @returns the JSON representation of the texture
  112940. */
  112941. serialize(): any;
  112942. /**
  112943. * Helper function to be called back once a list of texture contains only ready textures.
  112944. * @param textures Define the list of textures to wait for
  112945. * @param callback Define the callback triggered once the entire list will be ready
  112946. */
  112947. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  112948. private static _isScene;
  112949. }
  112950. }
  112951. declare module BABYLON {
  112952. /**
  112953. * Options to be used when creating an effect.
  112954. */
  112955. export interface IEffectCreationOptions {
  112956. /**
  112957. * Atrributes that will be used in the shader.
  112958. */
  112959. attributes: string[];
  112960. /**
  112961. * Uniform varible names that will be set in the shader.
  112962. */
  112963. uniformsNames: string[];
  112964. /**
  112965. * Uniform buffer variable names that will be set in the shader.
  112966. */
  112967. uniformBuffersNames: string[];
  112968. /**
  112969. * Sampler texture variable names that will be set in the shader.
  112970. */
  112971. samplers: string[];
  112972. /**
  112973. * Define statements that will be set in the shader.
  112974. */
  112975. defines: any;
  112976. /**
  112977. * Possible fallbacks for this effect to improve performance when needed.
  112978. */
  112979. fallbacks: Nullable<IEffectFallbacks>;
  112980. /**
  112981. * Callback that will be called when the shader is compiled.
  112982. */
  112983. onCompiled: Nullable<(effect: Effect) => void>;
  112984. /**
  112985. * Callback that will be called if an error occurs during shader compilation.
  112986. */
  112987. onError: Nullable<(effect: Effect, errors: string) => void>;
  112988. /**
  112989. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  112990. */
  112991. indexParameters?: any;
  112992. /**
  112993. * Max number of lights that can be used in the shader.
  112994. */
  112995. maxSimultaneousLights?: number;
  112996. /**
  112997. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  112998. */
  112999. transformFeedbackVaryings?: Nullable<string[]>;
  113000. /**
  113001. * 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
  113002. */
  113003. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  113004. /**
  113005. * Is this effect rendering to several color attachments ?
  113006. */
  113007. multiTarget?: boolean;
  113008. }
  113009. /**
  113010. * Effect containing vertex and fragment shader that can be executed on an object.
  113011. */
  113012. export class Effect implements IDisposable {
  113013. /**
  113014. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  113015. */
  113016. static ShadersRepository: string;
  113017. /**
  113018. * Enable logging of the shader code when a compilation error occurs
  113019. */
  113020. static LogShaderCodeOnCompilationError: boolean;
  113021. /**
  113022. * Name of the effect.
  113023. */
  113024. name: any;
  113025. /**
  113026. * String container all the define statements that should be set on the shader.
  113027. */
  113028. defines: string;
  113029. /**
  113030. * Callback that will be called when the shader is compiled.
  113031. */
  113032. onCompiled: Nullable<(effect: Effect) => void>;
  113033. /**
  113034. * Callback that will be called if an error occurs during shader compilation.
  113035. */
  113036. onError: Nullable<(effect: Effect, errors: string) => void>;
  113037. /**
  113038. * Callback that will be called when effect is bound.
  113039. */
  113040. onBind: Nullable<(effect: Effect) => void>;
  113041. /**
  113042. * Unique ID of the effect.
  113043. */
  113044. uniqueId: number;
  113045. /**
  113046. * Observable that will be called when the shader is compiled.
  113047. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  113048. */
  113049. onCompileObservable: Observable<Effect>;
  113050. /**
  113051. * Observable that will be called if an error occurs during shader compilation.
  113052. */
  113053. onErrorObservable: Observable<Effect>;
  113054. /** @hidden */
  113055. _onBindObservable: Nullable<Observable<Effect>>;
  113056. /**
  113057. * @hidden
  113058. * Specifies if the effect was previously ready
  113059. */
  113060. _wasPreviouslyReady: boolean;
  113061. /**
  113062. * Observable that will be called when effect is bound.
  113063. */
  113064. get onBindObservable(): Observable<Effect>;
  113065. /** @hidden */
  113066. _bonesComputationForcedToCPU: boolean;
  113067. /** @hidden */
  113068. _multiTarget: boolean;
  113069. private static _uniqueIdSeed;
  113070. private _engine;
  113071. private _uniformBuffersNames;
  113072. private _uniformBuffersNamesList;
  113073. private _uniformsNames;
  113074. private _samplerList;
  113075. private _samplers;
  113076. private _isReady;
  113077. private _compilationError;
  113078. private _allFallbacksProcessed;
  113079. private _attributesNames;
  113080. private _attributes;
  113081. private _attributeLocationByName;
  113082. private _uniforms;
  113083. /**
  113084. * Key for the effect.
  113085. * @hidden
  113086. */
  113087. _key: string;
  113088. private _indexParameters;
  113089. private _fallbacks;
  113090. private _vertexSourceCode;
  113091. private _fragmentSourceCode;
  113092. private _vertexSourceCodeOverride;
  113093. private _fragmentSourceCodeOverride;
  113094. private _transformFeedbackVaryings;
  113095. /**
  113096. * Compiled shader to webGL program.
  113097. * @hidden
  113098. */
  113099. _pipelineContext: Nullable<IPipelineContext>;
  113100. private _valueCache;
  113101. private static _baseCache;
  113102. /**
  113103. * Instantiates an effect.
  113104. * An effect can be used to create/manage/execute vertex and fragment shaders.
  113105. * @param baseName Name of the effect.
  113106. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  113107. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  113108. * @param samplers List of sampler variables that will be passed to the shader.
  113109. * @param engine Engine to be used to render the effect
  113110. * @param defines Define statements to be added to the shader.
  113111. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  113112. * @param onCompiled Callback that will be called when the shader is compiled.
  113113. * @param onError Callback that will be called if an error occurs during shader compilation.
  113114. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  113115. */
  113116. 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);
  113117. private _useFinalCode;
  113118. /**
  113119. * Unique key for this effect
  113120. */
  113121. get key(): string;
  113122. /**
  113123. * If the effect has been compiled and prepared.
  113124. * @returns if the effect is compiled and prepared.
  113125. */
  113126. isReady(): boolean;
  113127. private _isReadyInternal;
  113128. /**
  113129. * The engine the effect was initialized with.
  113130. * @returns the engine.
  113131. */
  113132. getEngine(): Engine;
  113133. /**
  113134. * The pipeline context for this effect
  113135. * @returns the associated pipeline context
  113136. */
  113137. getPipelineContext(): Nullable<IPipelineContext>;
  113138. /**
  113139. * The set of names of attribute variables for the shader.
  113140. * @returns An array of attribute names.
  113141. */
  113142. getAttributesNames(): string[];
  113143. /**
  113144. * Returns the attribute at the given index.
  113145. * @param index The index of the attribute.
  113146. * @returns The location of the attribute.
  113147. */
  113148. getAttributeLocation(index: number): number;
  113149. /**
  113150. * Returns the attribute based on the name of the variable.
  113151. * @param name of the attribute to look up.
  113152. * @returns the attribute location.
  113153. */
  113154. getAttributeLocationByName(name: string): number;
  113155. /**
  113156. * The number of attributes.
  113157. * @returns the numnber of attributes.
  113158. */
  113159. getAttributesCount(): number;
  113160. /**
  113161. * Gets the index of a uniform variable.
  113162. * @param uniformName of the uniform to look up.
  113163. * @returns the index.
  113164. */
  113165. getUniformIndex(uniformName: string): number;
  113166. /**
  113167. * Returns the attribute based on the name of the variable.
  113168. * @param uniformName of the uniform to look up.
  113169. * @returns the location of the uniform.
  113170. */
  113171. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  113172. /**
  113173. * Returns an array of sampler variable names
  113174. * @returns The array of sampler variable names.
  113175. */
  113176. getSamplers(): string[];
  113177. /**
  113178. * Returns an array of uniform variable names
  113179. * @returns The array of uniform variable names.
  113180. */
  113181. getUniformNames(): string[];
  113182. /**
  113183. * Returns an array of uniform buffer variable names
  113184. * @returns The array of uniform buffer variable names.
  113185. */
  113186. getUniformBuffersNames(): string[];
  113187. /**
  113188. * Returns the index parameters used to create the effect
  113189. * @returns The index parameters object
  113190. */
  113191. getIndexParameters(): any;
  113192. /**
  113193. * The error from the last compilation.
  113194. * @returns the error string.
  113195. */
  113196. getCompilationError(): string;
  113197. /**
  113198. * Gets a boolean indicating that all fallbacks were used during compilation
  113199. * @returns true if all fallbacks were used
  113200. */
  113201. allFallbacksProcessed(): boolean;
  113202. /**
  113203. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  113204. * @param func The callback to be used.
  113205. */
  113206. executeWhenCompiled(func: (effect: Effect) => void): void;
  113207. private _checkIsReady;
  113208. private _loadShader;
  113209. /**
  113210. * Gets the vertex shader source code of this effect
  113211. */
  113212. get vertexSourceCode(): string;
  113213. /**
  113214. * Gets the fragment shader source code of this effect
  113215. */
  113216. get fragmentSourceCode(): string;
  113217. /**
  113218. * Recompiles the webGL program
  113219. * @param vertexSourceCode The source code for the vertex shader.
  113220. * @param fragmentSourceCode The source code for the fragment shader.
  113221. * @param onCompiled Callback called when completed.
  113222. * @param onError Callback called on error.
  113223. * @hidden
  113224. */
  113225. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  113226. /**
  113227. * Prepares the effect
  113228. * @hidden
  113229. */
  113230. _prepareEffect(): void;
  113231. private _getShaderCodeAndErrorLine;
  113232. private _processCompilationErrors;
  113233. /**
  113234. * Checks if the effect is supported. (Must be called after compilation)
  113235. */
  113236. get isSupported(): boolean;
  113237. /**
  113238. * Binds a texture to the engine to be used as output of the shader.
  113239. * @param channel Name of the output variable.
  113240. * @param texture Texture to bind.
  113241. * @hidden
  113242. */
  113243. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  113244. /**
  113245. * Sets a texture on the engine to be used in the shader.
  113246. * @param channel Name of the sampler variable.
  113247. * @param texture Texture to set.
  113248. */
  113249. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  113250. /**
  113251. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  113252. * @param channel Name of the sampler variable.
  113253. * @param texture Texture to set.
  113254. */
  113255. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  113256. /**
  113257. * Sets an array of textures on the engine to be used in the shader.
  113258. * @param channel Name of the variable.
  113259. * @param textures Textures to set.
  113260. */
  113261. setTextureArray(channel: string, textures: BaseTexture[]): void;
  113262. /**
  113263. * 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)
  113264. * @param channel Name of the sampler variable.
  113265. * @param postProcess Post process to get the input texture from.
  113266. */
  113267. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  113268. /**
  113269. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  113270. * 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)
  113271. * @param channel Name of the sampler variable.
  113272. * @param postProcess Post process to get the output texture from.
  113273. */
  113274. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  113275. /** @hidden */
  113276. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  113277. /** @hidden */
  113278. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  113279. /** @hidden */
  113280. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  113281. /** @hidden */
  113282. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  113283. /**
  113284. * Binds a buffer to a uniform.
  113285. * @param buffer Buffer to bind.
  113286. * @param name Name of the uniform variable to bind to.
  113287. */
  113288. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  113289. /**
  113290. * Binds block to a uniform.
  113291. * @param blockName Name of the block to bind.
  113292. * @param index Index to bind.
  113293. */
  113294. bindUniformBlock(blockName: string, index: number): void;
  113295. /**
  113296. * Sets an interger value on a uniform variable.
  113297. * @param uniformName Name of the variable.
  113298. * @param value Value to be set.
  113299. * @returns this effect.
  113300. */
  113301. setInt(uniformName: string, value: number): Effect;
  113302. /**
  113303. * Sets an int array on a uniform variable.
  113304. * @param uniformName Name of the variable.
  113305. * @param array array to be set.
  113306. * @returns this effect.
  113307. */
  113308. setIntArray(uniformName: string, array: Int32Array): Effect;
  113309. /**
  113310. * 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)
  113311. * @param uniformName Name of the variable.
  113312. * @param array array to be set.
  113313. * @returns this effect.
  113314. */
  113315. setIntArray2(uniformName: string, array: Int32Array): Effect;
  113316. /**
  113317. * 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)
  113318. * @param uniformName Name of the variable.
  113319. * @param array array to be set.
  113320. * @returns this effect.
  113321. */
  113322. setIntArray3(uniformName: string, array: Int32Array): Effect;
  113323. /**
  113324. * 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)
  113325. * @param uniformName Name of the variable.
  113326. * @param array array to be set.
  113327. * @returns this effect.
  113328. */
  113329. setIntArray4(uniformName: string, array: Int32Array): Effect;
  113330. /**
  113331. * Sets an float array on a uniform variable.
  113332. * @param uniformName Name of the variable.
  113333. * @param array array to be set.
  113334. * @returns this effect.
  113335. */
  113336. setFloatArray(uniformName: string, array: Float32Array): Effect;
  113337. /**
  113338. * 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)
  113339. * @param uniformName Name of the variable.
  113340. * @param array array to be set.
  113341. * @returns this effect.
  113342. */
  113343. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  113344. /**
  113345. * 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)
  113346. * @param uniformName Name of the variable.
  113347. * @param array array to be set.
  113348. * @returns this effect.
  113349. */
  113350. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  113351. /**
  113352. * 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)
  113353. * @param uniformName Name of the variable.
  113354. * @param array array to be set.
  113355. * @returns this effect.
  113356. */
  113357. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  113358. /**
  113359. * Sets an array on a uniform variable.
  113360. * @param uniformName Name of the variable.
  113361. * @param array array to be set.
  113362. * @returns this effect.
  113363. */
  113364. setArray(uniformName: string, array: number[]): Effect;
  113365. /**
  113366. * 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)
  113367. * @param uniformName Name of the variable.
  113368. * @param array array to be set.
  113369. * @returns this effect.
  113370. */
  113371. setArray2(uniformName: string, array: number[]): Effect;
  113372. /**
  113373. * 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)
  113374. * @param uniformName Name of the variable.
  113375. * @param array array to be set.
  113376. * @returns this effect.
  113377. */
  113378. setArray3(uniformName: string, array: number[]): Effect;
  113379. /**
  113380. * 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)
  113381. * @param uniformName Name of the variable.
  113382. * @param array array to be set.
  113383. * @returns this effect.
  113384. */
  113385. setArray4(uniformName: string, array: number[]): Effect;
  113386. /**
  113387. * Sets matrices on a uniform variable.
  113388. * @param uniformName Name of the variable.
  113389. * @param matrices matrices to be set.
  113390. * @returns this effect.
  113391. */
  113392. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  113393. /**
  113394. * Sets matrix on a uniform variable.
  113395. * @param uniformName Name of the variable.
  113396. * @param matrix matrix to be set.
  113397. * @returns this effect.
  113398. */
  113399. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  113400. /**
  113401. * 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)
  113402. * @param uniformName Name of the variable.
  113403. * @param matrix matrix to be set.
  113404. * @returns this effect.
  113405. */
  113406. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113407. /**
  113408. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  113409. * @param uniformName Name of the variable.
  113410. * @param matrix matrix to be set.
  113411. * @returns this effect.
  113412. */
  113413. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  113414. /**
  113415. * Sets a float on a uniform variable.
  113416. * @param uniformName Name of the variable.
  113417. * @param value value to be set.
  113418. * @returns this effect.
  113419. */
  113420. setFloat(uniformName: string, value: number): Effect;
  113421. /**
  113422. * Sets a boolean on a uniform variable.
  113423. * @param uniformName Name of the variable.
  113424. * @param bool value to be set.
  113425. * @returns this effect.
  113426. */
  113427. setBool(uniformName: string, bool: boolean): Effect;
  113428. /**
  113429. * Sets a Vector2 on a uniform variable.
  113430. * @param uniformName Name of the variable.
  113431. * @param vector2 vector2 to be set.
  113432. * @returns this effect.
  113433. */
  113434. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  113435. /**
  113436. * Sets a float2 on a uniform variable.
  113437. * @param uniformName Name of the variable.
  113438. * @param x First float in float2.
  113439. * @param y Second float in float2.
  113440. * @returns this effect.
  113441. */
  113442. setFloat2(uniformName: string, x: number, y: number): Effect;
  113443. /**
  113444. * Sets a Vector3 on a uniform variable.
  113445. * @param uniformName Name of the variable.
  113446. * @param vector3 Value to be set.
  113447. * @returns this effect.
  113448. */
  113449. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  113450. /**
  113451. * Sets a float3 on a uniform variable.
  113452. * @param uniformName Name of the variable.
  113453. * @param x First float in float3.
  113454. * @param y Second float in float3.
  113455. * @param z Third float in float3.
  113456. * @returns this effect.
  113457. */
  113458. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  113459. /**
  113460. * Sets a Vector4 on a uniform variable.
  113461. * @param uniformName Name of the variable.
  113462. * @param vector4 Value to be set.
  113463. * @returns this effect.
  113464. */
  113465. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  113466. /**
  113467. * Sets a float4 on a uniform variable.
  113468. * @param uniformName Name of the variable.
  113469. * @param x First float in float4.
  113470. * @param y Second float in float4.
  113471. * @param z Third float in float4.
  113472. * @param w Fourth float in float4.
  113473. * @returns this effect.
  113474. */
  113475. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  113476. /**
  113477. * Sets a Color3 on a uniform variable.
  113478. * @param uniformName Name of the variable.
  113479. * @param color3 Value to be set.
  113480. * @returns this effect.
  113481. */
  113482. setColor3(uniformName: string, color3: IColor3Like): Effect;
  113483. /**
  113484. * Sets a Color4 on a uniform variable.
  113485. * @param uniformName Name of the variable.
  113486. * @param color3 Value to be set.
  113487. * @param alpha Alpha value to be set.
  113488. * @returns this effect.
  113489. */
  113490. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  113491. /**
  113492. * Sets a Color4 on a uniform variable
  113493. * @param uniformName defines the name of the variable
  113494. * @param color4 defines the value to be set
  113495. * @returns this effect.
  113496. */
  113497. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  113498. /** Release all associated resources */
  113499. dispose(): void;
  113500. /**
  113501. * This function will add a new shader to the shader store
  113502. * @param name the name of the shader
  113503. * @param pixelShader optional pixel shader content
  113504. * @param vertexShader optional vertex shader content
  113505. */
  113506. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  113507. /**
  113508. * Store of each shader (The can be looked up using effect.key)
  113509. */
  113510. static ShadersStore: {
  113511. [key: string]: string;
  113512. };
  113513. /**
  113514. * Store of each included file for a shader (The can be looked up using effect.key)
  113515. */
  113516. static IncludesShadersStore: {
  113517. [key: string]: string;
  113518. };
  113519. /**
  113520. * Resets the cache of effects.
  113521. */
  113522. static ResetCache(): void;
  113523. }
  113524. }
  113525. declare module BABYLON {
  113526. /**
  113527. * Interface used to describe the capabilities of the engine relatively to the current browser
  113528. */
  113529. export interface EngineCapabilities {
  113530. /** Maximum textures units per fragment shader */
  113531. maxTexturesImageUnits: number;
  113532. /** Maximum texture units per vertex shader */
  113533. maxVertexTextureImageUnits: number;
  113534. /** Maximum textures units in the entire pipeline */
  113535. maxCombinedTexturesImageUnits: number;
  113536. /** Maximum texture size */
  113537. maxTextureSize: number;
  113538. /** Maximum texture samples */
  113539. maxSamples?: number;
  113540. /** Maximum cube texture size */
  113541. maxCubemapTextureSize: number;
  113542. /** Maximum render texture size */
  113543. maxRenderTextureSize: number;
  113544. /** Maximum number of vertex attributes */
  113545. maxVertexAttribs: number;
  113546. /** Maximum number of varyings */
  113547. maxVaryingVectors: number;
  113548. /** Maximum number of uniforms per vertex shader */
  113549. maxVertexUniformVectors: number;
  113550. /** Maximum number of uniforms per fragment shader */
  113551. maxFragmentUniformVectors: number;
  113552. /** Defines if standard derivates (dx/dy) are supported */
  113553. standardDerivatives: boolean;
  113554. /** Defines if s3tc texture compression is supported */
  113555. s3tc?: WEBGL_compressed_texture_s3tc;
  113556. /** Defines if pvrtc texture compression is supported */
  113557. pvrtc: any;
  113558. /** Defines if etc1 texture compression is supported */
  113559. etc1: any;
  113560. /** Defines if etc2 texture compression is supported */
  113561. etc2: any;
  113562. /** Defines if astc texture compression is supported */
  113563. astc: any;
  113564. /** Defines if float textures are supported */
  113565. textureFloat: boolean;
  113566. /** Defines if vertex array objects are supported */
  113567. vertexArrayObject: boolean;
  113568. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  113569. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  113570. /** Gets the maximum level of anisotropy supported */
  113571. maxAnisotropy: number;
  113572. /** Defines if instancing is supported */
  113573. instancedArrays: boolean;
  113574. /** Defines if 32 bits indices are supported */
  113575. uintIndices: boolean;
  113576. /** Defines if high precision shaders are supported */
  113577. highPrecisionShaderSupported: boolean;
  113578. /** Defines if depth reading in the fragment shader is supported */
  113579. fragmentDepthSupported: boolean;
  113580. /** Defines if float texture linear filtering is supported*/
  113581. textureFloatLinearFiltering: boolean;
  113582. /** Defines if rendering to float textures is supported */
  113583. textureFloatRender: boolean;
  113584. /** Defines if half float textures are supported*/
  113585. textureHalfFloat: boolean;
  113586. /** Defines if half float texture linear filtering is supported*/
  113587. textureHalfFloatLinearFiltering: boolean;
  113588. /** Defines if rendering to half float textures is supported */
  113589. textureHalfFloatRender: boolean;
  113590. /** Defines if textureLOD shader command is supported */
  113591. textureLOD: boolean;
  113592. /** Defines if draw buffers extension is supported */
  113593. drawBuffersExtension: boolean;
  113594. /** Defines if depth textures are supported */
  113595. depthTextureExtension: boolean;
  113596. /** Defines if float color buffer are supported */
  113597. colorBufferFloat: boolean;
  113598. /** Gets disjoint timer query extension (null if not supported) */
  113599. timerQuery?: EXT_disjoint_timer_query;
  113600. /** Defines if timestamp can be used with timer query */
  113601. canUseTimestampForTimerQuery: boolean;
  113602. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  113603. multiview?: any;
  113604. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  113605. oculusMultiview?: any;
  113606. /** Function used to let the system compiles shaders in background */
  113607. parallelShaderCompile?: {
  113608. COMPLETION_STATUS_KHR: number;
  113609. };
  113610. /** Max number of texture samples for MSAA */
  113611. maxMSAASamples: number;
  113612. /** Defines if the blend min max extension is supported */
  113613. blendMinMax: boolean;
  113614. }
  113615. }
  113616. declare module BABYLON {
  113617. /**
  113618. * @hidden
  113619. **/
  113620. export class DepthCullingState {
  113621. private _isDepthTestDirty;
  113622. private _isDepthMaskDirty;
  113623. private _isDepthFuncDirty;
  113624. private _isCullFaceDirty;
  113625. private _isCullDirty;
  113626. private _isZOffsetDirty;
  113627. private _isFrontFaceDirty;
  113628. private _depthTest;
  113629. private _depthMask;
  113630. private _depthFunc;
  113631. private _cull;
  113632. private _cullFace;
  113633. private _zOffset;
  113634. private _frontFace;
  113635. /**
  113636. * Initializes the state.
  113637. */
  113638. constructor();
  113639. get isDirty(): boolean;
  113640. get zOffset(): number;
  113641. set zOffset(value: number);
  113642. get cullFace(): Nullable<number>;
  113643. set cullFace(value: Nullable<number>);
  113644. get cull(): Nullable<boolean>;
  113645. set cull(value: Nullable<boolean>);
  113646. get depthFunc(): Nullable<number>;
  113647. set depthFunc(value: Nullable<number>);
  113648. get depthMask(): boolean;
  113649. set depthMask(value: boolean);
  113650. get depthTest(): boolean;
  113651. set depthTest(value: boolean);
  113652. get frontFace(): Nullable<number>;
  113653. set frontFace(value: Nullable<number>);
  113654. reset(): void;
  113655. apply(gl: WebGLRenderingContext): void;
  113656. }
  113657. }
  113658. declare module BABYLON {
  113659. /**
  113660. * @hidden
  113661. **/
  113662. export class StencilState {
  113663. /** 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 */
  113664. static readonly ALWAYS: number;
  113665. /** Passed to stencilOperation to specify that stencil value must be kept */
  113666. static readonly KEEP: number;
  113667. /** Passed to stencilOperation to specify that stencil value must be replaced */
  113668. static readonly REPLACE: number;
  113669. private _isStencilTestDirty;
  113670. private _isStencilMaskDirty;
  113671. private _isStencilFuncDirty;
  113672. private _isStencilOpDirty;
  113673. private _stencilTest;
  113674. private _stencilMask;
  113675. private _stencilFunc;
  113676. private _stencilFuncRef;
  113677. private _stencilFuncMask;
  113678. private _stencilOpStencilFail;
  113679. private _stencilOpDepthFail;
  113680. private _stencilOpStencilDepthPass;
  113681. get isDirty(): boolean;
  113682. get stencilFunc(): number;
  113683. set stencilFunc(value: number);
  113684. get stencilFuncRef(): number;
  113685. set stencilFuncRef(value: number);
  113686. get stencilFuncMask(): number;
  113687. set stencilFuncMask(value: number);
  113688. get stencilOpStencilFail(): number;
  113689. set stencilOpStencilFail(value: number);
  113690. get stencilOpDepthFail(): number;
  113691. set stencilOpDepthFail(value: number);
  113692. get stencilOpStencilDepthPass(): number;
  113693. set stencilOpStencilDepthPass(value: number);
  113694. get stencilMask(): number;
  113695. set stencilMask(value: number);
  113696. get stencilTest(): boolean;
  113697. set stencilTest(value: boolean);
  113698. constructor();
  113699. reset(): void;
  113700. apply(gl: WebGLRenderingContext): void;
  113701. }
  113702. }
  113703. declare module BABYLON {
  113704. /**
  113705. * @hidden
  113706. **/
  113707. export class AlphaState {
  113708. private _isAlphaBlendDirty;
  113709. private _isBlendFunctionParametersDirty;
  113710. private _isBlendEquationParametersDirty;
  113711. private _isBlendConstantsDirty;
  113712. private _alphaBlend;
  113713. private _blendFunctionParameters;
  113714. private _blendEquationParameters;
  113715. private _blendConstants;
  113716. /**
  113717. * Initializes the state.
  113718. */
  113719. constructor();
  113720. get isDirty(): boolean;
  113721. get alphaBlend(): boolean;
  113722. set alphaBlend(value: boolean);
  113723. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  113724. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  113725. setAlphaEquationParameters(rgb: number, alpha: number): void;
  113726. reset(): void;
  113727. apply(gl: WebGLRenderingContext): void;
  113728. }
  113729. }
  113730. declare module BABYLON {
  113731. /** @hidden */
  113732. export class WebGL2ShaderProcessor implements IShaderProcessor {
  113733. attributeProcessor(attribute: string): string;
  113734. varyingProcessor(varying: string, isFragment: boolean): string;
  113735. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113736. }
  113737. }
  113738. declare module BABYLON {
  113739. /**
  113740. * Interface for attribute information associated with buffer instanciation
  113741. */
  113742. export interface InstancingAttributeInfo {
  113743. /**
  113744. * Name of the GLSL attribute
  113745. * if attribute index is not specified, this is used to retrieve the index from the effect
  113746. */
  113747. attributeName: string;
  113748. /**
  113749. * Index/offset of the attribute in the vertex shader
  113750. * if not specified, this will be computes from the name.
  113751. */
  113752. index?: number;
  113753. /**
  113754. * size of the attribute, 1, 2, 3 or 4
  113755. */
  113756. attributeSize: number;
  113757. /**
  113758. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  113759. */
  113760. offset: number;
  113761. /**
  113762. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  113763. * default to 1
  113764. */
  113765. divisor?: number;
  113766. /**
  113767. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  113768. * default is FLOAT
  113769. */
  113770. attributeType?: number;
  113771. /**
  113772. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  113773. */
  113774. normalized?: boolean;
  113775. }
  113776. }
  113777. declare module BABYLON {
  113778. interface ThinEngine {
  113779. /**
  113780. * Update a video texture
  113781. * @param texture defines the texture to update
  113782. * @param video defines the video element to use
  113783. * @param invertY defines if data must be stored with Y axis inverted
  113784. */
  113785. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  113786. }
  113787. }
  113788. declare module BABYLON {
  113789. interface ThinEngine {
  113790. /**
  113791. * Creates a dynamic texture
  113792. * @param width defines the width of the texture
  113793. * @param height defines the height of the texture
  113794. * @param generateMipMaps defines if the engine should generate the mip levels
  113795. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  113796. * @returns the dynamic texture inside an InternalTexture
  113797. */
  113798. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  113799. /**
  113800. * Update the content of a dynamic texture
  113801. * @param texture defines the texture to update
  113802. * @param canvas defines the canvas containing the source
  113803. * @param invertY defines if data must be stored with Y axis inverted
  113804. * @param premulAlpha defines if alpha is stored as premultiplied
  113805. * @param format defines the format of the data
  113806. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113807. */
  113808. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  113809. }
  113810. }
  113811. declare module BABYLON {
  113812. /**
  113813. * Settings for finer control over video usage
  113814. */
  113815. export interface VideoTextureSettings {
  113816. /**
  113817. * Applies `autoplay` to video, if specified
  113818. */
  113819. autoPlay?: boolean;
  113820. /**
  113821. * Applies `loop` to video, if specified
  113822. */
  113823. loop?: boolean;
  113824. /**
  113825. * Automatically updates internal texture from video at every frame in the render loop
  113826. */
  113827. autoUpdateTexture: boolean;
  113828. /**
  113829. * Image src displayed during the video loading or until the user interacts with the video.
  113830. */
  113831. poster?: string;
  113832. }
  113833. /**
  113834. * If you want to display a video in your scene, this is the special texture for that.
  113835. * This special texture works similar to other textures, with the exception of a few parameters.
  113836. * @see https://doc.babylonjs.com/how_to/video_texture
  113837. */
  113838. export class VideoTexture extends Texture {
  113839. /**
  113840. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  113841. */
  113842. readonly autoUpdateTexture: boolean;
  113843. /**
  113844. * The video instance used by the texture internally
  113845. */
  113846. readonly video: HTMLVideoElement;
  113847. private _onUserActionRequestedObservable;
  113848. /**
  113849. * Event triggerd when a dom action is required by the user to play the video.
  113850. * This happens due to recent changes in browser policies preventing video to auto start.
  113851. */
  113852. get onUserActionRequestedObservable(): Observable<Texture>;
  113853. private _generateMipMaps;
  113854. private _stillImageCaptured;
  113855. private _displayingPosterTexture;
  113856. private _settings;
  113857. private _createInternalTextureOnEvent;
  113858. private _frameId;
  113859. private _currentSrc;
  113860. /**
  113861. * Creates a video texture.
  113862. * If you want to display a video in your scene, this is the special texture for that.
  113863. * This special texture works similar to other textures, with the exception of a few parameters.
  113864. * @see https://doc.babylonjs.com/how_to/video_texture
  113865. * @param name optional name, will detect from video source, if not defined
  113866. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  113867. * @param scene is obviously the current scene.
  113868. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  113869. * @param invertY is false by default but can be used to invert video on Y axis
  113870. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  113871. * @param settings allows finer control over video usage
  113872. */
  113873. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  113874. private _getName;
  113875. private _getVideo;
  113876. private _createInternalTexture;
  113877. private reset;
  113878. /**
  113879. * @hidden Internal method to initiate `update`.
  113880. */
  113881. _rebuild(): void;
  113882. /**
  113883. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  113884. */
  113885. update(): void;
  113886. /**
  113887. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  113888. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  113889. */
  113890. updateTexture(isVisible: boolean): void;
  113891. protected _updateInternalTexture: () => void;
  113892. /**
  113893. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  113894. * @param url New url.
  113895. */
  113896. updateURL(url: string): void;
  113897. /**
  113898. * Clones the texture.
  113899. * @returns the cloned texture
  113900. */
  113901. clone(): VideoTexture;
  113902. /**
  113903. * Dispose the texture and release its associated resources.
  113904. */
  113905. dispose(): void;
  113906. /**
  113907. * Creates a video texture straight from a stream.
  113908. * @param scene Define the scene the texture should be created in
  113909. * @param stream Define the stream the texture should be created from
  113910. * @returns The created video texture as a promise
  113911. */
  113912. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  113913. /**
  113914. * Creates a video texture straight from your WebCam video feed.
  113915. * @param scene Define the scene the texture should be created in
  113916. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113917. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113918. * @returns The created video texture as a promise
  113919. */
  113920. static CreateFromWebCamAsync(scene: Scene, constraints: {
  113921. minWidth: number;
  113922. maxWidth: number;
  113923. minHeight: number;
  113924. maxHeight: number;
  113925. deviceId: string;
  113926. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  113927. /**
  113928. * Creates a video texture straight from your WebCam video feed.
  113929. * @param scene Define the scene the texture should be created in
  113930. * @param onReady Define a callback to triggered once the texture will be ready
  113931. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  113932. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  113933. */
  113934. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  113935. minWidth: number;
  113936. maxWidth: number;
  113937. minHeight: number;
  113938. maxHeight: number;
  113939. deviceId: string;
  113940. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  113941. }
  113942. }
  113943. declare module BABYLON {
  113944. /**
  113945. * Defines the interface used by objects working like Scene
  113946. * @hidden
  113947. */
  113948. export interface ISceneLike {
  113949. _addPendingData(data: any): void;
  113950. _removePendingData(data: any): void;
  113951. offlineProvider: IOfflineProvider;
  113952. }
  113953. /** Interface defining initialization parameters for Engine class */
  113954. export interface EngineOptions extends WebGLContextAttributes {
  113955. /**
  113956. * Defines if the engine should no exceed a specified device ratio
  113957. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  113958. */
  113959. limitDeviceRatio?: number;
  113960. /**
  113961. * Defines if webvr should be enabled automatically
  113962. * @see https://doc.babylonjs.com/how_to/webvr_camera
  113963. */
  113964. autoEnableWebVR?: boolean;
  113965. /**
  113966. * Defines if webgl2 should be turned off even if supported
  113967. * @see https://doc.babylonjs.com/features/webgl2
  113968. */
  113969. disableWebGL2Support?: boolean;
  113970. /**
  113971. * Defines if webaudio should be initialized as well
  113972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  113973. */
  113974. audioEngine?: boolean;
  113975. /**
  113976. * Defines if animations should run using a deterministic lock step
  113977. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  113978. */
  113979. deterministicLockstep?: boolean;
  113980. /** Defines the maximum steps to use with deterministic lock step mode */
  113981. lockstepMaxSteps?: number;
  113982. /** Defines the seconds between each deterministic lock step */
  113983. timeStep?: number;
  113984. /**
  113985. * Defines that engine should ignore context lost events
  113986. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  113987. */
  113988. doNotHandleContextLost?: boolean;
  113989. /**
  113990. * Defines that engine should ignore modifying touch action attribute and style
  113991. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  113992. */
  113993. doNotHandleTouchAction?: boolean;
  113994. /**
  113995. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  113996. */
  113997. useHighPrecisionFloats?: boolean;
  113998. /**
  113999. * Make the canvas XR Compatible for XR sessions
  114000. */
  114001. xrCompatible?: boolean;
  114002. /**
  114003. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  114004. */
  114005. useHighPrecisionMatrix?: boolean;
  114006. }
  114007. /**
  114008. * The base engine class (root of all engines)
  114009. */
  114010. export class ThinEngine {
  114011. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  114012. static ExceptionList: ({
  114013. key: string;
  114014. capture: string;
  114015. captureConstraint: number;
  114016. targets: string[];
  114017. } | {
  114018. key: string;
  114019. capture: null;
  114020. captureConstraint: null;
  114021. targets: string[];
  114022. })[];
  114023. /** @hidden */
  114024. static _TextureLoaders: IInternalTextureLoader[];
  114025. /**
  114026. * Returns the current npm package of the sdk
  114027. */
  114028. static get NpmPackage(): string;
  114029. /**
  114030. * Returns the current version of the framework
  114031. */
  114032. static get Version(): string;
  114033. /**
  114034. * Returns a string describing the current engine
  114035. */
  114036. get description(): string;
  114037. /**
  114038. * Gets or sets the epsilon value used by collision engine
  114039. */
  114040. static CollisionsEpsilon: number;
  114041. /**
  114042. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114043. */
  114044. static get ShadersRepository(): string;
  114045. static set ShadersRepository(value: string);
  114046. /** @hidden */
  114047. _shaderProcessor: IShaderProcessor;
  114048. /**
  114049. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  114050. */
  114051. forcePOTTextures: boolean;
  114052. /**
  114053. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  114054. */
  114055. isFullscreen: boolean;
  114056. /**
  114057. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  114058. */
  114059. cullBackFaces: boolean;
  114060. /**
  114061. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  114062. */
  114063. renderEvenInBackground: boolean;
  114064. /**
  114065. * Gets or sets a boolean indicating that cache can be kept between frames
  114066. */
  114067. preventCacheWipeBetweenFrames: boolean;
  114068. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  114069. validateShaderPrograms: boolean;
  114070. /**
  114071. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  114072. * This can provide greater z depth for distant objects.
  114073. */
  114074. useReverseDepthBuffer: boolean;
  114075. /**
  114076. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  114077. */
  114078. disableUniformBuffers: boolean;
  114079. /** @hidden */
  114080. _uniformBuffers: UniformBuffer[];
  114081. /**
  114082. * Gets a boolean indicating that the engine supports uniform buffers
  114083. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  114084. */
  114085. get supportsUniformBuffers(): boolean;
  114086. /** @hidden */
  114087. _gl: WebGLRenderingContext;
  114088. /** @hidden */
  114089. _webGLVersion: number;
  114090. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  114091. protected _windowIsBackground: boolean;
  114092. protected _creationOptions: EngineOptions;
  114093. protected _highPrecisionShadersAllowed: boolean;
  114094. /** @hidden */
  114095. get _shouldUseHighPrecisionShader(): boolean;
  114096. /**
  114097. * Gets a boolean indicating that only power of 2 textures are supported
  114098. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  114099. */
  114100. get needPOTTextures(): boolean;
  114101. /** @hidden */
  114102. _badOS: boolean;
  114103. /** @hidden */
  114104. _badDesktopOS: boolean;
  114105. private _hardwareScalingLevel;
  114106. /** @hidden */
  114107. _caps: EngineCapabilities;
  114108. private _isStencilEnable;
  114109. private _glVersion;
  114110. private _glRenderer;
  114111. private _glVendor;
  114112. /** @hidden */
  114113. _videoTextureSupported: boolean;
  114114. protected _renderingQueueLaunched: boolean;
  114115. protected _activeRenderLoops: (() => void)[];
  114116. /**
  114117. * Observable signaled when a context lost event is raised
  114118. */
  114119. onContextLostObservable: Observable<ThinEngine>;
  114120. /**
  114121. * Observable signaled when a context restored event is raised
  114122. */
  114123. onContextRestoredObservable: Observable<ThinEngine>;
  114124. private _onContextLost;
  114125. private _onContextRestored;
  114126. protected _contextWasLost: boolean;
  114127. /** @hidden */
  114128. _doNotHandleContextLost: boolean;
  114129. /**
  114130. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  114131. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  114132. */
  114133. get doNotHandleContextLost(): boolean;
  114134. set doNotHandleContextLost(value: boolean);
  114135. /**
  114136. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  114137. */
  114138. disableVertexArrayObjects: boolean;
  114139. /** @hidden */
  114140. protected _colorWrite: boolean;
  114141. /** @hidden */
  114142. protected _colorWriteChanged: boolean;
  114143. /** @hidden */
  114144. protected _depthCullingState: DepthCullingState;
  114145. /** @hidden */
  114146. protected _stencilState: StencilState;
  114147. /** @hidden */
  114148. _alphaState: AlphaState;
  114149. /** @hidden */
  114150. _alphaMode: number;
  114151. /** @hidden */
  114152. _alphaEquation: number;
  114153. /** @hidden */
  114154. _internalTexturesCache: InternalTexture[];
  114155. /** @hidden */
  114156. protected _activeChannel: number;
  114157. private _currentTextureChannel;
  114158. /** @hidden */
  114159. protected _boundTexturesCache: {
  114160. [key: string]: Nullable<InternalTexture>;
  114161. };
  114162. /** @hidden */
  114163. protected _currentEffect: Nullable<Effect>;
  114164. /** @hidden */
  114165. protected _currentProgram: Nullable<WebGLProgram>;
  114166. private _compiledEffects;
  114167. private _vertexAttribArraysEnabled;
  114168. /** @hidden */
  114169. protected _cachedViewport: Nullable<IViewportLike>;
  114170. private _cachedVertexArrayObject;
  114171. /** @hidden */
  114172. protected _cachedVertexBuffers: any;
  114173. /** @hidden */
  114174. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  114175. /** @hidden */
  114176. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  114177. /** @hidden */
  114178. _currentRenderTarget: Nullable<InternalTexture>;
  114179. private _uintIndicesCurrentlySet;
  114180. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  114181. /** @hidden */
  114182. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  114183. /** @hidden */
  114184. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  114185. private _currentBufferPointers;
  114186. private _currentInstanceLocations;
  114187. private _currentInstanceBuffers;
  114188. private _textureUnits;
  114189. /** @hidden */
  114190. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114191. /** @hidden */
  114192. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114193. /** @hidden */
  114194. _boundRenderFunction: any;
  114195. private _vaoRecordInProgress;
  114196. private _mustWipeVertexAttributes;
  114197. private _emptyTexture;
  114198. private _emptyCubeTexture;
  114199. private _emptyTexture3D;
  114200. private _emptyTexture2DArray;
  114201. /** @hidden */
  114202. _frameHandler: number;
  114203. private _nextFreeTextureSlots;
  114204. private _maxSimultaneousTextures;
  114205. private _activeRequests;
  114206. /** @hidden */
  114207. _transformTextureUrl: Nullable<(url: string) => string>;
  114208. protected get _supportsHardwareTextureRescaling(): boolean;
  114209. private _framebufferDimensionsObject;
  114210. /**
  114211. * sets the object from which width and height will be taken from when getting render width and height
  114212. * Will fallback to the gl object
  114213. * @param dimensions the framebuffer width and height that will be used.
  114214. */
  114215. set framebufferDimensionsObject(dimensions: Nullable<{
  114216. framebufferWidth: number;
  114217. framebufferHeight: number;
  114218. }>);
  114219. /**
  114220. * Gets the current viewport
  114221. */
  114222. get currentViewport(): Nullable<IViewportLike>;
  114223. /**
  114224. * Gets the default empty texture
  114225. */
  114226. get emptyTexture(): InternalTexture;
  114227. /**
  114228. * Gets the default empty 3D texture
  114229. */
  114230. get emptyTexture3D(): InternalTexture;
  114231. /**
  114232. * Gets the default empty 2D array texture
  114233. */
  114234. get emptyTexture2DArray(): InternalTexture;
  114235. /**
  114236. * Gets the default empty cube texture
  114237. */
  114238. get emptyCubeTexture(): InternalTexture;
  114239. /**
  114240. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  114241. */
  114242. readonly premultipliedAlpha: boolean;
  114243. /**
  114244. * Observable event triggered before each texture is initialized
  114245. */
  114246. onBeforeTextureInitObservable: Observable<Texture>;
  114247. /**
  114248. * Creates a new engine
  114249. * @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
  114250. * @param antialias defines enable antialiasing (default: false)
  114251. * @param options defines further options to be sent to the getContext() function
  114252. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114253. */
  114254. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114255. private _rebuildInternalTextures;
  114256. private _rebuildEffects;
  114257. /**
  114258. * Gets a boolean indicating if all created effects are ready
  114259. * @returns true if all effects are ready
  114260. */
  114261. areAllEffectsReady(): boolean;
  114262. protected _rebuildBuffers(): void;
  114263. protected _initGLContext(): void;
  114264. /**
  114265. * Gets version of the current webGL context
  114266. */
  114267. get webGLVersion(): number;
  114268. /**
  114269. * Gets a string idenfifying the name of the class
  114270. * @returns "Engine" string
  114271. */
  114272. getClassName(): string;
  114273. /**
  114274. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  114275. */
  114276. get isStencilEnable(): boolean;
  114277. /** @hidden */
  114278. _prepareWorkingCanvas(): void;
  114279. /**
  114280. * Reset the texture cache to empty state
  114281. */
  114282. resetTextureCache(): void;
  114283. /**
  114284. * Gets an object containing information about the current webGL context
  114285. * @returns an object containing the vender, the renderer and the version of the current webGL context
  114286. */
  114287. getGlInfo(): {
  114288. vendor: string;
  114289. renderer: string;
  114290. version: string;
  114291. };
  114292. /**
  114293. * Defines the hardware scaling level.
  114294. * By default the hardware scaling level is computed from the window device ratio.
  114295. * 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.
  114296. * @param level defines the level to use
  114297. */
  114298. setHardwareScalingLevel(level: number): void;
  114299. /**
  114300. * Gets the current hardware scaling level.
  114301. * By default the hardware scaling level is computed from the window device ratio.
  114302. * 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.
  114303. * @returns a number indicating the current hardware scaling level
  114304. */
  114305. getHardwareScalingLevel(): number;
  114306. /**
  114307. * Gets the list of loaded textures
  114308. * @returns an array containing all loaded textures
  114309. */
  114310. getLoadedTexturesCache(): InternalTexture[];
  114311. /**
  114312. * Gets the object containing all engine capabilities
  114313. * @returns the EngineCapabilities object
  114314. */
  114315. getCaps(): EngineCapabilities;
  114316. /**
  114317. * stop executing a render loop function and remove it from the execution array
  114318. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  114319. */
  114320. stopRenderLoop(renderFunction?: () => void): void;
  114321. /** @hidden */
  114322. _renderLoop(): void;
  114323. /**
  114324. * Gets the HTML canvas attached with the current webGL context
  114325. * @returns a HTML canvas
  114326. */
  114327. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  114328. /**
  114329. * Gets host window
  114330. * @returns the host window object
  114331. */
  114332. getHostWindow(): Nullable<Window>;
  114333. /**
  114334. * Gets the current render width
  114335. * @param useScreen defines if screen size must be used (or the current render target if any)
  114336. * @returns a number defining the current render width
  114337. */
  114338. getRenderWidth(useScreen?: boolean): number;
  114339. /**
  114340. * Gets the current render height
  114341. * @param useScreen defines if screen size must be used (or the current render target if any)
  114342. * @returns a number defining the current render height
  114343. */
  114344. getRenderHeight(useScreen?: boolean): number;
  114345. /**
  114346. * Can be used to override the current requestAnimationFrame requester.
  114347. * @hidden
  114348. */
  114349. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  114350. /**
  114351. * Register and execute a render loop. The engine can have more than one render function
  114352. * @param renderFunction defines the function to continuously execute
  114353. */
  114354. runRenderLoop(renderFunction: () => void): void;
  114355. /**
  114356. * Clear the current render buffer or the current render target (if any is set up)
  114357. * @param color defines the color to use
  114358. * @param backBuffer defines if the back buffer must be cleared
  114359. * @param depth defines if the depth buffer must be cleared
  114360. * @param stencil defines if the stencil buffer must be cleared
  114361. */
  114362. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114363. private _viewportCached;
  114364. /** @hidden */
  114365. _viewport(x: number, y: number, width: number, height: number): void;
  114366. /**
  114367. * Set the WebGL's viewport
  114368. * @param viewport defines the viewport element to be used
  114369. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114370. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114371. */
  114372. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114373. /**
  114374. * Begin a new frame
  114375. */
  114376. beginFrame(): void;
  114377. /**
  114378. * Enf the current frame
  114379. */
  114380. endFrame(): void;
  114381. /**
  114382. * Resize the view according to the canvas' size
  114383. */
  114384. resize(): void;
  114385. /**
  114386. * Force a specific size of the canvas
  114387. * @param width defines the new canvas' width
  114388. * @param height defines the new canvas' height
  114389. * @returns true if the size was changed
  114390. */
  114391. setSize(width: number, height: number): boolean;
  114392. /**
  114393. * Binds the frame buffer to the specified texture.
  114394. * @param texture The texture to render to or null for the default canvas
  114395. * @param faceIndex The face of the texture to render to in case of cube texture
  114396. * @param requiredWidth The width of the target to render to
  114397. * @param requiredHeight The height of the target to render to
  114398. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114399. * @param lodLevel defines the lod level to bind to the frame buffer
  114400. * @param layer defines the 2d array index to bind to frame buffer to
  114401. */
  114402. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  114403. /** @hidden */
  114404. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  114405. /**
  114406. * Unbind the current render target texture from the webGL context
  114407. * @param texture defines the render target texture to unbind
  114408. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114409. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114410. */
  114411. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114412. /**
  114413. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  114414. */
  114415. flushFramebuffer(): void;
  114416. /**
  114417. * Unbind the current render target and bind the default framebuffer
  114418. */
  114419. restoreDefaultFramebuffer(): void;
  114420. /** @hidden */
  114421. protected _resetVertexBufferBinding(): void;
  114422. /**
  114423. * Creates a vertex buffer
  114424. * @param data the data for the vertex buffer
  114425. * @returns the new WebGL static buffer
  114426. */
  114427. createVertexBuffer(data: DataArray): DataBuffer;
  114428. private _createVertexBuffer;
  114429. /**
  114430. * Creates a dynamic vertex buffer
  114431. * @param data the data for the dynamic vertex buffer
  114432. * @returns the new WebGL dynamic buffer
  114433. */
  114434. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  114435. protected _resetIndexBufferBinding(): void;
  114436. /**
  114437. * Creates a new index buffer
  114438. * @param indices defines the content of the index buffer
  114439. * @param updatable defines if the index buffer must be updatable
  114440. * @returns a new webGL buffer
  114441. */
  114442. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  114443. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  114444. /**
  114445. * Bind a webGL buffer to the webGL context
  114446. * @param buffer defines the buffer to bind
  114447. */
  114448. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  114449. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  114450. private bindBuffer;
  114451. /**
  114452. * update the bound buffer with the given data
  114453. * @param data defines the data to update
  114454. */
  114455. updateArrayBuffer(data: Float32Array): void;
  114456. private _vertexAttribPointer;
  114457. /** @hidden */
  114458. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  114459. private _bindVertexBuffersAttributes;
  114460. /**
  114461. * Records a vertex array object
  114462. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114463. * @param vertexBuffers defines the list of vertex buffers to store
  114464. * @param indexBuffer defines the index buffer to store
  114465. * @param effect defines the effect to store
  114466. * @returns the new vertex array object
  114467. */
  114468. recordVertexArrayObject(vertexBuffers: {
  114469. [key: string]: VertexBuffer;
  114470. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  114471. /**
  114472. * Bind a specific vertex array object
  114473. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  114474. * @param vertexArrayObject defines the vertex array object to bind
  114475. * @param indexBuffer defines the index buffer to bind
  114476. */
  114477. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  114478. /**
  114479. * Bind webGl buffers directly to the webGL context
  114480. * @param vertexBuffer defines the vertex buffer to bind
  114481. * @param indexBuffer defines the index buffer to bind
  114482. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114483. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114484. * @param effect defines the effect associated with the vertex buffer
  114485. */
  114486. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  114487. private _unbindVertexArrayObject;
  114488. /**
  114489. * Bind a list of vertex buffers to the webGL context
  114490. * @param vertexBuffers defines the list of vertex buffers to bind
  114491. * @param indexBuffer defines the index buffer to bind
  114492. * @param effect defines the effect associated with the vertex buffers
  114493. */
  114494. bindBuffers(vertexBuffers: {
  114495. [key: string]: Nullable<VertexBuffer>;
  114496. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  114497. /**
  114498. * Unbind all instance attributes
  114499. */
  114500. unbindInstanceAttributes(): void;
  114501. /**
  114502. * Release and free the memory of a vertex array object
  114503. * @param vao defines the vertex array object to delete
  114504. */
  114505. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  114506. /** @hidden */
  114507. _releaseBuffer(buffer: DataBuffer): boolean;
  114508. protected _deleteBuffer(buffer: DataBuffer): void;
  114509. /**
  114510. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  114511. * @param instancesBuffer defines the webGL buffer to update and bind
  114512. * @param data defines the data to store in the buffer
  114513. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  114514. */
  114515. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  114516. /**
  114517. * Bind the content of a webGL buffer used with instantiation
  114518. * @param instancesBuffer defines the webGL buffer to bind
  114519. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  114520. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  114521. */
  114522. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  114523. /**
  114524. * Disable the instance attribute corresponding to the name in parameter
  114525. * @param name defines the name of the attribute to disable
  114526. */
  114527. disableInstanceAttributeByName(name: string): void;
  114528. /**
  114529. * Disable the instance attribute corresponding to the location in parameter
  114530. * @param attributeLocation defines the attribute location of the attribute to disable
  114531. */
  114532. disableInstanceAttribute(attributeLocation: number): void;
  114533. /**
  114534. * Disable the attribute corresponding to the location in parameter
  114535. * @param attributeLocation defines the attribute location of the attribute to disable
  114536. */
  114537. disableAttributeByIndex(attributeLocation: number): void;
  114538. /**
  114539. * Send a draw order
  114540. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114541. * @param indexStart defines the starting index
  114542. * @param indexCount defines the number of index to draw
  114543. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114544. */
  114545. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114546. /**
  114547. * Draw a list of points
  114548. * @param verticesStart defines the index of first vertex to draw
  114549. * @param verticesCount defines the count of vertices to draw
  114550. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114551. */
  114552. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114553. /**
  114554. * Draw a list of unindexed primitives
  114555. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114556. * @param verticesStart defines the index of first vertex to draw
  114557. * @param verticesCount defines the count of vertices to draw
  114558. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114559. */
  114560. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114561. /**
  114562. * Draw a list of indexed primitives
  114563. * @param fillMode defines the primitive to use
  114564. * @param indexStart defines the starting index
  114565. * @param indexCount defines the number of index to draw
  114566. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114567. */
  114568. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114569. /**
  114570. * Draw a list of unindexed primitives
  114571. * @param fillMode defines the primitive to use
  114572. * @param verticesStart defines the index of first vertex to draw
  114573. * @param verticesCount defines the count of vertices to draw
  114574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114575. */
  114576. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114577. private _drawMode;
  114578. /** @hidden */
  114579. protected _reportDrawCall(): void;
  114580. /** @hidden */
  114581. _releaseEffect(effect: Effect): void;
  114582. /** @hidden */
  114583. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114584. /**
  114585. * Create a new effect (used to store vertex/fragment shaders)
  114586. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  114587. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  114588. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  114589. * @param samplers defines an array of string used to represent textures
  114590. * @param defines defines the string containing the defines to use to compile the shaders
  114591. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  114592. * @param onCompiled defines a function to call when the effect creation is successful
  114593. * @param onError defines a function to call when the effect creation has failed
  114594. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  114595. * @returns the new Effect
  114596. */
  114597. 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;
  114598. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  114599. private _compileShader;
  114600. private _compileRawShader;
  114601. /** @hidden */
  114602. _getShaderSource(shader: WebGLShader): Nullable<string>;
  114603. /**
  114604. * Directly creates a webGL program
  114605. * @param pipelineContext defines the pipeline context to attach to
  114606. * @param vertexCode defines the vertex shader code to use
  114607. * @param fragmentCode defines the fragment shader code to use
  114608. * @param context defines the webGL context to use (if not set, the current one will be used)
  114609. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114610. * @returns the new webGL program
  114611. */
  114612. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114613. /**
  114614. * Creates a webGL program
  114615. * @param pipelineContext defines the pipeline context to attach to
  114616. * @param vertexCode defines the vertex shader code to use
  114617. * @param fragmentCode defines the fragment shader code to use
  114618. * @param defines defines the string containing the defines to use to compile the shaders
  114619. * @param context defines the webGL context to use (if not set, the current one will be used)
  114620. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  114621. * @returns the new webGL program
  114622. */
  114623. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114624. /**
  114625. * Creates a new pipeline context
  114626. * @returns the new pipeline
  114627. */
  114628. createPipelineContext(): IPipelineContext;
  114629. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114630. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  114631. /** @hidden */
  114632. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  114633. /** @hidden */
  114634. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  114635. /** @hidden */
  114636. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  114637. /**
  114638. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114639. * @param pipelineContext defines the pipeline context to use
  114640. * @param uniformsNames defines the list of uniform names
  114641. * @returns an array of webGL uniform locations
  114642. */
  114643. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114644. /**
  114645. * Gets the lsit of active attributes for a given webGL program
  114646. * @param pipelineContext defines the pipeline context to use
  114647. * @param attributesNames defines the list of attribute names to get
  114648. * @returns an array of indices indicating the offset of each attribute
  114649. */
  114650. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114651. /**
  114652. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114653. * @param effect defines the effect to activate
  114654. */
  114655. enableEffect(effect: Nullable<Effect>): void;
  114656. /**
  114657. * Set the value of an uniform to a number (int)
  114658. * @param uniform defines the webGL uniform location where to store the value
  114659. * @param value defines the int number to store
  114660. */
  114661. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114662. /**
  114663. * Set the value of an uniform to an array of int32
  114664. * @param uniform defines the webGL uniform location where to store the value
  114665. * @param array defines the array of int32 to store
  114666. */
  114667. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114668. /**
  114669. * Set the value of an uniform to an array of int32 (stored as vec2)
  114670. * @param uniform defines the webGL uniform location where to store the value
  114671. * @param array defines the array of int32 to store
  114672. */
  114673. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114674. /**
  114675. * Set the value of an uniform to an array of int32 (stored as vec3)
  114676. * @param uniform defines the webGL uniform location where to store the value
  114677. * @param array defines the array of int32 to store
  114678. */
  114679. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114680. /**
  114681. * Set the value of an uniform to an array of int32 (stored as vec4)
  114682. * @param uniform defines the webGL uniform location where to store the value
  114683. * @param array defines the array of int32 to store
  114684. */
  114685. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  114686. /**
  114687. * Set the value of an uniform to an array of number
  114688. * @param uniform defines the webGL uniform location where to store the value
  114689. * @param array defines the array of number to store
  114690. */
  114691. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114692. /**
  114693. * Set the value of an uniform to an array of number (stored as vec2)
  114694. * @param uniform defines the webGL uniform location where to store the value
  114695. * @param array defines the array of number to store
  114696. */
  114697. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114698. /**
  114699. * Set the value of an uniform to an array of number (stored as vec3)
  114700. * @param uniform defines the webGL uniform location where to store the value
  114701. * @param array defines the array of number to store
  114702. */
  114703. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114704. /**
  114705. * Set the value of an uniform to an array of number (stored as vec4)
  114706. * @param uniform defines the webGL uniform location where to store the value
  114707. * @param array defines the array of number to store
  114708. */
  114709. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  114710. /**
  114711. * Set the value of an uniform to an array of float32 (stored as matrices)
  114712. * @param uniform defines the webGL uniform location where to store the value
  114713. * @param matrices defines the array of float32 to store
  114714. */
  114715. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  114716. /**
  114717. * Set the value of an uniform to a matrix (3x3)
  114718. * @param uniform defines the webGL uniform location where to store the value
  114719. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114720. */
  114721. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114722. /**
  114723. * Set the value of an uniform to a matrix (2x2)
  114724. * @param uniform defines the webGL uniform location where to store the value
  114725. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114726. */
  114727. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  114728. /**
  114729. * Set the value of an uniform to a number (float)
  114730. * @param uniform defines the webGL uniform location where to store the value
  114731. * @param value defines the float number to store
  114732. */
  114733. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  114734. /**
  114735. * Set the value of an uniform to a vec2
  114736. * @param uniform defines the webGL uniform location where to store the value
  114737. * @param x defines the 1st component of the value
  114738. * @param y defines the 2nd component of the value
  114739. */
  114740. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  114741. /**
  114742. * Set the value of an uniform to a vec3
  114743. * @param uniform defines the webGL uniform location where to store the value
  114744. * @param x defines the 1st component of the value
  114745. * @param y defines the 2nd component of the value
  114746. * @param z defines the 3rd component of the value
  114747. */
  114748. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  114749. /**
  114750. * Set the value of an uniform to a vec4
  114751. * @param uniform defines the webGL uniform location where to store the value
  114752. * @param x defines the 1st component of the value
  114753. * @param y defines the 2nd component of the value
  114754. * @param z defines the 3rd component of the value
  114755. * @param w defines the 4th component of the value
  114756. */
  114757. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  114758. /**
  114759. * Apply all cached states (depth, culling, stencil and alpha)
  114760. */
  114761. applyStates(): void;
  114762. /**
  114763. * Enable or disable color writing
  114764. * @param enable defines the state to set
  114765. */
  114766. setColorWrite(enable: boolean): void;
  114767. /**
  114768. * Gets a boolean indicating if color writing is enabled
  114769. * @returns the current color writing state
  114770. */
  114771. getColorWrite(): boolean;
  114772. /**
  114773. * Gets the depth culling state manager
  114774. */
  114775. get depthCullingState(): DepthCullingState;
  114776. /**
  114777. * Gets the alpha state manager
  114778. */
  114779. get alphaState(): AlphaState;
  114780. /**
  114781. * Gets the stencil state manager
  114782. */
  114783. get stencilState(): StencilState;
  114784. /**
  114785. * Clears the list of texture accessible through engine.
  114786. * This can help preventing texture load conflict due to name collision.
  114787. */
  114788. clearInternalTexturesCache(): void;
  114789. /**
  114790. * Force the entire cache to be cleared
  114791. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114792. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114793. */
  114794. wipeCaches(bruteForce?: boolean): void;
  114795. /** @hidden */
  114796. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  114797. min: number;
  114798. mag: number;
  114799. };
  114800. /** @hidden */
  114801. _createTexture(): WebGLTexture;
  114802. /**
  114803. * Usually called from Texture.ts.
  114804. * Passed information to create a WebGLTexture
  114805. * @param url defines a value which contains one of the following:
  114806. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114807. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114808. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114809. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114810. * @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)
  114811. * @param scene needed for loading to the correct scene
  114812. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114813. * @param onLoad optional callback to be called upon successful completion
  114814. * @param onError optional callback to be called upon failure
  114815. * @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
  114816. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114817. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114818. * @param forcedExtension defines the extension to use to pick the right loader
  114819. * @param mimeType defines an optional mime type
  114820. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114821. */
  114822. 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;
  114823. /**
  114824. * Loads an image as an HTMLImageElement.
  114825. * @param input url string, ArrayBuffer, or Blob to load
  114826. * @param onLoad callback called when the image successfully loads
  114827. * @param onError callback called when the image fails to load
  114828. * @param offlineProvider offline provider for caching
  114829. * @param mimeType optional mime type
  114830. * @returns the HTMLImageElement of the loaded image
  114831. * @hidden
  114832. */
  114833. 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>;
  114834. /**
  114835. * @hidden
  114836. */
  114837. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114838. private _unpackFlipYCached;
  114839. /**
  114840. * In case you are sharing the context with other applications, it might
  114841. * be interested to not cache the unpack flip y state to ensure a consistent
  114842. * value would be set.
  114843. */
  114844. enableUnpackFlipYCached: boolean;
  114845. /** @hidden */
  114846. _unpackFlipY(value: boolean): void;
  114847. /** @hidden */
  114848. _getUnpackAlignement(): number;
  114849. private _getTextureTarget;
  114850. /**
  114851. * Update the sampling mode of a given texture
  114852. * @param samplingMode defines the required sampling mode
  114853. * @param texture defines the texture to update
  114854. * @param generateMipMaps defines whether to generate mipmaps for the texture
  114855. */
  114856. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  114857. /**
  114858. * Update the sampling mode of a given texture
  114859. * @param texture defines the texture to update
  114860. * @param wrapU defines the texture wrap mode of the u coordinates
  114861. * @param wrapV defines the texture wrap mode of the v coordinates
  114862. * @param wrapR defines the texture wrap mode of the r coordinates
  114863. */
  114864. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  114865. /** @hidden */
  114866. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  114867. width: number;
  114868. height: number;
  114869. layers?: number;
  114870. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  114871. /** @hidden */
  114872. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114873. /** @hidden */
  114874. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  114875. /**
  114876. * Update a portion of an internal texture
  114877. * @param texture defines the texture to update
  114878. * @param imageData defines the data to store into the texture
  114879. * @param xOffset defines the x coordinates of the update rectangle
  114880. * @param yOffset defines the y coordinates of the update rectangle
  114881. * @param width defines the width of the update rectangle
  114882. * @param height defines the height of the update rectangle
  114883. * @param faceIndex defines the face index if texture is a cube (0 by default)
  114884. * @param lod defines the lod level to update (0 by default)
  114885. */
  114886. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  114887. /** @hidden */
  114888. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114889. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  114890. private _prepareWebGLTexture;
  114891. /** @hidden */
  114892. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  114893. private _getDepthStencilBuffer;
  114894. /** @hidden */
  114895. _releaseFramebufferObjects(texture: InternalTexture): void;
  114896. /** @hidden */
  114897. _releaseTexture(texture: InternalTexture): void;
  114898. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  114899. protected _setProgram(program: WebGLProgram): void;
  114900. protected _boundUniforms: {
  114901. [key: number]: WebGLUniformLocation;
  114902. };
  114903. /**
  114904. * Binds an effect to the webGL context
  114905. * @param effect defines the effect to bind
  114906. */
  114907. bindSamplers(effect: Effect): void;
  114908. private _activateCurrentTexture;
  114909. /** @hidden */
  114910. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  114911. /** @hidden */
  114912. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  114913. /**
  114914. * Unbind all textures from the webGL context
  114915. */
  114916. unbindAllTextures(): void;
  114917. /**
  114918. * Sets a texture to the according uniform.
  114919. * @param channel The texture channel
  114920. * @param uniform The uniform to set
  114921. * @param texture The texture to apply
  114922. */
  114923. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  114924. private _bindSamplerUniformToChannel;
  114925. private _getTextureWrapMode;
  114926. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  114927. /**
  114928. * Sets an array of texture to the webGL context
  114929. * @param channel defines the channel where the texture array must be set
  114930. * @param uniform defines the associated uniform location
  114931. * @param textures defines the array of textures to bind
  114932. */
  114933. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  114934. /** @hidden */
  114935. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  114936. private _setTextureParameterFloat;
  114937. private _setTextureParameterInteger;
  114938. /**
  114939. * Unbind all vertex attributes from the webGL context
  114940. */
  114941. unbindAllAttributes(): void;
  114942. /**
  114943. * 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
  114944. */
  114945. releaseEffects(): void;
  114946. /**
  114947. * Dispose and release all associated resources
  114948. */
  114949. dispose(): void;
  114950. /**
  114951. * Attach a new callback raised when context lost event is fired
  114952. * @param callback defines the callback to call
  114953. */
  114954. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114955. /**
  114956. * Attach a new callback raised when context restored event is fired
  114957. * @param callback defines the callback to call
  114958. */
  114959. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  114960. /**
  114961. * Get the current error code of the webGL context
  114962. * @returns the error code
  114963. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  114964. */
  114965. getError(): number;
  114966. private _canRenderToFloatFramebuffer;
  114967. private _canRenderToHalfFloatFramebuffer;
  114968. private _canRenderToFramebuffer;
  114969. /** @hidden */
  114970. _getWebGLTextureType(type: number): number;
  114971. /** @hidden */
  114972. _getInternalFormat(format: number): number;
  114973. /** @hidden */
  114974. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  114975. /** @hidden */
  114976. _getRGBAMultiSampleBufferFormat(type: number): number;
  114977. /** @hidden */
  114978. _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;
  114979. /**
  114980. * Loads a file from a url
  114981. * @param url url to load
  114982. * @param onSuccess callback called when the file successfully loads
  114983. * @param onProgress callback called while file is loading (if the server supports this mode)
  114984. * @param offlineProvider defines the offline provider for caching
  114985. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114986. * @param onError callback called when the file fails to load
  114987. * @returns a file request object
  114988. * @hidden
  114989. */
  114990. 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;
  114991. /**
  114992. * Reads pixels from the current frame buffer. Please note that this function can be slow
  114993. * @param x defines the x coordinate of the rectangle where pixels must be read
  114994. * @param y defines the y coordinate of the rectangle where pixels must be read
  114995. * @param width defines the width of the rectangle where pixels must be read
  114996. * @param height defines the height of the rectangle where pixels must be read
  114997. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  114998. * @returns a Uint8Array containing RGBA colors
  114999. */
  115000. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  115001. private static _isSupported;
  115002. /**
  115003. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  115004. * @returns true if the engine can be created
  115005. * @ignorenaming
  115006. */
  115007. static isSupported(): boolean;
  115008. /**
  115009. * Find the next highest power of two.
  115010. * @param x Number to start search from.
  115011. * @return Next highest power of two.
  115012. */
  115013. static CeilingPOT(x: number): number;
  115014. /**
  115015. * Find the next lowest power of two.
  115016. * @param x Number to start search from.
  115017. * @return Next lowest power of two.
  115018. */
  115019. static FloorPOT(x: number): number;
  115020. /**
  115021. * Find the nearest power of two.
  115022. * @param x Number to start search from.
  115023. * @return Next nearest power of two.
  115024. */
  115025. static NearestPOT(x: number): number;
  115026. /**
  115027. * Get the closest exponent of two
  115028. * @param value defines the value to approximate
  115029. * @param max defines the maximum value to return
  115030. * @param mode defines how to define the closest value
  115031. * @returns closest exponent of two of the given value
  115032. */
  115033. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  115034. /**
  115035. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  115036. * @param func - the function to be called
  115037. * @param requester - the object that will request the next frame. Falls back to window.
  115038. * @returns frame number
  115039. */
  115040. static QueueNewFrame(func: () => void, requester?: any): number;
  115041. /**
  115042. * Gets host document
  115043. * @returns the host document object
  115044. */
  115045. getHostDocument(): Nullable<Document>;
  115046. }
  115047. }
  115048. declare module BABYLON {
  115049. /**
  115050. * Class representing spherical harmonics coefficients to the 3rd degree
  115051. */
  115052. export class SphericalHarmonics {
  115053. /**
  115054. * Defines whether or not the harmonics have been prescaled for rendering.
  115055. */
  115056. preScaled: boolean;
  115057. /**
  115058. * The l0,0 coefficients of the spherical harmonics
  115059. */
  115060. l00: Vector3;
  115061. /**
  115062. * The l1,-1 coefficients of the spherical harmonics
  115063. */
  115064. l1_1: Vector3;
  115065. /**
  115066. * The l1,0 coefficients of the spherical harmonics
  115067. */
  115068. l10: Vector3;
  115069. /**
  115070. * The l1,1 coefficients of the spherical harmonics
  115071. */
  115072. l11: Vector3;
  115073. /**
  115074. * The l2,-2 coefficients of the spherical harmonics
  115075. */
  115076. l2_2: Vector3;
  115077. /**
  115078. * The l2,-1 coefficients of the spherical harmonics
  115079. */
  115080. l2_1: Vector3;
  115081. /**
  115082. * The l2,0 coefficients of the spherical harmonics
  115083. */
  115084. l20: Vector3;
  115085. /**
  115086. * The l2,1 coefficients of the spherical harmonics
  115087. */
  115088. l21: Vector3;
  115089. /**
  115090. * The l2,2 coefficients of the spherical harmonics
  115091. */
  115092. l22: Vector3;
  115093. /**
  115094. * Adds a light to the spherical harmonics
  115095. * @param direction the direction of the light
  115096. * @param color the color of the light
  115097. * @param deltaSolidAngle the delta solid angle of the light
  115098. */
  115099. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  115100. /**
  115101. * Scales the spherical harmonics by the given amount
  115102. * @param scale the amount to scale
  115103. */
  115104. scaleInPlace(scale: number): void;
  115105. /**
  115106. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  115107. *
  115108. * ```
  115109. * E_lm = A_l * L_lm
  115110. * ```
  115111. *
  115112. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  115113. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  115114. * the scaling factors are given in equation 9.
  115115. */
  115116. convertIncidentRadianceToIrradiance(): void;
  115117. /**
  115118. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  115119. *
  115120. * ```
  115121. * L = (1/pi) * E * rho
  115122. * ```
  115123. *
  115124. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  115125. */
  115126. convertIrradianceToLambertianRadiance(): void;
  115127. /**
  115128. * Integrates the reconstruction coefficients directly in to the SH preventing further
  115129. * required operations at run time.
  115130. *
  115131. * This is simply done by scaling back the SH with Ylm constants parameter.
  115132. * The trigonometric part being applied by the shader at run time.
  115133. */
  115134. preScaleForRendering(): void;
  115135. /**
  115136. * Constructs a spherical harmonics from an array.
  115137. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  115138. * @returns the spherical harmonics
  115139. */
  115140. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  115141. /**
  115142. * Gets the spherical harmonics from polynomial
  115143. * @param polynomial the spherical polynomial
  115144. * @returns the spherical harmonics
  115145. */
  115146. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  115147. }
  115148. /**
  115149. * Class representing spherical polynomial coefficients to the 3rd degree
  115150. */
  115151. export class SphericalPolynomial {
  115152. private _harmonics;
  115153. /**
  115154. * The spherical harmonics used to create the polynomials.
  115155. */
  115156. get preScaledHarmonics(): SphericalHarmonics;
  115157. /**
  115158. * The x coefficients of the spherical polynomial
  115159. */
  115160. x: Vector3;
  115161. /**
  115162. * The y coefficients of the spherical polynomial
  115163. */
  115164. y: Vector3;
  115165. /**
  115166. * The z coefficients of the spherical polynomial
  115167. */
  115168. z: Vector3;
  115169. /**
  115170. * The xx coefficients of the spherical polynomial
  115171. */
  115172. xx: Vector3;
  115173. /**
  115174. * The yy coefficients of the spherical polynomial
  115175. */
  115176. yy: Vector3;
  115177. /**
  115178. * The zz coefficients of the spherical polynomial
  115179. */
  115180. zz: Vector3;
  115181. /**
  115182. * The xy coefficients of the spherical polynomial
  115183. */
  115184. xy: Vector3;
  115185. /**
  115186. * The yz coefficients of the spherical polynomial
  115187. */
  115188. yz: Vector3;
  115189. /**
  115190. * The zx coefficients of the spherical polynomial
  115191. */
  115192. zx: Vector3;
  115193. /**
  115194. * Adds an ambient color to the spherical polynomial
  115195. * @param color the color to add
  115196. */
  115197. addAmbient(color: Color3): void;
  115198. /**
  115199. * Scales the spherical polynomial by the given amount
  115200. * @param scale the amount to scale
  115201. */
  115202. scaleInPlace(scale: number): void;
  115203. /**
  115204. * Gets the spherical polynomial from harmonics
  115205. * @param harmonics the spherical harmonics
  115206. * @returns the spherical polynomial
  115207. */
  115208. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  115209. /**
  115210. * Constructs a spherical polynomial from an array.
  115211. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  115212. * @returns the spherical polynomial
  115213. */
  115214. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  115215. }
  115216. }
  115217. declare module BABYLON {
  115218. /**
  115219. * Defines the source of the internal texture
  115220. */
  115221. export enum InternalTextureSource {
  115222. /**
  115223. * The source of the texture data is unknown
  115224. */
  115225. Unknown = 0,
  115226. /**
  115227. * Texture data comes from an URL
  115228. */
  115229. Url = 1,
  115230. /**
  115231. * Texture data is only used for temporary storage
  115232. */
  115233. Temp = 2,
  115234. /**
  115235. * Texture data comes from raw data (ArrayBuffer)
  115236. */
  115237. Raw = 3,
  115238. /**
  115239. * Texture content is dynamic (video or dynamic texture)
  115240. */
  115241. Dynamic = 4,
  115242. /**
  115243. * Texture content is generated by rendering to it
  115244. */
  115245. RenderTarget = 5,
  115246. /**
  115247. * Texture content is part of a multi render target process
  115248. */
  115249. MultiRenderTarget = 6,
  115250. /**
  115251. * Texture data comes from a cube data file
  115252. */
  115253. Cube = 7,
  115254. /**
  115255. * Texture data comes from a raw cube data
  115256. */
  115257. CubeRaw = 8,
  115258. /**
  115259. * Texture data come from a prefiltered cube data file
  115260. */
  115261. CubePrefiltered = 9,
  115262. /**
  115263. * Texture content is raw 3D data
  115264. */
  115265. Raw3D = 10,
  115266. /**
  115267. * Texture content is raw 2D array data
  115268. */
  115269. Raw2DArray = 11,
  115270. /**
  115271. * Texture content is a depth texture
  115272. */
  115273. Depth = 12,
  115274. /**
  115275. * Texture data comes from a raw cube data encoded with RGBD
  115276. */
  115277. CubeRawRGBD = 13
  115278. }
  115279. /**
  115280. * Class used to store data associated with WebGL texture data for the engine
  115281. * This class should not be used directly
  115282. */
  115283. export class InternalTexture {
  115284. /** @hidden */
  115285. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  115286. /**
  115287. * Defines if the texture is ready
  115288. */
  115289. isReady: boolean;
  115290. /**
  115291. * Defines if the texture is a cube texture
  115292. */
  115293. isCube: boolean;
  115294. /**
  115295. * Defines if the texture contains 3D data
  115296. */
  115297. is3D: boolean;
  115298. /**
  115299. * Defines if the texture contains 2D array data
  115300. */
  115301. is2DArray: boolean;
  115302. /**
  115303. * Defines if the texture contains multiview data
  115304. */
  115305. isMultiview: boolean;
  115306. /**
  115307. * Gets the URL used to load this texture
  115308. */
  115309. url: string;
  115310. /**
  115311. * Gets the sampling mode of the texture
  115312. */
  115313. samplingMode: number;
  115314. /**
  115315. * Gets a boolean indicating if the texture needs mipmaps generation
  115316. */
  115317. generateMipMaps: boolean;
  115318. /**
  115319. * Gets the number of samples used by the texture (WebGL2+ only)
  115320. */
  115321. samples: number;
  115322. /**
  115323. * Gets the type of the texture (int, float...)
  115324. */
  115325. type: number;
  115326. /**
  115327. * Gets the format of the texture (RGB, RGBA...)
  115328. */
  115329. format: number;
  115330. /**
  115331. * Observable called when the texture is loaded
  115332. */
  115333. onLoadedObservable: Observable<InternalTexture>;
  115334. /**
  115335. * Gets the width of the texture
  115336. */
  115337. width: number;
  115338. /**
  115339. * Gets the height of the texture
  115340. */
  115341. height: number;
  115342. /**
  115343. * Gets the depth of the texture
  115344. */
  115345. depth: number;
  115346. /**
  115347. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  115348. */
  115349. baseWidth: number;
  115350. /**
  115351. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  115352. */
  115353. baseHeight: number;
  115354. /**
  115355. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  115356. */
  115357. baseDepth: number;
  115358. /**
  115359. * Gets a boolean indicating if the texture is inverted on Y axis
  115360. */
  115361. invertY: boolean;
  115362. /** @hidden */
  115363. _invertVScale: boolean;
  115364. /** @hidden */
  115365. _associatedChannel: number;
  115366. /** @hidden */
  115367. _source: InternalTextureSource;
  115368. /** @hidden */
  115369. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  115370. /** @hidden */
  115371. _bufferView: Nullable<ArrayBufferView>;
  115372. /** @hidden */
  115373. _bufferViewArray: Nullable<ArrayBufferView[]>;
  115374. /** @hidden */
  115375. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  115376. /** @hidden */
  115377. _size: number;
  115378. /** @hidden */
  115379. _extension: string;
  115380. /** @hidden */
  115381. _files: Nullable<string[]>;
  115382. /** @hidden */
  115383. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115384. /** @hidden */
  115385. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115386. /** @hidden */
  115387. _framebuffer: Nullable<WebGLFramebuffer>;
  115388. /** @hidden */
  115389. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  115390. /** @hidden */
  115391. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  115392. /** @hidden */
  115393. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  115394. /** @hidden */
  115395. _attachments: Nullable<number[]>;
  115396. /** @hidden */
  115397. _textureArray: Nullable<InternalTexture[]>;
  115398. /** @hidden */
  115399. _cachedCoordinatesMode: Nullable<number>;
  115400. /** @hidden */
  115401. _cachedWrapU: Nullable<number>;
  115402. /** @hidden */
  115403. _cachedWrapV: Nullable<number>;
  115404. /** @hidden */
  115405. _cachedWrapR: Nullable<number>;
  115406. /** @hidden */
  115407. _cachedAnisotropicFilteringLevel: Nullable<number>;
  115408. /** @hidden */
  115409. _isDisabled: boolean;
  115410. /** @hidden */
  115411. _compression: Nullable<string>;
  115412. /** @hidden */
  115413. _generateStencilBuffer: boolean;
  115414. /** @hidden */
  115415. _generateDepthBuffer: boolean;
  115416. /** @hidden */
  115417. _comparisonFunction: number;
  115418. /** @hidden */
  115419. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  115420. /** @hidden */
  115421. _lodGenerationScale: number;
  115422. /** @hidden */
  115423. _lodGenerationOffset: number;
  115424. /** @hidden */
  115425. _depthStencilTexture: Nullable<InternalTexture>;
  115426. /** @hidden */
  115427. _colorTextureArray: Nullable<WebGLTexture>;
  115428. /** @hidden */
  115429. _depthStencilTextureArray: Nullable<WebGLTexture>;
  115430. /** @hidden */
  115431. _lodTextureHigh: Nullable<BaseTexture>;
  115432. /** @hidden */
  115433. _lodTextureMid: Nullable<BaseTexture>;
  115434. /** @hidden */
  115435. _lodTextureLow: Nullable<BaseTexture>;
  115436. /** @hidden */
  115437. _isRGBD: boolean;
  115438. /** @hidden */
  115439. _linearSpecularLOD: boolean;
  115440. /** @hidden */
  115441. _irradianceTexture: Nullable<BaseTexture>;
  115442. /** @hidden */
  115443. _webGLTexture: Nullable<WebGLTexture>;
  115444. /** @hidden */
  115445. _references: number;
  115446. private _engine;
  115447. /**
  115448. * Gets the Engine the texture belongs to.
  115449. * @returns The babylon engine
  115450. */
  115451. getEngine(): ThinEngine;
  115452. /**
  115453. * Gets the data source type of the texture
  115454. */
  115455. get source(): InternalTextureSource;
  115456. /**
  115457. * Creates a new InternalTexture
  115458. * @param engine defines the engine to use
  115459. * @param source defines the type of data that will be used
  115460. * @param delayAllocation if the texture allocation should be delayed (default: false)
  115461. */
  115462. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  115463. /**
  115464. * Increments the number of references (ie. the number of Texture that point to it)
  115465. */
  115466. incrementReferences(): void;
  115467. /**
  115468. * Change the size of the texture (not the size of the content)
  115469. * @param width defines the new width
  115470. * @param height defines the new height
  115471. * @param depth defines the new depth (1 by default)
  115472. */
  115473. updateSize(width: int, height: int, depth?: int): void;
  115474. /** @hidden */
  115475. _rebuild(): void;
  115476. /** @hidden */
  115477. _swapAndDie(target: InternalTexture): void;
  115478. /**
  115479. * Dispose the current allocated resources
  115480. */
  115481. dispose(): void;
  115482. }
  115483. }
  115484. declare module BABYLON {
  115485. /**
  115486. * Class used to work with sound analyzer using fast fourier transform (FFT)
  115487. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115488. */
  115489. export class Analyser {
  115490. /**
  115491. * Gets or sets the smoothing
  115492. * @ignorenaming
  115493. */
  115494. SMOOTHING: number;
  115495. /**
  115496. * Gets or sets the FFT table size
  115497. * @ignorenaming
  115498. */
  115499. FFT_SIZE: number;
  115500. /**
  115501. * Gets or sets the bar graph amplitude
  115502. * @ignorenaming
  115503. */
  115504. BARGRAPHAMPLITUDE: number;
  115505. /**
  115506. * Gets or sets the position of the debug canvas
  115507. * @ignorenaming
  115508. */
  115509. DEBUGCANVASPOS: {
  115510. x: number;
  115511. y: number;
  115512. };
  115513. /**
  115514. * Gets or sets the debug canvas size
  115515. * @ignorenaming
  115516. */
  115517. DEBUGCANVASSIZE: {
  115518. width: number;
  115519. height: number;
  115520. };
  115521. private _byteFreqs;
  115522. private _byteTime;
  115523. private _floatFreqs;
  115524. private _webAudioAnalyser;
  115525. private _debugCanvas;
  115526. private _debugCanvasContext;
  115527. private _scene;
  115528. private _registerFunc;
  115529. private _audioEngine;
  115530. /**
  115531. * Creates a new analyser
  115532. * @param scene defines hosting scene
  115533. */
  115534. constructor(scene: Scene);
  115535. /**
  115536. * Get the number of data values you will have to play with for the visualization
  115537. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  115538. * @returns a number
  115539. */
  115540. getFrequencyBinCount(): number;
  115541. /**
  115542. * Gets the current frequency data as a byte array
  115543. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115544. * @returns a Uint8Array
  115545. */
  115546. getByteFrequencyData(): Uint8Array;
  115547. /**
  115548. * Gets the current waveform as a byte array
  115549. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  115550. * @returns a Uint8Array
  115551. */
  115552. getByteTimeDomainData(): Uint8Array;
  115553. /**
  115554. * Gets the current frequency data as a float array
  115555. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  115556. * @returns a Float32Array
  115557. */
  115558. getFloatFrequencyData(): Float32Array;
  115559. /**
  115560. * Renders the debug canvas
  115561. */
  115562. drawDebugCanvas(): void;
  115563. /**
  115564. * Stops rendering the debug canvas and removes it
  115565. */
  115566. stopDebugCanvas(): void;
  115567. /**
  115568. * Connects two audio nodes
  115569. * @param inputAudioNode defines first node to connect
  115570. * @param outputAudioNode defines second node to connect
  115571. */
  115572. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  115573. /**
  115574. * Releases all associated resources
  115575. */
  115576. dispose(): void;
  115577. }
  115578. }
  115579. declare module BABYLON {
  115580. /**
  115581. * This represents an audio engine and it is responsible
  115582. * to play, synchronize and analyse sounds throughout the application.
  115583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115584. */
  115585. export interface IAudioEngine extends IDisposable {
  115586. /**
  115587. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115588. */
  115589. readonly canUseWebAudio: boolean;
  115590. /**
  115591. * Gets the current AudioContext if available.
  115592. */
  115593. readonly audioContext: Nullable<AudioContext>;
  115594. /**
  115595. * The master gain node defines the global audio volume of your audio engine.
  115596. */
  115597. readonly masterGain: GainNode;
  115598. /**
  115599. * Gets whether or not mp3 are supported by your browser.
  115600. */
  115601. readonly isMP3supported: boolean;
  115602. /**
  115603. * Gets whether or not ogg are supported by your browser.
  115604. */
  115605. readonly isOGGsupported: boolean;
  115606. /**
  115607. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115608. * @ignoreNaming
  115609. */
  115610. WarnedWebAudioUnsupported: boolean;
  115611. /**
  115612. * Defines if the audio engine relies on a custom unlocked button.
  115613. * In this case, the embedded button will not be displayed.
  115614. */
  115615. useCustomUnlockedButton: boolean;
  115616. /**
  115617. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  115618. */
  115619. readonly unlocked: boolean;
  115620. /**
  115621. * Event raised when audio has been unlocked on the browser.
  115622. */
  115623. onAudioUnlockedObservable: Observable<AudioEngine>;
  115624. /**
  115625. * Event raised when audio has been locked on the browser.
  115626. */
  115627. onAudioLockedObservable: Observable<AudioEngine>;
  115628. /**
  115629. * Flags the audio engine in Locked state.
  115630. * This happens due to new browser policies preventing audio to autoplay.
  115631. */
  115632. lock(): void;
  115633. /**
  115634. * Unlocks the audio engine once a user action has been done on the dom.
  115635. * This is helpful to resume play once browser policies have been satisfied.
  115636. */
  115637. unlock(): void;
  115638. /**
  115639. * Gets the global volume sets on the master gain.
  115640. * @returns the global volume if set or -1 otherwise
  115641. */
  115642. getGlobalVolume(): number;
  115643. /**
  115644. * Sets the global volume of your experience (sets on the master gain).
  115645. * @param newVolume Defines the new global volume of the application
  115646. */
  115647. setGlobalVolume(newVolume: number): void;
  115648. /**
  115649. * Connect the audio engine to an audio analyser allowing some amazing
  115650. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115651. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115652. * @param analyser The analyser to connect to the engine
  115653. */
  115654. connectToAnalyser(analyser: Analyser): void;
  115655. }
  115656. /**
  115657. * This represents the default audio engine used in babylon.
  115658. * It is responsible to play, synchronize and analyse sounds throughout the application.
  115659. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115660. */
  115661. export class AudioEngine implements IAudioEngine {
  115662. private _audioContext;
  115663. private _audioContextInitialized;
  115664. private _muteButton;
  115665. private _hostElement;
  115666. /**
  115667. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  115668. */
  115669. canUseWebAudio: boolean;
  115670. /**
  115671. * The master gain node defines the global audio volume of your audio engine.
  115672. */
  115673. masterGain: GainNode;
  115674. /**
  115675. * Defines if Babylon should emit a warning if WebAudio is not supported.
  115676. * @ignoreNaming
  115677. */
  115678. WarnedWebAudioUnsupported: boolean;
  115679. /**
  115680. * Gets whether or not mp3 are supported by your browser.
  115681. */
  115682. isMP3supported: boolean;
  115683. /**
  115684. * Gets whether or not ogg are supported by your browser.
  115685. */
  115686. isOGGsupported: boolean;
  115687. /**
  115688. * Gets whether audio has been unlocked on the device.
  115689. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  115690. * a user interaction has happened.
  115691. */
  115692. unlocked: boolean;
  115693. /**
  115694. * Defines if the audio engine relies on a custom unlocked button.
  115695. * In this case, the embedded button will not be displayed.
  115696. */
  115697. useCustomUnlockedButton: boolean;
  115698. /**
  115699. * Event raised when audio has been unlocked on the browser.
  115700. */
  115701. onAudioUnlockedObservable: Observable<AudioEngine>;
  115702. /**
  115703. * Event raised when audio has been locked on the browser.
  115704. */
  115705. onAudioLockedObservable: Observable<AudioEngine>;
  115706. /**
  115707. * Gets the current AudioContext if available.
  115708. */
  115709. get audioContext(): Nullable<AudioContext>;
  115710. private _connectedAnalyser;
  115711. /**
  115712. * Instantiates a new audio engine.
  115713. *
  115714. * There should be only one per page as some browsers restrict the number
  115715. * of audio contexts you can create.
  115716. * @param hostElement defines the host element where to display the mute icon if necessary
  115717. */
  115718. constructor(hostElement?: Nullable<HTMLElement>);
  115719. /**
  115720. * Flags the audio engine in Locked state.
  115721. * This happens due to new browser policies preventing audio to autoplay.
  115722. */
  115723. lock(): void;
  115724. /**
  115725. * Unlocks the audio engine once a user action has been done on the dom.
  115726. * This is helpful to resume play once browser policies have been satisfied.
  115727. */
  115728. unlock(): void;
  115729. private _resumeAudioContext;
  115730. private _initializeAudioContext;
  115731. private _tryToRun;
  115732. private _triggerRunningState;
  115733. private _triggerSuspendedState;
  115734. private _displayMuteButton;
  115735. private _moveButtonToTopLeft;
  115736. private _onResize;
  115737. private _hideMuteButton;
  115738. /**
  115739. * Destroy and release the resources associated with the audio ccontext.
  115740. */
  115741. dispose(): void;
  115742. /**
  115743. * Gets the global volume sets on the master gain.
  115744. * @returns the global volume if set or -1 otherwise
  115745. */
  115746. getGlobalVolume(): number;
  115747. /**
  115748. * Sets the global volume of your experience (sets on the master gain).
  115749. * @param newVolume Defines the new global volume of the application
  115750. */
  115751. setGlobalVolume(newVolume: number): void;
  115752. /**
  115753. * Connect the audio engine to an audio analyser allowing some amazing
  115754. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  115755. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  115756. * @param analyser The analyser to connect to the engine
  115757. */
  115758. connectToAnalyser(analyser: Analyser): void;
  115759. }
  115760. }
  115761. declare module BABYLON {
  115762. /**
  115763. * Interface used to present a loading screen while loading a scene
  115764. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115765. */
  115766. export interface ILoadingScreen {
  115767. /**
  115768. * Function called to display the loading screen
  115769. */
  115770. displayLoadingUI: () => void;
  115771. /**
  115772. * Function called to hide the loading screen
  115773. */
  115774. hideLoadingUI: () => void;
  115775. /**
  115776. * Gets or sets the color to use for the background
  115777. */
  115778. loadingUIBackgroundColor: string;
  115779. /**
  115780. * Gets or sets the text to display while loading
  115781. */
  115782. loadingUIText: string;
  115783. }
  115784. /**
  115785. * Class used for the default loading screen
  115786. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115787. */
  115788. export class DefaultLoadingScreen implements ILoadingScreen {
  115789. private _renderingCanvas;
  115790. private _loadingText;
  115791. private _loadingDivBackgroundColor;
  115792. private _loadingDiv;
  115793. private _loadingTextDiv;
  115794. /** Gets or sets the logo url to use for the default loading screen */
  115795. static DefaultLogoUrl: string;
  115796. /** Gets or sets the spinner url to use for the default loading screen */
  115797. static DefaultSpinnerUrl: string;
  115798. /**
  115799. * Creates a new default loading screen
  115800. * @param _renderingCanvas defines the canvas used to render the scene
  115801. * @param _loadingText defines the default text to display
  115802. * @param _loadingDivBackgroundColor defines the default background color
  115803. */
  115804. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  115805. /**
  115806. * Function called to display the loading screen
  115807. */
  115808. displayLoadingUI(): void;
  115809. /**
  115810. * Function called to hide the loading screen
  115811. */
  115812. hideLoadingUI(): void;
  115813. /**
  115814. * Gets or sets the text to display while loading
  115815. */
  115816. set loadingUIText(text: string);
  115817. get loadingUIText(): string;
  115818. /**
  115819. * Gets or sets the color to use for the background
  115820. */
  115821. get loadingUIBackgroundColor(): string;
  115822. set loadingUIBackgroundColor(color: string);
  115823. private _resizeLoadingUI;
  115824. }
  115825. }
  115826. declare module BABYLON {
  115827. /**
  115828. * Interface for any object that can request an animation frame
  115829. */
  115830. export interface ICustomAnimationFrameRequester {
  115831. /**
  115832. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  115833. */
  115834. renderFunction?: Function;
  115835. /**
  115836. * Called to request the next frame to render to
  115837. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  115838. */
  115839. requestAnimationFrame: Function;
  115840. /**
  115841. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  115842. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  115843. */
  115844. requestID?: number;
  115845. }
  115846. }
  115847. declare module BABYLON {
  115848. /**
  115849. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  115850. */
  115851. export class PerformanceMonitor {
  115852. private _enabled;
  115853. private _rollingFrameTime;
  115854. private _lastFrameTimeMs;
  115855. /**
  115856. * constructor
  115857. * @param frameSampleSize The number of samples required to saturate the sliding window
  115858. */
  115859. constructor(frameSampleSize?: number);
  115860. /**
  115861. * Samples current frame
  115862. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  115863. */
  115864. sampleFrame(timeMs?: number): void;
  115865. /**
  115866. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115867. */
  115868. get averageFrameTime(): number;
  115869. /**
  115870. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  115871. */
  115872. get averageFrameTimeVariance(): number;
  115873. /**
  115874. * Returns the frame time of the most recent frame
  115875. */
  115876. get instantaneousFrameTime(): number;
  115877. /**
  115878. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  115879. */
  115880. get averageFPS(): number;
  115881. /**
  115882. * Returns the average framerate in frames per second using the most recent frame time
  115883. */
  115884. get instantaneousFPS(): number;
  115885. /**
  115886. * Returns true if enough samples have been taken to completely fill the sliding window
  115887. */
  115888. get isSaturated(): boolean;
  115889. /**
  115890. * Enables contributions to the sliding window sample set
  115891. */
  115892. enable(): void;
  115893. /**
  115894. * Disables contributions to the sliding window sample set
  115895. * Samples will not be interpolated over the disabled period
  115896. */
  115897. disable(): void;
  115898. /**
  115899. * Returns true if sampling is enabled
  115900. */
  115901. get isEnabled(): boolean;
  115902. /**
  115903. * Resets performance monitor
  115904. */
  115905. reset(): void;
  115906. }
  115907. /**
  115908. * RollingAverage
  115909. *
  115910. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  115911. */
  115912. export class RollingAverage {
  115913. /**
  115914. * Current average
  115915. */
  115916. average: number;
  115917. /**
  115918. * Current variance
  115919. */
  115920. variance: number;
  115921. protected _samples: Array<number>;
  115922. protected _sampleCount: number;
  115923. protected _pos: number;
  115924. protected _m2: number;
  115925. /**
  115926. * constructor
  115927. * @param length The number of samples required to saturate the sliding window
  115928. */
  115929. constructor(length: number);
  115930. /**
  115931. * Adds a sample to the sample set
  115932. * @param v The sample value
  115933. */
  115934. add(v: number): void;
  115935. /**
  115936. * Returns previously added values or null if outside of history or outside the sliding window domain
  115937. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  115938. * @return Value previously recorded with add() or null if outside of range
  115939. */
  115940. history(i: number): number;
  115941. /**
  115942. * Returns true if enough samples have been taken to completely fill the sliding window
  115943. * @return true if sample-set saturated
  115944. */
  115945. isSaturated(): boolean;
  115946. /**
  115947. * Resets the rolling average (equivalent to 0 samples taken so far)
  115948. */
  115949. reset(): void;
  115950. /**
  115951. * Wraps a value around the sample range boundaries
  115952. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  115953. * @return Wrapped position in sample range
  115954. */
  115955. protected _wrapPosition(i: number): number;
  115956. }
  115957. }
  115958. declare module BABYLON {
  115959. /**
  115960. * This class is used to track a performance counter which is number based.
  115961. * The user has access to many properties which give statistics of different nature.
  115962. *
  115963. * The implementer can track two kinds of Performance Counter: time and count.
  115964. * 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.
  115965. * 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.
  115966. */
  115967. export class PerfCounter {
  115968. /**
  115969. * Gets or sets a global boolean to turn on and off all the counters
  115970. */
  115971. static Enabled: boolean;
  115972. /**
  115973. * Returns the smallest value ever
  115974. */
  115975. get min(): number;
  115976. /**
  115977. * Returns the biggest value ever
  115978. */
  115979. get max(): number;
  115980. /**
  115981. * Returns the average value since the performance counter is running
  115982. */
  115983. get average(): number;
  115984. /**
  115985. * Returns the average value of the last second the counter was monitored
  115986. */
  115987. get lastSecAverage(): number;
  115988. /**
  115989. * Returns the current value
  115990. */
  115991. get current(): number;
  115992. /**
  115993. * Gets the accumulated total
  115994. */
  115995. get total(): number;
  115996. /**
  115997. * Gets the total value count
  115998. */
  115999. get count(): number;
  116000. /**
  116001. * Creates a new counter
  116002. */
  116003. constructor();
  116004. /**
  116005. * Call this method to start monitoring a new frame.
  116006. * 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.
  116007. */
  116008. fetchNewFrame(): void;
  116009. /**
  116010. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  116011. * @param newCount the count value to add to the monitored count
  116012. * @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.
  116013. */
  116014. addCount(newCount: number, fetchResult: boolean): void;
  116015. /**
  116016. * Start monitoring this performance counter
  116017. */
  116018. beginMonitoring(): void;
  116019. /**
  116020. * Compute the time lapsed since the previous beginMonitoring() call.
  116021. * @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
  116022. */
  116023. endMonitoring(newFrame?: boolean): void;
  116024. private _fetchResult;
  116025. private _startMonitoringTime;
  116026. private _min;
  116027. private _max;
  116028. private _average;
  116029. private _current;
  116030. private _totalValueCount;
  116031. private _totalAccumulated;
  116032. private _lastSecAverage;
  116033. private _lastSecAccumulated;
  116034. private _lastSecTime;
  116035. private _lastSecValueCount;
  116036. }
  116037. }
  116038. declare module BABYLON {
  116039. interface ThinEngine {
  116040. /**
  116041. * Sets alpha constants used by some alpha blending modes
  116042. * @param r defines the red component
  116043. * @param g defines the green component
  116044. * @param b defines the blue component
  116045. * @param a defines the alpha component
  116046. */
  116047. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  116048. /**
  116049. * Sets the current alpha mode
  116050. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116051. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116052. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116053. */
  116054. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116055. /**
  116056. * Gets the current alpha mode
  116057. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116058. * @returns the current alpha mode
  116059. */
  116060. getAlphaMode(): number;
  116061. /**
  116062. * Sets the current alpha equation
  116063. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  116064. */
  116065. setAlphaEquation(equation: number): void;
  116066. /**
  116067. * Gets the current alpha equation.
  116068. * @returns the current alpha equation
  116069. */
  116070. getAlphaEquation(): number;
  116071. }
  116072. }
  116073. declare module BABYLON {
  116074. interface ThinEngine {
  116075. /** @hidden */
  116076. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  116077. }
  116078. }
  116079. declare module BABYLON {
  116080. /**
  116081. * Defines the interface used by display changed events
  116082. */
  116083. export interface IDisplayChangedEventArgs {
  116084. /** Gets the vrDisplay object (if any) */
  116085. vrDisplay: Nullable<any>;
  116086. /** Gets a boolean indicating if webVR is supported */
  116087. vrSupported: boolean;
  116088. }
  116089. /**
  116090. * Defines the interface used by objects containing a viewport (like a camera)
  116091. */
  116092. interface IViewportOwnerLike {
  116093. /**
  116094. * Gets or sets the viewport
  116095. */
  116096. viewport: IViewportLike;
  116097. }
  116098. /**
  116099. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  116100. */
  116101. export class Engine extends ThinEngine {
  116102. /** Defines that alpha blending is disabled */
  116103. static readonly ALPHA_DISABLE: number;
  116104. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  116105. static readonly ALPHA_ADD: number;
  116106. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  116107. static readonly ALPHA_COMBINE: number;
  116108. /** Defines that alpha blending to DEST - SRC * DEST */
  116109. static readonly ALPHA_SUBTRACT: number;
  116110. /** Defines that alpha blending to SRC * DEST */
  116111. static readonly ALPHA_MULTIPLY: number;
  116112. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  116113. static readonly ALPHA_MAXIMIZED: number;
  116114. /** Defines that alpha blending to SRC + DEST */
  116115. static readonly ALPHA_ONEONE: number;
  116116. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  116117. static readonly ALPHA_PREMULTIPLIED: number;
  116118. /**
  116119. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  116120. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  116121. */
  116122. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  116123. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  116124. static readonly ALPHA_INTERPOLATE: number;
  116125. /**
  116126. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  116127. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  116128. */
  116129. static readonly ALPHA_SCREENMODE: number;
  116130. /** Defines that the ressource is not delayed*/
  116131. static readonly DELAYLOADSTATE_NONE: number;
  116132. /** Defines that the ressource was successfully delay loaded */
  116133. static readonly DELAYLOADSTATE_LOADED: number;
  116134. /** Defines that the ressource is currently delay loading */
  116135. static readonly DELAYLOADSTATE_LOADING: number;
  116136. /** Defines that the ressource is delayed and has not started loading */
  116137. static readonly DELAYLOADSTATE_NOTLOADED: number;
  116138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  116139. static readonly NEVER: number;
  116140. /** 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 */
  116141. static readonly ALWAYS: number;
  116142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  116143. static readonly LESS: number;
  116144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  116145. static readonly EQUAL: number;
  116146. /** 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 */
  116147. static readonly LEQUAL: number;
  116148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  116149. static readonly GREATER: number;
  116150. /** 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 */
  116151. static readonly GEQUAL: number;
  116152. /** 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 */
  116153. static readonly NOTEQUAL: number;
  116154. /** Passed to stencilOperation to specify that stencil value must be kept */
  116155. static readonly KEEP: number;
  116156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  116157. static readonly REPLACE: number;
  116158. /** Passed to stencilOperation to specify that stencil value must be incremented */
  116159. static readonly INCR: number;
  116160. /** Passed to stencilOperation to specify that stencil value must be decremented */
  116161. static readonly DECR: number;
  116162. /** Passed to stencilOperation to specify that stencil value must be inverted */
  116163. static readonly INVERT: number;
  116164. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  116165. static readonly INCR_WRAP: number;
  116166. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  116167. static readonly DECR_WRAP: number;
  116168. /** Texture is not repeating outside of 0..1 UVs */
  116169. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  116170. /** Texture is repeating outside of 0..1 UVs */
  116171. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  116172. /** Texture is repeating and mirrored */
  116173. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  116174. /** ALPHA */
  116175. static readonly TEXTUREFORMAT_ALPHA: number;
  116176. /** LUMINANCE */
  116177. static readonly TEXTUREFORMAT_LUMINANCE: number;
  116178. /** LUMINANCE_ALPHA */
  116179. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  116180. /** RGB */
  116181. static readonly TEXTUREFORMAT_RGB: number;
  116182. /** RGBA */
  116183. static readonly TEXTUREFORMAT_RGBA: number;
  116184. /** RED */
  116185. static readonly TEXTUREFORMAT_RED: number;
  116186. /** RED (2nd reference) */
  116187. static readonly TEXTUREFORMAT_R: number;
  116188. /** RG */
  116189. static readonly TEXTUREFORMAT_RG: number;
  116190. /** RED_INTEGER */
  116191. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  116192. /** RED_INTEGER (2nd reference) */
  116193. static readonly TEXTUREFORMAT_R_INTEGER: number;
  116194. /** RG_INTEGER */
  116195. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  116196. /** RGB_INTEGER */
  116197. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  116198. /** RGBA_INTEGER */
  116199. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  116200. /** UNSIGNED_BYTE */
  116201. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  116202. /** UNSIGNED_BYTE (2nd reference) */
  116203. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  116204. /** FLOAT */
  116205. static readonly TEXTURETYPE_FLOAT: number;
  116206. /** HALF_FLOAT */
  116207. static readonly TEXTURETYPE_HALF_FLOAT: number;
  116208. /** BYTE */
  116209. static readonly TEXTURETYPE_BYTE: number;
  116210. /** SHORT */
  116211. static readonly TEXTURETYPE_SHORT: number;
  116212. /** UNSIGNED_SHORT */
  116213. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  116214. /** INT */
  116215. static readonly TEXTURETYPE_INT: number;
  116216. /** UNSIGNED_INT */
  116217. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  116218. /** UNSIGNED_SHORT_4_4_4_4 */
  116219. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  116220. /** UNSIGNED_SHORT_5_5_5_1 */
  116221. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  116222. /** UNSIGNED_SHORT_5_6_5 */
  116223. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  116224. /** UNSIGNED_INT_2_10_10_10_REV */
  116225. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  116226. /** UNSIGNED_INT_24_8 */
  116227. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  116228. /** UNSIGNED_INT_10F_11F_11F_REV */
  116229. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  116230. /** UNSIGNED_INT_5_9_9_9_REV */
  116231. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  116232. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  116233. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116234. /** nearest is mag = nearest and min = nearest and mip = linear */
  116235. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  116236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116237. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  116238. /** Trilinear is mag = linear and min = linear and mip = linear */
  116239. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  116240. /** nearest is mag = nearest and min = nearest and mip = linear */
  116241. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  116242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  116243. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  116244. /** Trilinear is mag = linear and min = linear and mip = linear */
  116245. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  116246. /** mag = nearest and min = nearest and mip = nearest */
  116247. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  116248. /** mag = nearest and min = linear and mip = nearest */
  116249. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  116250. /** mag = nearest and min = linear and mip = linear */
  116251. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  116252. /** mag = nearest and min = linear and mip = none */
  116253. static readonly TEXTURE_NEAREST_LINEAR: number;
  116254. /** mag = nearest and min = nearest and mip = none */
  116255. static readonly TEXTURE_NEAREST_NEAREST: number;
  116256. /** mag = linear and min = nearest and mip = nearest */
  116257. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  116258. /** mag = linear and min = nearest and mip = linear */
  116259. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  116260. /** mag = linear and min = linear and mip = none */
  116261. static readonly TEXTURE_LINEAR_LINEAR: number;
  116262. /** mag = linear and min = nearest and mip = none */
  116263. static readonly TEXTURE_LINEAR_NEAREST: number;
  116264. /** Explicit coordinates mode */
  116265. static readonly TEXTURE_EXPLICIT_MODE: number;
  116266. /** Spherical coordinates mode */
  116267. static readonly TEXTURE_SPHERICAL_MODE: number;
  116268. /** Planar coordinates mode */
  116269. static readonly TEXTURE_PLANAR_MODE: number;
  116270. /** Cubic coordinates mode */
  116271. static readonly TEXTURE_CUBIC_MODE: number;
  116272. /** Projection coordinates mode */
  116273. static readonly TEXTURE_PROJECTION_MODE: number;
  116274. /** Skybox coordinates mode */
  116275. static readonly TEXTURE_SKYBOX_MODE: number;
  116276. /** Inverse Cubic coordinates mode */
  116277. static readonly TEXTURE_INVCUBIC_MODE: number;
  116278. /** Equirectangular coordinates mode */
  116279. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  116280. /** Equirectangular Fixed coordinates mode */
  116281. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  116282. /** Equirectangular Fixed Mirrored coordinates mode */
  116283. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  116284. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  116285. static readonly SCALEMODE_FLOOR: number;
  116286. /** Defines that texture rescaling will look for the nearest power of 2 size */
  116287. static readonly SCALEMODE_NEAREST: number;
  116288. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  116289. static readonly SCALEMODE_CEILING: number;
  116290. /**
  116291. * Returns the current npm package of the sdk
  116292. */
  116293. static get NpmPackage(): string;
  116294. /**
  116295. * Returns the current version of the framework
  116296. */
  116297. static get Version(): string;
  116298. /** Gets the list of created engines */
  116299. static get Instances(): Engine[];
  116300. /**
  116301. * Gets the latest created engine
  116302. */
  116303. static get LastCreatedEngine(): Nullable<Engine>;
  116304. /**
  116305. * Gets the latest created scene
  116306. */
  116307. static get LastCreatedScene(): Nullable<Scene>;
  116308. /**
  116309. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  116310. * @param flag defines which part of the materials must be marked as dirty
  116311. * @param predicate defines a predicate used to filter which materials should be affected
  116312. */
  116313. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  116314. /**
  116315. * Method called to create the default loading screen.
  116316. * This can be overriden in your own app.
  116317. * @param canvas The rendering canvas element
  116318. * @returns The loading screen
  116319. */
  116320. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  116321. /**
  116322. * Method called to create the default rescale post process on each engine.
  116323. */
  116324. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  116325. /**
  116326. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  116327. **/
  116328. enableOfflineSupport: boolean;
  116329. /**
  116330. * 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)
  116331. **/
  116332. disableManifestCheck: boolean;
  116333. /**
  116334. * Gets the list of created scenes
  116335. */
  116336. scenes: Scene[];
  116337. /**
  116338. * Event raised when a new scene is created
  116339. */
  116340. onNewSceneAddedObservable: Observable<Scene>;
  116341. /**
  116342. * Gets the list of created postprocesses
  116343. */
  116344. postProcesses: PostProcess[];
  116345. /**
  116346. * Gets a boolean indicating if the pointer is currently locked
  116347. */
  116348. isPointerLock: boolean;
  116349. /**
  116350. * Observable event triggered each time the rendering canvas is resized
  116351. */
  116352. onResizeObservable: Observable<Engine>;
  116353. /**
  116354. * Observable event triggered each time the canvas loses focus
  116355. */
  116356. onCanvasBlurObservable: Observable<Engine>;
  116357. /**
  116358. * Observable event triggered each time the canvas gains focus
  116359. */
  116360. onCanvasFocusObservable: Observable<Engine>;
  116361. /**
  116362. * Observable event triggered each time the canvas receives pointerout event
  116363. */
  116364. onCanvasPointerOutObservable: Observable<PointerEvent>;
  116365. /**
  116366. * Observable raised when the engine begins a new frame
  116367. */
  116368. onBeginFrameObservable: Observable<Engine>;
  116369. /**
  116370. * If set, will be used to request the next animation frame for the render loop
  116371. */
  116372. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  116373. /**
  116374. * Observable raised when the engine ends the current frame
  116375. */
  116376. onEndFrameObservable: Observable<Engine>;
  116377. /**
  116378. * Observable raised when the engine is about to compile a shader
  116379. */
  116380. onBeforeShaderCompilationObservable: Observable<Engine>;
  116381. /**
  116382. * Observable raised when the engine has jsut compiled a shader
  116383. */
  116384. onAfterShaderCompilationObservable: Observable<Engine>;
  116385. /**
  116386. * Gets the audio engine
  116387. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116388. * @ignorenaming
  116389. */
  116390. static audioEngine: IAudioEngine;
  116391. /**
  116392. * Default AudioEngine factory responsible of creating the Audio Engine.
  116393. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  116394. */
  116395. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  116396. /**
  116397. * Default offline support factory responsible of creating a tool used to store data locally.
  116398. * By default, this will create a Database object if the workload has been embedded.
  116399. */
  116400. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  116401. private _loadingScreen;
  116402. private _pointerLockRequested;
  116403. private _rescalePostProcess;
  116404. private _deterministicLockstep;
  116405. private _lockstepMaxSteps;
  116406. private _timeStep;
  116407. protected get _supportsHardwareTextureRescaling(): boolean;
  116408. private _fps;
  116409. private _deltaTime;
  116410. /** @hidden */
  116411. _drawCalls: PerfCounter;
  116412. /** 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 */
  116413. canvasTabIndex: number;
  116414. /**
  116415. * Turn this value on if you want to pause FPS computation when in background
  116416. */
  116417. disablePerformanceMonitorInBackground: boolean;
  116418. private _performanceMonitor;
  116419. /**
  116420. * Gets the performance monitor attached to this engine
  116421. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  116422. */
  116423. get performanceMonitor(): PerformanceMonitor;
  116424. private _onFocus;
  116425. private _onBlur;
  116426. private _onCanvasPointerOut;
  116427. private _onCanvasBlur;
  116428. private _onCanvasFocus;
  116429. private _onFullscreenChange;
  116430. private _onPointerLockChange;
  116431. /**
  116432. * Gets the HTML element used to attach event listeners
  116433. * @returns a HTML element
  116434. */
  116435. getInputElement(): Nullable<HTMLElement>;
  116436. /**
  116437. * Creates a new engine
  116438. * @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
  116439. * @param antialias defines enable antialiasing (default: false)
  116440. * @param options defines further options to be sent to the getContext() function
  116441. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116442. */
  116443. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116444. /**
  116445. * Gets current aspect ratio
  116446. * @param viewportOwner defines the camera to use to get the aspect ratio
  116447. * @param useScreen defines if screen size must be used (or the current render target if any)
  116448. * @returns a number defining the aspect ratio
  116449. */
  116450. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  116451. /**
  116452. * Gets current screen aspect ratio
  116453. * @returns a number defining the aspect ratio
  116454. */
  116455. getScreenAspectRatio(): number;
  116456. /**
  116457. * Gets the client rect of the HTML canvas attached with the current webGL context
  116458. * @returns a client rectanglee
  116459. */
  116460. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  116461. /**
  116462. * Gets the client rect of the HTML element used for events
  116463. * @returns a client rectanglee
  116464. */
  116465. getInputElementClientRect(): Nullable<ClientRect>;
  116466. /**
  116467. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116468. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116469. * @returns true if engine is in deterministic lock step mode
  116470. */
  116471. isDeterministicLockStep(): boolean;
  116472. /**
  116473. * Gets the max steps when engine is running in deterministic lock step
  116474. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116475. * @returns the max steps
  116476. */
  116477. getLockstepMaxSteps(): number;
  116478. /**
  116479. * Returns the time in ms between steps when using deterministic lock step.
  116480. * @returns time step in (ms)
  116481. */
  116482. getTimeStep(): number;
  116483. /**
  116484. * Force the mipmap generation for the given render target texture
  116485. * @param texture defines the render target texture to use
  116486. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  116487. */
  116488. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  116489. /** States */
  116490. /**
  116491. * Set various states to the webGL context
  116492. * @param culling defines backface culling state
  116493. * @param zOffset defines the value to apply to zOffset (0 by default)
  116494. * @param force defines if states must be applied even if cache is up to date
  116495. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116496. */
  116497. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116498. /**
  116499. * Set the z offset to apply to current rendering
  116500. * @param value defines the offset to apply
  116501. */
  116502. setZOffset(value: number): void;
  116503. /**
  116504. * Gets the current value of the zOffset
  116505. * @returns the current zOffset state
  116506. */
  116507. getZOffset(): number;
  116508. /**
  116509. * Enable or disable depth buffering
  116510. * @param enable defines the state to set
  116511. */
  116512. setDepthBuffer(enable: boolean): void;
  116513. /**
  116514. * Gets a boolean indicating if depth writing is enabled
  116515. * @returns the current depth writing state
  116516. */
  116517. getDepthWrite(): boolean;
  116518. /**
  116519. * Enable or disable depth writing
  116520. * @param enable defines the state to set
  116521. */
  116522. setDepthWrite(enable: boolean): void;
  116523. /**
  116524. * Gets a boolean indicating if stencil buffer is enabled
  116525. * @returns the current stencil buffer state
  116526. */
  116527. getStencilBuffer(): boolean;
  116528. /**
  116529. * Enable or disable the stencil buffer
  116530. * @param enable defines if the stencil buffer must be enabled or disabled
  116531. */
  116532. setStencilBuffer(enable: boolean): void;
  116533. /**
  116534. * Gets the current stencil mask
  116535. * @returns a number defining the new stencil mask to use
  116536. */
  116537. getStencilMask(): number;
  116538. /**
  116539. * Sets the current stencil mask
  116540. * @param mask defines the new stencil mask to use
  116541. */
  116542. setStencilMask(mask: number): void;
  116543. /**
  116544. * Gets the current stencil function
  116545. * @returns a number defining the stencil function to use
  116546. */
  116547. getStencilFunction(): number;
  116548. /**
  116549. * Gets the current stencil reference value
  116550. * @returns a number defining the stencil reference value to use
  116551. */
  116552. getStencilFunctionReference(): number;
  116553. /**
  116554. * Gets the current stencil mask
  116555. * @returns a number defining the stencil mask to use
  116556. */
  116557. getStencilFunctionMask(): number;
  116558. /**
  116559. * Sets the current stencil function
  116560. * @param stencilFunc defines the new stencil function to use
  116561. */
  116562. setStencilFunction(stencilFunc: number): void;
  116563. /**
  116564. * Sets the current stencil reference
  116565. * @param reference defines the new stencil reference to use
  116566. */
  116567. setStencilFunctionReference(reference: number): void;
  116568. /**
  116569. * Sets the current stencil mask
  116570. * @param mask defines the new stencil mask to use
  116571. */
  116572. setStencilFunctionMask(mask: number): void;
  116573. /**
  116574. * Gets the current stencil operation when stencil fails
  116575. * @returns a number defining stencil operation to use when stencil fails
  116576. */
  116577. getStencilOperationFail(): number;
  116578. /**
  116579. * Gets the current stencil operation when depth fails
  116580. * @returns a number defining stencil operation to use when depth fails
  116581. */
  116582. getStencilOperationDepthFail(): number;
  116583. /**
  116584. * Gets the current stencil operation when stencil passes
  116585. * @returns a number defining stencil operation to use when stencil passes
  116586. */
  116587. getStencilOperationPass(): number;
  116588. /**
  116589. * Sets the stencil operation to use when stencil fails
  116590. * @param operation defines the stencil operation to use when stencil fails
  116591. */
  116592. setStencilOperationFail(operation: number): void;
  116593. /**
  116594. * Sets the stencil operation to use when depth fails
  116595. * @param operation defines the stencil operation to use when depth fails
  116596. */
  116597. setStencilOperationDepthFail(operation: number): void;
  116598. /**
  116599. * Sets the stencil operation to use when stencil passes
  116600. * @param operation defines the stencil operation to use when stencil passes
  116601. */
  116602. setStencilOperationPass(operation: number): void;
  116603. /**
  116604. * Sets a boolean indicating if the dithering state is enabled or disabled
  116605. * @param value defines the dithering state
  116606. */
  116607. setDitheringState(value: boolean): void;
  116608. /**
  116609. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  116610. * @param value defines the rasterizer state
  116611. */
  116612. setRasterizerState(value: boolean): void;
  116613. /**
  116614. * Gets the current depth function
  116615. * @returns a number defining the depth function
  116616. */
  116617. getDepthFunction(): Nullable<number>;
  116618. /**
  116619. * Sets the current depth function
  116620. * @param depthFunc defines the function to use
  116621. */
  116622. setDepthFunction(depthFunc: number): void;
  116623. /**
  116624. * Sets the current depth function to GREATER
  116625. */
  116626. setDepthFunctionToGreater(): void;
  116627. /**
  116628. * Sets the current depth function to GEQUAL
  116629. */
  116630. setDepthFunctionToGreaterOrEqual(): void;
  116631. /**
  116632. * Sets the current depth function to LESS
  116633. */
  116634. setDepthFunctionToLess(): void;
  116635. /**
  116636. * Sets the current depth function to LEQUAL
  116637. */
  116638. setDepthFunctionToLessOrEqual(): void;
  116639. private _cachedStencilBuffer;
  116640. private _cachedStencilFunction;
  116641. private _cachedStencilMask;
  116642. private _cachedStencilOperationPass;
  116643. private _cachedStencilOperationFail;
  116644. private _cachedStencilOperationDepthFail;
  116645. private _cachedStencilReference;
  116646. /**
  116647. * Caches the the state of the stencil buffer
  116648. */
  116649. cacheStencilState(): void;
  116650. /**
  116651. * Restores the state of the stencil buffer
  116652. */
  116653. restoreStencilState(): void;
  116654. /**
  116655. * Directly set the WebGL Viewport
  116656. * @param x defines the x coordinate of the viewport (in screen space)
  116657. * @param y defines the y coordinate of the viewport (in screen space)
  116658. * @param width defines the width of the viewport (in screen space)
  116659. * @param height defines the height of the viewport (in screen space)
  116660. * @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
  116661. */
  116662. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  116663. /**
  116664. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  116665. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116666. * @param y defines the y-coordinate of the corner of the clear rectangle
  116667. * @param width defines the width of the clear rectangle
  116668. * @param height defines the height of the clear rectangle
  116669. * @param clearColor defines the clear color
  116670. */
  116671. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  116672. /**
  116673. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  116674. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  116675. * @param y defines the y-coordinate of the corner of the clear rectangle
  116676. * @param width defines the width of the clear rectangle
  116677. * @param height defines the height of the clear rectangle
  116678. */
  116679. enableScissor(x: number, y: number, width: number, height: number): void;
  116680. /**
  116681. * Disable previously set scissor test rectangle
  116682. */
  116683. disableScissor(): void;
  116684. protected _reportDrawCall(): void;
  116685. /**
  116686. * Initializes a webVR display and starts listening to display change events
  116687. * The onVRDisplayChangedObservable will be notified upon these changes
  116688. * @returns The onVRDisplayChangedObservable
  116689. */
  116690. initWebVR(): Observable<IDisplayChangedEventArgs>;
  116691. /** @hidden */
  116692. _prepareVRComponent(): void;
  116693. /** @hidden */
  116694. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  116695. /** @hidden */
  116696. _submitVRFrame(): void;
  116697. /**
  116698. * Call this function to leave webVR mode
  116699. * Will do nothing if webVR is not supported or if there is no webVR device
  116700. * @see https://doc.babylonjs.com/how_to/webvr_camera
  116701. */
  116702. disableVR(): void;
  116703. /**
  116704. * Gets a boolean indicating that the system is in VR mode and is presenting
  116705. * @returns true if VR mode is engaged
  116706. */
  116707. isVRPresenting(): boolean;
  116708. /** @hidden */
  116709. _requestVRFrame(): void;
  116710. /** @hidden */
  116711. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  116712. /**
  116713. * Gets the source code of the vertex shader associated with a specific webGL program
  116714. * @param program defines the program to use
  116715. * @returns a string containing the source code of the vertex shader associated with the program
  116716. */
  116717. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  116718. /**
  116719. * Gets the source code of the fragment shader associated with a specific webGL program
  116720. * @param program defines the program to use
  116721. * @returns a string containing the source code of the fragment shader associated with the program
  116722. */
  116723. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  116724. /**
  116725. * Sets a depth stencil texture from a render target to the according uniform.
  116726. * @param channel The texture channel
  116727. * @param uniform The uniform to set
  116728. * @param texture The render target texture containing the depth stencil texture to apply
  116729. */
  116730. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  116731. /**
  116732. * Sets a texture to the webGL context from a postprocess
  116733. * @param channel defines the channel to use
  116734. * @param postProcess defines the source postprocess
  116735. */
  116736. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  116737. /**
  116738. * Binds the output of the passed in post process to the texture channel specified
  116739. * @param channel The channel the texture should be bound to
  116740. * @param postProcess The post process which's output should be bound
  116741. */
  116742. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  116743. protected _rebuildBuffers(): void;
  116744. /** @hidden */
  116745. _renderFrame(): void;
  116746. _renderLoop(): void;
  116747. /** @hidden */
  116748. _renderViews(): boolean;
  116749. /**
  116750. * Toggle full screen mode
  116751. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116752. */
  116753. switchFullscreen(requestPointerLock: boolean): void;
  116754. /**
  116755. * Enters full screen mode
  116756. * @param requestPointerLock defines if a pointer lock should be requested from the user
  116757. */
  116758. enterFullscreen(requestPointerLock: boolean): void;
  116759. /**
  116760. * Exits full screen mode
  116761. */
  116762. exitFullscreen(): void;
  116763. /**
  116764. * Enters Pointerlock mode
  116765. */
  116766. enterPointerlock(): void;
  116767. /**
  116768. * Exits Pointerlock mode
  116769. */
  116770. exitPointerlock(): void;
  116771. /**
  116772. * Begin a new frame
  116773. */
  116774. beginFrame(): void;
  116775. /**
  116776. * Enf the current frame
  116777. */
  116778. endFrame(): void;
  116779. resize(): void;
  116780. /**
  116781. * Force a specific size of the canvas
  116782. * @param width defines the new canvas' width
  116783. * @param height defines the new canvas' height
  116784. * @returns true if the size was changed
  116785. */
  116786. setSize(width: number, height: number): boolean;
  116787. /**
  116788. * Updates a dynamic vertex buffer.
  116789. * @param vertexBuffer the vertex buffer to update
  116790. * @param data the data used to update the vertex buffer
  116791. * @param byteOffset the byte offset of the data
  116792. * @param byteLength the byte length of the data
  116793. */
  116794. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  116795. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116796. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116797. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116798. _releaseTexture(texture: InternalTexture): void;
  116799. /**
  116800. * @hidden
  116801. * Rescales a texture
  116802. * @param source input texutre
  116803. * @param destination destination texture
  116804. * @param scene scene to use to render the resize
  116805. * @param internalFormat format to use when resizing
  116806. * @param onComplete callback to be called when resize has completed
  116807. */
  116808. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116809. /**
  116810. * Gets the current framerate
  116811. * @returns a number representing the framerate
  116812. */
  116813. getFps(): number;
  116814. /**
  116815. * Gets the time spent between current and previous frame
  116816. * @returns a number representing the delta time in ms
  116817. */
  116818. getDeltaTime(): number;
  116819. private _measureFps;
  116820. /** @hidden */
  116821. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  116822. /**
  116823. * Update a dynamic index buffer
  116824. * @param indexBuffer defines the target index buffer
  116825. * @param indices defines the data to update
  116826. * @param offset defines the offset in the target index buffer where update should start
  116827. */
  116828. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  116829. /**
  116830. * Updates the sample count of a render target texture
  116831. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  116832. * @param texture defines the texture to update
  116833. * @param samples defines the sample count to set
  116834. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  116835. */
  116836. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  116837. /**
  116838. * Updates a depth texture Comparison Mode and Function.
  116839. * If the comparison Function is equal to 0, the mode will be set to none.
  116840. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  116841. * @param texture The texture to set the comparison function for
  116842. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  116843. */
  116844. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  116845. /**
  116846. * Creates a webGL buffer to use with instanciation
  116847. * @param capacity defines the size of the buffer
  116848. * @returns the webGL buffer
  116849. */
  116850. createInstancesBuffer(capacity: number): DataBuffer;
  116851. /**
  116852. * Delete a webGL buffer used with instanciation
  116853. * @param buffer defines the webGL buffer to delete
  116854. */
  116855. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  116856. private _clientWaitAsync;
  116857. /** @hidden */
  116858. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  116859. dispose(): void;
  116860. private _disableTouchAction;
  116861. /**
  116862. * Display the loading screen
  116863. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116864. */
  116865. displayLoadingUI(): void;
  116866. /**
  116867. * Hide the loading screen
  116868. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116869. */
  116870. hideLoadingUI(): void;
  116871. /**
  116872. * Gets the current loading screen object
  116873. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116874. */
  116875. get loadingScreen(): ILoadingScreen;
  116876. /**
  116877. * Sets the current loading screen object
  116878. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116879. */
  116880. set loadingScreen(loadingScreen: ILoadingScreen);
  116881. /**
  116882. * Sets the current loading screen text
  116883. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116884. */
  116885. set loadingUIText(text: string);
  116886. /**
  116887. * Sets the current loading screen background color
  116888. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116889. */
  116890. set loadingUIBackgroundColor(color: string);
  116891. /** Pointerlock and fullscreen */
  116892. /**
  116893. * Ask the browser to promote the current element to pointerlock mode
  116894. * @param element defines the DOM element to promote
  116895. */
  116896. static _RequestPointerlock(element: HTMLElement): void;
  116897. /**
  116898. * Asks the browser to exit pointerlock mode
  116899. */
  116900. static _ExitPointerlock(): void;
  116901. /**
  116902. * Ask the browser to promote the current element to fullscreen rendering mode
  116903. * @param element defines the DOM element to promote
  116904. */
  116905. static _RequestFullscreen(element: HTMLElement): void;
  116906. /**
  116907. * Asks the browser to exit fullscreen mode
  116908. */
  116909. static _ExitFullscreen(): void;
  116910. }
  116911. }
  116912. declare module BABYLON {
  116913. /**
  116914. * The engine store class is responsible to hold all the instances of Engine and Scene created
  116915. * during the life time of the application.
  116916. */
  116917. export class EngineStore {
  116918. /** Gets the list of created engines */
  116919. static Instances: Engine[];
  116920. /** @hidden */
  116921. static _LastCreatedScene: Nullable<Scene>;
  116922. /**
  116923. * Gets the latest created engine
  116924. */
  116925. static get LastCreatedEngine(): Nullable<Engine>;
  116926. /**
  116927. * Gets the latest created scene
  116928. */
  116929. static get LastCreatedScene(): Nullable<Scene>;
  116930. /**
  116931. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  116932. * @ignorenaming
  116933. */
  116934. static UseFallbackTexture: boolean;
  116935. /**
  116936. * Texture content used if a texture cannot loaded
  116937. * @ignorenaming
  116938. */
  116939. static FallbackTexture: string;
  116940. }
  116941. }
  116942. declare module BABYLON {
  116943. /**
  116944. * Helper class that provides a small promise polyfill
  116945. */
  116946. export class PromisePolyfill {
  116947. /**
  116948. * Static function used to check if the polyfill is required
  116949. * If this is the case then the function will inject the polyfill to window.Promise
  116950. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  116951. */
  116952. static Apply(force?: boolean): void;
  116953. }
  116954. }
  116955. declare module BABYLON {
  116956. /**
  116957. * Interface for screenshot methods with describe argument called `size` as object with options
  116958. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  116959. */
  116960. export interface IScreenshotSize {
  116961. /**
  116962. * number in pixels for canvas height
  116963. */
  116964. height?: number;
  116965. /**
  116966. * multiplier allowing render at a higher or lower resolution
  116967. * If value is defined then height and width will be ignored and taken from camera
  116968. */
  116969. precision?: number;
  116970. /**
  116971. * number in pixels for canvas width
  116972. */
  116973. width?: number;
  116974. }
  116975. }
  116976. declare module BABYLON {
  116977. interface IColor4Like {
  116978. r: float;
  116979. g: float;
  116980. b: float;
  116981. a: float;
  116982. }
  116983. /**
  116984. * Class containing a set of static utilities functions
  116985. */
  116986. export class Tools {
  116987. /**
  116988. * Gets or sets the base URL to use to load assets
  116989. */
  116990. static get BaseUrl(): string;
  116991. static set BaseUrl(value: string);
  116992. /**
  116993. * Enable/Disable Custom HTTP Request Headers globally.
  116994. * default = false
  116995. * @see CustomRequestHeaders
  116996. */
  116997. static UseCustomRequestHeaders: boolean;
  116998. /**
  116999. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  117000. * i.e. when loading files, where the server/service expects an Authorization header
  117001. */
  117002. static CustomRequestHeaders: {
  117003. [key: string]: string;
  117004. };
  117005. /**
  117006. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  117007. */
  117008. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  117009. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  117010. /**
  117011. * Default behaviour for cors in the application.
  117012. * It can be a string if the expected behavior is identical in the entire app.
  117013. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  117014. */
  117015. static get CorsBehavior(): string | ((url: string | string[]) => string);
  117016. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  117017. /**
  117018. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117019. * @ignorenaming
  117020. */
  117021. static get UseFallbackTexture(): boolean;
  117022. static set UseFallbackTexture(value: boolean);
  117023. /**
  117024. * Use this object to register external classes like custom textures or material
  117025. * to allow the laoders to instantiate them
  117026. */
  117027. static get RegisteredExternalClasses(): {
  117028. [key: string]: Object;
  117029. };
  117030. static set RegisteredExternalClasses(classes: {
  117031. [key: string]: Object;
  117032. });
  117033. /**
  117034. * Texture content used if a texture cannot loaded
  117035. * @ignorenaming
  117036. */
  117037. static get fallbackTexture(): string;
  117038. static set fallbackTexture(value: string);
  117039. /**
  117040. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  117041. * @param u defines the coordinate on X axis
  117042. * @param v defines the coordinate on Y axis
  117043. * @param width defines the width of the source data
  117044. * @param height defines the height of the source data
  117045. * @param pixels defines the source byte array
  117046. * @param color defines the output color
  117047. */
  117048. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  117049. /**
  117050. * Interpolates between a and b via alpha
  117051. * @param a The lower value (returned when alpha = 0)
  117052. * @param b The upper value (returned when alpha = 1)
  117053. * @param alpha The interpolation-factor
  117054. * @return The mixed value
  117055. */
  117056. static Mix(a: number, b: number, alpha: number): number;
  117057. /**
  117058. * Tries to instantiate a new object from a given class name
  117059. * @param className defines the class name to instantiate
  117060. * @returns the new object or null if the system was not able to do the instantiation
  117061. */
  117062. static Instantiate(className: string): any;
  117063. /**
  117064. * Provides a slice function that will work even on IE
  117065. * @param data defines the array to slice
  117066. * @param start defines the start of the data (optional)
  117067. * @param end defines the end of the data (optional)
  117068. * @returns the new sliced array
  117069. */
  117070. static Slice<T>(data: T, start?: number, end?: number): T;
  117071. /**
  117072. * Polyfill for setImmediate
  117073. * @param action defines the action to execute after the current execution block
  117074. */
  117075. static SetImmediate(action: () => void): void;
  117076. /**
  117077. * Function indicating if a number is an exponent of 2
  117078. * @param value defines the value to test
  117079. * @returns true if the value is an exponent of 2
  117080. */
  117081. static IsExponentOfTwo(value: number): boolean;
  117082. private static _tmpFloatArray;
  117083. /**
  117084. * Returns the nearest 32-bit single precision float representation of a Number
  117085. * @param value A Number. If the parameter is of a different type, it will get converted
  117086. * to a number or to NaN if it cannot be converted
  117087. * @returns number
  117088. */
  117089. static FloatRound(value: number): number;
  117090. /**
  117091. * Extracts the filename from a path
  117092. * @param path defines the path to use
  117093. * @returns the filename
  117094. */
  117095. static GetFilename(path: string): string;
  117096. /**
  117097. * Extracts the "folder" part of a path (everything before the filename).
  117098. * @param uri The URI to extract the info from
  117099. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  117100. * @returns The "folder" part of the path
  117101. */
  117102. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  117103. /**
  117104. * Extracts text content from a DOM element hierarchy
  117105. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  117106. */
  117107. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  117108. /**
  117109. * Convert an angle in radians to degrees
  117110. * @param angle defines the angle to convert
  117111. * @returns the angle in degrees
  117112. */
  117113. static ToDegrees(angle: number): number;
  117114. /**
  117115. * Convert an angle in degrees to radians
  117116. * @param angle defines the angle to convert
  117117. * @returns the angle in radians
  117118. */
  117119. static ToRadians(angle: number): number;
  117120. /**
  117121. * Returns an array if obj is not an array
  117122. * @param obj defines the object to evaluate as an array
  117123. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  117124. * @returns either obj directly if obj is an array or a new array containing obj
  117125. */
  117126. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  117127. /**
  117128. * Gets the pointer prefix to use
  117129. * @param engine defines the engine we are finding the prefix for
  117130. * @returns "pointer" if touch is enabled. Else returns "mouse"
  117131. */
  117132. static GetPointerPrefix(engine: Engine): string;
  117133. /**
  117134. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  117135. * @param url define the url we are trying
  117136. * @param element define the dom element where to configure the cors policy
  117137. */
  117138. static SetCorsBehavior(url: string | string[], element: {
  117139. crossOrigin: string | null;
  117140. }): void;
  117141. /**
  117142. * Removes unwanted characters from an url
  117143. * @param url defines the url to clean
  117144. * @returns the cleaned url
  117145. */
  117146. static CleanUrl(url: string): string;
  117147. /**
  117148. * Gets or sets a function used to pre-process url before using them to load assets
  117149. */
  117150. static get PreprocessUrl(): (url: string) => string;
  117151. static set PreprocessUrl(processor: (url: string) => string);
  117152. /**
  117153. * Loads an image as an HTMLImageElement.
  117154. * @param input url string, ArrayBuffer, or Blob to load
  117155. * @param onLoad callback called when the image successfully loads
  117156. * @param onError callback called when the image fails to load
  117157. * @param offlineProvider offline provider for caching
  117158. * @param mimeType optional mime type
  117159. * @returns the HTMLImageElement of the loaded image
  117160. */
  117161. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  117162. /**
  117163. * Loads a file from a url
  117164. * @param url url string, ArrayBuffer, or Blob to load
  117165. * @param onSuccess callback called when the file successfully loads
  117166. * @param onProgress callback called while file is loading (if the server supports this mode)
  117167. * @param offlineProvider defines the offline provider for caching
  117168. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117169. * @param onError callback called when the file fails to load
  117170. * @returns a file request object
  117171. */
  117172. 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;
  117173. /**
  117174. * Loads a file from a url
  117175. * @param url the file url to load
  117176. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117177. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  117178. */
  117179. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  117180. /**
  117181. * Load a script (identified by an url). When the url returns, the
  117182. * content of this file is added into a new script element, attached to the DOM (body element)
  117183. * @param scriptUrl defines the url of the script to laod
  117184. * @param onSuccess defines the callback called when the script is loaded
  117185. * @param onError defines the callback to call if an error occurs
  117186. * @param scriptId defines the id of the script element
  117187. */
  117188. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  117189. /**
  117190. * Load an asynchronous script (identified by an url). When the url returns, the
  117191. * content of this file is added into a new script element, attached to the DOM (body element)
  117192. * @param scriptUrl defines the url of the script to laod
  117193. * @param scriptId defines the id of the script element
  117194. * @returns a promise request object
  117195. */
  117196. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  117197. /**
  117198. * Loads a file from a blob
  117199. * @param fileToLoad defines the blob to use
  117200. * @param callback defines the callback to call when data is loaded
  117201. * @param progressCallback defines the callback to call during loading process
  117202. * @returns a file request object
  117203. */
  117204. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  117205. /**
  117206. * Reads a file from a File object
  117207. * @param file defines the file to load
  117208. * @param onSuccess defines the callback to call when data is loaded
  117209. * @param onProgress defines the callback to call during loading process
  117210. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117211. * @param onError defines the callback to call when an error occurs
  117212. * @returns a file request object
  117213. */
  117214. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117215. /**
  117216. * Creates a data url from a given string content
  117217. * @param content defines the content to convert
  117218. * @returns the new data url link
  117219. */
  117220. static FileAsURL(content: string): string;
  117221. /**
  117222. * Format the given number to a specific decimal format
  117223. * @param value defines the number to format
  117224. * @param decimals defines the number of decimals to use
  117225. * @returns the formatted string
  117226. */
  117227. static Format(value: number, decimals?: number): string;
  117228. /**
  117229. * Tries to copy an object by duplicating every property
  117230. * @param source defines the source object
  117231. * @param destination defines the target object
  117232. * @param doNotCopyList defines a list of properties to avoid
  117233. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  117234. */
  117235. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  117236. /**
  117237. * Gets a boolean indicating if the given object has no own property
  117238. * @param obj defines the object to test
  117239. * @returns true if object has no own property
  117240. */
  117241. static IsEmpty(obj: any): boolean;
  117242. /**
  117243. * Function used to register events at window level
  117244. * @param windowElement defines the Window object to use
  117245. * @param events defines the events to register
  117246. */
  117247. static RegisterTopRootEvents(windowElement: Window, events: {
  117248. name: string;
  117249. handler: Nullable<(e: FocusEvent) => any>;
  117250. }[]): void;
  117251. /**
  117252. * Function used to unregister events from window level
  117253. * @param windowElement defines the Window object to use
  117254. * @param events defines the events to unregister
  117255. */
  117256. static UnregisterTopRootEvents(windowElement: Window, events: {
  117257. name: string;
  117258. handler: Nullable<(e: FocusEvent) => any>;
  117259. }[]): void;
  117260. /**
  117261. * @ignore
  117262. */
  117263. static _ScreenshotCanvas: HTMLCanvasElement;
  117264. /**
  117265. * Dumps the current bound framebuffer
  117266. * @param width defines the rendering width
  117267. * @param height defines the rendering height
  117268. * @param engine defines the hosting engine
  117269. * @param successCallback defines the callback triggered once the data are available
  117270. * @param mimeType defines the mime type of the result
  117271. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  117272. */
  117273. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117274. /**
  117275. * Converts the canvas data to blob.
  117276. * This acts as a polyfill for browsers not supporting the to blob function.
  117277. * @param canvas Defines the canvas to extract the data from
  117278. * @param successCallback Defines the callback triggered once the data are available
  117279. * @param mimeType Defines the mime type of the result
  117280. */
  117281. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  117282. /**
  117283. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  117284. * @param successCallback defines the callback triggered once the data are available
  117285. * @param mimeType defines the mime type of the result
  117286. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  117287. */
  117288. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  117289. /**
  117290. * Downloads a blob in the browser
  117291. * @param blob defines the blob to download
  117292. * @param fileName defines the name of the downloaded file
  117293. */
  117294. static Download(blob: Blob, fileName: string): void;
  117295. /**
  117296. * Captures a screenshot of the current rendering
  117297. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117298. * @param engine defines the rendering engine
  117299. * @param camera defines the source camera
  117300. * @param size This parameter can be set to a single number or to an object with the
  117301. * following (optional) properties: precision, width, height. If a single number is passed,
  117302. * it will be used for both width and height. If an object is passed, the screenshot size
  117303. * will be derived from the parameters. The precision property is a multiplier allowing
  117304. * rendering at a higher or lower resolution
  117305. * @param successCallback defines the callback receives a single parameter which contains the
  117306. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117307. * src parameter of an <img> to display it
  117308. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117309. * Check your browser for supported MIME types
  117310. */
  117311. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  117312. /**
  117313. * Captures a screenshot of the current rendering
  117314. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117315. * @param engine defines the rendering engine
  117316. * @param camera defines the source camera
  117317. * @param size This parameter can be set to a single number or to an object with the
  117318. * following (optional) properties: precision, width, height. If a single number is passed,
  117319. * it will be used for both width and height. If an object is passed, the screenshot size
  117320. * will be derived from the parameters. The precision property is a multiplier allowing
  117321. * rendering at a higher or lower resolution
  117322. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  117323. * Check your browser for supported MIME types
  117324. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117325. * to the src parameter of an <img> to display it
  117326. */
  117327. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  117328. /**
  117329. * Generates an image screenshot from the specified camera.
  117330. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117331. * @param engine The engine to use for rendering
  117332. * @param camera The camera to use for rendering
  117333. * @param size This parameter can be set to a single number or to an object with the
  117334. * following (optional) properties: precision, width, height. If a single number is passed,
  117335. * it will be used for both width and height. If an object is passed, the screenshot size
  117336. * will be derived from the parameters. The precision property is a multiplier allowing
  117337. * rendering at a higher or lower resolution
  117338. * @param successCallback The callback receives a single parameter which contains the
  117339. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  117340. * src parameter of an <img> to display it
  117341. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117342. * Check your browser for supported MIME types
  117343. * @param samples Texture samples (default: 1)
  117344. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117345. * @param fileName A name for for the downloaded file.
  117346. */
  117347. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  117348. /**
  117349. * Generates an image screenshot from the specified camera.
  117350. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  117351. * @param engine The engine to use for rendering
  117352. * @param camera The camera to use for rendering
  117353. * @param size This parameter can be set to a single number or to an object with the
  117354. * following (optional) properties: precision, width, height. If a single number is passed,
  117355. * it will be used for both width and height. If an object is passed, the screenshot size
  117356. * will be derived from the parameters. The precision property is a multiplier allowing
  117357. * rendering at a higher or lower resolution
  117358. * @param mimeType The MIME type of the screenshot image (default: image/png).
  117359. * Check your browser for supported MIME types
  117360. * @param samples Texture samples (default: 1)
  117361. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  117362. * @param fileName A name for for the downloaded file.
  117363. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  117364. * to the src parameter of an <img> to display it
  117365. */
  117366. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  117367. /**
  117368. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  117369. * Be aware Math.random() could cause collisions, but:
  117370. * "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"
  117371. * @returns a pseudo random id
  117372. */
  117373. static RandomId(): string;
  117374. /**
  117375. * Test if the given uri is a base64 string
  117376. * @param uri The uri to test
  117377. * @return True if the uri is a base64 string or false otherwise
  117378. */
  117379. static IsBase64(uri: string): boolean;
  117380. /**
  117381. * Decode the given base64 uri.
  117382. * @param uri The uri to decode
  117383. * @return The decoded base64 data.
  117384. */
  117385. static DecodeBase64(uri: string): ArrayBuffer;
  117386. /**
  117387. * Gets the absolute url.
  117388. * @param url the input url
  117389. * @return the absolute url
  117390. */
  117391. static GetAbsoluteUrl(url: string): string;
  117392. /**
  117393. * No log
  117394. */
  117395. static readonly NoneLogLevel: number;
  117396. /**
  117397. * Only message logs
  117398. */
  117399. static readonly MessageLogLevel: number;
  117400. /**
  117401. * Only warning logs
  117402. */
  117403. static readonly WarningLogLevel: number;
  117404. /**
  117405. * Only error logs
  117406. */
  117407. static readonly ErrorLogLevel: number;
  117408. /**
  117409. * All logs
  117410. */
  117411. static readonly AllLogLevel: number;
  117412. /**
  117413. * Gets a value indicating the number of loading errors
  117414. * @ignorenaming
  117415. */
  117416. static get errorsCount(): number;
  117417. /**
  117418. * Callback called when a new log is added
  117419. */
  117420. static OnNewCacheEntry: (entry: string) => void;
  117421. /**
  117422. * Log a message to the console
  117423. * @param message defines the message to log
  117424. */
  117425. static Log(message: string): void;
  117426. /**
  117427. * Write a warning message to the console
  117428. * @param message defines the message to log
  117429. */
  117430. static Warn(message: string): void;
  117431. /**
  117432. * Write an error message to the console
  117433. * @param message defines the message to log
  117434. */
  117435. static Error(message: string): void;
  117436. /**
  117437. * Gets current log cache (list of logs)
  117438. */
  117439. static get LogCache(): string;
  117440. /**
  117441. * Clears the log cache
  117442. */
  117443. static ClearLogCache(): void;
  117444. /**
  117445. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  117446. */
  117447. static set LogLevels(level: number);
  117448. /**
  117449. * Checks if the window object exists
  117450. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  117451. */
  117452. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  117453. /**
  117454. * No performance log
  117455. */
  117456. static readonly PerformanceNoneLogLevel: number;
  117457. /**
  117458. * Use user marks to log performance
  117459. */
  117460. static readonly PerformanceUserMarkLogLevel: number;
  117461. /**
  117462. * Log performance to the console
  117463. */
  117464. static readonly PerformanceConsoleLogLevel: number;
  117465. private static _performance;
  117466. /**
  117467. * Sets the current performance log level
  117468. */
  117469. static set PerformanceLogLevel(level: number);
  117470. private static _StartPerformanceCounterDisabled;
  117471. private static _EndPerformanceCounterDisabled;
  117472. private static _StartUserMark;
  117473. private static _EndUserMark;
  117474. private static _StartPerformanceConsole;
  117475. private static _EndPerformanceConsole;
  117476. /**
  117477. * Starts a performance counter
  117478. */
  117479. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117480. /**
  117481. * Ends a specific performance coutner
  117482. */
  117483. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  117484. /**
  117485. * Gets either window.performance.now() if supported or Date.now() else
  117486. */
  117487. static get Now(): number;
  117488. /**
  117489. * This method will return the name of the class used to create the instance of the given object.
  117490. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  117491. * @param object the object to get the class name from
  117492. * @param isType defines if the object is actually a type
  117493. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  117494. */
  117495. static GetClassName(object: any, isType?: boolean): string;
  117496. /**
  117497. * Gets the first element of an array satisfying a given predicate
  117498. * @param array defines the array to browse
  117499. * @param predicate defines the predicate to use
  117500. * @returns null if not found or the element
  117501. */
  117502. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  117503. /**
  117504. * This method will return the name of the full name of the class, including its owning module (if any).
  117505. * 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).
  117506. * @param object the object to get the class name from
  117507. * @param isType defines if the object is actually a type
  117508. * @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.
  117509. * @ignorenaming
  117510. */
  117511. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  117512. /**
  117513. * Returns a promise that resolves after the given amount of time.
  117514. * @param delay Number of milliseconds to delay
  117515. * @returns Promise that resolves after the given amount of time
  117516. */
  117517. static DelayAsync(delay: number): Promise<void>;
  117518. /**
  117519. * Utility function to detect if the current user agent is Safari
  117520. * @returns whether or not the current user agent is safari
  117521. */
  117522. static IsSafari(): boolean;
  117523. }
  117524. /**
  117525. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  117526. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  117527. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  117528. * @param name The name of the class, case should be preserved
  117529. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  117530. */
  117531. export function className(name: string, module?: string): (target: Object) => void;
  117532. /**
  117533. * An implementation of a loop for asynchronous functions.
  117534. */
  117535. export class AsyncLoop {
  117536. /**
  117537. * Defines the number of iterations for the loop
  117538. */
  117539. iterations: number;
  117540. /**
  117541. * Defines the current index of the loop.
  117542. */
  117543. index: number;
  117544. private _done;
  117545. private _fn;
  117546. private _successCallback;
  117547. /**
  117548. * Constructor.
  117549. * @param iterations the number of iterations.
  117550. * @param func the function to run each iteration
  117551. * @param successCallback the callback that will be called upon succesful execution
  117552. * @param offset starting offset.
  117553. */
  117554. constructor(
  117555. /**
  117556. * Defines the number of iterations for the loop
  117557. */
  117558. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  117559. /**
  117560. * Execute the next iteration. Must be called after the last iteration was finished.
  117561. */
  117562. executeNext(): void;
  117563. /**
  117564. * Break the loop and run the success callback.
  117565. */
  117566. breakLoop(): void;
  117567. /**
  117568. * Create and run an async loop.
  117569. * @param iterations the number of iterations.
  117570. * @param fn the function to run each iteration
  117571. * @param successCallback the callback that will be called upon succesful execution
  117572. * @param offset starting offset.
  117573. * @returns the created async loop object
  117574. */
  117575. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  117576. /**
  117577. * A for-loop that will run a given number of iterations synchronous and the rest async.
  117578. * @param iterations total number of iterations
  117579. * @param syncedIterations number of synchronous iterations in each async iteration.
  117580. * @param fn the function to call each iteration.
  117581. * @param callback a success call back that will be called when iterating stops.
  117582. * @param breakFunction a break condition (optional)
  117583. * @param timeout timeout settings for the setTimeout function. default - 0.
  117584. * @returns the created async loop object
  117585. */
  117586. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  117587. }
  117588. }
  117589. declare module BABYLON {
  117590. /**
  117591. * This class implement a typical dictionary using a string as key and the generic type T as value.
  117592. * The underlying implementation relies on an associative array to ensure the best performances.
  117593. * The value can be anything including 'null' but except 'undefined'
  117594. */
  117595. export class StringDictionary<T> {
  117596. /**
  117597. * This will clear this dictionary and copy the content from the 'source' one.
  117598. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  117599. * @param source the dictionary to take the content from and copy to this dictionary
  117600. */
  117601. copyFrom(source: StringDictionary<T>): void;
  117602. /**
  117603. * Get a value based from its key
  117604. * @param key the given key to get the matching value from
  117605. * @return the value if found, otherwise undefined is returned
  117606. */
  117607. get(key: string): T | undefined;
  117608. /**
  117609. * Get a value from its key or add it if it doesn't exist.
  117610. * This method will ensure you that a given key/data will be present in the dictionary.
  117611. * @param key the given key to get the matching value from
  117612. * @param factory the factory that will create the value if the key is not present in the dictionary.
  117613. * The factory will only be invoked if there's no data for the given key.
  117614. * @return the value corresponding to the key.
  117615. */
  117616. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  117617. /**
  117618. * Get a value from its key if present in the dictionary otherwise add it
  117619. * @param key the key to get the value from
  117620. * @param val if there's no such key/value pair in the dictionary add it with this value
  117621. * @return the value corresponding to the key
  117622. */
  117623. getOrAdd(key: string, val: T): T;
  117624. /**
  117625. * Check if there's a given key in the dictionary
  117626. * @param key the key to check for
  117627. * @return true if the key is present, false otherwise
  117628. */
  117629. contains(key: string): boolean;
  117630. /**
  117631. * Add a new key and its corresponding value
  117632. * @param key the key to add
  117633. * @param value the value corresponding to the key
  117634. * @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
  117635. */
  117636. add(key: string, value: T): boolean;
  117637. /**
  117638. * Update a specific value associated to a key
  117639. * @param key defines the key to use
  117640. * @param value defines the value to store
  117641. * @returns true if the value was updated (or false if the key was not found)
  117642. */
  117643. set(key: string, value: T): boolean;
  117644. /**
  117645. * Get the element of the given key and remove it from the dictionary
  117646. * @param key defines the key to search
  117647. * @returns the value associated with the key or null if not found
  117648. */
  117649. getAndRemove(key: string): Nullable<T>;
  117650. /**
  117651. * Remove a key/value from the dictionary.
  117652. * @param key the key to remove
  117653. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  117654. */
  117655. remove(key: string): boolean;
  117656. /**
  117657. * Clear the whole content of the dictionary
  117658. */
  117659. clear(): void;
  117660. /**
  117661. * Gets the current count
  117662. */
  117663. get count(): number;
  117664. /**
  117665. * Execute a callback on each key/val of the dictionary.
  117666. * Note that you can remove any element in this dictionary in the callback implementation
  117667. * @param callback the callback to execute on a given key/value pair
  117668. */
  117669. forEach(callback: (key: string, val: T) => void): void;
  117670. /**
  117671. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  117672. * If the callback returns null or undefined the method will iterate to the next key/value pair
  117673. * Note that you can remove any element in this dictionary in the callback implementation
  117674. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  117675. * @returns the first item
  117676. */
  117677. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  117678. private _count;
  117679. private _data;
  117680. }
  117681. }
  117682. declare module BABYLON {
  117683. /** @hidden */
  117684. export interface ICollisionCoordinator {
  117685. createCollider(): Collider;
  117686. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117687. init(scene: Scene): void;
  117688. }
  117689. /** @hidden */
  117690. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  117691. private _scene;
  117692. private _scaledPosition;
  117693. private _scaledVelocity;
  117694. private _finalPosition;
  117695. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  117696. createCollider(): Collider;
  117697. init(scene: Scene): void;
  117698. private _collideWithWorld;
  117699. }
  117700. }
  117701. declare module BABYLON {
  117702. /**
  117703. * Class used to manage all inputs for the scene.
  117704. */
  117705. export class InputManager {
  117706. /** The distance in pixel that you have to move to prevent some events */
  117707. static DragMovementThreshold: number;
  117708. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  117709. static LongPressDelay: number;
  117710. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  117711. static DoubleClickDelay: number;
  117712. /** If you need to check double click without raising a single click at first click, enable this flag */
  117713. static ExclusiveDoubleClickMode: boolean;
  117714. /** 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. */
  117715. private _alreadyAttached;
  117716. private _wheelEventName;
  117717. private _onPointerMove;
  117718. private _onPointerDown;
  117719. private _onPointerUp;
  117720. private _initClickEvent;
  117721. private _initActionManager;
  117722. private _delayedSimpleClick;
  117723. private _delayedSimpleClickTimeout;
  117724. private _previousDelayedSimpleClickTimeout;
  117725. private _meshPickProceed;
  117726. private _previousButtonPressed;
  117727. private _currentPickResult;
  117728. private _previousPickResult;
  117729. private _totalPointersPressed;
  117730. private _doubleClickOccured;
  117731. private _pointerOverMesh;
  117732. private _pickedDownMesh;
  117733. private _pickedUpMesh;
  117734. private _pointerX;
  117735. private _pointerY;
  117736. private _unTranslatedPointerX;
  117737. private _unTranslatedPointerY;
  117738. private _startingPointerPosition;
  117739. private _previousStartingPointerPosition;
  117740. private _startingPointerTime;
  117741. private _previousStartingPointerTime;
  117742. private _pointerCaptures;
  117743. private _onKeyDown;
  117744. private _onKeyUp;
  117745. private _onCanvasFocusObserver;
  117746. private _onCanvasBlurObserver;
  117747. private _scene;
  117748. /**
  117749. * Creates a new InputManager
  117750. * @param scene defines the hosting scene
  117751. */
  117752. constructor(scene: Scene);
  117753. /**
  117754. * Gets the mesh that is currently under the pointer
  117755. */
  117756. get meshUnderPointer(): Nullable<AbstractMesh>;
  117757. /**
  117758. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  117759. */
  117760. get unTranslatedPointer(): Vector2;
  117761. /**
  117762. * Gets or sets the current on-screen X position of the pointer
  117763. */
  117764. get pointerX(): number;
  117765. set pointerX(value: number);
  117766. /**
  117767. * Gets or sets the current on-screen Y position of the pointer
  117768. */
  117769. get pointerY(): number;
  117770. set pointerY(value: number);
  117771. private _updatePointerPosition;
  117772. private _processPointerMove;
  117773. private _setRayOnPointerInfo;
  117774. private _checkPrePointerObservable;
  117775. /**
  117776. * Use this method to simulate a pointer move on a mesh
  117777. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117778. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117779. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117780. */
  117781. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117782. /**
  117783. * Use this method to simulate a pointer down on a mesh
  117784. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117785. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117786. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117787. */
  117788. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  117789. private _processPointerDown;
  117790. /** @hidden */
  117791. _isPointerSwiping(): boolean;
  117792. /**
  117793. * Use this method to simulate a pointer up on a mesh
  117794. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117795. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117796. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117797. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117798. */
  117799. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  117800. private _processPointerUp;
  117801. /**
  117802. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117803. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117804. * @returns true if the pointer was captured
  117805. */
  117806. isPointerCaptured(pointerId?: number): boolean;
  117807. /**
  117808. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117809. * @param attachUp defines if you want to attach events to pointerup
  117810. * @param attachDown defines if you want to attach events to pointerdown
  117811. * @param attachMove defines if you want to attach events to pointermove
  117812. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  117813. */
  117814. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  117815. /**
  117816. * Detaches all event handlers
  117817. */
  117818. detachControl(): void;
  117819. /**
  117820. * Force the value of meshUnderPointer
  117821. * @param mesh defines the mesh to use
  117822. */
  117823. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117824. /**
  117825. * Gets the mesh under the pointer
  117826. * @returns a Mesh or null if no mesh is under the pointer
  117827. */
  117828. getPointerOverMesh(): Nullable<AbstractMesh>;
  117829. }
  117830. }
  117831. declare module BABYLON {
  117832. /**
  117833. * This class defines the direct association between an animation and a target
  117834. */
  117835. export class TargetedAnimation {
  117836. /**
  117837. * Animation to perform
  117838. */
  117839. animation: Animation;
  117840. /**
  117841. * Target to animate
  117842. */
  117843. target: any;
  117844. /**
  117845. * Returns the string "TargetedAnimation"
  117846. * @returns "TargetedAnimation"
  117847. */
  117848. getClassName(): string;
  117849. /**
  117850. * Serialize the object
  117851. * @returns the JSON object representing the current entity
  117852. */
  117853. serialize(): any;
  117854. }
  117855. /**
  117856. * Use this class to create coordinated animations on multiple targets
  117857. */
  117858. export class AnimationGroup implements IDisposable {
  117859. /** The name of the animation group */
  117860. name: string;
  117861. private _scene;
  117862. private _targetedAnimations;
  117863. private _animatables;
  117864. private _from;
  117865. private _to;
  117866. private _isStarted;
  117867. private _isPaused;
  117868. private _speedRatio;
  117869. private _loopAnimation;
  117870. private _isAdditive;
  117871. /**
  117872. * Gets or sets the unique id of the node
  117873. */
  117874. uniqueId: number;
  117875. /**
  117876. * This observable will notify when one animation have ended
  117877. */
  117878. onAnimationEndObservable: Observable<TargetedAnimation>;
  117879. /**
  117880. * Observer raised when one animation loops
  117881. */
  117882. onAnimationLoopObservable: Observable<TargetedAnimation>;
  117883. /**
  117884. * Observer raised when all animations have looped
  117885. */
  117886. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  117887. /**
  117888. * This observable will notify when all animations have ended.
  117889. */
  117890. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  117891. /**
  117892. * This observable will notify when all animations have paused.
  117893. */
  117894. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  117895. /**
  117896. * This observable will notify when all animations are playing.
  117897. */
  117898. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  117899. /**
  117900. * Gets the first frame
  117901. */
  117902. get from(): number;
  117903. /**
  117904. * Gets the last frame
  117905. */
  117906. get to(): number;
  117907. /**
  117908. * Define if the animations are started
  117909. */
  117910. get isStarted(): boolean;
  117911. /**
  117912. * Gets a value indicating that the current group is playing
  117913. */
  117914. get isPlaying(): boolean;
  117915. /**
  117916. * Gets or sets the speed ratio to use for all animations
  117917. */
  117918. get speedRatio(): number;
  117919. /**
  117920. * Gets or sets the speed ratio to use for all animations
  117921. */
  117922. set speedRatio(value: number);
  117923. /**
  117924. * Gets or sets if all animations should loop or not
  117925. */
  117926. get loopAnimation(): boolean;
  117927. set loopAnimation(value: boolean);
  117928. /**
  117929. * Gets or sets if all animations should be evaluated additively
  117930. */
  117931. get isAdditive(): boolean;
  117932. set isAdditive(value: boolean);
  117933. /**
  117934. * Gets the targeted animations for this animation group
  117935. */
  117936. get targetedAnimations(): Array<TargetedAnimation>;
  117937. /**
  117938. * returning the list of animatables controlled by this animation group.
  117939. */
  117940. get animatables(): Array<Animatable>;
  117941. /**
  117942. * Gets the list of target animations
  117943. */
  117944. get children(): TargetedAnimation[];
  117945. /**
  117946. * Instantiates a new Animation Group.
  117947. * This helps managing several animations at once.
  117948. * @see https://doc.babylonjs.com/how_to/group
  117949. * @param name Defines the name of the group
  117950. * @param scene Defines the scene the group belongs to
  117951. */
  117952. constructor(
  117953. /** The name of the animation group */
  117954. name: string, scene?: Nullable<Scene>);
  117955. /**
  117956. * Add an animation (with its target) in the group
  117957. * @param animation defines the animation we want to add
  117958. * @param target defines the target of the animation
  117959. * @returns the TargetedAnimation object
  117960. */
  117961. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  117962. /**
  117963. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  117964. * It can add constant keys at begin or end
  117965. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  117966. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  117967. * @returns the animation group
  117968. */
  117969. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  117970. private _animationLoopCount;
  117971. private _animationLoopFlags;
  117972. private _processLoop;
  117973. /**
  117974. * Start all animations on given targets
  117975. * @param loop defines if animations must loop
  117976. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  117977. * @param from defines the from key (optional)
  117978. * @param to defines the to key (optional)
  117979. * @param isAdditive defines the additive state for the resulting animatables (optional)
  117980. * @returns the current animation group
  117981. */
  117982. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  117983. /**
  117984. * Pause all animations
  117985. * @returns the animation group
  117986. */
  117987. pause(): AnimationGroup;
  117988. /**
  117989. * Play all animations to initial state
  117990. * This function will start() the animations if they were not started or will restart() them if they were paused
  117991. * @param loop defines if animations must loop
  117992. * @returns the animation group
  117993. */
  117994. play(loop?: boolean): AnimationGroup;
  117995. /**
  117996. * Reset all animations to initial state
  117997. * @returns the animation group
  117998. */
  117999. reset(): AnimationGroup;
  118000. /**
  118001. * Restart animations from key 0
  118002. * @returns the animation group
  118003. */
  118004. restart(): AnimationGroup;
  118005. /**
  118006. * Stop all animations
  118007. * @returns the animation group
  118008. */
  118009. stop(): AnimationGroup;
  118010. /**
  118011. * Set animation weight for all animatables
  118012. * @param weight defines the weight to use
  118013. * @return the animationGroup
  118014. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118015. */
  118016. setWeightForAllAnimatables(weight: number): AnimationGroup;
  118017. /**
  118018. * Synchronize and normalize all animatables with a source animatable
  118019. * @param root defines the root animatable to synchronize with
  118020. * @return the animationGroup
  118021. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  118022. */
  118023. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  118024. /**
  118025. * Goes to a specific frame in this animation group
  118026. * @param frame the frame number to go to
  118027. * @return the animationGroup
  118028. */
  118029. goToFrame(frame: number): AnimationGroup;
  118030. /**
  118031. * Dispose all associated resources
  118032. */
  118033. dispose(): void;
  118034. private _checkAnimationGroupEnded;
  118035. /**
  118036. * Clone the current animation group and returns a copy
  118037. * @param newName defines the name of the new group
  118038. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  118039. * @returns the new aniamtion group
  118040. */
  118041. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  118042. /**
  118043. * Serializes the animationGroup to an object
  118044. * @returns Serialized object
  118045. */
  118046. serialize(): any;
  118047. /**
  118048. * Returns a new AnimationGroup object parsed from the source provided.
  118049. * @param parsedAnimationGroup defines the source
  118050. * @param scene defines the scene that will receive the animationGroup
  118051. * @returns a new AnimationGroup
  118052. */
  118053. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  118054. /**
  118055. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118056. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  118057. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118058. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  118059. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  118060. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  118061. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  118062. */
  118063. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  118064. /**
  118065. * Returns the string "AnimationGroup"
  118066. * @returns "AnimationGroup"
  118067. */
  118068. getClassName(): string;
  118069. /**
  118070. * Creates a detailled string about the object
  118071. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  118072. * @returns a string representing the object
  118073. */
  118074. toString(fullDetails?: boolean): string;
  118075. }
  118076. }
  118077. declare module BABYLON {
  118078. /**
  118079. * Define an interface for all classes that will hold resources
  118080. */
  118081. export interface IDisposable {
  118082. /**
  118083. * Releases all held resources
  118084. */
  118085. dispose(): void;
  118086. }
  118087. /** Interface defining initialization parameters for Scene class */
  118088. export interface SceneOptions {
  118089. /**
  118090. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  118091. * It will improve performance when the number of geometries becomes important.
  118092. */
  118093. useGeometryUniqueIdsMap?: boolean;
  118094. /**
  118095. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  118096. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118097. */
  118098. useMaterialMeshMap?: boolean;
  118099. /**
  118100. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  118101. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  118102. */
  118103. useClonedMeshMap?: boolean;
  118104. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  118105. virtual?: boolean;
  118106. }
  118107. /**
  118108. * Represents a scene to be rendered by the engine.
  118109. * @see https://doc.babylonjs.com/features/scene
  118110. */
  118111. export class Scene extends AbstractScene implements IAnimatable {
  118112. /** The fog is deactivated */
  118113. static readonly FOGMODE_NONE: number;
  118114. /** The fog density is following an exponential function */
  118115. static readonly FOGMODE_EXP: number;
  118116. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  118117. static readonly FOGMODE_EXP2: number;
  118118. /** The fog density is following a linear function. */
  118119. static readonly FOGMODE_LINEAR: number;
  118120. /**
  118121. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  118122. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118123. */
  118124. static MinDeltaTime: number;
  118125. /**
  118126. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  118127. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118128. */
  118129. static MaxDeltaTime: number;
  118130. /**
  118131. * Factory used to create the default material.
  118132. * @param name The name of the material to create
  118133. * @param scene The scene to create the material for
  118134. * @returns The default material
  118135. */
  118136. static DefaultMaterialFactory(scene: Scene): Material;
  118137. /**
  118138. * Factory used to create the a collision coordinator.
  118139. * @returns The collision coordinator
  118140. */
  118141. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  118142. /** @hidden */
  118143. _inputManager: InputManager;
  118144. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  118145. cameraToUseForPointers: Nullable<Camera>;
  118146. /** @hidden */
  118147. readonly _isScene: boolean;
  118148. /** @hidden */
  118149. _blockEntityCollection: boolean;
  118150. /**
  118151. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  118152. */
  118153. autoClear: boolean;
  118154. /**
  118155. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  118156. */
  118157. autoClearDepthAndStencil: boolean;
  118158. /**
  118159. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  118160. */
  118161. clearColor: Color4;
  118162. /**
  118163. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  118164. */
  118165. ambientColor: Color3;
  118166. /**
  118167. * This is use to store the default BRDF lookup for PBR materials in your scene.
  118168. * It should only be one of the following (if not the default embedded one):
  118169. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  118170. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  118171. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  118172. * The material properties need to be setup according to the type of texture in use.
  118173. */
  118174. environmentBRDFTexture: BaseTexture;
  118175. /** @hidden */
  118176. protected _environmentTexture: Nullable<BaseTexture>;
  118177. /**
  118178. * Texture used in all pbr material as the reflection texture.
  118179. * As in the majority of the scene they are the same (exception for multi room and so on),
  118180. * this is easier to reference from here than from all the materials.
  118181. */
  118182. get environmentTexture(): Nullable<BaseTexture>;
  118183. /**
  118184. * Texture used in all pbr material as the reflection texture.
  118185. * As in the majority of the scene they are the same (exception for multi room and so on),
  118186. * this is easier to set here than in all the materials.
  118187. */
  118188. set environmentTexture(value: Nullable<BaseTexture>);
  118189. /** @hidden */
  118190. protected _environmentIntensity: number;
  118191. /**
  118192. * Intensity of the environment in all pbr material.
  118193. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118194. * As in the majority of the scene they are the same (exception for multi room and so on),
  118195. * this is easier to reference from here than from all the materials.
  118196. */
  118197. get environmentIntensity(): number;
  118198. /**
  118199. * Intensity of the environment in all pbr material.
  118200. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  118201. * As in the majority of the scene they are the same (exception for multi room and so on),
  118202. * this is easier to set here than in all the materials.
  118203. */
  118204. set environmentIntensity(value: number);
  118205. /** @hidden */
  118206. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118207. /**
  118208. * Default image processing configuration used either in the rendering
  118209. * Forward main pass or through the imageProcessingPostProcess if present.
  118210. * As in the majority of the scene they are the same (exception for multi camera),
  118211. * this is easier to reference from here than from all the materials and post process.
  118212. *
  118213. * No setter as we it is a shared configuration, you can set the values instead.
  118214. */
  118215. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  118216. private _forceWireframe;
  118217. /**
  118218. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  118219. */
  118220. set forceWireframe(value: boolean);
  118221. get forceWireframe(): boolean;
  118222. private _skipFrustumClipping;
  118223. /**
  118224. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  118225. */
  118226. set skipFrustumClipping(value: boolean);
  118227. get skipFrustumClipping(): boolean;
  118228. private _forcePointsCloud;
  118229. /**
  118230. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  118231. */
  118232. set forcePointsCloud(value: boolean);
  118233. get forcePointsCloud(): boolean;
  118234. /**
  118235. * Gets or sets the active clipplane 1
  118236. */
  118237. clipPlane: Nullable<Plane>;
  118238. /**
  118239. * Gets or sets the active clipplane 2
  118240. */
  118241. clipPlane2: Nullable<Plane>;
  118242. /**
  118243. * Gets or sets the active clipplane 3
  118244. */
  118245. clipPlane3: Nullable<Plane>;
  118246. /**
  118247. * Gets or sets the active clipplane 4
  118248. */
  118249. clipPlane4: Nullable<Plane>;
  118250. /**
  118251. * Gets or sets the active clipplane 5
  118252. */
  118253. clipPlane5: Nullable<Plane>;
  118254. /**
  118255. * Gets or sets the active clipplane 6
  118256. */
  118257. clipPlane6: Nullable<Plane>;
  118258. /**
  118259. * Gets or sets a boolean indicating if animations are enabled
  118260. */
  118261. animationsEnabled: boolean;
  118262. private _animationPropertiesOverride;
  118263. /**
  118264. * Gets or sets the animation properties override
  118265. */
  118266. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  118267. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  118268. /**
  118269. * Gets or sets a boolean indicating if a constant deltatime has to be used
  118270. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  118271. */
  118272. useConstantAnimationDeltaTime: boolean;
  118273. /**
  118274. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  118275. * Please note that it requires to run a ray cast through the scene on every frame
  118276. */
  118277. constantlyUpdateMeshUnderPointer: boolean;
  118278. /**
  118279. * Defines the HTML cursor to use when hovering over interactive elements
  118280. */
  118281. hoverCursor: string;
  118282. /**
  118283. * Defines the HTML default cursor to use (empty by default)
  118284. */
  118285. defaultCursor: string;
  118286. /**
  118287. * Defines whether cursors are handled by the scene.
  118288. */
  118289. doNotHandleCursors: boolean;
  118290. /**
  118291. * This is used to call preventDefault() on pointer down
  118292. * in order to block unwanted artifacts like system double clicks
  118293. */
  118294. preventDefaultOnPointerDown: boolean;
  118295. /**
  118296. * This is used to call preventDefault() on pointer up
  118297. * in order to block unwanted artifacts like system double clicks
  118298. */
  118299. preventDefaultOnPointerUp: boolean;
  118300. /**
  118301. * Gets or sets user defined metadata
  118302. */
  118303. metadata: any;
  118304. /**
  118305. * For internal use only. Please do not use.
  118306. */
  118307. reservedDataStore: any;
  118308. /**
  118309. * Gets the name of the plugin used to load this scene (null by default)
  118310. */
  118311. loadingPluginName: string;
  118312. /**
  118313. * Use this array to add regular expressions used to disable offline support for specific urls
  118314. */
  118315. disableOfflineSupportExceptionRules: RegExp[];
  118316. /**
  118317. * An event triggered when the scene is disposed.
  118318. */
  118319. onDisposeObservable: Observable<Scene>;
  118320. private _onDisposeObserver;
  118321. /** Sets a function to be executed when this scene is disposed. */
  118322. set onDispose(callback: () => void);
  118323. /**
  118324. * An event triggered before rendering the scene (right after animations and physics)
  118325. */
  118326. onBeforeRenderObservable: Observable<Scene>;
  118327. private _onBeforeRenderObserver;
  118328. /** Sets a function to be executed before rendering this scene */
  118329. set beforeRender(callback: Nullable<() => void>);
  118330. /**
  118331. * An event triggered after rendering the scene
  118332. */
  118333. onAfterRenderObservable: Observable<Scene>;
  118334. /**
  118335. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  118336. */
  118337. onAfterRenderCameraObservable: Observable<Camera>;
  118338. private _onAfterRenderObserver;
  118339. /** Sets a function to be executed after rendering this scene */
  118340. set afterRender(callback: Nullable<() => void>);
  118341. /**
  118342. * An event triggered before animating the scene
  118343. */
  118344. onBeforeAnimationsObservable: Observable<Scene>;
  118345. /**
  118346. * An event triggered after animations processing
  118347. */
  118348. onAfterAnimationsObservable: Observable<Scene>;
  118349. /**
  118350. * An event triggered before draw calls are ready to be sent
  118351. */
  118352. onBeforeDrawPhaseObservable: Observable<Scene>;
  118353. /**
  118354. * An event triggered after draw calls have been sent
  118355. */
  118356. onAfterDrawPhaseObservable: Observable<Scene>;
  118357. /**
  118358. * An event triggered when the scene is ready
  118359. */
  118360. onReadyObservable: Observable<Scene>;
  118361. /**
  118362. * An event triggered before rendering a camera
  118363. */
  118364. onBeforeCameraRenderObservable: Observable<Camera>;
  118365. private _onBeforeCameraRenderObserver;
  118366. /** Sets a function to be executed before rendering a camera*/
  118367. set beforeCameraRender(callback: () => void);
  118368. /**
  118369. * An event triggered after rendering a camera
  118370. */
  118371. onAfterCameraRenderObservable: Observable<Camera>;
  118372. private _onAfterCameraRenderObserver;
  118373. /** Sets a function to be executed after rendering a camera*/
  118374. set afterCameraRender(callback: () => void);
  118375. /**
  118376. * An event triggered when active meshes evaluation is about to start
  118377. */
  118378. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  118379. /**
  118380. * An event triggered when active meshes evaluation is done
  118381. */
  118382. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  118383. /**
  118384. * An event triggered when particles rendering is about to start
  118385. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118386. */
  118387. onBeforeParticlesRenderingObservable: Observable<Scene>;
  118388. /**
  118389. * An event triggered when particles rendering is done
  118390. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  118391. */
  118392. onAfterParticlesRenderingObservable: Observable<Scene>;
  118393. /**
  118394. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  118395. */
  118396. onDataLoadedObservable: Observable<Scene>;
  118397. /**
  118398. * An event triggered when a camera is created
  118399. */
  118400. onNewCameraAddedObservable: Observable<Camera>;
  118401. /**
  118402. * An event triggered when a camera is removed
  118403. */
  118404. onCameraRemovedObservable: Observable<Camera>;
  118405. /**
  118406. * An event triggered when a light is created
  118407. */
  118408. onNewLightAddedObservable: Observable<Light>;
  118409. /**
  118410. * An event triggered when a light is removed
  118411. */
  118412. onLightRemovedObservable: Observable<Light>;
  118413. /**
  118414. * An event triggered when a geometry is created
  118415. */
  118416. onNewGeometryAddedObservable: Observable<Geometry>;
  118417. /**
  118418. * An event triggered when a geometry is removed
  118419. */
  118420. onGeometryRemovedObservable: Observable<Geometry>;
  118421. /**
  118422. * An event triggered when a transform node is created
  118423. */
  118424. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  118425. /**
  118426. * An event triggered when a transform node is removed
  118427. */
  118428. onTransformNodeRemovedObservable: Observable<TransformNode>;
  118429. /**
  118430. * An event triggered when a mesh is created
  118431. */
  118432. onNewMeshAddedObservable: Observable<AbstractMesh>;
  118433. /**
  118434. * An event triggered when a mesh is removed
  118435. */
  118436. onMeshRemovedObservable: Observable<AbstractMesh>;
  118437. /**
  118438. * An event triggered when a skeleton is created
  118439. */
  118440. onNewSkeletonAddedObservable: Observable<Skeleton>;
  118441. /**
  118442. * An event triggered when a skeleton is removed
  118443. */
  118444. onSkeletonRemovedObservable: Observable<Skeleton>;
  118445. /**
  118446. * An event triggered when a material is created
  118447. */
  118448. onNewMaterialAddedObservable: Observable<Material>;
  118449. /**
  118450. * An event triggered when a material is removed
  118451. */
  118452. onMaterialRemovedObservable: Observable<Material>;
  118453. /**
  118454. * An event triggered when a texture is created
  118455. */
  118456. onNewTextureAddedObservable: Observable<BaseTexture>;
  118457. /**
  118458. * An event triggered when a texture is removed
  118459. */
  118460. onTextureRemovedObservable: Observable<BaseTexture>;
  118461. /**
  118462. * An event triggered when render targets are about to be rendered
  118463. * Can happen multiple times per frame.
  118464. */
  118465. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  118466. /**
  118467. * An event triggered when render targets were rendered.
  118468. * Can happen multiple times per frame.
  118469. */
  118470. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  118471. /**
  118472. * An event triggered before calculating deterministic simulation step
  118473. */
  118474. onBeforeStepObservable: Observable<Scene>;
  118475. /**
  118476. * An event triggered after calculating deterministic simulation step
  118477. */
  118478. onAfterStepObservable: Observable<Scene>;
  118479. /**
  118480. * An event triggered when the activeCamera property is updated
  118481. */
  118482. onActiveCameraChanged: Observable<Scene>;
  118483. /**
  118484. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  118485. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118486. * 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)
  118487. */
  118488. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118489. /**
  118490. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  118491. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  118492. * 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)
  118493. */
  118494. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  118495. /**
  118496. * This Observable will when a mesh has been imported into the scene.
  118497. */
  118498. onMeshImportedObservable: Observable<AbstractMesh>;
  118499. /**
  118500. * This Observable will when an animation file has been imported into the scene.
  118501. */
  118502. onAnimationFileImportedObservable: Observable<Scene>;
  118503. /**
  118504. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  118505. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  118506. */
  118507. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  118508. /** @hidden */
  118509. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  118510. /**
  118511. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  118512. */
  118513. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  118514. /**
  118515. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  118516. */
  118517. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  118518. /**
  118519. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  118520. */
  118521. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  118522. /** Callback called when a pointer move is detected */
  118523. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118524. /** Callback called when a pointer down is detected */
  118525. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  118526. /** Callback called when a pointer up is detected */
  118527. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  118528. /** Callback called when a pointer pick is detected */
  118529. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  118530. /**
  118531. * 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).
  118532. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  118533. */
  118534. onPrePointerObservable: Observable<PointerInfoPre>;
  118535. /**
  118536. * Observable event triggered each time an input event is received from the rendering canvas
  118537. */
  118538. onPointerObservable: Observable<PointerInfo>;
  118539. /**
  118540. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  118541. */
  118542. get unTranslatedPointer(): Vector2;
  118543. /**
  118544. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  118545. */
  118546. static get DragMovementThreshold(): number;
  118547. static set DragMovementThreshold(value: number);
  118548. /**
  118549. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  118550. */
  118551. static get LongPressDelay(): number;
  118552. static set LongPressDelay(value: number);
  118553. /**
  118554. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  118555. */
  118556. static get DoubleClickDelay(): number;
  118557. static set DoubleClickDelay(value: number);
  118558. /** If you need to check double click without raising a single click at first click, enable this flag */
  118559. static get ExclusiveDoubleClickMode(): boolean;
  118560. static set ExclusiveDoubleClickMode(value: boolean);
  118561. /** @hidden */
  118562. _mirroredCameraPosition: Nullable<Vector3>;
  118563. /**
  118564. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  118565. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  118566. */
  118567. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  118568. /**
  118569. * Observable event triggered each time an keyboard event is received from the hosting window
  118570. */
  118571. onKeyboardObservable: Observable<KeyboardInfo>;
  118572. private _useRightHandedSystem;
  118573. /**
  118574. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  118575. */
  118576. set useRightHandedSystem(value: boolean);
  118577. get useRightHandedSystem(): boolean;
  118578. private _timeAccumulator;
  118579. private _currentStepId;
  118580. private _currentInternalStep;
  118581. /**
  118582. * Sets the step Id used by deterministic lock step
  118583. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118584. * @param newStepId defines the step Id
  118585. */
  118586. setStepId(newStepId: number): void;
  118587. /**
  118588. * Gets the step Id used by deterministic lock step
  118589. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118590. * @returns the step Id
  118591. */
  118592. getStepId(): number;
  118593. /**
  118594. * Gets the internal step used by deterministic lock step
  118595. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118596. * @returns the internal step
  118597. */
  118598. getInternalStep(): number;
  118599. private _fogEnabled;
  118600. /**
  118601. * Gets or sets a boolean indicating if fog is enabled on this scene
  118602. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118603. * (Default is true)
  118604. */
  118605. set fogEnabled(value: boolean);
  118606. get fogEnabled(): boolean;
  118607. private _fogMode;
  118608. /**
  118609. * Gets or sets the fog mode to use
  118610. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118611. * | mode | value |
  118612. * | --- | --- |
  118613. * | FOGMODE_NONE | 0 |
  118614. * | FOGMODE_EXP | 1 |
  118615. * | FOGMODE_EXP2 | 2 |
  118616. * | FOGMODE_LINEAR | 3 |
  118617. */
  118618. set fogMode(value: number);
  118619. get fogMode(): number;
  118620. /**
  118621. * Gets or sets the fog color to use
  118622. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118623. * (Default is Color3(0.2, 0.2, 0.3))
  118624. */
  118625. fogColor: Color3;
  118626. /**
  118627. * Gets or sets the fog density to use
  118628. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118629. * (Default is 0.1)
  118630. */
  118631. fogDensity: number;
  118632. /**
  118633. * Gets or sets the fog start distance to use
  118634. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118635. * (Default is 0)
  118636. */
  118637. fogStart: number;
  118638. /**
  118639. * Gets or sets the fog end distance to use
  118640. * @see https://doc.babylonjs.com/babylon101/environment#fog
  118641. * (Default is 1000)
  118642. */
  118643. fogEnd: number;
  118644. /**
  118645. * Flag indicating that the frame buffer binding is handled by another component
  118646. */
  118647. prePass: boolean;
  118648. private _shadowsEnabled;
  118649. /**
  118650. * Gets or sets a boolean indicating if shadows are enabled on this scene
  118651. */
  118652. set shadowsEnabled(value: boolean);
  118653. get shadowsEnabled(): boolean;
  118654. private _lightsEnabled;
  118655. /**
  118656. * Gets or sets a boolean indicating if lights are enabled on this scene
  118657. */
  118658. set lightsEnabled(value: boolean);
  118659. get lightsEnabled(): boolean;
  118660. /** All of the active cameras added to this scene. */
  118661. activeCameras: Camera[];
  118662. /** @hidden */
  118663. _activeCamera: Nullable<Camera>;
  118664. /** Gets or sets the current active camera */
  118665. get activeCamera(): Nullable<Camera>;
  118666. set activeCamera(value: Nullable<Camera>);
  118667. private _defaultMaterial;
  118668. /** The default material used on meshes when no material is affected */
  118669. get defaultMaterial(): Material;
  118670. /** The default material used on meshes when no material is affected */
  118671. set defaultMaterial(value: Material);
  118672. private _texturesEnabled;
  118673. /**
  118674. * Gets or sets a boolean indicating if textures are enabled on this scene
  118675. */
  118676. set texturesEnabled(value: boolean);
  118677. get texturesEnabled(): boolean;
  118678. /**
  118679. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  118680. */
  118681. physicsEnabled: boolean;
  118682. /**
  118683. * Gets or sets a boolean indicating if particles are enabled on this scene
  118684. */
  118685. particlesEnabled: boolean;
  118686. /**
  118687. * Gets or sets a boolean indicating if sprites are enabled on this scene
  118688. */
  118689. spritesEnabled: boolean;
  118690. private _skeletonsEnabled;
  118691. /**
  118692. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  118693. */
  118694. set skeletonsEnabled(value: boolean);
  118695. get skeletonsEnabled(): boolean;
  118696. /**
  118697. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  118698. */
  118699. lensFlaresEnabled: boolean;
  118700. /**
  118701. * Gets or sets a boolean indicating if collisions are enabled on this scene
  118702. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118703. */
  118704. collisionsEnabled: boolean;
  118705. private _collisionCoordinator;
  118706. /** @hidden */
  118707. get collisionCoordinator(): ICollisionCoordinator;
  118708. /**
  118709. * Defines the gravity applied to this scene (used only for collisions)
  118710. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  118711. */
  118712. gravity: Vector3;
  118713. /**
  118714. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  118715. */
  118716. postProcessesEnabled: boolean;
  118717. /**
  118718. * The list of postprocesses added to the scene
  118719. */
  118720. postProcesses: PostProcess[];
  118721. /**
  118722. * Gets the current postprocess manager
  118723. */
  118724. postProcessManager: PostProcessManager;
  118725. /**
  118726. * Gets or sets a boolean indicating if render targets are enabled on this scene
  118727. */
  118728. renderTargetsEnabled: boolean;
  118729. /**
  118730. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  118731. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  118732. */
  118733. dumpNextRenderTargets: boolean;
  118734. /**
  118735. * The list of user defined render targets added to the scene
  118736. */
  118737. customRenderTargets: RenderTargetTexture[];
  118738. /**
  118739. * Defines if texture loading must be delayed
  118740. * If true, textures will only be loaded when they need to be rendered
  118741. */
  118742. useDelayedTextureLoading: boolean;
  118743. /**
  118744. * Gets the list of meshes imported to the scene through SceneLoader
  118745. */
  118746. importedMeshesFiles: String[];
  118747. /**
  118748. * Gets or sets a boolean indicating if probes are enabled on this scene
  118749. */
  118750. probesEnabled: boolean;
  118751. /**
  118752. * Gets or sets the current offline provider to use to store scene data
  118753. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118754. */
  118755. offlineProvider: IOfflineProvider;
  118756. /**
  118757. * Gets or sets the action manager associated with the scene
  118758. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  118759. */
  118760. actionManager: AbstractActionManager;
  118761. private _meshesForIntersections;
  118762. /**
  118763. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  118764. */
  118765. proceduralTexturesEnabled: boolean;
  118766. private _engine;
  118767. private _totalVertices;
  118768. /** @hidden */
  118769. _activeIndices: PerfCounter;
  118770. /** @hidden */
  118771. _activeParticles: PerfCounter;
  118772. /** @hidden */
  118773. _activeBones: PerfCounter;
  118774. private _animationRatio;
  118775. /** @hidden */
  118776. _animationTimeLast: number;
  118777. /** @hidden */
  118778. _animationTime: number;
  118779. /**
  118780. * Gets or sets a general scale for animation speed
  118781. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  118782. */
  118783. animationTimeScale: number;
  118784. /** @hidden */
  118785. _cachedMaterial: Nullable<Material>;
  118786. /** @hidden */
  118787. _cachedEffect: Nullable<Effect>;
  118788. /** @hidden */
  118789. _cachedVisibility: Nullable<number>;
  118790. private _renderId;
  118791. private _frameId;
  118792. private _executeWhenReadyTimeoutId;
  118793. private _intermediateRendering;
  118794. private _viewUpdateFlag;
  118795. private _projectionUpdateFlag;
  118796. /** @hidden */
  118797. _toBeDisposed: Nullable<IDisposable>[];
  118798. private _activeRequests;
  118799. /** @hidden */
  118800. _pendingData: any[];
  118801. private _isDisposed;
  118802. /**
  118803. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  118804. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  118805. */
  118806. dispatchAllSubMeshesOfActiveMeshes: boolean;
  118807. private _activeMeshes;
  118808. private _processedMaterials;
  118809. private _renderTargets;
  118810. /** @hidden */
  118811. _activeParticleSystems: SmartArray<IParticleSystem>;
  118812. private _activeSkeletons;
  118813. private _softwareSkinnedMeshes;
  118814. private _renderingManager;
  118815. /** @hidden */
  118816. _activeAnimatables: Animatable[];
  118817. private _transformMatrix;
  118818. private _sceneUbo;
  118819. /** @hidden */
  118820. _viewMatrix: Matrix;
  118821. private _projectionMatrix;
  118822. /** @hidden */
  118823. _forcedViewPosition: Nullable<Vector3>;
  118824. /** @hidden */
  118825. _frustumPlanes: Plane[];
  118826. /**
  118827. * Gets the list of frustum planes (built from the active camera)
  118828. */
  118829. get frustumPlanes(): Plane[];
  118830. /**
  118831. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  118832. * This is useful if there are more lights that the maximum simulteanous authorized
  118833. */
  118834. requireLightSorting: boolean;
  118835. /** @hidden */
  118836. readonly useMaterialMeshMap: boolean;
  118837. /** @hidden */
  118838. readonly useClonedMeshMap: boolean;
  118839. private _externalData;
  118840. private _uid;
  118841. /**
  118842. * @hidden
  118843. * Backing store of defined scene components.
  118844. */
  118845. _components: ISceneComponent[];
  118846. /**
  118847. * @hidden
  118848. * Backing store of defined scene components.
  118849. */
  118850. _serializableComponents: ISceneSerializableComponent[];
  118851. /**
  118852. * List of components to register on the next registration step.
  118853. */
  118854. private _transientComponents;
  118855. /**
  118856. * Registers the transient components if needed.
  118857. */
  118858. private _registerTransientComponents;
  118859. /**
  118860. * @hidden
  118861. * Add a component to the scene.
  118862. * Note that the ccomponent could be registered on th next frame if this is called after
  118863. * the register component stage.
  118864. * @param component Defines the component to add to the scene
  118865. */
  118866. _addComponent(component: ISceneComponent): void;
  118867. /**
  118868. * @hidden
  118869. * Gets a component from the scene.
  118870. * @param name defines the name of the component to retrieve
  118871. * @returns the component or null if not present
  118872. */
  118873. _getComponent(name: string): Nullable<ISceneComponent>;
  118874. /**
  118875. * @hidden
  118876. * Defines the actions happening before camera updates.
  118877. */
  118878. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  118879. /**
  118880. * @hidden
  118881. * Defines the actions happening before clear the canvas.
  118882. */
  118883. _beforeClearStage: Stage<SimpleStageAction>;
  118884. /**
  118885. * @hidden
  118886. * Defines the actions when collecting render targets for the frame.
  118887. */
  118888. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118889. /**
  118890. * @hidden
  118891. * Defines the actions happening for one camera in the frame.
  118892. */
  118893. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  118894. /**
  118895. * @hidden
  118896. * Defines the actions happening during the per mesh ready checks.
  118897. */
  118898. _isReadyForMeshStage: Stage<MeshStageAction>;
  118899. /**
  118900. * @hidden
  118901. * Defines the actions happening before evaluate active mesh checks.
  118902. */
  118903. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  118904. /**
  118905. * @hidden
  118906. * Defines the actions happening during the evaluate sub mesh checks.
  118907. */
  118908. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  118909. /**
  118910. * @hidden
  118911. * Defines the actions happening during the active mesh stage.
  118912. */
  118913. _activeMeshStage: Stage<ActiveMeshStageAction>;
  118914. /**
  118915. * @hidden
  118916. * Defines the actions happening during the per camera render target step.
  118917. */
  118918. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  118919. /**
  118920. * @hidden
  118921. * Defines the actions happening just before the active camera is drawing.
  118922. */
  118923. _beforeCameraDrawStage: Stage<CameraStageAction>;
  118924. /**
  118925. * @hidden
  118926. * Defines the actions happening just before a render target is drawing.
  118927. */
  118928. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118929. /**
  118930. * @hidden
  118931. * Defines the actions happening just before a rendering group is drawing.
  118932. */
  118933. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118934. /**
  118935. * @hidden
  118936. * Defines the actions happening just before a mesh is drawing.
  118937. */
  118938. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118939. /**
  118940. * @hidden
  118941. * Defines the actions happening just after a mesh has been drawn.
  118942. */
  118943. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  118944. /**
  118945. * @hidden
  118946. * Defines the actions happening just after a rendering group has been drawn.
  118947. */
  118948. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  118949. /**
  118950. * @hidden
  118951. * Defines the actions happening just after the active camera has been drawn.
  118952. */
  118953. _afterCameraDrawStage: Stage<CameraStageAction>;
  118954. /**
  118955. * @hidden
  118956. * Defines the actions happening just after a render target has been drawn.
  118957. */
  118958. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  118959. /**
  118960. * @hidden
  118961. * Defines the actions happening just after rendering all cameras and computing intersections.
  118962. */
  118963. _afterRenderStage: Stage<SimpleStageAction>;
  118964. /**
  118965. * @hidden
  118966. * Defines the actions happening when a pointer move event happens.
  118967. */
  118968. _pointerMoveStage: Stage<PointerMoveStageAction>;
  118969. /**
  118970. * @hidden
  118971. * Defines the actions happening when a pointer down event happens.
  118972. */
  118973. _pointerDownStage: Stage<PointerUpDownStageAction>;
  118974. /**
  118975. * @hidden
  118976. * Defines the actions happening when a pointer up event happens.
  118977. */
  118978. _pointerUpStage: Stage<PointerUpDownStageAction>;
  118979. /**
  118980. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  118981. */
  118982. private geometriesByUniqueId;
  118983. /**
  118984. * Creates a new Scene
  118985. * @param engine defines the engine to use to render this scene
  118986. * @param options defines the scene options
  118987. */
  118988. constructor(engine: Engine, options?: SceneOptions);
  118989. /**
  118990. * Gets a string idenfifying the name of the class
  118991. * @returns "Scene" string
  118992. */
  118993. getClassName(): string;
  118994. private _defaultMeshCandidates;
  118995. /**
  118996. * @hidden
  118997. */
  118998. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118999. private _defaultSubMeshCandidates;
  119000. /**
  119001. * @hidden
  119002. */
  119003. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119004. /**
  119005. * Sets the default candidate providers for the scene.
  119006. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  119007. * and getCollidingSubMeshCandidates to their default function
  119008. */
  119009. setDefaultCandidateProviders(): void;
  119010. /**
  119011. * Gets the mesh that is currently under the pointer
  119012. */
  119013. get meshUnderPointer(): Nullable<AbstractMesh>;
  119014. /**
  119015. * Gets or sets the current on-screen X position of the pointer
  119016. */
  119017. get pointerX(): number;
  119018. set pointerX(value: number);
  119019. /**
  119020. * Gets or sets the current on-screen Y position of the pointer
  119021. */
  119022. get pointerY(): number;
  119023. set pointerY(value: number);
  119024. /**
  119025. * Gets the cached material (ie. the latest rendered one)
  119026. * @returns the cached material
  119027. */
  119028. getCachedMaterial(): Nullable<Material>;
  119029. /**
  119030. * Gets the cached effect (ie. the latest rendered one)
  119031. * @returns the cached effect
  119032. */
  119033. getCachedEffect(): Nullable<Effect>;
  119034. /**
  119035. * Gets the cached visibility state (ie. the latest rendered one)
  119036. * @returns the cached visibility state
  119037. */
  119038. getCachedVisibility(): Nullable<number>;
  119039. /**
  119040. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  119041. * @param material defines the current material
  119042. * @param effect defines the current effect
  119043. * @param visibility defines the current visibility state
  119044. * @returns true if one parameter is not cached
  119045. */
  119046. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  119047. /**
  119048. * Gets the engine associated with the scene
  119049. * @returns an Engine
  119050. */
  119051. getEngine(): Engine;
  119052. /**
  119053. * Gets the total number of vertices rendered per frame
  119054. * @returns the total number of vertices rendered per frame
  119055. */
  119056. getTotalVertices(): number;
  119057. /**
  119058. * Gets the performance counter for total vertices
  119059. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119060. */
  119061. get totalVerticesPerfCounter(): PerfCounter;
  119062. /**
  119063. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  119064. * @returns the total number of active indices rendered per frame
  119065. */
  119066. getActiveIndices(): number;
  119067. /**
  119068. * Gets the performance counter for active indices
  119069. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119070. */
  119071. get totalActiveIndicesPerfCounter(): PerfCounter;
  119072. /**
  119073. * Gets the total number of active particles rendered per frame
  119074. * @returns the total number of active particles rendered per frame
  119075. */
  119076. getActiveParticles(): number;
  119077. /**
  119078. * Gets the performance counter for active particles
  119079. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119080. */
  119081. get activeParticlesPerfCounter(): PerfCounter;
  119082. /**
  119083. * Gets the total number of active bones rendered per frame
  119084. * @returns the total number of active bones rendered per frame
  119085. */
  119086. getActiveBones(): number;
  119087. /**
  119088. * Gets the performance counter for active bones
  119089. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  119090. */
  119091. get activeBonesPerfCounter(): PerfCounter;
  119092. /**
  119093. * Gets the array of active meshes
  119094. * @returns an array of AbstractMesh
  119095. */
  119096. getActiveMeshes(): SmartArray<AbstractMesh>;
  119097. /**
  119098. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  119099. * @returns a number
  119100. */
  119101. getAnimationRatio(): number;
  119102. /**
  119103. * Gets an unique Id for the current render phase
  119104. * @returns a number
  119105. */
  119106. getRenderId(): number;
  119107. /**
  119108. * Gets an unique Id for the current frame
  119109. * @returns a number
  119110. */
  119111. getFrameId(): number;
  119112. /** Call this function if you want to manually increment the render Id*/
  119113. incrementRenderId(): void;
  119114. private _createUbo;
  119115. /**
  119116. * Use this method to simulate a pointer move on a mesh
  119117. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119118. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119119. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119120. * @returns the current scene
  119121. */
  119122. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119123. /**
  119124. * Use this method to simulate a pointer down on a mesh
  119125. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119126. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119127. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119128. * @returns the current scene
  119129. */
  119130. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  119131. /**
  119132. * Use this method to simulate a pointer up on a mesh
  119133. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119134. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119135. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119136. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119137. * @returns the current scene
  119138. */
  119139. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  119140. /**
  119141. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119142. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119143. * @returns true if the pointer was captured
  119144. */
  119145. isPointerCaptured(pointerId?: number): boolean;
  119146. /**
  119147. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119148. * @param attachUp defines if you want to attach events to pointerup
  119149. * @param attachDown defines if you want to attach events to pointerdown
  119150. * @param attachMove defines if you want to attach events to pointermove
  119151. */
  119152. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  119153. /** Detaches all event handlers*/
  119154. detachControl(): void;
  119155. /**
  119156. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  119157. * Delay loaded resources are not taking in account
  119158. * @return true if all required resources are ready
  119159. */
  119160. isReady(): boolean;
  119161. /** Resets all cached information relative to material (including effect and visibility) */
  119162. resetCachedMaterial(): void;
  119163. /**
  119164. * Registers a function to be called before every frame render
  119165. * @param func defines the function to register
  119166. */
  119167. registerBeforeRender(func: () => void): void;
  119168. /**
  119169. * Unregisters a function called before every frame render
  119170. * @param func defines the function to unregister
  119171. */
  119172. unregisterBeforeRender(func: () => void): void;
  119173. /**
  119174. * Registers a function to be called after every frame render
  119175. * @param func defines the function to register
  119176. */
  119177. registerAfterRender(func: () => void): void;
  119178. /**
  119179. * Unregisters a function called after every frame render
  119180. * @param func defines the function to unregister
  119181. */
  119182. unregisterAfterRender(func: () => void): void;
  119183. private _executeOnceBeforeRender;
  119184. /**
  119185. * The provided function will run before render once and will be disposed afterwards.
  119186. * A timeout delay can be provided so that the function will be executed in N ms.
  119187. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  119188. * @param func The function to be executed.
  119189. * @param timeout optional delay in ms
  119190. */
  119191. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  119192. /** @hidden */
  119193. _addPendingData(data: any): void;
  119194. /** @hidden */
  119195. _removePendingData(data: any): void;
  119196. /**
  119197. * Returns the number of items waiting to be loaded
  119198. * @returns the number of items waiting to be loaded
  119199. */
  119200. getWaitingItemsCount(): number;
  119201. /**
  119202. * Returns a boolean indicating if the scene is still loading data
  119203. */
  119204. get isLoading(): boolean;
  119205. /**
  119206. * Registers a function to be executed when the scene is ready
  119207. * @param {Function} func - the function to be executed
  119208. */
  119209. executeWhenReady(func: () => void): void;
  119210. /**
  119211. * Returns a promise that resolves when the scene is ready
  119212. * @returns A promise that resolves when the scene is ready
  119213. */
  119214. whenReadyAsync(): Promise<void>;
  119215. /** @hidden */
  119216. _checkIsReady(): void;
  119217. /**
  119218. * Gets all animatable attached to the scene
  119219. */
  119220. get animatables(): Animatable[];
  119221. /**
  119222. * Resets the last animation time frame.
  119223. * Useful to override when animations start running when loading a scene for the first time.
  119224. */
  119225. resetLastAnimationTimeFrame(): void;
  119226. /**
  119227. * Gets the current view matrix
  119228. * @returns a Matrix
  119229. */
  119230. getViewMatrix(): Matrix;
  119231. /**
  119232. * Gets the current projection matrix
  119233. * @returns a Matrix
  119234. */
  119235. getProjectionMatrix(): Matrix;
  119236. /**
  119237. * Gets the current transform matrix
  119238. * @returns a Matrix made of View * Projection
  119239. */
  119240. getTransformMatrix(): Matrix;
  119241. /**
  119242. * Sets the current transform matrix
  119243. * @param viewL defines the View matrix to use
  119244. * @param projectionL defines the Projection matrix to use
  119245. * @param viewR defines the right View matrix to use (if provided)
  119246. * @param projectionR defines the right Projection matrix to use (if provided)
  119247. */
  119248. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  119249. /**
  119250. * Gets the uniform buffer used to store scene data
  119251. * @returns a UniformBuffer
  119252. */
  119253. getSceneUniformBuffer(): UniformBuffer;
  119254. /**
  119255. * Gets an unique (relatively to the current scene) Id
  119256. * @returns an unique number for the scene
  119257. */
  119258. getUniqueId(): number;
  119259. /**
  119260. * Add a mesh to the list of scene's meshes
  119261. * @param newMesh defines the mesh to add
  119262. * @param recursive if all child meshes should also be added to the scene
  119263. */
  119264. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  119265. /**
  119266. * Remove a mesh for the list of scene's meshes
  119267. * @param toRemove defines the mesh to remove
  119268. * @param recursive if all child meshes should also be removed from the scene
  119269. * @returns the index where the mesh was in the mesh list
  119270. */
  119271. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  119272. /**
  119273. * Add a transform node to the list of scene's transform nodes
  119274. * @param newTransformNode defines the transform node to add
  119275. */
  119276. addTransformNode(newTransformNode: TransformNode): void;
  119277. /**
  119278. * Remove a transform node for the list of scene's transform nodes
  119279. * @param toRemove defines the transform node to remove
  119280. * @returns the index where the transform node was in the transform node list
  119281. */
  119282. removeTransformNode(toRemove: TransformNode): number;
  119283. /**
  119284. * Remove a skeleton for the list of scene's skeletons
  119285. * @param toRemove defines the skeleton to remove
  119286. * @returns the index where the skeleton was in the skeleton list
  119287. */
  119288. removeSkeleton(toRemove: Skeleton): number;
  119289. /**
  119290. * Remove a morph target for the list of scene's morph targets
  119291. * @param toRemove defines the morph target to remove
  119292. * @returns the index where the morph target was in the morph target list
  119293. */
  119294. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  119295. /**
  119296. * Remove a light for the list of scene's lights
  119297. * @param toRemove defines the light to remove
  119298. * @returns the index where the light was in the light list
  119299. */
  119300. removeLight(toRemove: Light): number;
  119301. /**
  119302. * Remove a camera for the list of scene's cameras
  119303. * @param toRemove defines the camera to remove
  119304. * @returns the index where the camera was in the camera list
  119305. */
  119306. removeCamera(toRemove: Camera): number;
  119307. /**
  119308. * Remove a particle system for the list of scene's particle systems
  119309. * @param toRemove defines the particle system to remove
  119310. * @returns the index where the particle system was in the particle system list
  119311. */
  119312. removeParticleSystem(toRemove: IParticleSystem): number;
  119313. /**
  119314. * Remove a animation for the list of scene's animations
  119315. * @param toRemove defines the animation to remove
  119316. * @returns the index where the animation was in the animation list
  119317. */
  119318. removeAnimation(toRemove: Animation): number;
  119319. /**
  119320. * Will stop the animation of the given target
  119321. * @param target - the target
  119322. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  119323. * @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)
  119324. */
  119325. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  119326. /**
  119327. * Removes the given animation group from this scene.
  119328. * @param toRemove The animation group to remove
  119329. * @returns The index of the removed animation group
  119330. */
  119331. removeAnimationGroup(toRemove: AnimationGroup): number;
  119332. /**
  119333. * Removes the given multi-material from this scene.
  119334. * @param toRemove The multi-material to remove
  119335. * @returns The index of the removed multi-material
  119336. */
  119337. removeMultiMaterial(toRemove: MultiMaterial): number;
  119338. /**
  119339. * Removes the given material from this scene.
  119340. * @param toRemove The material to remove
  119341. * @returns The index of the removed material
  119342. */
  119343. removeMaterial(toRemove: Material): number;
  119344. /**
  119345. * Removes the given action manager from this scene.
  119346. * @param toRemove The action manager to remove
  119347. * @returns The index of the removed action manager
  119348. */
  119349. removeActionManager(toRemove: AbstractActionManager): number;
  119350. /**
  119351. * Removes the given texture from this scene.
  119352. * @param toRemove The texture to remove
  119353. * @returns The index of the removed texture
  119354. */
  119355. removeTexture(toRemove: BaseTexture): number;
  119356. /**
  119357. * Adds the given light to this scene
  119358. * @param newLight The light to add
  119359. */
  119360. addLight(newLight: Light): void;
  119361. /**
  119362. * Sorts the list list based on light priorities
  119363. */
  119364. sortLightsByPriority(): void;
  119365. /**
  119366. * Adds the given camera to this scene
  119367. * @param newCamera The camera to add
  119368. */
  119369. addCamera(newCamera: Camera): void;
  119370. /**
  119371. * Adds the given skeleton to this scene
  119372. * @param newSkeleton The skeleton to add
  119373. */
  119374. addSkeleton(newSkeleton: Skeleton): void;
  119375. /**
  119376. * Adds the given particle system to this scene
  119377. * @param newParticleSystem The particle system to add
  119378. */
  119379. addParticleSystem(newParticleSystem: IParticleSystem): void;
  119380. /**
  119381. * Adds the given animation to this scene
  119382. * @param newAnimation The animation to add
  119383. */
  119384. addAnimation(newAnimation: Animation): void;
  119385. /**
  119386. * Adds the given animation group to this scene.
  119387. * @param newAnimationGroup The animation group to add
  119388. */
  119389. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  119390. /**
  119391. * Adds the given multi-material to this scene
  119392. * @param newMultiMaterial The multi-material to add
  119393. */
  119394. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  119395. /**
  119396. * Adds the given material to this scene
  119397. * @param newMaterial The material to add
  119398. */
  119399. addMaterial(newMaterial: Material): void;
  119400. /**
  119401. * Adds the given morph target to this scene
  119402. * @param newMorphTargetManager The morph target to add
  119403. */
  119404. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  119405. /**
  119406. * Adds the given geometry to this scene
  119407. * @param newGeometry The geometry to add
  119408. */
  119409. addGeometry(newGeometry: Geometry): void;
  119410. /**
  119411. * Adds the given action manager to this scene
  119412. * @param newActionManager The action manager to add
  119413. */
  119414. addActionManager(newActionManager: AbstractActionManager): void;
  119415. /**
  119416. * Adds the given texture to this scene.
  119417. * @param newTexture The texture to add
  119418. */
  119419. addTexture(newTexture: BaseTexture): void;
  119420. /**
  119421. * Switch active camera
  119422. * @param newCamera defines the new active camera
  119423. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  119424. */
  119425. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  119426. /**
  119427. * sets the active camera of the scene using its ID
  119428. * @param id defines the camera's ID
  119429. * @return the new active camera or null if none found.
  119430. */
  119431. setActiveCameraByID(id: string): Nullable<Camera>;
  119432. /**
  119433. * sets the active camera of the scene using its name
  119434. * @param name defines the camera's name
  119435. * @returns the new active camera or null if none found.
  119436. */
  119437. setActiveCameraByName(name: string): Nullable<Camera>;
  119438. /**
  119439. * get an animation group using its name
  119440. * @param name defines the material's name
  119441. * @return the animation group or null if none found.
  119442. */
  119443. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  119444. /**
  119445. * Get a material using its unique id
  119446. * @param uniqueId defines the material's unique id
  119447. * @return the material or null if none found.
  119448. */
  119449. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  119450. /**
  119451. * get a material using its id
  119452. * @param id defines the material's ID
  119453. * @return the material or null if none found.
  119454. */
  119455. getMaterialByID(id: string): Nullable<Material>;
  119456. /**
  119457. * Gets a the last added material using a given id
  119458. * @param id defines the material's ID
  119459. * @return the last material with the given id or null if none found.
  119460. */
  119461. getLastMaterialByID(id: string): Nullable<Material>;
  119462. /**
  119463. * Gets a material using its name
  119464. * @param name defines the material's name
  119465. * @return the material or null if none found.
  119466. */
  119467. getMaterialByName(name: string): Nullable<Material>;
  119468. /**
  119469. * Get a texture using its unique id
  119470. * @param uniqueId defines the texture's unique id
  119471. * @return the texture or null if none found.
  119472. */
  119473. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  119474. /**
  119475. * Gets a camera using its id
  119476. * @param id defines the id to look for
  119477. * @returns the camera or null if not found
  119478. */
  119479. getCameraByID(id: string): Nullable<Camera>;
  119480. /**
  119481. * Gets a camera using its unique id
  119482. * @param uniqueId defines the unique id to look for
  119483. * @returns the camera or null if not found
  119484. */
  119485. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  119486. /**
  119487. * Gets a camera using its name
  119488. * @param name defines the camera's name
  119489. * @return the camera or null if none found.
  119490. */
  119491. getCameraByName(name: string): Nullable<Camera>;
  119492. /**
  119493. * Gets a bone using its id
  119494. * @param id defines the bone's id
  119495. * @return the bone or null if not found
  119496. */
  119497. getBoneByID(id: string): Nullable<Bone>;
  119498. /**
  119499. * Gets a bone using its id
  119500. * @param name defines the bone's name
  119501. * @return the bone or null if not found
  119502. */
  119503. getBoneByName(name: string): Nullable<Bone>;
  119504. /**
  119505. * Gets a light node using its name
  119506. * @param name defines the the light's name
  119507. * @return the light or null if none found.
  119508. */
  119509. getLightByName(name: string): Nullable<Light>;
  119510. /**
  119511. * Gets a light node using its id
  119512. * @param id defines the light's id
  119513. * @return the light or null if none found.
  119514. */
  119515. getLightByID(id: string): Nullable<Light>;
  119516. /**
  119517. * Gets a light node using its scene-generated unique ID
  119518. * @param uniqueId defines the light's unique id
  119519. * @return the light or null if none found.
  119520. */
  119521. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  119522. /**
  119523. * Gets a particle system by id
  119524. * @param id defines the particle system id
  119525. * @return the corresponding system or null if none found
  119526. */
  119527. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  119528. /**
  119529. * Gets a geometry using its ID
  119530. * @param id defines the geometry's id
  119531. * @return the geometry or null if none found.
  119532. */
  119533. getGeometryByID(id: string): Nullable<Geometry>;
  119534. private _getGeometryByUniqueID;
  119535. /**
  119536. * Add a new geometry to this scene
  119537. * @param geometry defines the geometry to be added to the scene.
  119538. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  119539. * @return a boolean defining if the geometry was added or not
  119540. */
  119541. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  119542. /**
  119543. * Removes an existing geometry
  119544. * @param geometry defines the geometry to be removed from the scene
  119545. * @return a boolean defining if the geometry was removed or not
  119546. */
  119547. removeGeometry(geometry: Geometry): boolean;
  119548. /**
  119549. * Gets the list of geometries attached to the scene
  119550. * @returns an array of Geometry
  119551. */
  119552. getGeometries(): Geometry[];
  119553. /**
  119554. * Gets the first added mesh found of a given ID
  119555. * @param id defines the id to search for
  119556. * @return the mesh found or null if not found at all
  119557. */
  119558. getMeshByID(id: string): Nullable<AbstractMesh>;
  119559. /**
  119560. * Gets a list of meshes using their id
  119561. * @param id defines the id to search for
  119562. * @returns a list of meshes
  119563. */
  119564. getMeshesByID(id: string): Array<AbstractMesh>;
  119565. /**
  119566. * Gets the first added transform node found of a given ID
  119567. * @param id defines the id to search for
  119568. * @return the found transform node or null if not found at all.
  119569. */
  119570. getTransformNodeByID(id: string): Nullable<TransformNode>;
  119571. /**
  119572. * Gets a transform node with its auto-generated unique id
  119573. * @param uniqueId efines the unique id to search for
  119574. * @return the found transform node or null if not found at all.
  119575. */
  119576. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  119577. /**
  119578. * Gets a list of transform nodes using their id
  119579. * @param id defines the id to search for
  119580. * @returns a list of transform nodes
  119581. */
  119582. getTransformNodesByID(id: string): Array<TransformNode>;
  119583. /**
  119584. * Gets a mesh with its auto-generated unique id
  119585. * @param uniqueId defines the unique id to search for
  119586. * @return the found mesh or null if not found at all.
  119587. */
  119588. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  119589. /**
  119590. * Gets a the last added mesh using a given id
  119591. * @param id defines the id to search for
  119592. * @return the found mesh or null if not found at all.
  119593. */
  119594. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  119595. /**
  119596. * Gets a the last added node (Mesh, Camera, Light) using a given id
  119597. * @param id defines the id to search for
  119598. * @return the found node or null if not found at all
  119599. */
  119600. getLastEntryByID(id: string): Nullable<Node>;
  119601. /**
  119602. * Gets a node (Mesh, Camera, Light) using a given id
  119603. * @param id defines the id to search for
  119604. * @return the found node or null if not found at all
  119605. */
  119606. getNodeByID(id: string): Nullable<Node>;
  119607. /**
  119608. * Gets a node (Mesh, Camera, Light) using a given name
  119609. * @param name defines the name to search for
  119610. * @return the found node or null if not found at all.
  119611. */
  119612. getNodeByName(name: string): Nullable<Node>;
  119613. /**
  119614. * Gets a mesh using a given name
  119615. * @param name defines the name to search for
  119616. * @return the found mesh or null if not found at all.
  119617. */
  119618. getMeshByName(name: string): Nullable<AbstractMesh>;
  119619. /**
  119620. * Gets a transform node using a given name
  119621. * @param name defines the name to search for
  119622. * @return the found transform node or null if not found at all.
  119623. */
  119624. getTransformNodeByName(name: string): Nullable<TransformNode>;
  119625. /**
  119626. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  119627. * @param id defines the id to search for
  119628. * @return the found skeleton or null if not found at all.
  119629. */
  119630. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  119631. /**
  119632. * Gets a skeleton using a given auto generated unique id
  119633. * @param uniqueId defines the unique id to search for
  119634. * @return the found skeleton or null if not found at all.
  119635. */
  119636. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  119637. /**
  119638. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  119639. * @param id defines the id to search for
  119640. * @return the found skeleton or null if not found at all.
  119641. */
  119642. getSkeletonById(id: string): Nullable<Skeleton>;
  119643. /**
  119644. * Gets a skeleton using a given name
  119645. * @param name defines the name to search for
  119646. * @return the found skeleton or null if not found at all.
  119647. */
  119648. getSkeletonByName(name: string): Nullable<Skeleton>;
  119649. /**
  119650. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  119651. * @param id defines the id to search for
  119652. * @return the found morph target manager or null if not found at all.
  119653. */
  119654. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  119655. /**
  119656. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  119657. * @param id defines the id to search for
  119658. * @return the found morph target or null if not found at all.
  119659. */
  119660. getMorphTargetById(id: string): Nullable<MorphTarget>;
  119661. /**
  119662. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  119663. * @param name defines the name to search for
  119664. * @return the found morph target or null if not found at all.
  119665. */
  119666. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  119667. /**
  119668. * Gets a boolean indicating if the given mesh is active
  119669. * @param mesh defines the mesh to look for
  119670. * @returns true if the mesh is in the active list
  119671. */
  119672. isActiveMesh(mesh: AbstractMesh): boolean;
  119673. /**
  119674. * Return a unique id as a string which can serve as an identifier for the scene
  119675. */
  119676. get uid(): string;
  119677. /**
  119678. * Add an externaly attached data from its key.
  119679. * This method call will fail and return false, if such key already exists.
  119680. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  119681. * @param key the unique key that identifies the data
  119682. * @param data the data object to associate to the key for this Engine instance
  119683. * @return true if no such key were already present and the data was added successfully, false otherwise
  119684. */
  119685. addExternalData<T>(key: string, data: T): boolean;
  119686. /**
  119687. * Get an externaly attached data from its key
  119688. * @param key the unique key that identifies the data
  119689. * @return the associated data, if present (can be null), or undefined if not present
  119690. */
  119691. getExternalData<T>(key: string): Nullable<T>;
  119692. /**
  119693. * Get an externaly attached data from its key, create it using a factory if it's not already present
  119694. * @param key the unique key that identifies the data
  119695. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  119696. * @return the associated data, can be null if the factory returned null.
  119697. */
  119698. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  119699. /**
  119700. * Remove an externaly attached data from the Engine instance
  119701. * @param key the unique key that identifies the data
  119702. * @return true if the data was successfully removed, false if it doesn't exist
  119703. */
  119704. removeExternalData(key: string): boolean;
  119705. private _evaluateSubMesh;
  119706. /**
  119707. * Clear the processed materials smart array preventing retention point in material dispose.
  119708. */
  119709. freeProcessedMaterials(): void;
  119710. private _preventFreeActiveMeshesAndRenderingGroups;
  119711. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  119712. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  119713. * when disposing several meshes in a row or a hierarchy of meshes.
  119714. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  119715. */
  119716. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  119717. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  119718. /**
  119719. * Clear the active meshes smart array preventing retention point in mesh dispose.
  119720. */
  119721. freeActiveMeshes(): void;
  119722. /**
  119723. * Clear the info related to rendering groups preventing retention points during dispose.
  119724. */
  119725. freeRenderingGroups(): void;
  119726. /** @hidden */
  119727. _isInIntermediateRendering(): boolean;
  119728. /**
  119729. * Lambda returning the list of potentially active meshes.
  119730. */
  119731. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  119732. /**
  119733. * Lambda returning the list of potentially active sub meshes.
  119734. */
  119735. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  119736. /**
  119737. * Lambda returning the list of potentially intersecting sub meshes.
  119738. */
  119739. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  119740. /**
  119741. * Lambda returning the list of potentially colliding sub meshes.
  119742. */
  119743. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  119744. private _activeMeshesFrozen;
  119745. private _skipEvaluateActiveMeshesCompletely;
  119746. /**
  119747. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  119748. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  119749. * @returns the current scene
  119750. */
  119751. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  119752. /**
  119753. * Use this function to restart evaluating active meshes on every frame
  119754. * @returns the current scene
  119755. */
  119756. unfreezeActiveMeshes(): Scene;
  119757. private _evaluateActiveMeshes;
  119758. private _activeMesh;
  119759. /**
  119760. * Update the transform matrix to update from the current active camera
  119761. * @param force defines a boolean used to force the update even if cache is up to date
  119762. */
  119763. updateTransformMatrix(force?: boolean): void;
  119764. private _bindFrameBuffer;
  119765. /** @hidden */
  119766. _allowPostProcessClearColor: boolean;
  119767. /** @hidden */
  119768. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  119769. private _processSubCameras;
  119770. private _checkIntersections;
  119771. /** @hidden */
  119772. _advancePhysicsEngineStep(step: number): void;
  119773. /**
  119774. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  119775. */
  119776. getDeterministicFrameTime: () => number;
  119777. /** @hidden */
  119778. _animate(): void;
  119779. /** Execute all animations (for a frame) */
  119780. animate(): void;
  119781. /**
  119782. * Render the scene
  119783. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  119784. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  119785. */
  119786. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  119787. /**
  119788. * Freeze all materials
  119789. * A frozen material will not be updatable but should be faster to render
  119790. */
  119791. freezeMaterials(): void;
  119792. /**
  119793. * Unfreeze all materials
  119794. * A frozen material will not be updatable but should be faster to render
  119795. */
  119796. unfreezeMaterials(): void;
  119797. /**
  119798. * Releases all held ressources
  119799. */
  119800. dispose(): void;
  119801. /**
  119802. * Gets if the scene is already disposed
  119803. */
  119804. get isDisposed(): boolean;
  119805. /**
  119806. * Call this function to reduce memory footprint of the scene.
  119807. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  119808. */
  119809. clearCachedVertexData(): void;
  119810. /**
  119811. * This function will remove the local cached buffer data from texture.
  119812. * It will save memory but will prevent the texture from being rebuilt
  119813. */
  119814. cleanCachedTextureBuffer(): void;
  119815. /**
  119816. * Get the world extend vectors with an optional filter
  119817. *
  119818. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  119819. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  119820. */
  119821. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  119822. min: Vector3;
  119823. max: Vector3;
  119824. };
  119825. /**
  119826. * Creates a ray that can be used to pick in the scene
  119827. * @param x defines the x coordinate of the origin (on-screen)
  119828. * @param y defines the y coordinate of the origin (on-screen)
  119829. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119830. * @param camera defines the camera to use for the picking
  119831. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119832. * @returns a Ray
  119833. */
  119834. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  119835. /**
  119836. * Creates a ray that can be used to pick in the scene
  119837. * @param x defines the x coordinate of the origin (on-screen)
  119838. * @param y defines the y coordinate of the origin (on-screen)
  119839. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  119840. * @param result defines the ray where to store the picking ray
  119841. * @param camera defines the camera to use for the picking
  119842. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  119843. * @returns the current scene
  119844. */
  119845. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  119846. /**
  119847. * Creates a ray that can be used to pick in the scene
  119848. * @param x defines the x coordinate of the origin (on-screen)
  119849. * @param y defines the y coordinate of the origin (on-screen)
  119850. * @param camera defines the camera to use for the picking
  119851. * @returns a Ray
  119852. */
  119853. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  119854. /**
  119855. * Creates a ray that can be used to pick in the scene
  119856. * @param x defines the x coordinate of the origin (on-screen)
  119857. * @param y defines the y coordinate of the origin (on-screen)
  119858. * @param result defines the ray where to store the picking ray
  119859. * @param camera defines the camera to use for the picking
  119860. * @returns the current scene
  119861. */
  119862. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  119863. /** Launch a ray to try to pick a mesh in the scene
  119864. * @param x position on screen
  119865. * @param y position on screen
  119866. * @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
  119867. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119868. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119869. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119870. * @returns a PickingInfo
  119871. */
  119872. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119873. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  119874. * @param x position on screen
  119875. * @param y position on screen
  119876. * @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
  119877. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119878. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119879. * @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)
  119880. */
  119881. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  119882. /** Use the given ray to pick a mesh in the scene
  119883. * @param ray The ray to use to pick meshes
  119884. * @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
  119885. * @param fastCheck defines if the first intersection will be used (and not the closest)
  119886. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119887. * @returns a PickingInfo
  119888. */
  119889. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  119890. /**
  119891. * Launch a ray to try to pick a mesh in the scene
  119892. * @param x X position on screen
  119893. * @param y Y position on screen
  119894. * @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
  119895. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  119896. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119897. * @returns an array of PickingInfo
  119898. */
  119899. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119900. /**
  119901. * Launch a ray to try to pick a mesh in the scene
  119902. * @param ray Ray to use
  119903. * @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
  119904. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  119905. * @returns an array of PickingInfo
  119906. */
  119907. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  119908. /**
  119909. * Force the value of meshUnderPointer
  119910. * @param mesh defines the mesh to use
  119911. */
  119912. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  119913. /**
  119914. * Gets the mesh under the pointer
  119915. * @returns a Mesh or null if no mesh is under the pointer
  119916. */
  119917. getPointerOverMesh(): Nullable<AbstractMesh>;
  119918. /** @hidden */
  119919. _rebuildGeometries(): void;
  119920. /** @hidden */
  119921. _rebuildTextures(): void;
  119922. private _getByTags;
  119923. /**
  119924. * Get a list of meshes by tags
  119925. * @param tagsQuery defines the tags query to use
  119926. * @param forEach defines a predicate used to filter results
  119927. * @returns an array of Mesh
  119928. */
  119929. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  119930. /**
  119931. * Get a list of cameras by tags
  119932. * @param tagsQuery defines the tags query to use
  119933. * @param forEach defines a predicate used to filter results
  119934. * @returns an array of Camera
  119935. */
  119936. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  119937. /**
  119938. * Get a list of lights by tags
  119939. * @param tagsQuery defines the tags query to use
  119940. * @param forEach defines a predicate used to filter results
  119941. * @returns an array of Light
  119942. */
  119943. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  119944. /**
  119945. * Get a list of materials by tags
  119946. * @param tagsQuery defines the tags query to use
  119947. * @param forEach defines a predicate used to filter results
  119948. * @returns an array of Material
  119949. */
  119950. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  119951. /**
  119952. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119953. * This allowed control for front to back rendering or reversly depending of the special needs.
  119954. *
  119955. * @param renderingGroupId The rendering group id corresponding to its index
  119956. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119957. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119958. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119959. */
  119960. 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;
  119961. /**
  119962. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119963. *
  119964. * @param renderingGroupId The rendering group id corresponding to its index
  119965. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119966. * @param depth Automatically clears depth between groups if true and autoClear is true.
  119967. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  119968. */
  119969. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  119970. /**
  119971. * Gets the current auto clear configuration for one rendering group of the rendering
  119972. * manager.
  119973. * @param index the rendering group index to get the information for
  119974. * @returns The auto clear setup for the requested rendering group
  119975. */
  119976. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  119977. private _blockMaterialDirtyMechanism;
  119978. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  119979. get blockMaterialDirtyMechanism(): boolean;
  119980. set blockMaterialDirtyMechanism(value: boolean);
  119981. /**
  119982. * Will flag all materials as dirty to trigger new shader compilation
  119983. * @param flag defines the flag used to specify which material part must be marked as dirty
  119984. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  119985. */
  119986. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  119987. /** @hidden */
  119988. _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;
  119989. /** @hidden */
  119990. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119991. /** @hidden */
  119992. _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;
  119993. /** @hidden */
  119994. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  119995. /** @hidden */
  119996. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  119997. /** @hidden */
  119998. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  119999. }
  120000. }
  120001. declare module BABYLON {
  120002. /**
  120003. * Set of assets to keep when moving a scene into an asset container.
  120004. */
  120005. export class KeepAssets extends AbstractScene {
  120006. }
  120007. /**
  120008. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  120009. */
  120010. export class InstantiatedEntries {
  120011. /**
  120012. * List of new root nodes (eg. nodes with no parent)
  120013. */
  120014. rootNodes: TransformNode[];
  120015. /**
  120016. * List of new skeletons
  120017. */
  120018. skeletons: Skeleton[];
  120019. /**
  120020. * List of new animation groups
  120021. */
  120022. animationGroups: AnimationGroup[];
  120023. }
  120024. /**
  120025. * Container with a set of assets that can be added or removed from a scene.
  120026. */
  120027. export class AssetContainer extends AbstractScene {
  120028. private _wasAddedToScene;
  120029. /**
  120030. * The scene the AssetContainer belongs to.
  120031. */
  120032. scene: Scene;
  120033. /**
  120034. * Instantiates an AssetContainer.
  120035. * @param scene The scene the AssetContainer belongs to.
  120036. */
  120037. constructor(scene: Scene);
  120038. /**
  120039. * Instantiate or clone all meshes and add the new ones to the scene.
  120040. * Skeletons and animation groups will all be cloned
  120041. * @param nameFunction defines an optional function used to get new names for clones
  120042. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  120043. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  120044. */
  120045. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  120046. /**
  120047. * Adds all the assets from the container to the scene.
  120048. */
  120049. addAllToScene(): void;
  120050. /**
  120051. * Removes all the assets in the container from the scene
  120052. */
  120053. removeAllFromScene(): void;
  120054. /**
  120055. * Disposes all the assets in the container
  120056. */
  120057. dispose(): void;
  120058. private _moveAssets;
  120059. /**
  120060. * Removes all the assets contained in the scene and adds them to the container.
  120061. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  120062. */
  120063. moveAllFromScene(keepAssets?: KeepAssets): void;
  120064. /**
  120065. * 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.
  120066. * @returns the root mesh
  120067. */
  120068. createRootMesh(): Mesh;
  120069. /**
  120070. * Merge animations (direct and animation groups) from this asset container into a scene
  120071. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  120072. * @param animatables set of animatables to retarget to a node from the scene
  120073. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  120074. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  120075. */
  120076. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  120077. }
  120078. }
  120079. declare module BABYLON {
  120080. /**
  120081. * Defines how the parser contract is defined.
  120082. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  120083. */
  120084. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  120085. /**
  120086. * Defines how the individual parser contract is defined.
  120087. * These parser can parse an individual asset
  120088. */
  120089. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  120090. /**
  120091. * Base class of the scene acting as a container for the different elements composing a scene.
  120092. * This class is dynamically extended by the different components of the scene increasing
  120093. * flexibility and reducing coupling
  120094. */
  120095. export abstract class AbstractScene {
  120096. /**
  120097. * Stores the list of available parsers in the application.
  120098. */
  120099. private static _BabylonFileParsers;
  120100. /**
  120101. * Stores the list of available individual parsers in the application.
  120102. */
  120103. private static _IndividualBabylonFileParsers;
  120104. /**
  120105. * Adds a parser in the list of available ones
  120106. * @param name Defines the name of the parser
  120107. * @param parser Defines the parser to add
  120108. */
  120109. static AddParser(name: string, parser: BabylonFileParser): void;
  120110. /**
  120111. * Gets a general parser from the list of avaialble ones
  120112. * @param name Defines the name of the parser
  120113. * @returns the requested parser or null
  120114. */
  120115. static GetParser(name: string): Nullable<BabylonFileParser>;
  120116. /**
  120117. * Adds n individual parser in the list of available ones
  120118. * @param name Defines the name of the parser
  120119. * @param parser Defines the parser to add
  120120. */
  120121. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  120122. /**
  120123. * Gets an individual parser from the list of avaialble ones
  120124. * @param name Defines the name of the parser
  120125. * @returns the requested parser or null
  120126. */
  120127. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  120128. /**
  120129. * Parser json data and populate both a scene and its associated container object
  120130. * @param jsonData Defines the data to parse
  120131. * @param scene Defines the scene to parse the data for
  120132. * @param container Defines the container attached to the parsing sequence
  120133. * @param rootUrl Defines the root url of the data
  120134. */
  120135. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  120136. /**
  120137. * Gets the list of root nodes (ie. nodes with no parent)
  120138. */
  120139. rootNodes: Node[];
  120140. /** All of the cameras added to this scene
  120141. * @see https://doc.babylonjs.com/babylon101/cameras
  120142. */
  120143. cameras: Camera[];
  120144. /**
  120145. * All of the lights added to this scene
  120146. * @see https://doc.babylonjs.com/babylon101/lights
  120147. */
  120148. lights: Light[];
  120149. /**
  120150. * All of the (abstract) meshes added to this scene
  120151. */
  120152. meshes: AbstractMesh[];
  120153. /**
  120154. * The list of skeletons added to the scene
  120155. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  120156. */
  120157. skeletons: Skeleton[];
  120158. /**
  120159. * All of the particle systems added to this scene
  120160. * @see https://doc.babylonjs.com/babylon101/particles
  120161. */
  120162. particleSystems: IParticleSystem[];
  120163. /**
  120164. * Gets a list of Animations associated with the scene
  120165. */
  120166. animations: Animation[];
  120167. /**
  120168. * All of the animation groups added to this scene
  120169. * @see https://doc.babylonjs.com/how_to/group
  120170. */
  120171. animationGroups: AnimationGroup[];
  120172. /**
  120173. * All of the multi-materials added to this scene
  120174. * @see https://doc.babylonjs.com/how_to/multi_materials
  120175. */
  120176. multiMaterials: MultiMaterial[];
  120177. /**
  120178. * All of the materials added to this scene
  120179. * In the context of a Scene, it is not supposed to be modified manually.
  120180. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  120181. * Note also that the order of the Material within the array is not significant and might change.
  120182. * @see https://doc.babylonjs.com/babylon101/materials
  120183. */
  120184. materials: Material[];
  120185. /**
  120186. * The list of morph target managers added to the scene
  120187. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  120188. */
  120189. morphTargetManagers: MorphTargetManager[];
  120190. /**
  120191. * The list of geometries used in the scene.
  120192. */
  120193. geometries: Geometry[];
  120194. /**
  120195. * All of the tranform nodes added to this scene
  120196. * In the context of a Scene, it is not supposed to be modified manually.
  120197. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  120198. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  120199. * @see https://doc.babylonjs.com/how_to/transformnode
  120200. */
  120201. transformNodes: TransformNode[];
  120202. /**
  120203. * ActionManagers available on the scene.
  120204. */
  120205. actionManagers: AbstractActionManager[];
  120206. /**
  120207. * Textures to keep.
  120208. */
  120209. textures: BaseTexture[];
  120210. /**
  120211. * Environment texture for the scene
  120212. */
  120213. environmentTexture: Nullable<BaseTexture>;
  120214. /**
  120215. * @returns all meshes, lights, cameras, transformNodes and bones
  120216. */
  120217. getNodes(): Array<Node>;
  120218. }
  120219. }
  120220. declare module BABYLON {
  120221. /**
  120222. * Interface used to define options for Sound class
  120223. */
  120224. export interface ISoundOptions {
  120225. /**
  120226. * Does the sound autoplay once loaded.
  120227. */
  120228. autoplay?: boolean;
  120229. /**
  120230. * Does the sound loop after it finishes playing once.
  120231. */
  120232. loop?: boolean;
  120233. /**
  120234. * Sound's volume
  120235. */
  120236. volume?: number;
  120237. /**
  120238. * Is it a spatial sound?
  120239. */
  120240. spatialSound?: boolean;
  120241. /**
  120242. * Maximum distance to hear that sound
  120243. */
  120244. maxDistance?: number;
  120245. /**
  120246. * Uses user defined attenuation function
  120247. */
  120248. useCustomAttenuation?: boolean;
  120249. /**
  120250. * Define the roll off factor of spatial sounds.
  120251. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120252. */
  120253. rolloffFactor?: number;
  120254. /**
  120255. * Define the reference distance the sound should be heard perfectly.
  120256. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120257. */
  120258. refDistance?: number;
  120259. /**
  120260. * Define the distance attenuation model the sound will follow.
  120261. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120262. */
  120263. distanceModel?: string;
  120264. /**
  120265. * Defines the playback speed (1 by default)
  120266. */
  120267. playbackRate?: number;
  120268. /**
  120269. * Defines if the sound is from a streaming source
  120270. */
  120271. streaming?: boolean;
  120272. /**
  120273. * Defines an optional length (in seconds) inside the sound file
  120274. */
  120275. length?: number;
  120276. /**
  120277. * Defines an optional offset (in seconds) inside the sound file
  120278. */
  120279. offset?: number;
  120280. /**
  120281. * If true, URLs will not be required to state the audio file codec to use.
  120282. */
  120283. skipCodecCheck?: boolean;
  120284. }
  120285. /**
  120286. * Defines a sound that can be played in the application.
  120287. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  120288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120289. */
  120290. export class Sound {
  120291. /**
  120292. * The name of the sound in the scene.
  120293. */
  120294. name: string;
  120295. /**
  120296. * Does the sound autoplay once loaded.
  120297. */
  120298. autoplay: boolean;
  120299. /**
  120300. * Does the sound loop after it finishes playing once.
  120301. */
  120302. loop: boolean;
  120303. /**
  120304. * Does the sound use a custom attenuation curve to simulate the falloff
  120305. * happening when the source gets further away from the camera.
  120306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120307. */
  120308. useCustomAttenuation: boolean;
  120309. /**
  120310. * The sound track id this sound belongs to.
  120311. */
  120312. soundTrackId: number;
  120313. /**
  120314. * Is this sound currently played.
  120315. */
  120316. isPlaying: boolean;
  120317. /**
  120318. * Is this sound currently paused.
  120319. */
  120320. isPaused: boolean;
  120321. /**
  120322. * Does this sound enables spatial sound.
  120323. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120324. */
  120325. spatialSound: boolean;
  120326. /**
  120327. * Define the reference distance the sound should be heard perfectly.
  120328. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120329. */
  120330. refDistance: number;
  120331. /**
  120332. * Define the roll off factor of spatial sounds.
  120333. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120334. */
  120335. rolloffFactor: number;
  120336. /**
  120337. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  120338. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120339. */
  120340. maxDistance: number;
  120341. /**
  120342. * Define the distance attenuation model the sound will follow.
  120343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120344. */
  120345. distanceModel: string;
  120346. /**
  120347. * @hidden
  120348. * Back Compat
  120349. **/
  120350. onended: () => any;
  120351. /**
  120352. * Gets or sets an object used to store user defined information for the sound.
  120353. */
  120354. metadata: any;
  120355. /**
  120356. * Observable event when the current playing sound finishes.
  120357. */
  120358. onEndedObservable: Observable<Sound>;
  120359. private _panningModel;
  120360. private _playbackRate;
  120361. private _streaming;
  120362. private _startTime;
  120363. private _startOffset;
  120364. private _position;
  120365. /** @hidden */
  120366. _positionInEmitterSpace: boolean;
  120367. private _localDirection;
  120368. private _volume;
  120369. private _isReadyToPlay;
  120370. private _isDirectional;
  120371. private _readyToPlayCallback;
  120372. private _audioBuffer;
  120373. private _soundSource;
  120374. private _streamingSource;
  120375. private _soundPanner;
  120376. private _soundGain;
  120377. private _inputAudioNode;
  120378. private _outputAudioNode;
  120379. private _coneInnerAngle;
  120380. private _coneOuterAngle;
  120381. private _coneOuterGain;
  120382. private _scene;
  120383. private _connectedTransformNode;
  120384. private _customAttenuationFunction;
  120385. private _registerFunc;
  120386. private _isOutputConnected;
  120387. private _htmlAudioElement;
  120388. private _urlType;
  120389. private _length?;
  120390. private _offset?;
  120391. /** @hidden */
  120392. static _SceneComponentInitialization: (scene: Scene) => void;
  120393. /**
  120394. * Create a sound and attach it to a scene
  120395. * @param name Name of your sound
  120396. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  120397. * @param scene defines the scene the sound belongs to
  120398. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  120399. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  120400. */
  120401. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  120402. /**
  120403. * Release the sound and its associated resources
  120404. */
  120405. dispose(): void;
  120406. /**
  120407. * Gets if the sounds is ready to be played or not.
  120408. * @returns true if ready, otherwise false
  120409. */
  120410. isReady(): boolean;
  120411. private _soundLoaded;
  120412. /**
  120413. * Sets the data of the sound from an audiobuffer
  120414. * @param audioBuffer The audioBuffer containing the data
  120415. */
  120416. setAudioBuffer(audioBuffer: AudioBuffer): void;
  120417. /**
  120418. * Updates the current sounds options such as maxdistance, loop...
  120419. * @param options A JSON object containing values named as the object properties
  120420. */
  120421. updateOptions(options: ISoundOptions): void;
  120422. private _createSpatialParameters;
  120423. private _updateSpatialParameters;
  120424. /**
  120425. * Switch the panning model to HRTF:
  120426. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120427. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120428. */
  120429. switchPanningModelToHRTF(): void;
  120430. /**
  120431. * Switch the panning model to Equal Power:
  120432. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120433. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120434. */
  120435. switchPanningModelToEqualPower(): void;
  120436. private _switchPanningModel;
  120437. /**
  120438. * Connect this sound to a sound track audio node like gain...
  120439. * @param soundTrackAudioNode the sound track audio node to connect to
  120440. */
  120441. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  120442. /**
  120443. * Transform this sound into a directional source
  120444. * @param coneInnerAngle Size of the inner cone in degree
  120445. * @param coneOuterAngle Size of the outer cone in degree
  120446. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  120447. */
  120448. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  120449. /**
  120450. * Gets or sets the inner angle for the directional cone.
  120451. */
  120452. get directionalConeInnerAngle(): number;
  120453. /**
  120454. * Gets or sets the inner angle for the directional cone.
  120455. */
  120456. set directionalConeInnerAngle(value: number);
  120457. /**
  120458. * Gets or sets the outer angle for the directional cone.
  120459. */
  120460. get directionalConeOuterAngle(): number;
  120461. /**
  120462. * Gets or sets the outer angle for the directional cone.
  120463. */
  120464. set directionalConeOuterAngle(value: number);
  120465. /**
  120466. * Sets the position of the emitter if spatial sound is enabled
  120467. * @param newPosition Defines the new posisiton
  120468. */
  120469. setPosition(newPosition: Vector3): void;
  120470. /**
  120471. * Sets the local direction of the emitter if spatial sound is enabled
  120472. * @param newLocalDirection Defines the new local direction
  120473. */
  120474. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  120475. private _updateDirection;
  120476. /** @hidden */
  120477. updateDistanceFromListener(): void;
  120478. /**
  120479. * Sets a new custom attenuation function for the sound.
  120480. * @param callback Defines the function used for the attenuation
  120481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  120482. */
  120483. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  120484. /**
  120485. * Play the sound
  120486. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  120487. * @param offset (optional) Start the sound at a specific time in seconds
  120488. * @param length (optional) Sound duration (in seconds)
  120489. */
  120490. play(time?: number, offset?: number, length?: number): void;
  120491. private _onended;
  120492. /**
  120493. * Stop the sound
  120494. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  120495. */
  120496. stop(time?: number): void;
  120497. /**
  120498. * Put the sound in pause
  120499. */
  120500. pause(): void;
  120501. /**
  120502. * Sets a dedicated volume for this sounds
  120503. * @param newVolume Define the new volume of the sound
  120504. * @param time Define time for gradual change to new volume
  120505. */
  120506. setVolume(newVolume: number, time?: number): void;
  120507. /**
  120508. * Set the sound play back rate
  120509. * @param newPlaybackRate Define the playback rate the sound should be played at
  120510. */
  120511. setPlaybackRate(newPlaybackRate: number): void;
  120512. /**
  120513. * Gets the volume of the sound.
  120514. * @returns the volume of the sound
  120515. */
  120516. getVolume(): number;
  120517. /**
  120518. * Attach the sound to a dedicated mesh
  120519. * @param transformNode The transform node to connect the sound with
  120520. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120521. */
  120522. attachToMesh(transformNode: TransformNode): void;
  120523. /**
  120524. * Detach the sound from the previously attached mesh
  120525. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  120526. */
  120527. detachFromMesh(): void;
  120528. private _onRegisterAfterWorldMatrixUpdate;
  120529. /**
  120530. * Clone the current sound in the scene.
  120531. * @returns the new sound clone
  120532. */
  120533. clone(): Nullable<Sound>;
  120534. /**
  120535. * Gets the current underlying audio buffer containing the data
  120536. * @returns the audio buffer
  120537. */
  120538. getAudioBuffer(): Nullable<AudioBuffer>;
  120539. /**
  120540. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  120541. * @returns the source node
  120542. */
  120543. getSoundSource(): Nullable<AudioBufferSourceNode>;
  120544. /**
  120545. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  120546. * @returns the gain node
  120547. */
  120548. getSoundGain(): Nullable<GainNode>;
  120549. /**
  120550. * Serializes the Sound in a JSON representation
  120551. * @returns the JSON representation of the sound
  120552. */
  120553. serialize(): any;
  120554. /**
  120555. * Parse a JSON representation of a sound to innstantiate in a given scene
  120556. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  120557. * @param scene Define the scene the new parsed sound should be created in
  120558. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  120559. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  120560. * @returns the newly parsed sound
  120561. */
  120562. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  120563. }
  120564. }
  120565. declare module BABYLON {
  120566. /**
  120567. * This defines an action helpful to play a defined sound on a triggered action.
  120568. */
  120569. export class PlaySoundAction extends Action {
  120570. private _sound;
  120571. /**
  120572. * Instantiate the action
  120573. * @param triggerOptions defines the trigger options
  120574. * @param sound defines the sound to play
  120575. * @param condition defines the trigger related conditions
  120576. */
  120577. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120578. /** @hidden */
  120579. _prepare(): void;
  120580. /**
  120581. * Execute the action and play the sound.
  120582. */
  120583. execute(): void;
  120584. /**
  120585. * Serializes the actions and its related information.
  120586. * @param parent defines the object to serialize in
  120587. * @returns the serialized object
  120588. */
  120589. serialize(parent: any): any;
  120590. }
  120591. /**
  120592. * This defines an action helpful to stop a defined sound on a triggered action.
  120593. */
  120594. export class StopSoundAction extends Action {
  120595. private _sound;
  120596. /**
  120597. * Instantiate the action
  120598. * @param triggerOptions defines the trigger options
  120599. * @param sound defines the sound to stop
  120600. * @param condition defines the trigger related conditions
  120601. */
  120602. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  120603. /** @hidden */
  120604. _prepare(): void;
  120605. /**
  120606. * Execute the action and stop the sound.
  120607. */
  120608. execute(): void;
  120609. /**
  120610. * Serializes the actions and its related information.
  120611. * @param parent defines the object to serialize in
  120612. * @returns the serialized object
  120613. */
  120614. serialize(parent: any): any;
  120615. }
  120616. }
  120617. declare module BABYLON {
  120618. /**
  120619. * This defines an action responsible to change the value of a property
  120620. * by interpolating between its current value and the newly set one once triggered.
  120621. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120622. */
  120623. export class InterpolateValueAction extends Action {
  120624. /**
  120625. * Defines the path of the property where the value should be interpolated
  120626. */
  120627. propertyPath: string;
  120628. /**
  120629. * Defines the target value at the end of the interpolation.
  120630. */
  120631. value: any;
  120632. /**
  120633. * Defines the time it will take for the property to interpolate to the value.
  120634. */
  120635. duration: number;
  120636. /**
  120637. * Defines if the other scene animations should be stopped when the action has been triggered
  120638. */
  120639. stopOtherAnimations?: boolean;
  120640. /**
  120641. * Defines a callback raised once the interpolation animation has been done.
  120642. */
  120643. onInterpolationDone?: () => void;
  120644. /**
  120645. * Observable triggered once the interpolation animation has been done.
  120646. */
  120647. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  120648. private _target;
  120649. private _effectiveTarget;
  120650. private _property;
  120651. /**
  120652. * Instantiate the action
  120653. * @param triggerOptions defines the trigger options
  120654. * @param target defines the object containing the value to interpolate
  120655. * @param propertyPath defines the path to the property in the target object
  120656. * @param value defines the target value at the end of the interpolation
  120657. * @param duration deines the time it will take for the property to interpolate to the value.
  120658. * @param condition defines the trigger related conditions
  120659. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  120660. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  120661. */
  120662. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  120663. /** @hidden */
  120664. _prepare(): void;
  120665. /**
  120666. * Execute the action starts the value interpolation.
  120667. */
  120668. execute(): void;
  120669. /**
  120670. * Serializes the actions and its related information.
  120671. * @param parent defines the object to serialize in
  120672. * @returns the serialized object
  120673. */
  120674. serialize(parent: any): any;
  120675. }
  120676. }
  120677. declare module BABYLON {
  120678. /**
  120679. * Options allowed during the creation of a sound track.
  120680. */
  120681. export interface ISoundTrackOptions {
  120682. /**
  120683. * The volume the sound track should take during creation
  120684. */
  120685. volume?: number;
  120686. /**
  120687. * Define if the sound track is the main sound track of the scene
  120688. */
  120689. mainTrack?: boolean;
  120690. }
  120691. /**
  120692. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  120693. * It will be also used in a future release to apply effects on a specific track.
  120694. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120695. */
  120696. export class SoundTrack {
  120697. /**
  120698. * The unique identifier of the sound track in the scene.
  120699. */
  120700. id: number;
  120701. /**
  120702. * The list of sounds included in the sound track.
  120703. */
  120704. soundCollection: Array<Sound>;
  120705. private _outputAudioNode;
  120706. private _scene;
  120707. private _connectedAnalyser;
  120708. private _options;
  120709. private _isInitialized;
  120710. /**
  120711. * Creates a new sound track.
  120712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  120713. * @param scene Define the scene the sound track belongs to
  120714. * @param options
  120715. */
  120716. constructor(scene: Scene, options?: ISoundTrackOptions);
  120717. private _initializeSoundTrackAudioGraph;
  120718. /**
  120719. * Release the sound track and its associated resources
  120720. */
  120721. dispose(): void;
  120722. /**
  120723. * Adds a sound to this sound track
  120724. * @param sound define the cound to add
  120725. * @ignoreNaming
  120726. */
  120727. AddSound(sound: Sound): void;
  120728. /**
  120729. * Removes a sound to this sound track
  120730. * @param sound define the cound to remove
  120731. * @ignoreNaming
  120732. */
  120733. RemoveSound(sound: Sound): void;
  120734. /**
  120735. * Set a global volume for the full sound track.
  120736. * @param newVolume Define the new volume of the sound track
  120737. */
  120738. setVolume(newVolume: number): void;
  120739. /**
  120740. * Switch the panning model to HRTF:
  120741. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  120742. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120743. */
  120744. switchPanningModelToHRTF(): void;
  120745. /**
  120746. * Switch the panning model to Equal Power:
  120747. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  120748. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  120749. */
  120750. switchPanningModelToEqualPower(): void;
  120751. /**
  120752. * Connect the sound track to an audio analyser allowing some amazing
  120753. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  120754. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  120755. * @param analyser The analyser to connect to the engine
  120756. */
  120757. connectToAnalyser(analyser: Analyser): void;
  120758. }
  120759. }
  120760. declare module BABYLON {
  120761. interface AbstractScene {
  120762. /**
  120763. * The list of sounds used in the scene.
  120764. */
  120765. sounds: Nullable<Array<Sound>>;
  120766. }
  120767. interface Scene {
  120768. /**
  120769. * @hidden
  120770. * Backing field
  120771. */
  120772. _mainSoundTrack: SoundTrack;
  120773. /**
  120774. * The main sound track played by the scene.
  120775. * It cotains your primary collection of sounds.
  120776. */
  120777. mainSoundTrack: SoundTrack;
  120778. /**
  120779. * The list of sound tracks added to the scene
  120780. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120781. */
  120782. soundTracks: Nullable<Array<SoundTrack>>;
  120783. /**
  120784. * Gets a sound using a given name
  120785. * @param name defines the name to search for
  120786. * @return the found sound or null if not found at all.
  120787. */
  120788. getSoundByName(name: string): Nullable<Sound>;
  120789. /**
  120790. * Gets or sets if audio support is enabled
  120791. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120792. */
  120793. audioEnabled: boolean;
  120794. /**
  120795. * Gets or sets if audio will be output to headphones
  120796. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120797. */
  120798. headphone: boolean;
  120799. /**
  120800. * Gets or sets custom audio listener position provider
  120801. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120802. */
  120803. audioListenerPositionProvider: Nullable<() => Vector3>;
  120804. /**
  120805. * Gets or sets a refresh rate when using 3D audio positioning
  120806. */
  120807. audioPositioningRefreshRate: number;
  120808. }
  120809. /**
  120810. * Defines the sound scene component responsible to manage any sounds
  120811. * in a given scene.
  120812. */
  120813. export class AudioSceneComponent implements ISceneSerializableComponent {
  120814. /**
  120815. * The component name helpfull to identify the component in the list of scene components.
  120816. */
  120817. readonly name: string;
  120818. /**
  120819. * The scene the component belongs to.
  120820. */
  120821. scene: Scene;
  120822. private _audioEnabled;
  120823. /**
  120824. * Gets whether audio is enabled or not.
  120825. * Please use related enable/disable method to switch state.
  120826. */
  120827. get audioEnabled(): boolean;
  120828. private _headphone;
  120829. /**
  120830. * Gets whether audio is outputing to headphone or not.
  120831. * Please use the according Switch methods to change output.
  120832. */
  120833. get headphone(): boolean;
  120834. /**
  120835. * Gets or sets a refresh rate when using 3D audio positioning
  120836. */
  120837. audioPositioningRefreshRate: number;
  120838. private _audioListenerPositionProvider;
  120839. /**
  120840. * Gets the current audio listener position provider
  120841. */
  120842. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  120843. /**
  120844. * Sets a custom listener position for all sounds in the scene
  120845. * By default, this is the position of the first active camera
  120846. */
  120847. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  120848. /**
  120849. * Creates a new instance of the component for the given scene
  120850. * @param scene Defines the scene to register the component in
  120851. */
  120852. constructor(scene: Scene);
  120853. /**
  120854. * Registers the component in a given scene
  120855. */
  120856. register(): void;
  120857. /**
  120858. * Rebuilds the elements related to this component in case of
  120859. * context lost for instance.
  120860. */
  120861. rebuild(): void;
  120862. /**
  120863. * Serializes the component data to the specified json object
  120864. * @param serializationObject The object to serialize to
  120865. */
  120866. serialize(serializationObject: any): void;
  120867. /**
  120868. * Adds all the elements from the container to the scene
  120869. * @param container the container holding the elements
  120870. */
  120871. addFromContainer(container: AbstractScene): void;
  120872. /**
  120873. * Removes all the elements in the container from the scene
  120874. * @param container contains the elements to remove
  120875. * @param dispose if the removed element should be disposed (default: false)
  120876. */
  120877. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120878. /**
  120879. * Disposes the component and the associated ressources.
  120880. */
  120881. dispose(): void;
  120882. /**
  120883. * Disables audio in the associated scene.
  120884. */
  120885. disableAudio(): void;
  120886. /**
  120887. * Enables audio in the associated scene.
  120888. */
  120889. enableAudio(): void;
  120890. /**
  120891. * Switch audio to headphone output.
  120892. */
  120893. switchAudioModeForHeadphones(): void;
  120894. /**
  120895. * Switch audio to normal speakers.
  120896. */
  120897. switchAudioModeForNormalSpeakers(): void;
  120898. private _cachedCameraDirection;
  120899. private _cachedCameraPosition;
  120900. private _lastCheck;
  120901. private _afterRender;
  120902. }
  120903. }
  120904. declare module BABYLON {
  120905. /**
  120906. * Wraps one or more Sound objects and selects one with random weight for playback.
  120907. */
  120908. export class WeightedSound {
  120909. /** When true a Sound will be selected and played when the current playing Sound completes. */
  120910. loop: boolean;
  120911. private _coneInnerAngle;
  120912. private _coneOuterAngle;
  120913. private _volume;
  120914. /** A Sound is currently playing. */
  120915. isPlaying: boolean;
  120916. /** A Sound is currently paused. */
  120917. isPaused: boolean;
  120918. private _sounds;
  120919. private _weights;
  120920. private _currentIndex?;
  120921. /**
  120922. * Creates a new WeightedSound from the list of sounds given.
  120923. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  120924. * @param sounds Array of Sounds that will be selected from.
  120925. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  120926. */
  120927. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  120928. /**
  120929. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  120930. */
  120931. get directionalConeInnerAngle(): number;
  120932. /**
  120933. * The size of cone in degress for a directional sound in which there will be no attenuation.
  120934. */
  120935. set directionalConeInnerAngle(value: number);
  120936. /**
  120937. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120938. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120939. */
  120940. get directionalConeOuterAngle(): number;
  120941. /**
  120942. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  120943. * Listener angles between innerAngle and outerAngle will falloff linearly.
  120944. */
  120945. set directionalConeOuterAngle(value: number);
  120946. /**
  120947. * Playback volume.
  120948. */
  120949. get volume(): number;
  120950. /**
  120951. * Playback volume.
  120952. */
  120953. set volume(value: number);
  120954. private _onended;
  120955. /**
  120956. * Suspend playback
  120957. */
  120958. pause(): void;
  120959. /**
  120960. * Stop playback
  120961. */
  120962. stop(): void;
  120963. /**
  120964. * Start playback.
  120965. * @param startOffset Position the clip head at a specific time in seconds.
  120966. */
  120967. play(startOffset?: number): void;
  120968. }
  120969. }
  120970. declare module BABYLON {
  120971. /**
  120972. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  120973. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120974. */
  120975. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  120976. /**
  120977. * Gets the name of the behavior.
  120978. */
  120979. get name(): string;
  120980. /**
  120981. * The easing function used by animations
  120982. */
  120983. static EasingFunction: BackEase;
  120984. /**
  120985. * The easing mode used by animations
  120986. */
  120987. static EasingMode: number;
  120988. /**
  120989. * The duration of the animation, in milliseconds
  120990. */
  120991. transitionDuration: number;
  120992. /**
  120993. * Length of the distance animated by the transition when lower radius is reached
  120994. */
  120995. lowerRadiusTransitionRange: number;
  120996. /**
  120997. * Length of the distance animated by the transition when upper radius is reached
  120998. */
  120999. upperRadiusTransitionRange: number;
  121000. private _autoTransitionRange;
  121001. /**
  121002. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121003. */
  121004. get autoTransitionRange(): boolean;
  121005. /**
  121006. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  121007. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  121008. */
  121009. set autoTransitionRange(value: boolean);
  121010. private _attachedCamera;
  121011. private _onAfterCheckInputsObserver;
  121012. private _onMeshTargetChangedObserver;
  121013. /**
  121014. * Initializes the behavior.
  121015. */
  121016. init(): void;
  121017. /**
  121018. * Attaches the behavior to its arc rotate camera.
  121019. * @param camera Defines the camera to attach the behavior to
  121020. */
  121021. attach(camera: ArcRotateCamera): void;
  121022. /**
  121023. * Detaches the behavior from its current arc rotate camera.
  121024. */
  121025. detach(): void;
  121026. private _radiusIsAnimating;
  121027. private _radiusBounceTransition;
  121028. private _animatables;
  121029. private _cachedWheelPrecision;
  121030. /**
  121031. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  121032. * @param radiusLimit The limit to check against.
  121033. * @return Bool to indicate if at limit.
  121034. */
  121035. private _isRadiusAtLimit;
  121036. /**
  121037. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  121038. * @param radiusDelta The delta by which to animate to. Can be negative.
  121039. */
  121040. private _applyBoundRadiusAnimation;
  121041. /**
  121042. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  121043. */
  121044. protected _clearAnimationLocks(): void;
  121045. /**
  121046. * Stops and removes all animations that have been applied to the camera
  121047. */
  121048. stopAllAnimations(): void;
  121049. }
  121050. }
  121051. declare module BABYLON {
  121052. /**
  121053. * 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.
  121054. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121055. */
  121056. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  121057. /**
  121058. * Gets the name of the behavior.
  121059. */
  121060. get name(): string;
  121061. private _mode;
  121062. private _radiusScale;
  121063. private _positionScale;
  121064. private _defaultElevation;
  121065. private _elevationReturnTime;
  121066. private _elevationReturnWaitTime;
  121067. private _zoomStopsAnimation;
  121068. private _framingTime;
  121069. /**
  121070. * The easing function used by animations
  121071. */
  121072. static EasingFunction: ExponentialEase;
  121073. /**
  121074. * The easing mode used by animations
  121075. */
  121076. static EasingMode: number;
  121077. /**
  121078. * Sets the current mode used by the behavior
  121079. */
  121080. set mode(mode: number);
  121081. /**
  121082. * Gets current mode used by the behavior.
  121083. */
  121084. get mode(): number;
  121085. /**
  121086. * Sets the scale applied to the radius (1 by default)
  121087. */
  121088. set radiusScale(radius: number);
  121089. /**
  121090. * Gets the scale applied to the radius
  121091. */
  121092. get radiusScale(): number;
  121093. /**
  121094. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121095. */
  121096. set positionScale(scale: number);
  121097. /**
  121098. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  121099. */
  121100. get positionScale(): number;
  121101. /**
  121102. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121103. * behaviour is triggered, in radians.
  121104. */
  121105. set defaultElevation(elevation: number);
  121106. /**
  121107. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  121108. * behaviour is triggered, in radians.
  121109. */
  121110. get defaultElevation(): number;
  121111. /**
  121112. * Sets the time (in milliseconds) taken to return to the default beta position.
  121113. * Negative value indicates camera should not return to default.
  121114. */
  121115. set elevationReturnTime(speed: number);
  121116. /**
  121117. * Gets the time (in milliseconds) taken to return to the default beta position.
  121118. * Negative value indicates camera should not return to default.
  121119. */
  121120. get elevationReturnTime(): number;
  121121. /**
  121122. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121123. */
  121124. set elevationReturnWaitTime(time: number);
  121125. /**
  121126. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  121127. */
  121128. get elevationReturnWaitTime(): number;
  121129. /**
  121130. * Sets the flag that indicates if user zooming should stop animation.
  121131. */
  121132. set zoomStopsAnimation(flag: boolean);
  121133. /**
  121134. * Gets the flag that indicates if user zooming should stop animation.
  121135. */
  121136. get zoomStopsAnimation(): boolean;
  121137. /**
  121138. * Sets the transition time when framing the mesh, in milliseconds
  121139. */
  121140. set framingTime(time: number);
  121141. /**
  121142. * Gets the transition time when framing the mesh, in milliseconds
  121143. */
  121144. get framingTime(): number;
  121145. /**
  121146. * Define if the behavior should automatically change the configured
  121147. * camera limits and sensibilities.
  121148. */
  121149. autoCorrectCameraLimitsAndSensibility: boolean;
  121150. private _onPrePointerObservableObserver;
  121151. private _onAfterCheckInputsObserver;
  121152. private _onMeshTargetChangedObserver;
  121153. private _attachedCamera;
  121154. private _isPointerDown;
  121155. private _lastInteractionTime;
  121156. /**
  121157. * Initializes the behavior.
  121158. */
  121159. init(): void;
  121160. /**
  121161. * Attaches the behavior to its arc rotate camera.
  121162. * @param camera Defines the camera to attach the behavior to
  121163. */
  121164. attach(camera: ArcRotateCamera): void;
  121165. /**
  121166. * Detaches the behavior from its current arc rotate camera.
  121167. */
  121168. detach(): void;
  121169. private _animatables;
  121170. private _betaIsAnimating;
  121171. private _betaTransition;
  121172. private _radiusTransition;
  121173. private _vectorTransition;
  121174. /**
  121175. * Targets the given mesh and updates zoom level accordingly.
  121176. * @param mesh The mesh to target.
  121177. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121178. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121179. */
  121180. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121181. /**
  121182. * Targets the given mesh with its children and updates zoom level accordingly.
  121183. * @param mesh The mesh to target.
  121184. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121185. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121186. */
  121187. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121188. /**
  121189. * Targets the given meshes with their children and updates zoom level accordingly.
  121190. * @param meshes The mesh to target.
  121191. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121192. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121193. */
  121194. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121195. /**
  121196. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  121197. * @param minimumWorld Determines the smaller position of the bounding box extend
  121198. * @param maximumWorld Determines the bigger position of the bounding box extend
  121199. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  121200. * @param onAnimationEnd Callback triggered at the end of the framing animation
  121201. */
  121202. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  121203. /**
  121204. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  121205. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  121206. * frustum width.
  121207. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  121208. * to fully enclose the mesh in the viewing frustum.
  121209. */
  121210. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  121211. /**
  121212. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  121213. * is automatically returned to its default position (expected to be above ground plane).
  121214. */
  121215. private _maintainCameraAboveGround;
  121216. /**
  121217. * Returns the frustum slope based on the canvas ratio and camera FOV
  121218. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  121219. */
  121220. private _getFrustumSlope;
  121221. /**
  121222. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  121223. */
  121224. private _clearAnimationLocks;
  121225. /**
  121226. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  121227. */
  121228. private _applyUserInteraction;
  121229. /**
  121230. * Stops and removes all animations that have been applied to the camera
  121231. */
  121232. stopAllAnimations(): void;
  121233. /**
  121234. * Gets a value indicating if the user is moving the camera
  121235. */
  121236. get isUserIsMoving(): boolean;
  121237. /**
  121238. * The camera can move all the way towards the mesh.
  121239. */
  121240. static IgnoreBoundsSizeMode: number;
  121241. /**
  121242. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  121243. */
  121244. static FitFrustumSidesMode: number;
  121245. }
  121246. }
  121247. declare module BABYLON {
  121248. /**
  121249. * Base class for Camera Pointer Inputs.
  121250. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  121251. * for example usage.
  121252. */
  121253. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  121254. /**
  121255. * Defines the camera the input is attached to.
  121256. */
  121257. abstract camera: Camera;
  121258. /**
  121259. * Whether keyboard modifier keys are pressed at time of last mouse event.
  121260. */
  121261. protected _altKey: boolean;
  121262. protected _ctrlKey: boolean;
  121263. protected _metaKey: boolean;
  121264. protected _shiftKey: boolean;
  121265. /**
  121266. * Which mouse buttons were pressed at time of last mouse event.
  121267. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  121268. */
  121269. protected _buttonsPressed: number;
  121270. /**
  121271. * Defines the buttons associated with the input to handle camera move.
  121272. */
  121273. buttons: number[];
  121274. /**
  121275. * Attach the input controls to a specific dom element to get the input from.
  121276. * @param element Defines the element the controls should be listened from
  121277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121278. */
  121279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121280. /**
  121281. * Detach the current controls from the specified dom element.
  121282. * @param element Defines the element to stop listening the inputs from
  121283. */
  121284. detachControl(element: Nullable<HTMLElement>): void;
  121285. /**
  121286. * Gets the class name of the current input.
  121287. * @returns the class name
  121288. */
  121289. getClassName(): string;
  121290. /**
  121291. * Get the friendly name associated with the input class.
  121292. * @returns the input friendly name
  121293. */
  121294. getSimpleName(): string;
  121295. /**
  121296. * Called on pointer POINTERDOUBLETAP event.
  121297. * Override this method to provide functionality on POINTERDOUBLETAP event.
  121298. */
  121299. protected onDoubleTap(type: string): void;
  121300. /**
  121301. * Called on pointer POINTERMOVE event if only a single touch is active.
  121302. * Override this method to provide functionality.
  121303. */
  121304. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121305. /**
  121306. * Called on pointer POINTERMOVE event if multiple touches are active.
  121307. * Override this method to provide functionality.
  121308. */
  121309. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121310. /**
  121311. * Called on JS contextmenu event.
  121312. * Override this method to provide functionality.
  121313. */
  121314. protected onContextMenu(evt: PointerEvent): void;
  121315. /**
  121316. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121317. * press.
  121318. * Override this method to provide functionality.
  121319. */
  121320. protected onButtonDown(evt: PointerEvent): void;
  121321. /**
  121322. * Called each time a new POINTERUP event occurs. Ie, for each button
  121323. * release.
  121324. * Override this method to provide functionality.
  121325. */
  121326. protected onButtonUp(evt: PointerEvent): void;
  121327. /**
  121328. * Called when window becomes inactive.
  121329. * Override this method to provide functionality.
  121330. */
  121331. protected onLostFocus(): void;
  121332. private _pointerInput;
  121333. private _observer;
  121334. private _onLostFocus;
  121335. private pointA;
  121336. private pointB;
  121337. }
  121338. }
  121339. declare module BABYLON {
  121340. /**
  121341. * Manage the pointers inputs to control an arc rotate camera.
  121342. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121343. */
  121344. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  121345. /**
  121346. * Defines the camera the input is attached to.
  121347. */
  121348. camera: ArcRotateCamera;
  121349. /**
  121350. * Gets the class name of the current input.
  121351. * @returns the class name
  121352. */
  121353. getClassName(): string;
  121354. /**
  121355. * Defines the buttons associated with the input to handle camera move.
  121356. */
  121357. buttons: number[];
  121358. /**
  121359. * Defines the pointer angular sensibility along the X axis or how fast is
  121360. * the camera rotating.
  121361. */
  121362. angularSensibilityX: number;
  121363. /**
  121364. * Defines the pointer angular sensibility along the Y axis or how fast is
  121365. * the camera rotating.
  121366. */
  121367. angularSensibilityY: number;
  121368. /**
  121369. * Defines the pointer pinch precision or how fast is the camera zooming.
  121370. */
  121371. pinchPrecision: number;
  121372. /**
  121373. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121374. * from 0.
  121375. * It defines the percentage of current camera.radius to use as delta when
  121376. * pinch zoom is used.
  121377. */
  121378. pinchDeltaPercentage: number;
  121379. /**
  121380. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121381. * that any object in the plane at the camera's target point will scale
  121382. * perfectly with finger motion.
  121383. * Overrides pinchDeltaPercentage and pinchPrecision.
  121384. */
  121385. useNaturalPinchZoom: boolean;
  121386. /**
  121387. * Defines the pointer panning sensibility or how fast is the camera moving.
  121388. */
  121389. panningSensibility: number;
  121390. /**
  121391. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  121392. */
  121393. multiTouchPanning: boolean;
  121394. /**
  121395. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  121396. * zoom (pinch) through multitouch.
  121397. */
  121398. multiTouchPanAndZoom: boolean;
  121399. /**
  121400. * Revers pinch action direction.
  121401. */
  121402. pinchInwards: boolean;
  121403. private _isPanClick;
  121404. private _twoFingerActivityCount;
  121405. private _isPinching;
  121406. /**
  121407. * Called on pointer POINTERMOVE event if only a single touch is active.
  121408. */
  121409. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121410. /**
  121411. * Called on pointer POINTERDOUBLETAP event.
  121412. */
  121413. protected onDoubleTap(type: string): void;
  121414. /**
  121415. * Called on pointer POINTERMOVE event if multiple touches are active.
  121416. */
  121417. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121418. /**
  121419. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  121420. * press.
  121421. */
  121422. protected onButtonDown(evt: PointerEvent): void;
  121423. /**
  121424. * Called each time a new POINTERUP event occurs. Ie, for each button
  121425. * release.
  121426. */
  121427. protected onButtonUp(evt: PointerEvent): void;
  121428. /**
  121429. * Called when window becomes inactive.
  121430. */
  121431. protected onLostFocus(): void;
  121432. }
  121433. }
  121434. declare module BABYLON {
  121435. /**
  121436. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  121437. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121438. */
  121439. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  121440. /**
  121441. * Defines the camera the input is attached to.
  121442. */
  121443. camera: ArcRotateCamera;
  121444. /**
  121445. * Defines the list of key codes associated with the up action (increase alpha)
  121446. */
  121447. keysUp: number[];
  121448. /**
  121449. * Defines the list of key codes associated with the down action (decrease alpha)
  121450. */
  121451. keysDown: number[];
  121452. /**
  121453. * Defines the list of key codes associated with the left action (increase beta)
  121454. */
  121455. keysLeft: number[];
  121456. /**
  121457. * Defines the list of key codes associated with the right action (decrease beta)
  121458. */
  121459. keysRight: number[];
  121460. /**
  121461. * Defines the list of key codes associated with the reset action.
  121462. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  121463. */
  121464. keysReset: number[];
  121465. /**
  121466. * Defines the panning sensibility of the inputs.
  121467. * (How fast is the camera panning)
  121468. */
  121469. panningSensibility: number;
  121470. /**
  121471. * Defines the zooming sensibility of the inputs.
  121472. * (How fast is the camera zooming)
  121473. */
  121474. zoomingSensibility: number;
  121475. /**
  121476. * Defines whether maintaining the alt key down switch the movement mode from
  121477. * orientation to zoom.
  121478. */
  121479. useAltToZoom: boolean;
  121480. /**
  121481. * Rotation speed of the camera
  121482. */
  121483. angularSpeed: number;
  121484. private _keys;
  121485. private _ctrlPressed;
  121486. private _altPressed;
  121487. private _onCanvasBlurObserver;
  121488. private _onKeyboardObserver;
  121489. private _engine;
  121490. private _scene;
  121491. /**
  121492. * Attach the input controls to a specific dom element to get the input from.
  121493. * @param element Defines the element the controls should be listened from
  121494. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121495. */
  121496. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121497. /**
  121498. * Detach the current controls from the specified dom element.
  121499. * @param element Defines the element to stop listening the inputs from
  121500. */
  121501. detachControl(element: Nullable<HTMLElement>): void;
  121502. /**
  121503. * Update the current camera state depending on the inputs that have been used this frame.
  121504. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121505. */
  121506. checkInputs(): void;
  121507. /**
  121508. * Gets the class name of the current intput.
  121509. * @returns the class name
  121510. */
  121511. getClassName(): string;
  121512. /**
  121513. * Get the friendly name associated with the input class.
  121514. * @returns the input friendly name
  121515. */
  121516. getSimpleName(): string;
  121517. }
  121518. }
  121519. declare module BABYLON {
  121520. /**
  121521. * Manage the mouse wheel inputs to control an arc rotate camera.
  121522. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121523. */
  121524. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  121525. /**
  121526. * Defines the camera the input is attached to.
  121527. */
  121528. camera: ArcRotateCamera;
  121529. /**
  121530. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121531. */
  121532. wheelPrecision: number;
  121533. /**
  121534. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121535. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121536. */
  121537. wheelDeltaPercentage: number;
  121538. private _wheel;
  121539. private _observer;
  121540. private computeDeltaFromMouseWheelLegacyEvent;
  121541. /**
  121542. * Attach the input controls to a specific dom element to get the input from.
  121543. * @param element Defines the element the controls should be listened from
  121544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121545. */
  121546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121547. /**
  121548. * Detach the current controls from the specified dom element.
  121549. * @param element Defines the element to stop listening the inputs from
  121550. */
  121551. detachControl(element: Nullable<HTMLElement>): void;
  121552. /**
  121553. * Gets the class name of the current intput.
  121554. * @returns the class name
  121555. */
  121556. getClassName(): string;
  121557. /**
  121558. * Get the friendly name associated with the input class.
  121559. * @returns the input friendly name
  121560. */
  121561. getSimpleName(): string;
  121562. }
  121563. }
  121564. declare module BABYLON {
  121565. /**
  121566. * Default Inputs manager for the ArcRotateCamera.
  121567. * It groups all the default supported inputs for ease of use.
  121568. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121569. */
  121570. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  121571. /**
  121572. * Instantiates a new ArcRotateCameraInputsManager.
  121573. * @param camera Defines the camera the inputs belong to
  121574. */
  121575. constructor(camera: ArcRotateCamera);
  121576. /**
  121577. * Add mouse wheel input support to the input manager.
  121578. * @returns the current input manager
  121579. */
  121580. addMouseWheel(): ArcRotateCameraInputsManager;
  121581. /**
  121582. * Add pointers input support to the input manager.
  121583. * @returns the current input manager
  121584. */
  121585. addPointers(): ArcRotateCameraInputsManager;
  121586. /**
  121587. * Add keyboard input support to the input manager.
  121588. * @returns the current input manager
  121589. */
  121590. addKeyboard(): ArcRotateCameraInputsManager;
  121591. }
  121592. }
  121593. declare module BABYLON {
  121594. /**
  121595. * This represents an orbital type of camera.
  121596. *
  121597. * 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.
  121598. * 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.
  121599. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  121600. */
  121601. export class ArcRotateCamera extends TargetCamera {
  121602. /**
  121603. * Defines the rotation angle of the camera along the longitudinal axis.
  121604. */
  121605. alpha: number;
  121606. /**
  121607. * Defines the rotation angle of the camera along the latitudinal axis.
  121608. */
  121609. beta: number;
  121610. /**
  121611. * Defines the radius of the camera from it s target point.
  121612. */
  121613. radius: number;
  121614. protected _target: Vector3;
  121615. protected _targetHost: Nullable<AbstractMesh>;
  121616. /**
  121617. * Defines the target point of the camera.
  121618. * The camera looks towards it form the radius distance.
  121619. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  121620. */
  121621. get target(): Vector3;
  121622. set target(value: Vector3);
  121623. /**
  121624. * Define the current local position of the camera in the scene
  121625. */
  121626. get position(): Vector3;
  121627. set position(newPosition: Vector3);
  121628. protected _upVector: Vector3;
  121629. protected _upToYMatrix: Matrix;
  121630. protected _YToUpMatrix: Matrix;
  121631. /**
  121632. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  121633. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  121634. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  121635. */
  121636. set upVector(vec: Vector3);
  121637. get upVector(): Vector3;
  121638. /**
  121639. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  121640. */
  121641. setMatUp(): void;
  121642. /**
  121643. * Current inertia value on the longitudinal axis.
  121644. * The bigger this number the longer it will take for the camera to stop.
  121645. */
  121646. inertialAlphaOffset: number;
  121647. /**
  121648. * Current inertia value on the latitudinal axis.
  121649. * The bigger this number the longer it will take for the camera to stop.
  121650. */
  121651. inertialBetaOffset: number;
  121652. /**
  121653. * Current inertia value on the radius axis.
  121654. * The bigger this number the longer it will take for the camera to stop.
  121655. */
  121656. inertialRadiusOffset: number;
  121657. /**
  121658. * Minimum allowed angle on the longitudinal axis.
  121659. * This can help limiting how the Camera is able to move in the scene.
  121660. */
  121661. lowerAlphaLimit: Nullable<number>;
  121662. /**
  121663. * Maximum allowed angle on the longitudinal axis.
  121664. * This can help limiting how the Camera is able to move in the scene.
  121665. */
  121666. upperAlphaLimit: Nullable<number>;
  121667. /**
  121668. * Minimum allowed angle on the latitudinal axis.
  121669. * This can help limiting how the Camera is able to move in the scene.
  121670. */
  121671. lowerBetaLimit: number;
  121672. /**
  121673. * Maximum allowed angle on the latitudinal axis.
  121674. * This can help limiting how the Camera is able to move in the scene.
  121675. */
  121676. upperBetaLimit: number;
  121677. /**
  121678. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  121679. * This can help limiting how the Camera is able to move in the scene.
  121680. */
  121681. lowerRadiusLimit: Nullable<number>;
  121682. /**
  121683. * Maximum allowed distance of the camera to the target (The camera can not get further).
  121684. * This can help limiting how the Camera is able to move in the scene.
  121685. */
  121686. upperRadiusLimit: Nullable<number>;
  121687. /**
  121688. * Defines the current inertia value used during panning of the camera along the X axis.
  121689. */
  121690. inertialPanningX: number;
  121691. /**
  121692. * Defines the current inertia value used during panning of the camera along the Y axis.
  121693. */
  121694. inertialPanningY: number;
  121695. /**
  121696. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  121697. * Basically if your fingers moves away from more than this distance you will be considered
  121698. * in pinch mode.
  121699. */
  121700. pinchToPanMaxDistance: number;
  121701. /**
  121702. * Defines the maximum distance the camera can pan.
  121703. * This could help keeping the cammera always in your scene.
  121704. */
  121705. panningDistanceLimit: Nullable<number>;
  121706. /**
  121707. * Defines the target of the camera before paning.
  121708. */
  121709. panningOriginTarget: Vector3;
  121710. /**
  121711. * Defines the value of the inertia used during panning.
  121712. * 0 would mean stop inertia and one would mean no decelleration at all.
  121713. */
  121714. panningInertia: number;
  121715. /**
  121716. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  121717. */
  121718. get angularSensibilityX(): number;
  121719. set angularSensibilityX(value: number);
  121720. /**
  121721. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  121722. */
  121723. get angularSensibilityY(): number;
  121724. set angularSensibilityY(value: number);
  121725. /**
  121726. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  121727. */
  121728. get pinchPrecision(): number;
  121729. set pinchPrecision(value: number);
  121730. /**
  121731. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  121732. * It will be used instead of pinchDeltaPrecision if different from 0.
  121733. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121734. */
  121735. get pinchDeltaPercentage(): number;
  121736. set pinchDeltaPercentage(value: number);
  121737. /**
  121738. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  121739. * and pinch delta percentage.
  121740. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  121741. * that any object in the plane at the camera's target point will scale
  121742. * perfectly with finger motion.
  121743. */
  121744. get useNaturalPinchZoom(): boolean;
  121745. set useNaturalPinchZoom(value: boolean);
  121746. /**
  121747. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  121748. */
  121749. get panningSensibility(): number;
  121750. set panningSensibility(value: number);
  121751. /**
  121752. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  121753. */
  121754. get keysUp(): number[];
  121755. set keysUp(value: number[]);
  121756. /**
  121757. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  121758. */
  121759. get keysDown(): number[];
  121760. set keysDown(value: number[]);
  121761. /**
  121762. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  121763. */
  121764. get keysLeft(): number[];
  121765. set keysLeft(value: number[]);
  121766. /**
  121767. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  121768. */
  121769. get keysRight(): number[];
  121770. set keysRight(value: number[]);
  121771. /**
  121772. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  121773. */
  121774. get wheelPrecision(): number;
  121775. set wheelPrecision(value: number);
  121776. /**
  121777. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  121778. * It will be used instead of pinchDeltaPrecision if different from 0.
  121779. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  121780. */
  121781. get wheelDeltaPercentage(): number;
  121782. set wheelDeltaPercentage(value: number);
  121783. /**
  121784. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  121785. */
  121786. zoomOnFactor: number;
  121787. /**
  121788. * Defines a screen offset for the camera position.
  121789. */
  121790. targetScreenOffset: Vector2;
  121791. /**
  121792. * Allows the camera to be completely reversed.
  121793. * If false the camera can not arrive upside down.
  121794. */
  121795. allowUpsideDown: boolean;
  121796. /**
  121797. * Define if double tap/click is used to restore the previously saved state of the camera.
  121798. */
  121799. useInputToRestoreState: boolean;
  121800. /** @hidden */
  121801. _viewMatrix: Matrix;
  121802. /** @hidden */
  121803. _useCtrlForPanning: boolean;
  121804. /** @hidden */
  121805. _panningMouseButton: number;
  121806. /**
  121807. * Defines the input associated to the camera.
  121808. */
  121809. inputs: ArcRotateCameraInputsManager;
  121810. /** @hidden */
  121811. _reset: () => void;
  121812. /**
  121813. * Defines the allowed panning axis.
  121814. */
  121815. panningAxis: Vector3;
  121816. protected _localDirection: Vector3;
  121817. protected _transformedDirection: Vector3;
  121818. private _bouncingBehavior;
  121819. /**
  121820. * Gets the bouncing behavior of the camera if it has been enabled.
  121821. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121822. */
  121823. get bouncingBehavior(): Nullable<BouncingBehavior>;
  121824. /**
  121825. * Defines if the bouncing behavior of the camera is enabled on the camera.
  121826. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  121827. */
  121828. get useBouncingBehavior(): boolean;
  121829. set useBouncingBehavior(value: boolean);
  121830. private _framingBehavior;
  121831. /**
  121832. * Gets the framing behavior of the camera if it has been enabled.
  121833. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121834. */
  121835. get framingBehavior(): Nullable<FramingBehavior>;
  121836. /**
  121837. * Defines if the framing behavior of the camera is enabled on the camera.
  121838. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  121839. */
  121840. get useFramingBehavior(): boolean;
  121841. set useFramingBehavior(value: boolean);
  121842. private _autoRotationBehavior;
  121843. /**
  121844. * Gets the auto rotation behavior of the camera if it has been enabled.
  121845. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121846. */
  121847. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  121848. /**
  121849. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  121850. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121851. */
  121852. get useAutoRotationBehavior(): boolean;
  121853. set useAutoRotationBehavior(value: boolean);
  121854. /**
  121855. * Observable triggered when the mesh target has been changed on the camera.
  121856. */
  121857. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  121858. /**
  121859. * Event raised when the camera is colliding with a mesh.
  121860. */
  121861. onCollide: (collidedMesh: AbstractMesh) => void;
  121862. /**
  121863. * Defines whether the camera should check collision with the objects oh the scene.
  121864. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  121865. */
  121866. checkCollisions: boolean;
  121867. /**
  121868. * Defines the collision radius of the camera.
  121869. * This simulates a sphere around the camera.
  121870. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121871. */
  121872. collisionRadius: Vector3;
  121873. protected _collider: Collider;
  121874. protected _previousPosition: Vector3;
  121875. protected _collisionVelocity: Vector3;
  121876. protected _newPosition: Vector3;
  121877. protected _previousAlpha: number;
  121878. protected _previousBeta: number;
  121879. protected _previousRadius: number;
  121880. protected _collisionTriggered: boolean;
  121881. protected _targetBoundingCenter: Nullable<Vector3>;
  121882. private _computationVector;
  121883. /**
  121884. * Instantiates a new ArcRotateCamera in a given scene
  121885. * @param name Defines the name of the camera
  121886. * @param alpha Defines the camera rotation along the logitudinal axis
  121887. * @param beta Defines the camera rotation along the latitudinal axis
  121888. * @param radius Defines the camera distance from its target
  121889. * @param target Defines the camera target
  121890. * @param scene Defines the scene the camera belongs to
  121891. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  121892. */
  121893. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121894. /** @hidden */
  121895. _initCache(): void;
  121896. /** @hidden */
  121897. _updateCache(ignoreParentClass?: boolean): void;
  121898. protected _getTargetPosition(): Vector3;
  121899. private _storedAlpha;
  121900. private _storedBeta;
  121901. private _storedRadius;
  121902. private _storedTarget;
  121903. private _storedTargetScreenOffset;
  121904. /**
  121905. * Stores the current state of the camera (alpha, beta, radius and target)
  121906. * @returns the camera itself
  121907. */
  121908. storeState(): Camera;
  121909. /**
  121910. * @hidden
  121911. * Restored camera state. You must call storeState() first
  121912. */
  121913. _restoreStateValues(): boolean;
  121914. /** @hidden */
  121915. _isSynchronizedViewMatrix(): boolean;
  121916. /**
  121917. * Attached controls to the current camera.
  121918. * @param element Defines the element the controls should be listened from
  121919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121920. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  121921. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  121922. */
  121923. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  121924. /**
  121925. * Detach the current controls from the camera.
  121926. * The camera will stop reacting to inputs.
  121927. * @param element Defines the element to stop listening the inputs from
  121928. */
  121929. detachControl(element: HTMLElement): void;
  121930. /** @hidden */
  121931. _checkInputs(): void;
  121932. protected _checkLimits(): void;
  121933. /**
  121934. * Rebuilds angles (alpha, beta) and radius from the give position and target
  121935. */
  121936. rebuildAnglesAndRadius(): void;
  121937. /**
  121938. * Use a position to define the current camera related information like alpha, beta and radius
  121939. * @param position Defines the position to set the camera at
  121940. */
  121941. setPosition(position: Vector3): void;
  121942. /**
  121943. * Defines the target the camera should look at.
  121944. * This will automatically adapt alpha beta and radius to fit within the new target.
  121945. * @param target Defines the new target as a Vector or a mesh
  121946. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  121947. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  121948. */
  121949. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  121950. /** @hidden */
  121951. _getViewMatrix(): Matrix;
  121952. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  121953. /**
  121954. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  121955. * @param meshes Defines the mesh to zoom on
  121956. * @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)
  121957. */
  121958. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  121959. /**
  121960. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  121961. * The target will be changed but the radius
  121962. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  121963. * @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)
  121964. */
  121965. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  121966. min: Vector3;
  121967. max: Vector3;
  121968. distance: number;
  121969. }, doNotUpdateMaxZ?: boolean): void;
  121970. /**
  121971. * @override
  121972. * Override Camera.createRigCamera
  121973. */
  121974. createRigCamera(name: string, cameraIndex: number): Camera;
  121975. /**
  121976. * @hidden
  121977. * @override
  121978. * Override Camera._updateRigCameras
  121979. */
  121980. _updateRigCameras(): void;
  121981. /**
  121982. * Destroy the camera and release the current resources hold by it.
  121983. */
  121984. dispose(): void;
  121985. /**
  121986. * Gets the current object class name.
  121987. * @return the class name
  121988. */
  121989. getClassName(): string;
  121990. }
  121991. }
  121992. declare module BABYLON {
  121993. /**
  121994. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  121995. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  121996. */
  121997. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  121998. /**
  121999. * Gets the name of the behavior.
  122000. */
  122001. get name(): string;
  122002. private _zoomStopsAnimation;
  122003. private _idleRotationSpeed;
  122004. private _idleRotationWaitTime;
  122005. private _idleRotationSpinupTime;
  122006. /**
  122007. * Sets the flag that indicates if user zooming should stop animation.
  122008. */
  122009. set zoomStopsAnimation(flag: boolean);
  122010. /**
  122011. * Gets the flag that indicates if user zooming should stop animation.
  122012. */
  122013. get zoomStopsAnimation(): boolean;
  122014. /**
  122015. * Sets the default speed at which the camera rotates around the model.
  122016. */
  122017. set idleRotationSpeed(speed: number);
  122018. /**
  122019. * Gets the default speed at which the camera rotates around the model.
  122020. */
  122021. get idleRotationSpeed(): number;
  122022. /**
  122023. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  122024. */
  122025. set idleRotationWaitTime(time: number);
  122026. /**
  122027. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  122028. */
  122029. get idleRotationWaitTime(): number;
  122030. /**
  122031. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122032. */
  122033. set idleRotationSpinupTime(time: number);
  122034. /**
  122035. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  122036. */
  122037. get idleRotationSpinupTime(): number;
  122038. /**
  122039. * Gets a value indicating if the camera is currently rotating because of this behavior
  122040. */
  122041. get rotationInProgress(): boolean;
  122042. private _onPrePointerObservableObserver;
  122043. private _onAfterCheckInputsObserver;
  122044. private _attachedCamera;
  122045. private _isPointerDown;
  122046. private _lastFrameTime;
  122047. private _lastInteractionTime;
  122048. private _cameraRotationSpeed;
  122049. /**
  122050. * Initializes the behavior.
  122051. */
  122052. init(): void;
  122053. /**
  122054. * Attaches the behavior to its arc rotate camera.
  122055. * @param camera Defines the camera to attach the behavior to
  122056. */
  122057. attach(camera: ArcRotateCamera): void;
  122058. /**
  122059. * Detaches the behavior from its current arc rotate camera.
  122060. */
  122061. detach(): void;
  122062. /**
  122063. * Returns true if user is scrolling.
  122064. * @return true if user is scrolling.
  122065. */
  122066. private _userIsZooming;
  122067. private _lastFrameRadius;
  122068. private _shouldAnimationStopForInteraction;
  122069. /**
  122070. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122071. */
  122072. private _applyUserInteraction;
  122073. private _userIsMoving;
  122074. }
  122075. }
  122076. declare module BABYLON {
  122077. /**
  122078. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  122079. */
  122080. export class AttachToBoxBehavior implements Behavior<Mesh> {
  122081. private ui;
  122082. /**
  122083. * The name of the behavior
  122084. */
  122085. name: string;
  122086. /**
  122087. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  122088. */
  122089. distanceAwayFromFace: number;
  122090. /**
  122091. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  122092. */
  122093. distanceAwayFromBottomOfFace: number;
  122094. private _faceVectors;
  122095. private _target;
  122096. private _scene;
  122097. private _onRenderObserver;
  122098. private _tmpMatrix;
  122099. private _tmpVector;
  122100. /**
  122101. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  122102. * @param ui The transform node that should be attched to the mesh
  122103. */
  122104. constructor(ui: TransformNode);
  122105. /**
  122106. * Initializes the behavior
  122107. */
  122108. init(): void;
  122109. private _closestFace;
  122110. private _zeroVector;
  122111. private _lookAtTmpMatrix;
  122112. private _lookAtToRef;
  122113. /**
  122114. * Attaches the AttachToBoxBehavior to the passed in mesh
  122115. * @param target The mesh that the specified node will be attached to
  122116. */
  122117. attach(target: Mesh): void;
  122118. /**
  122119. * Detaches the behavior from the mesh
  122120. */
  122121. detach(): void;
  122122. }
  122123. }
  122124. declare module BABYLON {
  122125. /**
  122126. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  122127. */
  122128. export class FadeInOutBehavior implements Behavior<Mesh> {
  122129. /**
  122130. * Time in milliseconds to delay before fading in (Default: 0)
  122131. */
  122132. delay: number;
  122133. /**
  122134. * Time in milliseconds for the mesh to fade in (Default: 300)
  122135. */
  122136. fadeInTime: number;
  122137. private _millisecondsPerFrame;
  122138. private _hovered;
  122139. private _hoverValue;
  122140. private _ownerNode;
  122141. /**
  122142. * Instatiates the FadeInOutBehavior
  122143. */
  122144. constructor();
  122145. /**
  122146. * The name of the behavior
  122147. */
  122148. get name(): string;
  122149. /**
  122150. * Initializes the behavior
  122151. */
  122152. init(): void;
  122153. /**
  122154. * Attaches the fade behavior on the passed in mesh
  122155. * @param ownerNode The mesh that will be faded in/out once attached
  122156. */
  122157. attach(ownerNode: Mesh): void;
  122158. /**
  122159. * Detaches the behavior from the mesh
  122160. */
  122161. detach(): void;
  122162. /**
  122163. * Triggers the mesh to begin fading in or out
  122164. * @param value if the object should fade in or out (true to fade in)
  122165. */
  122166. fadeIn(value: boolean): void;
  122167. private _update;
  122168. private _setAllVisibility;
  122169. }
  122170. }
  122171. declare module BABYLON {
  122172. /**
  122173. * Class containing a set of static utilities functions for managing Pivots
  122174. * @hidden
  122175. */
  122176. export class PivotTools {
  122177. private static _PivotCached;
  122178. private static _OldPivotPoint;
  122179. private static _PivotTranslation;
  122180. private static _PivotTmpVector;
  122181. /** @hidden */
  122182. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  122183. /** @hidden */
  122184. static _RestorePivotPoint(mesh: AbstractMesh): void;
  122185. }
  122186. }
  122187. declare module BABYLON {
  122188. /**
  122189. * Class containing static functions to help procedurally build meshes
  122190. */
  122191. export class PlaneBuilder {
  122192. /**
  122193. * Creates a plane mesh
  122194. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  122195. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  122196. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  122197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122200. * @param name defines the name of the mesh
  122201. * @param options defines the options used to create the mesh
  122202. * @param scene defines the hosting scene
  122203. * @returns the plane mesh
  122204. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  122205. */
  122206. static CreatePlane(name: string, options: {
  122207. size?: number;
  122208. width?: number;
  122209. height?: number;
  122210. sideOrientation?: number;
  122211. frontUVs?: Vector4;
  122212. backUVs?: Vector4;
  122213. updatable?: boolean;
  122214. sourcePlane?: Plane;
  122215. }, scene?: Nullable<Scene>): Mesh;
  122216. }
  122217. }
  122218. declare module BABYLON {
  122219. /**
  122220. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  122221. */
  122222. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  122223. private static _AnyMouseID;
  122224. /**
  122225. * Abstract mesh the behavior is set on
  122226. */
  122227. attachedNode: AbstractMesh;
  122228. private _dragPlane;
  122229. private _scene;
  122230. private _pointerObserver;
  122231. private _beforeRenderObserver;
  122232. private static _planeScene;
  122233. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  122234. /**
  122235. * 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)
  122236. */
  122237. maxDragAngle: number;
  122238. /**
  122239. * @hidden
  122240. */
  122241. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  122242. /**
  122243. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122244. */
  122245. currentDraggingPointerID: number;
  122246. /**
  122247. * The last position where the pointer hit the drag plane in world space
  122248. */
  122249. lastDragPosition: Vector3;
  122250. /**
  122251. * If the behavior is currently in a dragging state
  122252. */
  122253. dragging: boolean;
  122254. /**
  122255. * 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)
  122256. */
  122257. dragDeltaRatio: number;
  122258. /**
  122259. * If the drag plane orientation should be updated during the dragging (Default: true)
  122260. */
  122261. updateDragPlane: boolean;
  122262. private _debugMode;
  122263. private _moving;
  122264. /**
  122265. * Fires each time the attached mesh is dragged with the pointer
  122266. * * delta between last drag position and current drag position in world space
  122267. * * dragDistance along the drag axis
  122268. * * dragPlaneNormal normal of the current drag plane used during the drag
  122269. * * dragPlanePoint in world space where the drag intersects the drag plane
  122270. */
  122271. onDragObservable: Observable<{
  122272. delta: Vector3;
  122273. dragPlanePoint: Vector3;
  122274. dragPlaneNormal: Vector3;
  122275. dragDistance: number;
  122276. pointerId: number;
  122277. }>;
  122278. /**
  122279. * Fires each time a drag begins (eg. mouse down on mesh)
  122280. */
  122281. onDragStartObservable: Observable<{
  122282. dragPlanePoint: Vector3;
  122283. pointerId: number;
  122284. }>;
  122285. /**
  122286. * Fires each time a drag ends (eg. mouse release after drag)
  122287. */
  122288. onDragEndObservable: Observable<{
  122289. dragPlanePoint: Vector3;
  122290. pointerId: number;
  122291. }>;
  122292. /**
  122293. * If the attached mesh should be moved when dragged
  122294. */
  122295. moveAttached: boolean;
  122296. /**
  122297. * If the drag behavior will react to drag events (Default: true)
  122298. */
  122299. enabled: boolean;
  122300. /**
  122301. * If pointer events should start and release the drag (Default: true)
  122302. */
  122303. startAndReleaseDragOnPointerEvents: boolean;
  122304. /**
  122305. * If camera controls should be detached during the drag
  122306. */
  122307. detachCameraControls: boolean;
  122308. /**
  122309. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  122310. */
  122311. useObjectOrientationForDragging: boolean;
  122312. private _options;
  122313. /**
  122314. * Gets the options used by the behavior
  122315. */
  122316. get options(): {
  122317. dragAxis?: Vector3;
  122318. dragPlaneNormal?: Vector3;
  122319. };
  122320. /**
  122321. * Sets the options used by the behavior
  122322. */
  122323. set options(options: {
  122324. dragAxis?: Vector3;
  122325. dragPlaneNormal?: Vector3;
  122326. });
  122327. /**
  122328. * Creates a pointer drag behavior that can be attached to a mesh
  122329. * @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)
  122330. */
  122331. constructor(options?: {
  122332. dragAxis?: Vector3;
  122333. dragPlaneNormal?: Vector3;
  122334. });
  122335. /**
  122336. * Predicate to determine if it is valid to move the object to a new position when it is moved
  122337. */
  122338. validateDrag: (targetPosition: Vector3) => boolean;
  122339. /**
  122340. * The name of the behavior
  122341. */
  122342. get name(): string;
  122343. /**
  122344. * Initializes the behavior
  122345. */
  122346. init(): void;
  122347. private _tmpVector;
  122348. private _alternatePickedPoint;
  122349. private _worldDragAxis;
  122350. private _targetPosition;
  122351. private _attachedElement;
  122352. /**
  122353. * Attaches the drag behavior the passed in mesh
  122354. * @param ownerNode The mesh that will be dragged around once attached
  122355. * @param predicate Predicate to use for pick filtering
  122356. */
  122357. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  122358. /**
  122359. * Force relase the drag action by code.
  122360. */
  122361. releaseDrag(): void;
  122362. private _startDragRay;
  122363. private _lastPointerRay;
  122364. /**
  122365. * Simulates the start of a pointer drag event on the behavior
  122366. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  122367. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  122368. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  122369. */
  122370. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  122371. private _startDrag;
  122372. private _dragDelta;
  122373. private _moveDrag;
  122374. private _pickWithRayOnDragPlane;
  122375. private _pointA;
  122376. private _pointC;
  122377. private _localAxis;
  122378. private _lookAt;
  122379. private _updateDragPlanePosition;
  122380. /**
  122381. * Detaches the behavior from the mesh
  122382. */
  122383. detach(): void;
  122384. }
  122385. }
  122386. declare module BABYLON {
  122387. /**
  122388. * A behavior that when attached to a mesh will allow the mesh to be scaled
  122389. */
  122390. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  122391. private _dragBehaviorA;
  122392. private _dragBehaviorB;
  122393. private _startDistance;
  122394. private _initialScale;
  122395. private _targetScale;
  122396. private _ownerNode;
  122397. private _sceneRenderObserver;
  122398. /**
  122399. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  122400. */
  122401. constructor();
  122402. /**
  122403. * The name of the behavior
  122404. */
  122405. get name(): string;
  122406. /**
  122407. * Initializes the behavior
  122408. */
  122409. init(): void;
  122410. private _getCurrentDistance;
  122411. /**
  122412. * Attaches the scale behavior the passed in mesh
  122413. * @param ownerNode The mesh that will be scaled around once attached
  122414. */
  122415. attach(ownerNode: Mesh): void;
  122416. /**
  122417. * Detaches the behavior from the mesh
  122418. */
  122419. detach(): void;
  122420. }
  122421. }
  122422. declare module BABYLON {
  122423. /**
  122424. * 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
  122425. */
  122426. export class SixDofDragBehavior implements Behavior<Mesh> {
  122427. private static _virtualScene;
  122428. private _ownerNode;
  122429. private _sceneRenderObserver;
  122430. private _scene;
  122431. private _targetPosition;
  122432. private _virtualOriginMesh;
  122433. private _virtualDragMesh;
  122434. private _pointerObserver;
  122435. private _moving;
  122436. private _startingOrientation;
  122437. private _attachedElement;
  122438. /**
  122439. * 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)
  122440. */
  122441. private zDragFactor;
  122442. /**
  122443. * If the object should rotate to face the drag origin
  122444. */
  122445. rotateDraggedObject: boolean;
  122446. /**
  122447. * If the behavior is currently in a dragging state
  122448. */
  122449. dragging: boolean;
  122450. /**
  122451. * 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)
  122452. */
  122453. dragDeltaRatio: number;
  122454. /**
  122455. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  122456. */
  122457. currentDraggingPointerID: number;
  122458. /**
  122459. * If camera controls should be detached during the drag
  122460. */
  122461. detachCameraControls: boolean;
  122462. /**
  122463. * Fires each time a drag starts
  122464. */
  122465. onDragStartObservable: Observable<{}>;
  122466. /**
  122467. * Fires each time a drag ends (eg. mouse release after drag)
  122468. */
  122469. onDragEndObservable: Observable<{}>;
  122470. /**
  122471. * 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
  122472. */
  122473. constructor();
  122474. /**
  122475. * The name of the behavior
  122476. */
  122477. get name(): string;
  122478. /**
  122479. * Initializes the behavior
  122480. */
  122481. init(): void;
  122482. /**
  122483. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  122484. */
  122485. private get _pointerCamera();
  122486. /**
  122487. * Attaches the scale behavior the passed in mesh
  122488. * @param ownerNode The mesh that will be scaled around once attached
  122489. */
  122490. attach(ownerNode: Mesh): void;
  122491. /**
  122492. * Detaches the behavior from the mesh
  122493. */
  122494. detach(): void;
  122495. }
  122496. }
  122497. declare module BABYLON {
  122498. /**
  122499. * Class used to apply inverse kinematics to bones
  122500. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  122501. */
  122502. export class BoneIKController {
  122503. private static _tmpVecs;
  122504. private static _tmpQuat;
  122505. private static _tmpMats;
  122506. /**
  122507. * Gets or sets the target mesh
  122508. */
  122509. targetMesh: AbstractMesh;
  122510. /** Gets or sets the mesh used as pole */
  122511. poleTargetMesh: AbstractMesh;
  122512. /**
  122513. * Gets or sets the bone used as pole
  122514. */
  122515. poleTargetBone: Nullable<Bone>;
  122516. /**
  122517. * Gets or sets the target position
  122518. */
  122519. targetPosition: Vector3;
  122520. /**
  122521. * Gets or sets the pole target position
  122522. */
  122523. poleTargetPosition: Vector3;
  122524. /**
  122525. * Gets or sets the pole target local offset
  122526. */
  122527. poleTargetLocalOffset: Vector3;
  122528. /**
  122529. * Gets or sets the pole angle
  122530. */
  122531. poleAngle: number;
  122532. /**
  122533. * Gets or sets the mesh associated with the controller
  122534. */
  122535. mesh: AbstractMesh;
  122536. /**
  122537. * 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)
  122538. */
  122539. slerpAmount: number;
  122540. private _bone1Quat;
  122541. private _bone1Mat;
  122542. private _bone2Ang;
  122543. private _bone1;
  122544. private _bone2;
  122545. private _bone1Length;
  122546. private _bone2Length;
  122547. private _maxAngle;
  122548. private _maxReach;
  122549. private _rightHandedSystem;
  122550. private _bendAxis;
  122551. private _slerping;
  122552. private _adjustRoll;
  122553. /**
  122554. * Gets or sets maximum allowed angle
  122555. */
  122556. get maxAngle(): number;
  122557. set maxAngle(value: number);
  122558. /**
  122559. * Creates a new BoneIKController
  122560. * @param mesh defines the mesh to control
  122561. * @param bone defines the bone to control
  122562. * @param options defines options to set up the controller
  122563. */
  122564. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  122565. targetMesh?: AbstractMesh;
  122566. poleTargetMesh?: AbstractMesh;
  122567. poleTargetBone?: Bone;
  122568. poleTargetLocalOffset?: Vector3;
  122569. poleAngle?: number;
  122570. bendAxis?: Vector3;
  122571. maxAngle?: number;
  122572. slerpAmount?: number;
  122573. });
  122574. private _setMaxAngle;
  122575. /**
  122576. * Force the controller to update the bones
  122577. */
  122578. update(): void;
  122579. }
  122580. }
  122581. declare module BABYLON {
  122582. /**
  122583. * Class used to make a bone look toward a point in space
  122584. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  122585. */
  122586. export class BoneLookController {
  122587. private static _tmpVecs;
  122588. private static _tmpQuat;
  122589. private static _tmpMats;
  122590. /**
  122591. * The target Vector3 that the bone will look at
  122592. */
  122593. target: Vector3;
  122594. /**
  122595. * The mesh that the bone is attached to
  122596. */
  122597. mesh: AbstractMesh;
  122598. /**
  122599. * The bone that will be looking to the target
  122600. */
  122601. bone: Bone;
  122602. /**
  122603. * The up axis of the coordinate system that is used when the bone is rotated
  122604. */
  122605. upAxis: Vector3;
  122606. /**
  122607. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  122608. */
  122609. upAxisSpace: Space;
  122610. /**
  122611. * Used to make an adjustment to the yaw of the bone
  122612. */
  122613. adjustYaw: number;
  122614. /**
  122615. * Used to make an adjustment to the pitch of the bone
  122616. */
  122617. adjustPitch: number;
  122618. /**
  122619. * Used to make an adjustment to the roll of the bone
  122620. */
  122621. adjustRoll: number;
  122622. /**
  122623. * 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)
  122624. */
  122625. slerpAmount: number;
  122626. private _minYaw;
  122627. private _maxYaw;
  122628. private _minPitch;
  122629. private _maxPitch;
  122630. private _minYawSin;
  122631. private _minYawCos;
  122632. private _maxYawSin;
  122633. private _maxYawCos;
  122634. private _midYawConstraint;
  122635. private _minPitchTan;
  122636. private _maxPitchTan;
  122637. private _boneQuat;
  122638. private _slerping;
  122639. private _transformYawPitch;
  122640. private _transformYawPitchInv;
  122641. private _firstFrameSkipped;
  122642. private _yawRange;
  122643. private _fowardAxis;
  122644. /**
  122645. * Gets or sets the minimum yaw angle that the bone can look to
  122646. */
  122647. get minYaw(): number;
  122648. set minYaw(value: number);
  122649. /**
  122650. * Gets or sets the maximum yaw angle that the bone can look to
  122651. */
  122652. get maxYaw(): number;
  122653. set maxYaw(value: number);
  122654. /**
  122655. * Gets or sets the minimum pitch angle that the bone can look to
  122656. */
  122657. get minPitch(): number;
  122658. set minPitch(value: number);
  122659. /**
  122660. * Gets or sets the maximum pitch angle that the bone can look to
  122661. */
  122662. get maxPitch(): number;
  122663. set maxPitch(value: number);
  122664. /**
  122665. * Create a BoneLookController
  122666. * @param mesh the mesh that the bone belongs to
  122667. * @param bone the bone that will be looking to the target
  122668. * @param target the target Vector3 to look at
  122669. * @param options optional settings:
  122670. * * maxYaw: the maximum angle the bone will yaw to
  122671. * * minYaw: the minimum angle the bone will yaw to
  122672. * * maxPitch: the maximum angle the bone will pitch to
  122673. * * minPitch: the minimum angle the bone will yaw to
  122674. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  122675. * * upAxis: the up axis of the coordinate system
  122676. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  122677. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  122678. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  122679. * * adjustYaw: used to make an adjustment to the yaw of the bone
  122680. * * adjustPitch: used to make an adjustment to the pitch of the bone
  122681. * * adjustRoll: used to make an adjustment to the roll of the bone
  122682. **/
  122683. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  122684. maxYaw?: number;
  122685. minYaw?: number;
  122686. maxPitch?: number;
  122687. minPitch?: number;
  122688. slerpAmount?: number;
  122689. upAxis?: Vector3;
  122690. upAxisSpace?: Space;
  122691. yawAxis?: Vector3;
  122692. pitchAxis?: Vector3;
  122693. adjustYaw?: number;
  122694. adjustPitch?: number;
  122695. adjustRoll?: number;
  122696. });
  122697. /**
  122698. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  122699. */
  122700. update(): void;
  122701. private _getAngleDiff;
  122702. private _getAngleBetween;
  122703. private _isAngleBetween;
  122704. }
  122705. }
  122706. declare module BABYLON {
  122707. /**
  122708. * Manage the gamepad inputs to control an arc rotate camera.
  122709. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122710. */
  122711. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  122712. /**
  122713. * Defines the camera the input is attached to.
  122714. */
  122715. camera: ArcRotateCamera;
  122716. /**
  122717. * Defines the gamepad the input is gathering event from.
  122718. */
  122719. gamepad: Nullable<Gamepad>;
  122720. /**
  122721. * Defines the gamepad rotation sensiblity.
  122722. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122723. */
  122724. gamepadRotationSensibility: number;
  122725. /**
  122726. * Defines the gamepad move sensiblity.
  122727. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122728. */
  122729. gamepadMoveSensibility: number;
  122730. private _yAxisScale;
  122731. /**
  122732. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122733. */
  122734. get invertYAxis(): boolean;
  122735. set invertYAxis(value: boolean);
  122736. private _onGamepadConnectedObserver;
  122737. private _onGamepadDisconnectedObserver;
  122738. /**
  122739. * Attach the input controls to a specific dom element to get the input from.
  122740. * @param element Defines the element the controls should be listened from
  122741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122742. */
  122743. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122744. /**
  122745. * Detach the current controls from the specified dom element.
  122746. * @param element Defines the element to stop listening the inputs from
  122747. */
  122748. detachControl(element: Nullable<HTMLElement>): void;
  122749. /**
  122750. * Update the current camera state depending on the inputs that have been used this frame.
  122751. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122752. */
  122753. checkInputs(): void;
  122754. /**
  122755. * Gets the class name of the current intput.
  122756. * @returns the class name
  122757. */
  122758. getClassName(): string;
  122759. /**
  122760. * Get the friendly name associated with the input class.
  122761. * @returns the input friendly name
  122762. */
  122763. getSimpleName(): string;
  122764. }
  122765. }
  122766. declare module BABYLON {
  122767. interface ArcRotateCameraInputsManager {
  122768. /**
  122769. * Add orientation input support to the input manager.
  122770. * @returns the current input manager
  122771. */
  122772. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  122773. }
  122774. /**
  122775. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  122776. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122777. */
  122778. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  122779. /**
  122780. * Defines the camera the input is attached to.
  122781. */
  122782. camera: ArcRotateCamera;
  122783. /**
  122784. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  122785. */
  122786. alphaCorrection: number;
  122787. /**
  122788. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  122789. */
  122790. gammaCorrection: number;
  122791. private _alpha;
  122792. private _gamma;
  122793. private _dirty;
  122794. private _deviceOrientationHandler;
  122795. /**
  122796. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  122797. */
  122798. constructor();
  122799. /**
  122800. * Attach the input controls to a specific dom element to get the input from.
  122801. * @param element Defines the element the controls should be listened from
  122802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122803. */
  122804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122805. /** @hidden */
  122806. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  122807. /**
  122808. * Update the current camera state depending on the inputs that have been used this frame.
  122809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122810. */
  122811. checkInputs(): void;
  122812. /**
  122813. * Detach the current controls from the specified dom element.
  122814. * @param element Defines the element to stop listening the inputs from
  122815. */
  122816. detachControl(element: Nullable<HTMLElement>): void;
  122817. /**
  122818. * Gets the class name of the current intput.
  122819. * @returns the class name
  122820. */
  122821. getClassName(): string;
  122822. /**
  122823. * Get the friendly name associated with the input class.
  122824. * @returns the input friendly name
  122825. */
  122826. getSimpleName(): string;
  122827. }
  122828. }
  122829. declare module BABYLON {
  122830. /**
  122831. * Listen to mouse events to control the camera.
  122832. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122833. */
  122834. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  122835. /**
  122836. * Defines the camera the input is attached to.
  122837. */
  122838. camera: FlyCamera;
  122839. /**
  122840. * Defines if touch is enabled. (Default is true.)
  122841. */
  122842. touchEnabled: boolean;
  122843. /**
  122844. * Defines the buttons associated with the input to handle camera rotation.
  122845. */
  122846. buttons: number[];
  122847. /**
  122848. * Assign buttons for Yaw control.
  122849. */
  122850. buttonsYaw: number[];
  122851. /**
  122852. * Assign buttons for Pitch control.
  122853. */
  122854. buttonsPitch: number[];
  122855. /**
  122856. * Assign buttons for Roll control.
  122857. */
  122858. buttonsRoll: number[];
  122859. /**
  122860. * Detect if any button is being pressed while mouse is moved.
  122861. * -1 = Mouse locked.
  122862. * 0 = Left button.
  122863. * 1 = Middle Button.
  122864. * 2 = Right Button.
  122865. */
  122866. activeButton: number;
  122867. /**
  122868. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  122869. * Higher values reduce its sensitivity.
  122870. */
  122871. angularSensibility: number;
  122872. private _mousemoveCallback;
  122873. private _observer;
  122874. private _rollObserver;
  122875. private previousPosition;
  122876. private noPreventDefault;
  122877. private element;
  122878. /**
  122879. * Listen to mouse events to control the camera.
  122880. * @param touchEnabled Define if touch is enabled. (Default is true.)
  122881. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122882. */
  122883. constructor(touchEnabled?: boolean);
  122884. /**
  122885. * Attach the mouse control to the HTML DOM element.
  122886. * @param element Defines the element that listens to the input events.
  122887. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  122888. */
  122889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122890. /**
  122891. * Detach the current controls from the specified dom element.
  122892. * @param element Defines the element to stop listening the inputs from
  122893. */
  122894. detachControl(element: Nullable<HTMLElement>): void;
  122895. /**
  122896. * Gets the class name of the current input.
  122897. * @returns the class name.
  122898. */
  122899. getClassName(): string;
  122900. /**
  122901. * Get the friendly name associated with the input class.
  122902. * @returns the input's friendly name.
  122903. */
  122904. getSimpleName(): string;
  122905. private _pointerInput;
  122906. private _onMouseMove;
  122907. /**
  122908. * Rotate camera by mouse offset.
  122909. */
  122910. private rotateCamera;
  122911. }
  122912. }
  122913. declare module BABYLON {
  122914. /**
  122915. * Default Inputs manager for the FlyCamera.
  122916. * It groups all the default supported inputs for ease of use.
  122917. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122918. */
  122919. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  122920. /**
  122921. * Instantiates a new FlyCameraInputsManager.
  122922. * @param camera Defines the camera the inputs belong to.
  122923. */
  122924. constructor(camera: FlyCamera);
  122925. /**
  122926. * Add keyboard input support to the input manager.
  122927. * @returns the new FlyCameraKeyboardMoveInput().
  122928. */
  122929. addKeyboard(): FlyCameraInputsManager;
  122930. /**
  122931. * Add mouse input support to the input manager.
  122932. * @param touchEnabled Enable touch screen support.
  122933. * @returns the new FlyCameraMouseInput().
  122934. */
  122935. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  122936. }
  122937. }
  122938. declare module BABYLON {
  122939. /**
  122940. * This is a flying camera, designed for 3D movement and rotation in all directions,
  122941. * such as in a 3D Space Shooter or a Flight Simulator.
  122942. */
  122943. export class FlyCamera extends TargetCamera {
  122944. /**
  122945. * Define the collision ellipsoid of the camera.
  122946. * This is helpful for simulating a camera body, like a player's body.
  122947. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122948. */
  122949. ellipsoid: Vector3;
  122950. /**
  122951. * Define an offset for the position of the ellipsoid around the camera.
  122952. * This can be helpful if the camera is attached away from the player's body center,
  122953. * such as at its head.
  122954. */
  122955. ellipsoidOffset: Vector3;
  122956. /**
  122957. * Enable or disable collisions of the camera with the rest of the scene objects.
  122958. */
  122959. checkCollisions: boolean;
  122960. /**
  122961. * Enable or disable gravity on the camera.
  122962. */
  122963. applyGravity: boolean;
  122964. /**
  122965. * Define the current direction the camera is moving to.
  122966. */
  122967. cameraDirection: Vector3;
  122968. /**
  122969. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  122970. * This overrides and empties cameraRotation.
  122971. */
  122972. rotationQuaternion: Quaternion;
  122973. /**
  122974. * Track Roll to maintain the wanted Rolling when looking around.
  122975. */
  122976. _trackRoll: number;
  122977. /**
  122978. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  122979. */
  122980. rollCorrect: number;
  122981. /**
  122982. * Mimic a banked turn, Rolling the camera when Yawing.
  122983. * It's recommended to use rollCorrect = 10 for faster banking correction.
  122984. */
  122985. bankedTurn: boolean;
  122986. /**
  122987. * Limit in radians for how much Roll banking will add. (Default: 90°)
  122988. */
  122989. bankedTurnLimit: number;
  122990. /**
  122991. * Value of 0 disables the banked Roll.
  122992. * Value of 1 is equal to the Yaw angle in radians.
  122993. */
  122994. bankedTurnMultiplier: number;
  122995. /**
  122996. * The inputs manager loads all the input sources, such as keyboard and mouse.
  122997. */
  122998. inputs: FlyCameraInputsManager;
  122999. /**
  123000. * Gets the input sensibility for mouse input.
  123001. * Higher values reduce sensitivity.
  123002. */
  123003. get angularSensibility(): number;
  123004. /**
  123005. * Sets the input sensibility for a mouse input.
  123006. * Higher values reduce sensitivity.
  123007. */
  123008. set angularSensibility(value: number);
  123009. /**
  123010. * Get the keys for camera movement forward.
  123011. */
  123012. get keysForward(): number[];
  123013. /**
  123014. * Set the keys for camera movement forward.
  123015. */
  123016. set keysForward(value: number[]);
  123017. /**
  123018. * Get the keys for camera movement backward.
  123019. */
  123020. get keysBackward(): number[];
  123021. set keysBackward(value: number[]);
  123022. /**
  123023. * Get the keys for camera movement up.
  123024. */
  123025. get keysUp(): number[];
  123026. /**
  123027. * Set the keys for camera movement up.
  123028. */
  123029. set keysUp(value: number[]);
  123030. /**
  123031. * Get the keys for camera movement down.
  123032. */
  123033. get keysDown(): number[];
  123034. /**
  123035. * Set the keys for camera movement down.
  123036. */
  123037. set keysDown(value: number[]);
  123038. /**
  123039. * Get the keys for camera movement left.
  123040. */
  123041. get keysLeft(): number[];
  123042. /**
  123043. * Set the keys for camera movement left.
  123044. */
  123045. set keysLeft(value: number[]);
  123046. /**
  123047. * Set the keys for camera movement right.
  123048. */
  123049. get keysRight(): number[];
  123050. /**
  123051. * Set the keys for camera movement right.
  123052. */
  123053. set keysRight(value: number[]);
  123054. /**
  123055. * Event raised when the camera collides with a mesh in the scene.
  123056. */
  123057. onCollide: (collidedMesh: AbstractMesh) => void;
  123058. private _collider;
  123059. private _needMoveForGravity;
  123060. private _oldPosition;
  123061. private _diffPosition;
  123062. private _newPosition;
  123063. /** @hidden */
  123064. _localDirection: Vector3;
  123065. /** @hidden */
  123066. _transformedDirection: Vector3;
  123067. /**
  123068. * Instantiates a FlyCamera.
  123069. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123070. * such as in a 3D Space Shooter or a Flight Simulator.
  123071. * @param name Define the name of the camera in the scene.
  123072. * @param position Define the starting position of the camera in the scene.
  123073. * @param scene Define the scene the camera belongs to.
  123074. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  123075. */
  123076. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123077. /**
  123078. * Attach a control to the HTML DOM element.
  123079. * @param element Defines the element that listens to the input events.
  123080. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  123081. */
  123082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123083. /**
  123084. * Detach a control from the HTML DOM element.
  123085. * The camera will stop reacting to that input.
  123086. * @param element Defines the element that listens to the input events.
  123087. */
  123088. detachControl(element: HTMLElement): void;
  123089. private _collisionMask;
  123090. /**
  123091. * Get the mask that the camera ignores in collision events.
  123092. */
  123093. get collisionMask(): number;
  123094. /**
  123095. * Set the mask that the camera ignores in collision events.
  123096. */
  123097. set collisionMask(mask: number);
  123098. /** @hidden */
  123099. _collideWithWorld(displacement: Vector3): void;
  123100. /** @hidden */
  123101. private _onCollisionPositionChange;
  123102. /** @hidden */
  123103. _checkInputs(): void;
  123104. /** @hidden */
  123105. _decideIfNeedsToMove(): boolean;
  123106. /** @hidden */
  123107. _updatePosition(): void;
  123108. /**
  123109. * Restore the Roll to its target value at the rate specified.
  123110. * @param rate - Higher means slower restoring.
  123111. * @hidden
  123112. */
  123113. restoreRoll(rate: number): void;
  123114. /**
  123115. * Destroy the camera and release the current resources held by it.
  123116. */
  123117. dispose(): void;
  123118. /**
  123119. * Get the current object class name.
  123120. * @returns the class name.
  123121. */
  123122. getClassName(): string;
  123123. }
  123124. }
  123125. declare module BABYLON {
  123126. /**
  123127. * Listen to keyboard events to control the camera.
  123128. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123129. */
  123130. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  123131. /**
  123132. * Defines the camera the input is attached to.
  123133. */
  123134. camera: FlyCamera;
  123135. /**
  123136. * The list of keyboard keys used to control the forward move of the camera.
  123137. */
  123138. keysForward: number[];
  123139. /**
  123140. * The list of keyboard keys used to control the backward move of the camera.
  123141. */
  123142. keysBackward: number[];
  123143. /**
  123144. * The list of keyboard keys used to control the forward move of the camera.
  123145. */
  123146. keysUp: number[];
  123147. /**
  123148. * The list of keyboard keys used to control the backward move of the camera.
  123149. */
  123150. keysDown: number[];
  123151. /**
  123152. * The list of keyboard keys used to control the right strafe move of the camera.
  123153. */
  123154. keysRight: number[];
  123155. /**
  123156. * The list of keyboard keys used to control the left strafe move of the camera.
  123157. */
  123158. keysLeft: number[];
  123159. private _keys;
  123160. private _onCanvasBlurObserver;
  123161. private _onKeyboardObserver;
  123162. private _engine;
  123163. private _scene;
  123164. /**
  123165. * Attach the input controls to a specific dom element to get the input from.
  123166. * @param element Defines the element the controls should be listened from
  123167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123168. */
  123169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123170. /**
  123171. * Detach the current controls from the specified dom element.
  123172. * @param element Defines the element to stop listening the inputs from
  123173. */
  123174. detachControl(element: Nullable<HTMLElement>): void;
  123175. /**
  123176. * Gets the class name of the current intput.
  123177. * @returns the class name
  123178. */
  123179. getClassName(): string;
  123180. /** @hidden */
  123181. _onLostFocus(e: FocusEvent): void;
  123182. /**
  123183. * Get the friendly name associated with the input class.
  123184. * @returns the input friendly name
  123185. */
  123186. getSimpleName(): string;
  123187. /**
  123188. * Update the current camera state depending on the inputs that have been used this frame.
  123189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123190. */
  123191. checkInputs(): void;
  123192. }
  123193. }
  123194. declare module BABYLON {
  123195. /**
  123196. * Manage the mouse wheel inputs to control a follow camera.
  123197. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123198. */
  123199. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  123200. /**
  123201. * Defines the camera the input is attached to.
  123202. */
  123203. camera: FollowCamera;
  123204. /**
  123205. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  123206. */
  123207. axisControlRadius: boolean;
  123208. /**
  123209. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  123210. */
  123211. axisControlHeight: boolean;
  123212. /**
  123213. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  123214. */
  123215. axisControlRotation: boolean;
  123216. /**
  123217. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  123218. * relation to mouseWheel events.
  123219. */
  123220. wheelPrecision: number;
  123221. /**
  123222. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123223. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123224. */
  123225. wheelDeltaPercentage: number;
  123226. private _wheel;
  123227. private _observer;
  123228. /**
  123229. * Attach the input controls to a specific dom element to get the input from.
  123230. * @param element Defines the element the controls should be listened from
  123231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123232. */
  123233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123234. /**
  123235. * Detach the current controls from the specified dom element.
  123236. * @param element Defines the element to stop listening the inputs from
  123237. */
  123238. detachControl(element: Nullable<HTMLElement>): void;
  123239. /**
  123240. * Gets the class name of the current intput.
  123241. * @returns the class name
  123242. */
  123243. getClassName(): string;
  123244. /**
  123245. * Get the friendly name associated with the input class.
  123246. * @returns the input friendly name
  123247. */
  123248. getSimpleName(): string;
  123249. }
  123250. }
  123251. declare module BABYLON {
  123252. /**
  123253. * Manage the pointers inputs to control an follow camera.
  123254. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123255. */
  123256. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  123257. /**
  123258. * Defines the camera the input is attached to.
  123259. */
  123260. camera: FollowCamera;
  123261. /**
  123262. * Gets the class name of the current input.
  123263. * @returns the class name
  123264. */
  123265. getClassName(): string;
  123266. /**
  123267. * Defines the pointer angular sensibility along the X axis or how fast is
  123268. * the camera rotating.
  123269. * A negative number will reverse the axis direction.
  123270. */
  123271. angularSensibilityX: number;
  123272. /**
  123273. * Defines the pointer angular sensibility along the Y axis or how fast is
  123274. * the camera rotating.
  123275. * A negative number will reverse the axis direction.
  123276. */
  123277. angularSensibilityY: number;
  123278. /**
  123279. * Defines the pointer pinch precision or how fast is the camera zooming.
  123280. * A negative number will reverse the axis direction.
  123281. */
  123282. pinchPrecision: number;
  123283. /**
  123284. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123285. * from 0.
  123286. * It defines the percentage of current camera.radius to use as delta when
  123287. * pinch zoom is used.
  123288. */
  123289. pinchDeltaPercentage: number;
  123290. /**
  123291. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  123292. */
  123293. axisXControlRadius: boolean;
  123294. /**
  123295. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  123296. */
  123297. axisXControlHeight: boolean;
  123298. /**
  123299. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  123300. */
  123301. axisXControlRotation: boolean;
  123302. /**
  123303. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  123304. */
  123305. axisYControlRadius: boolean;
  123306. /**
  123307. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  123308. */
  123309. axisYControlHeight: boolean;
  123310. /**
  123311. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  123312. */
  123313. axisYControlRotation: boolean;
  123314. /**
  123315. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  123316. */
  123317. axisPinchControlRadius: boolean;
  123318. /**
  123319. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  123320. */
  123321. axisPinchControlHeight: boolean;
  123322. /**
  123323. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  123324. */
  123325. axisPinchControlRotation: boolean;
  123326. /**
  123327. * Log error messages if basic misconfiguration has occurred.
  123328. */
  123329. warningEnable: boolean;
  123330. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123331. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123332. private _warningCounter;
  123333. private _warning;
  123334. }
  123335. }
  123336. declare module BABYLON {
  123337. /**
  123338. * Default Inputs manager for the FollowCamera.
  123339. * It groups all the default supported inputs for ease of use.
  123340. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123341. */
  123342. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  123343. /**
  123344. * Instantiates a new FollowCameraInputsManager.
  123345. * @param camera Defines the camera the inputs belong to
  123346. */
  123347. constructor(camera: FollowCamera);
  123348. /**
  123349. * Add keyboard input support to the input manager.
  123350. * @returns the current input manager
  123351. */
  123352. addKeyboard(): FollowCameraInputsManager;
  123353. /**
  123354. * Add mouse wheel input support to the input manager.
  123355. * @returns the current input manager
  123356. */
  123357. addMouseWheel(): FollowCameraInputsManager;
  123358. /**
  123359. * Add pointers input support to the input manager.
  123360. * @returns the current input manager
  123361. */
  123362. addPointers(): FollowCameraInputsManager;
  123363. /**
  123364. * Add orientation input support to the input manager.
  123365. * @returns the current input manager
  123366. */
  123367. addVRDeviceOrientation(): FollowCameraInputsManager;
  123368. }
  123369. }
  123370. declare module BABYLON {
  123371. /**
  123372. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  123373. * an arc rotate version arcFollowCamera are available.
  123374. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123375. */
  123376. export class FollowCamera extends TargetCamera {
  123377. /**
  123378. * Distance the follow camera should follow an object at
  123379. */
  123380. radius: number;
  123381. /**
  123382. * Minimum allowed distance of the camera to the axis of rotation
  123383. * (The camera can not get closer).
  123384. * This can help limiting how the Camera is able to move in the scene.
  123385. */
  123386. lowerRadiusLimit: Nullable<number>;
  123387. /**
  123388. * Maximum allowed distance of the camera to the axis of rotation
  123389. * (The camera can not get further).
  123390. * This can help limiting how the Camera is able to move in the scene.
  123391. */
  123392. upperRadiusLimit: Nullable<number>;
  123393. /**
  123394. * Define a rotation offset between the camera and the object it follows
  123395. */
  123396. rotationOffset: number;
  123397. /**
  123398. * Minimum allowed angle to camera position relative to target object.
  123399. * This can help limiting how the Camera is able to move in the scene.
  123400. */
  123401. lowerRotationOffsetLimit: Nullable<number>;
  123402. /**
  123403. * Maximum allowed angle to camera position relative to target object.
  123404. * This can help limiting how the Camera is able to move in the scene.
  123405. */
  123406. upperRotationOffsetLimit: Nullable<number>;
  123407. /**
  123408. * Define a height offset between the camera and the object it follows.
  123409. * It can help following an object from the top (like a car chaing a plane)
  123410. */
  123411. heightOffset: number;
  123412. /**
  123413. * Minimum allowed height of camera position relative to target object.
  123414. * This can help limiting how the Camera is able to move in the scene.
  123415. */
  123416. lowerHeightOffsetLimit: Nullable<number>;
  123417. /**
  123418. * Maximum allowed height of camera position relative to target object.
  123419. * This can help limiting how the Camera is able to move in the scene.
  123420. */
  123421. upperHeightOffsetLimit: Nullable<number>;
  123422. /**
  123423. * Define how fast the camera can accelerate to follow it s target.
  123424. */
  123425. cameraAcceleration: number;
  123426. /**
  123427. * Define the speed limit of the camera following an object.
  123428. */
  123429. maxCameraSpeed: number;
  123430. /**
  123431. * Define the target of the camera.
  123432. */
  123433. lockedTarget: Nullable<AbstractMesh>;
  123434. /**
  123435. * Defines the input associated with the camera.
  123436. */
  123437. inputs: FollowCameraInputsManager;
  123438. /**
  123439. * Instantiates the follow camera.
  123440. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123441. * @param name Define the name of the camera in the scene
  123442. * @param position Define the position of the camera
  123443. * @param scene Define the scene the camera belong to
  123444. * @param lockedTarget Define the target of the camera
  123445. */
  123446. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  123447. private _follow;
  123448. /**
  123449. * Attached controls to the current camera.
  123450. * @param element Defines the element the controls should be listened from
  123451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123452. */
  123453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123454. /**
  123455. * Detach the current controls from the camera.
  123456. * The camera will stop reacting to inputs.
  123457. * @param element Defines the element to stop listening the inputs from
  123458. */
  123459. detachControl(element: HTMLElement): void;
  123460. /** @hidden */
  123461. _checkInputs(): void;
  123462. private _checkLimits;
  123463. /**
  123464. * Gets the camera class name.
  123465. * @returns the class name
  123466. */
  123467. getClassName(): string;
  123468. }
  123469. /**
  123470. * Arc Rotate version of the follow camera.
  123471. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  123472. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123473. */
  123474. export class ArcFollowCamera extends TargetCamera {
  123475. /** The longitudinal angle of the camera */
  123476. alpha: number;
  123477. /** The latitudinal angle of the camera */
  123478. beta: number;
  123479. /** The radius of the camera from its target */
  123480. radius: number;
  123481. private _cartesianCoordinates;
  123482. /** Define the camera target (the mesh it should follow) */
  123483. private _meshTarget;
  123484. /**
  123485. * Instantiates a new ArcFollowCamera
  123486. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  123487. * @param name Define the name of the camera
  123488. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  123489. * @param beta Define the rotation angle of the camera around the elevation axis
  123490. * @param radius Define the radius of the camera from its target point
  123491. * @param target Define the target of the camera
  123492. * @param scene Define the scene the camera belongs to
  123493. */
  123494. constructor(name: string,
  123495. /** The longitudinal angle of the camera */
  123496. alpha: number,
  123497. /** The latitudinal angle of the camera */
  123498. beta: number,
  123499. /** The radius of the camera from its target */
  123500. radius: number,
  123501. /** Define the camera target (the mesh it should follow) */
  123502. target: Nullable<AbstractMesh>, scene: Scene);
  123503. private _follow;
  123504. /** @hidden */
  123505. _checkInputs(): void;
  123506. /**
  123507. * Returns the class name of the object.
  123508. * It is mostly used internally for serialization purposes.
  123509. */
  123510. getClassName(): string;
  123511. }
  123512. }
  123513. declare module BABYLON {
  123514. /**
  123515. * Manage the keyboard inputs to control the movement of a follow camera.
  123516. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123517. */
  123518. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  123519. /**
  123520. * Defines the camera the input is attached to.
  123521. */
  123522. camera: FollowCamera;
  123523. /**
  123524. * Defines the list of key codes associated with the up action (increase heightOffset)
  123525. */
  123526. keysHeightOffsetIncr: number[];
  123527. /**
  123528. * Defines the list of key codes associated with the down action (decrease heightOffset)
  123529. */
  123530. keysHeightOffsetDecr: number[];
  123531. /**
  123532. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  123533. */
  123534. keysHeightOffsetModifierAlt: boolean;
  123535. /**
  123536. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  123537. */
  123538. keysHeightOffsetModifierCtrl: boolean;
  123539. /**
  123540. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  123541. */
  123542. keysHeightOffsetModifierShift: boolean;
  123543. /**
  123544. * Defines the list of key codes associated with the left action (increase rotationOffset)
  123545. */
  123546. keysRotationOffsetIncr: number[];
  123547. /**
  123548. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  123549. */
  123550. keysRotationOffsetDecr: number[];
  123551. /**
  123552. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  123553. */
  123554. keysRotationOffsetModifierAlt: boolean;
  123555. /**
  123556. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  123557. */
  123558. keysRotationOffsetModifierCtrl: boolean;
  123559. /**
  123560. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  123561. */
  123562. keysRotationOffsetModifierShift: boolean;
  123563. /**
  123564. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  123565. */
  123566. keysRadiusIncr: number[];
  123567. /**
  123568. * Defines the list of key codes associated with the zoom-out action (increase radius)
  123569. */
  123570. keysRadiusDecr: number[];
  123571. /**
  123572. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  123573. */
  123574. keysRadiusModifierAlt: boolean;
  123575. /**
  123576. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  123577. */
  123578. keysRadiusModifierCtrl: boolean;
  123579. /**
  123580. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  123581. */
  123582. keysRadiusModifierShift: boolean;
  123583. /**
  123584. * Defines the rate of change of heightOffset.
  123585. */
  123586. heightSensibility: number;
  123587. /**
  123588. * Defines the rate of change of rotationOffset.
  123589. */
  123590. rotationSensibility: number;
  123591. /**
  123592. * Defines the rate of change of radius.
  123593. */
  123594. radiusSensibility: number;
  123595. private _keys;
  123596. private _ctrlPressed;
  123597. private _altPressed;
  123598. private _shiftPressed;
  123599. private _onCanvasBlurObserver;
  123600. private _onKeyboardObserver;
  123601. private _engine;
  123602. private _scene;
  123603. /**
  123604. * Attach the input controls to a specific dom element to get the input from.
  123605. * @param element Defines the element the controls should be listened from
  123606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123607. */
  123608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123609. /**
  123610. * Detach the current controls from the specified dom element.
  123611. * @param element Defines the element to stop listening the inputs from
  123612. */
  123613. detachControl(element: Nullable<HTMLElement>): void;
  123614. /**
  123615. * Update the current camera state depending on the inputs that have been used this frame.
  123616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123617. */
  123618. checkInputs(): void;
  123619. /**
  123620. * Gets the class name of the current input.
  123621. * @returns the class name
  123622. */
  123623. getClassName(): string;
  123624. /**
  123625. * Get the friendly name associated with the input class.
  123626. * @returns the input friendly name
  123627. */
  123628. getSimpleName(): string;
  123629. /**
  123630. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123631. * allow modification of the heightOffset value.
  123632. */
  123633. private _modifierHeightOffset;
  123634. /**
  123635. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123636. * allow modification of the rotationOffset value.
  123637. */
  123638. private _modifierRotationOffset;
  123639. /**
  123640. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  123641. * allow modification of the radius value.
  123642. */
  123643. private _modifierRadius;
  123644. }
  123645. }
  123646. declare module BABYLON {
  123647. interface FreeCameraInputsManager {
  123648. /**
  123649. * @hidden
  123650. */
  123651. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  123652. /**
  123653. * Add orientation input support to the input manager.
  123654. * @returns the current input manager
  123655. */
  123656. addDeviceOrientation(): FreeCameraInputsManager;
  123657. }
  123658. /**
  123659. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  123660. * Screen rotation is taken into account.
  123661. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123662. */
  123663. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  123664. private _camera;
  123665. private _screenOrientationAngle;
  123666. private _constantTranform;
  123667. private _screenQuaternion;
  123668. private _alpha;
  123669. private _beta;
  123670. private _gamma;
  123671. /**
  123672. * Can be used to detect if a device orientation sensor is available on a device
  123673. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  123674. * @returns a promise that will resolve on orientation change
  123675. */
  123676. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  123677. /**
  123678. * @hidden
  123679. */
  123680. _onDeviceOrientationChangedObservable: Observable<void>;
  123681. /**
  123682. * Instantiates a new input
  123683. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123684. */
  123685. constructor();
  123686. /**
  123687. * Define the camera controlled by the input.
  123688. */
  123689. get camera(): FreeCamera;
  123690. set camera(camera: FreeCamera);
  123691. /**
  123692. * Attach the input controls to a specific dom element to get the input from.
  123693. * @param element Defines the element the controls should be listened from
  123694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123695. */
  123696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123697. private _orientationChanged;
  123698. private _deviceOrientation;
  123699. /**
  123700. * Detach the current controls from the specified dom element.
  123701. * @param element Defines the element to stop listening the inputs from
  123702. */
  123703. detachControl(element: Nullable<HTMLElement>): void;
  123704. /**
  123705. * Update the current camera state depending on the inputs that have been used this frame.
  123706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123707. */
  123708. checkInputs(): void;
  123709. /**
  123710. * Gets the class name of the current intput.
  123711. * @returns the class name
  123712. */
  123713. getClassName(): string;
  123714. /**
  123715. * Get the friendly name associated with the input class.
  123716. * @returns the input friendly name
  123717. */
  123718. getSimpleName(): string;
  123719. }
  123720. }
  123721. declare module BABYLON {
  123722. /**
  123723. * Manage the gamepad inputs to control a free camera.
  123724. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123725. */
  123726. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  123727. /**
  123728. * Define the camera the input is attached to.
  123729. */
  123730. camera: FreeCamera;
  123731. /**
  123732. * Define the Gamepad controlling the input
  123733. */
  123734. gamepad: Nullable<Gamepad>;
  123735. /**
  123736. * Defines the gamepad rotation sensiblity.
  123737. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123738. */
  123739. gamepadAngularSensibility: number;
  123740. /**
  123741. * Defines the gamepad move sensiblity.
  123742. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123743. */
  123744. gamepadMoveSensibility: number;
  123745. private _yAxisScale;
  123746. /**
  123747. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123748. */
  123749. get invertYAxis(): boolean;
  123750. set invertYAxis(value: boolean);
  123751. private _onGamepadConnectedObserver;
  123752. private _onGamepadDisconnectedObserver;
  123753. private _cameraTransform;
  123754. private _deltaTransform;
  123755. private _vector3;
  123756. private _vector2;
  123757. /**
  123758. * Attach the input controls to a specific dom element to get the input from.
  123759. * @param element Defines the element the controls should be listened from
  123760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123761. */
  123762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123763. /**
  123764. * Detach the current controls from the specified dom element.
  123765. * @param element Defines the element to stop listening the inputs from
  123766. */
  123767. detachControl(element: Nullable<HTMLElement>): void;
  123768. /**
  123769. * Update the current camera state depending on the inputs that have been used this frame.
  123770. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123771. */
  123772. checkInputs(): void;
  123773. /**
  123774. * Gets the class name of the current intput.
  123775. * @returns the class name
  123776. */
  123777. getClassName(): string;
  123778. /**
  123779. * Get the friendly name associated with the input class.
  123780. * @returns the input friendly name
  123781. */
  123782. getSimpleName(): string;
  123783. }
  123784. }
  123785. declare module BABYLON {
  123786. /**
  123787. * Defines the potential axis of a Joystick
  123788. */
  123789. export enum JoystickAxis {
  123790. /** X axis */
  123791. X = 0,
  123792. /** Y axis */
  123793. Y = 1,
  123794. /** Z axis */
  123795. Z = 2
  123796. }
  123797. /**
  123798. * Represents the different customization options available
  123799. * for VirtualJoystick
  123800. */
  123801. interface VirtualJoystickCustomizations {
  123802. /**
  123803. * Size of the joystick's puck
  123804. */
  123805. puckSize: number;
  123806. /**
  123807. * Size of the joystick's container
  123808. */
  123809. containerSize: number;
  123810. /**
  123811. * Color of the joystick && puck
  123812. */
  123813. color: string;
  123814. /**
  123815. * Image URL for the joystick's puck
  123816. */
  123817. puckImage?: string;
  123818. /**
  123819. * Image URL for the joystick's container
  123820. */
  123821. containerImage?: string;
  123822. /**
  123823. * Defines the unmoving position of the joystick container
  123824. */
  123825. position?: {
  123826. x: number;
  123827. y: number;
  123828. };
  123829. /**
  123830. * Defines whether or not the joystick container is always visible
  123831. */
  123832. alwaysVisible: boolean;
  123833. /**
  123834. * Defines whether or not to limit the movement of the puck to the joystick's container
  123835. */
  123836. limitToContainer: boolean;
  123837. }
  123838. /**
  123839. * Class used to define virtual joystick (used in touch mode)
  123840. */
  123841. export class VirtualJoystick {
  123842. /**
  123843. * Gets or sets a boolean indicating that left and right values must be inverted
  123844. */
  123845. reverseLeftRight: boolean;
  123846. /**
  123847. * Gets or sets a boolean indicating that up and down values must be inverted
  123848. */
  123849. reverseUpDown: boolean;
  123850. /**
  123851. * Gets the offset value for the position (ie. the change of the position value)
  123852. */
  123853. deltaPosition: Vector3;
  123854. /**
  123855. * Gets a boolean indicating if the virtual joystick was pressed
  123856. */
  123857. pressed: boolean;
  123858. /**
  123859. * Canvas the virtual joystick will render onto, default z-index of this is 5
  123860. */
  123861. static Canvas: Nullable<HTMLCanvasElement>;
  123862. /**
  123863. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  123864. */
  123865. limitToContainer: boolean;
  123866. private static _globalJoystickIndex;
  123867. private static _alwaysVisibleSticks;
  123868. private static vjCanvasContext;
  123869. private static vjCanvasWidth;
  123870. private static vjCanvasHeight;
  123871. private static halfWidth;
  123872. private static _GetDefaultOptions;
  123873. private _action;
  123874. private _axisTargetedByLeftAndRight;
  123875. private _axisTargetedByUpAndDown;
  123876. private _joystickSensibility;
  123877. private _inversedSensibility;
  123878. private _joystickPointerID;
  123879. private _joystickColor;
  123880. private _joystickPointerPos;
  123881. private _joystickPreviousPointerPos;
  123882. private _joystickPointerStartPos;
  123883. private _deltaJoystickVector;
  123884. private _leftJoystick;
  123885. private _touches;
  123886. private _joystickPosition;
  123887. private _alwaysVisible;
  123888. private _puckImage;
  123889. private _containerImage;
  123890. private _joystickPuckSize;
  123891. private _joystickContainerSize;
  123892. private _clearPuckSize;
  123893. private _clearContainerSize;
  123894. private _clearPuckSizeOffset;
  123895. private _clearContainerSizeOffset;
  123896. private _onPointerDownHandlerRef;
  123897. private _onPointerMoveHandlerRef;
  123898. private _onPointerUpHandlerRef;
  123899. private _onResize;
  123900. /**
  123901. * Creates a new virtual joystick
  123902. * @param leftJoystick defines that the joystick is for left hand (false by default)
  123903. * @param customizations Defines the options we want to customize the VirtualJoystick
  123904. */
  123905. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  123906. /**
  123907. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  123908. * @param newJoystickSensibility defines the new sensibility
  123909. */
  123910. setJoystickSensibility(newJoystickSensibility: number): void;
  123911. private _onPointerDown;
  123912. private _onPointerMove;
  123913. private _onPointerUp;
  123914. /**
  123915. * Change the color of the virtual joystick
  123916. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  123917. */
  123918. setJoystickColor(newColor: string): void;
  123919. /**
  123920. * Size of the joystick's container
  123921. */
  123922. set containerSize(newSize: number);
  123923. get containerSize(): number;
  123924. /**
  123925. * Size of the joystick's puck
  123926. */
  123927. set puckSize(newSize: number);
  123928. get puckSize(): number;
  123929. /**
  123930. * Clears the set position of the joystick
  123931. */
  123932. clearPosition(): void;
  123933. /**
  123934. * Defines whether or not the joystick container is always visible
  123935. */
  123936. set alwaysVisible(value: boolean);
  123937. get alwaysVisible(): boolean;
  123938. /**
  123939. * Sets the constant position of the Joystick container
  123940. * @param x X axis coordinate
  123941. * @param y Y axis coordinate
  123942. */
  123943. setPosition(x: number, y: number): void;
  123944. /**
  123945. * Defines a callback to call when the joystick is touched
  123946. * @param action defines the callback
  123947. */
  123948. setActionOnTouch(action: () => any): void;
  123949. /**
  123950. * Defines which axis you'd like to control for left & right
  123951. * @param axis defines the axis to use
  123952. */
  123953. setAxisForLeftRight(axis: JoystickAxis): void;
  123954. /**
  123955. * Defines which axis you'd like to control for up & down
  123956. * @param axis defines the axis to use
  123957. */
  123958. setAxisForUpDown(axis: JoystickAxis): void;
  123959. /**
  123960. * Clears the canvas from the previous puck / container draw
  123961. */
  123962. private _clearPreviousDraw;
  123963. /**
  123964. * Loads `urlPath` to be used for the container's image
  123965. * @param urlPath defines the urlPath of an image to use
  123966. */
  123967. setContainerImage(urlPath: string): void;
  123968. /**
  123969. * Loads `urlPath` to be used for the puck's image
  123970. * @param urlPath defines the urlPath of an image to use
  123971. */
  123972. setPuckImage(urlPath: string): void;
  123973. /**
  123974. * Draws the Virtual Joystick's container
  123975. */
  123976. private _drawContainer;
  123977. /**
  123978. * Draws the Virtual Joystick's puck
  123979. */
  123980. private _drawPuck;
  123981. private _drawVirtualJoystick;
  123982. /**
  123983. * Release internal HTML canvas
  123984. */
  123985. releaseCanvas(): void;
  123986. }
  123987. }
  123988. declare module BABYLON {
  123989. interface FreeCameraInputsManager {
  123990. /**
  123991. * Add virtual joystick input support to the input manager.
  123992. * @returns the current input manager
  123993. */
  123994. addVirtualJoystick(): FreeCameraInputsManager;
  123995. }
  123996. /**
  123997. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  123998. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123999. */
  124000. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  124001. /**
  124002. * Defines the camera the input is attached to.
  124003. */
  124004. camera: FreeCamera;
  124005. private _leftjoystick;
  124006. private _rightjoystick;
  124007. /**
  124008. * Gets the left stick of the virtual joystick.
  124009. * @returns The virtual Joystick
  124010. */
  124011. getLeftJoystick(): VirtualJoystick;
  124012. /**
  124013. * Gets the right stick of the virtual joystick.
  124014. * @returns The virtual Joystick
  124015. */
  124016. getRightJoystick(): VirtualJoystick;
  124017. /**
  124018. * Update the current camera state depending on the inputs that have been used this frame.
  124019. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124020. */
  124021. checkInputs(): void;
  124022. /**
  124023. * Attach the input controls to a specific dom element to get the input from.
  124024. * @param element Defines the element the controls should be listened from
  124025. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124026. */
  124027. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124028. /**
  124029. * Detach the current controls from the specified dom element.
  124030. * @param element Defines the element to stop listening the inputs from
  124031. */
  124032. detachControl(element: Nullable<HTMLElement>): void;
  124033. /**
  124034. * Gets the class name of the current intput.
  124035. * @returns the class name
  124036. */
  124037. getClassName(): string;
  124038. /**
  124039. * Get the friendly name associated with the input class.
  124040. * @returns the input friendly name
  124041. */
  124042. getSimpleName(): string;
  124043. }
  124044. }
  124045. declare module BABYLON {
  124046. /**
  124047. * This represents a FPS type of camera controlled by touch.
  124048. * This is like a universal camera minus the Gamepad controls.
  124049. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124050. */
  124051. export class TouchCamera extends FreeCamera {
  124052. /**
  124053. * Defines the touch sensibility for rotation.
  124054. * The higher the faster.
  124055. */
  124056. get touchAngularSensibility(): number;
  124057. set touchAngularSensibility(value: number);
  124058. /**
  124059. * Defines the touch sensibility for move.
  124060. * The higher the faster.
  124061. */
  124062. get touchMoveSensibility(): number;
  124063. set touchMoveSensibility(value: number);
  124064. /**
  124065. * Instantiates a new touch camera.
  124066. * This represents a FPS type of camera controlled by touch.
  124067. * This is like a universal camera minus the Gamepad controls.
  124068. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124069. * @param name Define the name of the camera in the scene
  124070. * @param position Define the start position of the camera in the scene
  124071. * @param scene Define the scene the camera belongs to
  124072. */
  124073. constructor(name: string, position: Vector3, scene: Scene);
  124074. /**
  124075. * Gets the current object class name.
  124076. * @return the class name
  124077. */
  124078. getClassName(): string;
  124079. /** @hidden */
  124080. _setupInputs(): void;
  124081. }
  124082. }
  124083. declare module BABYLON {
  124084. /**
  124085. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  124086. * being tilted forward or back and left or right.
  124087. */
  124088. export class DeviceOrientationCamera extends FreeCamera {
  124089. private _initialQuaternion;
  124090. private _quaternionCache;
  124091. private _tmpDragQuaternion;
  124092. private _disablePointerInputWhenUsingDeviceOrientation;
  124093. /**
  124094. * Creates a new device orientation camera
  124095. * @param name The name of the camera
  124096. * @param position The start position camera
  124097. * @param scene The scene the camera belongs to
  124098. */
  124099. constructor(name: string, position: Vector3, scene: Scene);
  124100. /**
  124101. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  124102. */
  124103. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  124104. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  124105. private _dragFactor;
  124106. /**
  124107. * Enabled turning on the y axis when the orientation sensor is active
  124108. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  124109. */
  124110. enableHorizontalDragging(dragFactor?: number): void;
  124111. /**
  124112. * Gets the current instance class name ("DeviceOrientationCamera").
  124113. * This helps avoiding instanceof at run time.
  124114. * @returns the class name
  124115. */
  124116. getClassName(): string;
  124117. /**
  124118. * @hidden
  124119. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  124120. */
  124121. _checkInputs(): void;
  124122. /**
  124123. * Reset the camera to its default orientation on the specified axis only.
  124124. * @param axis The axis to reset
  124125. */
  124126. resetToCurrentRotation(axis?: Axis): void;
  124127. }
  124128. }
  124129. declare module BABYLON {
  124130. /**
  124131. * Defines supported buttons for XBox360 compatible gamepads
  124132. */
  124133. export enum Xbox360Button {
  124134. /** A */
  124135. A = 0,
  124136. /** B */
  124137. B = 1,
  124138. /** X */
  124139. X = 2,
  124140. /** Y */
  124141. Y = 3,
  124142. /** Left button */
  124143. LB = 4,
  124144. /** Right button */
  124145. RB = 5,
  124146. /** Back */
  124147. Back = 8,
  124148. /** Start */
  124149. Start = 9,
  124150. /** Left stick */
  124151. LeftStick = 10,
  124152. /** Right stick */
  124153. RightStick = 11
  124154. }
  124155. /** Defines values for XBox360 DPad */
  124156. export enum Xbox360Dpad {
  124157. /** Up */
  124158. Up = 12,
  124159. /** Down */
  124160. Down = 13,
  124161. /** Left */
  124162. Left = 14,
  124163. /** Right */
  124164. Right = 15
  124165. }
  124166. /**
  124167. * Defines a XBox360 gamepad
  124168. */
  124169. export class Xbox360Pad extends Gamepad {
  124170. private _leftTrigger;
  124171. private _rightTrigger;
  124172. private _onlefttriggerchanged;
  124173. private _onrighttriggerchanged;
  124174. private _onbuttondown;
  124175. private _onbuttonup;
  124176. private _ondpaddown;
  124177. private _ondpadup;
  124178. /** Observable raised when a button is pressed */
  124179. onButtonDownObservable: Observable<Xbox360Button>;
  124180. /** Observable raised when a button is released */
  124181. onButtonUpObservable: Observable<Xbox360Button>;
  124182. /** Observable raised when a pad is pressed */
  124183. onPadDownObservable: Observable<Xbox360Dpad>;
  124184. /** Observable raised when a pad is released */
  124185. onPadUpObservable: Observable<Xbox360Dpad>;
  124186. private _buttonA;
  124187. private _buttonB;
  124188. private _buttonX;
  124189. private _buttonY;
  124190. private _buttonBack;
  124191. private _buttonStart;
  124192. private _buttonLB;
  124193. private _buttonRB;
  124194. private _buttonLeftStick;
  124195. private _buttonRightStick;
  124196. private _dPadUp;
  124197. private _dPadDown;
  124198. private _dPadLeft;
  124199. private _dPadRight;
  124200. private _isXboxOnePad;
  124201. /**
  124202. * Creates a new XBox360 gamepad object
  124203. * @param id defines the id of this gamepad
  124204. * @param index defines its index
  124205. * @param gamepad defines the internal HTML gamepad object
  124206. * @param xboxOne defines if it is a XBox One gamepad
  124207. */
  124208. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  124209. /**
  124210. * Defines the callback to call when left trigger is pressed
  124211. * @param callback defines the callback to use
  124212. */
  124213. onlefttriggerchanged(callback: (value: number) => void): void;
  124214. /**
  124215. * Defines the callback to call when right trigger is pressed
  124216. * @param callback defines the callback to use
  124217. */
  124218. onrighttriggerchanged(callback: (value: number) => void): void;
  124219. /**
  124220. * Gets the left trigger value
  124221. */
  124222. get leftTrigger(): number;
  124223. /**
  124224. * Sets the left trigger value
  124225. */
  124226. set leftTrigger(newValue: number);
  124227. /**
  124228. * Gets the right trigger value
  124229. */
  124230. get rightTrigger(): number;
  124231. /**
  124232. * Sets the right trigger value
  124233. */
  124234. set rightTrigger(newValue: number);
  124235. /**
  124236. * Defines the callback to call when a button is pressed
  124237. * @param callback defines the callback to use
  124238. */
  124239. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  124240. /**
  124241. * Defines the callback to call when a button is released
  124242. * @param callback defines the callback to use
  124243. */
  124244. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  124245. /**
  124246. * Defines the callback to call when a pad is pressed
  124247. * @param callback defines the callback to use
  124248. */
  124249. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  124250. /**
  124251. * Defines the callback to call when a pad is released
  124252. * @param callback defines the callback to use
  124253. */
  124254. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  124255. private _setButtonValue;
  124256. private _setDPadValue;
  124257. /**
  124258. * Gets the value of the `A` button
  124259. */
  124260. get buttonA(): number;
  124261. /**
  124262. * Sets the value of the `A` button
  124263. */
  124264. set buttonA(value: number);
  124265. /**
  124266. * Gets the value of the `B` button
  124267. */
  124268. get buttonB(): number;
  124269. /**
  124270. * Sets the value of the `B` button
  124271. */
  124272. set buttonB(value: number);
  124273. /**
  124274. * Gets the value of the `X` button
  124275. */
  124276. get buttonX(): number;
  124277. /**
  124278. * Sets the value of the `X` button
  124279. */
  124280. set buttonX(value: number);
  124281. /**
  124282. * Gets the value of the `Y` button
  124283. */
  124284. get buttonY(): number;
  124285. /**
  124286. * Sets the value of the `Y` button
  124287. */
  124288. set buttonY(value: number);
  124289. /**
  124290. * Gets the value of the `Start` button
  124291. */
  124292. get buttonStart(): number;
  124293. /**
  124294. * Sets the value of the `Start` button
  124295. */
  124296. set buttonStart(value: number);
  124297. /**
  124298. * Gets the value of the `Back` button
  124299. */
  124300. get buttonBack(): number;
  124301. /**
  124302. * Sets the value of the `Back` button
  124303. */
  124304. set buttonBack(value: number);
  124305. /**
  124306. * Gets the value of the `Left` button
  124307. */
  124308. get buttonLB(): number;
  124309. /**
  124310. * Sets the value of the `Left` button
  124311. */
  124312. set buttonLB(value: number);
  124313. /**
  124314. * Gets the value of the `Right` button
  124315. */
  124316. get buttonRB(): number;
  124317. /**
  124318. * Sets the value of the `Right` button
  124319. */
  124320. set buttonRB(value: number);
  124321. /**
  124322. * Gets the value of the Left joystick
  124323. */
  124324. get buttonLeftStick(): number;
  124325. /**
  124326. * Sets the value of the Left joystick
  124327. */
  124328. set buttonLeftStick(value: number);
  124329. /**
  124330. * Gets the value of the Right joystick
  124331. */
  124332. get buttonRightStick(): number;
  124333. /**
  124334. * Sets the value of the Right joystick
  124335. */
  124336. set buttonRightStick(value: number);
  124337. /**
  124338. * Gets the value of D-pad up
  124339. */
  124340. get dPadUp(): number;
  124341. /**
  124342. * Sets the value of D-pad up
  124343. */
  124344. set dPadUp(value: number);
  124345. /**
  124346. * Gets the value of D-pad down
  124347. */
  124348. get dPadDown(): number;
  124349. /**
  124350. * Sets the value of D-pad down
  124351. */
  124352. set dPadDown(value: number);
  124353. /**
  124354. * Gets the value of D-pad left
  124355. */
  124356. get dPadLeft(): number;
  124357. /**
  124358. * Sets the value of D-pad left
  124359. */
  124360. set dPadLeft(value: number);
  124361. /**
  124362. * Gets the value of D-pad right
  124363. */
  124364. get dPadRight(): number;
  124365. /**
  124366. * Sets the value of D-pad right
  124367. */
  124368. set dPadRight(value: number);
  124369. /**
  124370. * Force the gamepad to synchronize with device values
  124371. */
  124372. update(): void;
  124373. /**
  124374. * Disposes the gamepad
  124375. */
  124376. dispose(): void;
  124377. }
  124378. }
  124379. declare module BABYLON {
  124380. /**
  124381. * Defines supported buttons for DualShock compatible gamepads
  124382. */
  124383. export enum DualShockButton {
  124384. /** Cross */
  124385. Cross = 0,
  124386. /** Circle */
  124387. Circle = 1,
  124388. /** Square */
  124389. Square = 2,
  124390. /** Triangle */
  124391. Triangle = 3,
  124392. /** L1 */
  124393. L1 = 4,
  124394. /** R1 */
  124395. R1 = 5,
  124396. /** Share */
  124397. Share = 8,
  124398. /** Options */
  124399. Options = 9,
  124400. /** Left stick */
  124401. LeftStick = 10,
  124402. /** Right stick */
  124403. RightStick = 11
  124404. }
  124405. /** Defines values for DualShock DPad */
  124406. export enum DualShockDpad {
  124407. /** Up */
  124408. Up = 12,
  124409. /** Down */
  124410. Down = 13,
  124411. /** Left */
  124412. Left = 14,
  124413. /** Right */
  124414. Right = 15
  124415. }
  124416. /**
  124417. * Defines a DualShock gamepad
  124418. */
  124419. export class DualShockPad extends Gamepad {
  124420. private _leftTrigger;
  124421. private _rightTrigger;
  124422. private _onlefttriggerchanged;
  124423. private _onrighttriggerchanged;
  124424. private _onbuttondown;
  124425. private _onbuttonup;
  124426. private _ondpaddown;
  124427. private _ondpadup;
  124428. /** Observable raised when a button is pressed */
  124429. onButtonDownObservable: Observable<DualShockButton>;
  124430. /** Observable raised when a button is released */
  124431. onButtonUpObservable: Observable<DualShockButton>;
  124432. /** Observable raised when a pad is pressed */
  124433. onPadDownObservable: Observable<DualShockDpad>;
  124434. /** Observable raised when a pad is released */
  124435. onPadUpObservable: Observable<DualShockDpad>;
  124436. private _buttonCross;
  124437. private _buttonCircle;
  124438. private _buttonSquare;
  124439. private _buttonTriangle;
  124440. private _buttonShare;
  124441. private _buttonOptions;
  124442. private _buttonL1;
  124443. private _buttonR1;
  124444. private _buttonLeftStick;
  124445. private _buttonRightStick;
  124446. private _dPadUp;
  124447. private _dPadDown;
  124448. private _dPadLeft;
  124449. private _dPadRight;
  124450. /**
  124451. * Creates a new DualShock gamepad object
  124452. * @param id defines the id of this gamepad
  124453. * @param index defines its index
  124454. * @param gamepad defines the internal HTML gamepad object
  124455. */
  124456. constructor(id: string, index: number, gamepad: any);
  124457. /**
  124458. * Defines the callback to call when left trigger is pressed
  124459. * @param callback defines the callback to use
  124460. */
  124461. onlefttriggerchanged(callback: (value: number) => void): void;
  124462. /**
  124463. * Defines the callback to call when right trigger is pressed
  124464. * @param callback defines the callback to use
  124465. */
  124466. onrighttriggerchanged(callback: (value: number) => void): void;
  124467. /**
  124468. * Gets the left trigger value
  124469. */
  124470. get leftTrigger(): number;
  124471. /**
  124472. * Sets the left trigger value
  124473. */
  124474. set leftTrigger(newValue: number);
  124475. /**
  124476. * Gets the right trigger value
  124477. */
  124478. get rightTrigger(): number;
  124479. /**
  124480. * Sets the right trigger value
  124481. */
  124482. set rightTrigger(newValue: number);
  124483. /**
  124484. * Defines the callback to call when a button is pressed
  124485. * @param callback defines the callback to use
  124486. */
  124487. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  124488. /**
  124489. * Defines the callback to call when a button is released
  124490. * @param callback defines the callback to use
  124491. */
  124492. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  124493. /**
  124494. * Defines the callback to call when a pad is pressed
  124495. * @param callback defines the callback to use
  124496. */
  124497. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  124498. /**
  124499. * Defines the callback to call when a pad is released
  124500. * @param callback defines the callback to use
  124501. */
  124502. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  124503. private _setButtonValue;
  124504. private _setDPadValue;
  124505. /**
  124506. * Gets the value of the `Cross` button
  124507. */
  124508. get buttonCross(): number;
  124509. /**
  124510. * Sets the value of the `Cross` button
  124511. */
  124512. set buttonCross(value: number);
  124513. /**
  124514. * Gets the value of the `Circle` button
  124515. */
  124516. get buttonCircle(): number;
  124517. /**
  124518. * Sets the value of the `Circle` button
  124519. */
  124520. set buttonCircle(value: number);
  124521. /**
  124522. * Gets the value of the `Square` button
  124523. */
  124524. get buttonSquare(): number;
  124525. /**
  124526. * Sets the value of the `Square` button
  124527. */
  124528. set buttonSquare(value: number);
  124529. /**
  124530. * Gets the value of the `Triangle` button
  124531. */
  124532. get buttonTriangle(): number;
  124533. /**
  124534. * Sets the value of the `Triangle` button
  124535. */
  124536. set buttonTriangle(value: number);
  124537. /**
  124538. * Gets the value of the `Options` button
  124539. */
  124540. get buttonOptions(): number;
  124541. /**
  124542. * Sets the value of the `Options` button
  124543. */
  124544. set buttonOptions(value: number);
  124545. /**
  124546. * Gets the value of the `Share` button
  124547. */
  124548. get buttonShare(): number;
  124549. /**
  124550. * Sets the value of the `Share` button
  124551. */
  124552. set buttonShare(value: number);
  124553. /**
  124554. * Gets the value of the `L1` button
  124555. */
  124556. get buttonL1(): number;
  124557. /**
  124558. * Sets the value of the `L1` button
  124559. */
  124560. set buttonL1(value: number);
  124561. /**
  124562. * Gets the value of the `R1` button
  124563. */
  124564. get buttonR1(): number;
  124565. /**
  124566. * Sets the value of the `R1` button
  124567. */
  124568. set buttonR1(value: number);
  124569. /**
  124570. * Gets the value of the Left joystick
  124571. */
  124572. get buttonLeftStick(): number;
  124573. /**
  124574. * Sets the value of the Left joystick
  124575. */
  124576. set buttonLeftStick(value: number);
  124577. /**
  124578. * Gets the value of the Right joystick
  124579. */
  124580. get buttonRightStick(): number;
  124581. /**
  124582. * Sets the value of the Right joystick
  124583. */
  124584. set buttonRightStick(value: number);
  124585. /**
  124586. * Gets the value of D-pad up
  124587. */
  124588. get dPadUp(): number;
  124589. /**
  124590. * Sets the value of D-pad up
  124591. */
  124592. set dPadUp(value: number);
  124593. /**
  124594. * Gets the value of D-pad down
  124595. */
  124596. get dPadDown(): number;
  124597. /**
  124598. * Sets the value of D-pad down
  124599. */
  124600. set dPadDown(value: number);
  124601. /**
  124602. * Gets the value of D-pad left
  124603. */
  124604. get dPadLeft(): number;
  124605. /**
  124606. * Sets the value of D-pad left
  124607. */
  124608. set dPadLeft(value: number);
  124609. /**
  124610. * Gets the value of D-pad right
  124611. */
  124612. get dPadRight(): number;
  124613. /**
  124614. * Sets the value of D-pad right
  124615. */
  124616. set dPadRight(value: number);
  124617. /**
  124618. * Force the gamepad to synchronize with device values
  124619. */
  124620. update(): void;
  124621. /**
  124622. * Disposes the gamepad
  124623. */
  124624. dispose(): void;
  124625. }
  124626. }
  124627. declare module BABYLON {
  124628. /**
  124629. * Manager for handling gamepads
  124630. */
  124631. export class GamepadManager {
  124632. private _scene?;
  124633. private _babylonGamepads;
  124634. private _oneGamepadConnected;
  124635. /** @hidden */
  124636. _isMonitoring: boolean;
  124637. private _gamepadEventSupported;
  124638. private _gamepadSupport?;
  124639. /**
  124640. * observable to be triggered when the gamepad controller has been connected
  124641. */
  124642. onGamepadConnectedObservable: Observable<Gamepad>;
  124643. /**
  124644. * observable to be triggered when the gamepad controller has been disconnected
  124645. */
  124646. onGamepadDisconnectedObservable: Observable<Gamepad>;
  124647. private _onGamepadConnectedEvent;
  124648. private _onGamepadDisconnectedEvent;
  124649. /**
  124650. * Initializes the gamepad manager
  124651. * @param _scene BabylonJS scene
  124652. */
  124653. constructor(_scene?: Scene | undefined);
  124654. /**
  124655. * The gamepads in the game pad manager
  124656. */
  124657. get gamepads(): Gamepad[];
  124658. /**
  124659. * Get the gamepad controllers based on type
  124660. * @param type The type of gamepad controller
  124661. * @returns Nullable gamepad
  124662. */
  124663. getGamepadByType(type?: number): Nullable<Gamepad>;
  124664. /**
  124665. * Disposes the gamepad manager
  124666. */
  124667. dispose(): void;
  124668. private _addNewGamepad;
  124669. private _startMonitoringGamepads;
  124670. private _stopMonitoringGamepads;
  124671. /** @hidden */
  124672. _checkGamepadsStatus(): void;
  124673. private _updateGamepadObjects;
  124674. }
  124675. }
  124676. declare module BABYLON {
  124677. interface Scene {
  124678. /** @hidden */
  124679. _gamepadManager: Nullable<GamepadManager>;
  124680. /**
  124681. * Gets the gamepad manager associated with the scene
  124682. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  124683. */
  124684. gamepadManager: GamepadManager;
  124685. }
  124686. /**
  124687. * Interface representing a free camera inputs manager
  124688. */
  124689. interface FreeCameraInputsManager {
  124690. /**
  124691. * Adds gamepad input support to the FreeCameraInputsManager.
  124692. * @returns the FreeCameraInputsManager
  124693. */
  124694. addGamepad(): FreeCameraInputsManager;
  124695. }
  124696. /**
  124697. * Interface representing an arc rotate camera inputs manager
  124698. */
  124699. interface ArcRotateCameraInputsManager {
  124700. /**
  124701. * Adds gamepad input support to the ArcRotateCamera InputManager.
  124702. * @returns the camera inputs manager
  124703. */
  124704. addGamepad(): ArcRotateCameraInputsManager;
  124705. }
  124706. /**
  124707. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  124708. */
  124709. export class GamepadSystemSceneComponent implements ISceneComponent {
  124710. /**
  124711. * The component name helpfull to identify the component in the list of scene components.
  124712. */
  124713. readonly name: string;
  124714. /**
  124715. * The scene the component belongs to.
  124716. */
  124717. scene: Scene;
  124718. /**
  124719. * Creates a new instance of the component for the given scene
  124720. * @param scene Defines the scene to register the component in
  124721. */
  124722. constructor(scene: Scene);
  124723. /**
  124724. * Registers the component in a given scene
  124725. */
  124726. register(): void;
  124727. /**
  124728. * Rebuilds the elements related to this component in case of
  124729. * context lost for instance.
  124730. */
  124731. rebuild(): void;
  124732. /**
  124733. * Disposes the component and the associated ressources
  124734. */
  124735. dispose(): void;
  124736. private _beforeCameraUpdate;
  124737. }
  124738. }
  124739. declare module BABYLON {
  124740. /**
  124741. * 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,
  124742. * which still works and will still be found in many Playgrounds.
  124743. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124744. */
  124745. export class UniversalCamera extends TouchCamera {
  124746. /**
  124747. * Defines the gamepad rotation sensiblity.
  124748. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124749. */
  124750. get gamepadAngularSensibility(): number;
  124751. set gamepadAngularSensibility(value: number);
  124752. /**
  124753. * Defines the gamepad move sensiblity.
  124754. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124755. */
  124756. get gamepadMoveSensibility(): number;
  124757. set gamepadMoveSensibility(value: number);
  124758. /**
  124759. * 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,
  124760. * which still works and will still be found in many Playgrounds.
  124761. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124762. * @param name Define the name of the camera in the scene
  124763. * @param position Define the start position of the camera in the scene
  124764. * @param scene Define the scene the camera belongs to
  124765. */
  124766. constructor(name: string, position: Vector3, scene: Scene);
  124767. /**
  124768. * Gets the current object class name.
  124769. * @return the class name
  124770. */
  124771. getClassName(): string;
  124772. }
  124773. }
  124774. declare module BABYLON {
  124775. /**
  124776. * This represents a FPS type of camera. This is only here for back compat purpose.
  124777. * Please use the UniversalCamera instead as both are identical.
  124778. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124779. */
  124780. export class GamepadCamera extends UniversalCamera {
  124781. /**
  124782. * Instantiates a new Gamepad Camera
  124783. * This represents a FPS type of camera. This is only here for back compat purpose.
  124784. * Please use the UniversalCamera instead as both are identical.
  124785. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  124786. * @param name Define the name of the camera in the scene
  124787. * @param position Define the start position of the camera in the scene
  124788. * @param scene Define the scene the camera belongs to
  124789. */
  124790. constructor(name: string, position: Vector3, scene: Scene);
  124791. /**
  124792. * Gets the current object class name.
  124793. * @return the class name
  124794. */
  124795. getClassName(): string;
  124796. }
  124797. }
  124798. declare module BABYLON {
  124799. /** @hidden */
  124800. export var passPixelShader: {
  124801. name: string;
  124802. shader: string;
  124803. };
  124804. }
  124805. declare module BABYLON {
  124806. /** @hidden */
  124807. export var passCubePixelShader: {
  124808. name: string;
  124809. shader: string;
  124810. };
  124811. }
  124812. declare module BABYLON {
  124813. /**
  124814. * PassPostProcess which produces an output the same as it's input
  124815. */
  124816. export class PassPostProcess extends PostProcess {
  124817. /**
  124818. * Creates the PassPostProcess
  124819. * @param name The name of the effect.
  124820. * @param options The required width/height ratio to downsize to before computing the render pass.
  124821. * @param camera The camera to apply the render pass to.
  124822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124823. * @param engine The engine which the post process will be applied. (default: current engine)
  124824. * @param reusable If the post process can be reused on the same frame. (default: false)
  124825. * @param textureType The type of texture to be used when performing the post processing.
  124826. * @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)
  124827. */
  124828. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124829. }
  124830. /**
  124831. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124832. */
  124833. export class PassCubePostProcess extends PostProcess {
  124834. private _face;
  124835. /**
  124836. * Gets or sets the cube face to display.
  124837. * * 0 is +X
  124838. * * 1 is -X
  124839. * * 2 is +Y
  124840. * * 3 is -Y
  124841. * * 4 is +Z
  124842. * * 5 is -Z
  124843. */
  124844. get face(): number;
  124845. set face(value: number);
  124846. /**
  124847. * Creates the PassCubePostProcess
  124848. * @param name The name of the effect.
  124849. * @param options The required width/height ratio to downsize to before computing the render pass.
  124850. * @param camera The camera to apply the render pass to.
  124851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124852. * @param engine The engine which the post process will be applied. (default: current engine)
  124853. * @param reusable If the post process can be reused on the same frame. (default: false)
  124854. * @param textureType The type of texture to be used when performing the post processing.
  124855. * @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)
  124856. */
  124857. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124858. }
  124859. }
  124860. declare module BABYLON {
  124861. /** @hidden */
  124862. export var anaglyphPixelShader: {
  124863. name: string;
  124864. shader: string;
  124865. };
  124866. }
  124867. declare module BABYLON {
  124868. /**
  124869. * Postprocess used to generate anaglyphic rendering
  124870. */
  124871. export class AnaglyphPostProcess extends PostProcess {
  124872. private _passedProcess;
  124873. /**
  124874. * Creates a new AnaglyphPostProcess
  124875. * @param name defines postprocess name
  124876. * @param options defines creation options or target ratio scale
  124877. * @param rigCameras defines cameras using this postprocess
  124878. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  124879. * @param engine defines hosting engine
  124880. * @param reusable defines if the postprocess will be reused multiple times per frame
  124881. */
  124882. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  124883. }
  124884. }
  124885. declare module BABYLON {
  124886. /**
  124887. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  124888. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124889. */
  124890. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  124891. /**
  124892. * Creates a new AnaglyphArcRotateCamera
  124893. * @param name defines camera name
  124894. * @param alpha defines alpha angle (in radians)
  124895. * @param beta defines beta angle (in radians)
  124896. * @param radius defines radius
  124897. * @param target defines camera target
  124898. * @param interaxialDistance defines distance between each color axis
  124899. * @param scene defines the hosting scene
  124900. */
  124901. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  124902. /**
  124903. * Gets camera class name
  124904. * @returns AnaglyphArcRotateCamera
  124905. */
  124906. getClassName(): string;
  124907. }
  124908. }
  124909. declare module BABYLON {
  124910. /**
  124911. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  124912. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124913. */
  124914. export class AnaglyphFreeCamera extends FreeCamera {
  124915. /**
  124916. * Creates a new AnaglyphFreeCamera
  124917. * @param name defines camera name
  124918. * @param position defines initial position
  124919. * @param interaxialDistance defines distance between each color axis
  124920. * @param scene defines the hosting scene
  124921. */
  124922. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124923. /**
  124924. * Gets camera class name
  124925. * @returns AnaglyphFreeCamera
  124926. */
  124927. getClassName(): string;
  124928. }
  124929. }
  124930. declare module BABYLON {
  124931. /**
  124932. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  124933. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124934. */
  124935. export class AnaglyphGamepadCamera extends GamepadCamera {
  124936. /**
  124937. * Creates a new AnaglyphGamepadCamera
  124938. * @param name defines camera name
  124939. * @param position defines initial position
  124940. * @param interaxialDistance defines distance between each color axis
  124941. * @param scene defines the hosting scene
  124942. */
  124943. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124944. /**
  124945. * Gets camera class name
  124946. * @returns AnaglyphGamepadCamera
  124947. */
  124948. getClassName(): string;
  124949. }
  124950. }
  124951. declare module BABYLON {
  124952. /**
  124953. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  124954. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  124955. */
  124956. export class AnaglyphUniversalCamera extends UniversalCamera {
  124957. /**
  124958. * Creates a new AnaglyphUniversalCamera
  124959. * @param name defines camera name
  124960. * @param position defines initial position
  124961. * @param interaxialDistance defines distance between each color axis
  124962. * @param scene defines the hosting scene
  124963. */
  124964. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  124965. /**
  124966. * Gets camera class name
  124967. * @returns AnaglyphUniversalCamera
  124968. */
  124969. getClassName(): string;
  124970. }
  124971. }
  124972. declare module BABYLON {
  124973. /**
  124974. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  124975. * @see https://doc.babylonjs.com/features/cameras
  124976. */
  124977. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  124978. /**
  124979. * Creates a new StereoscopicArcRotateCamera
  124980. * @param name defines camera name
  124981. * @param alpha defines alpha angle (in radians)
  124982. * @param beta defines beta angle (in radians)
  124983. * @param radius defines radius
  124984. * @param target defines camera target
  124985. * @param interaxialDistance defines distance between each color axis
  124986. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  124987. * @param scene defines the hosting scene
  124988. */
  124989. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  124990. /**
  124991. * Gets camera class name
  124992. * @returns StereoscopicArcRotateCamera
  124993. */
  124994. getClassName(): string;
  124995. }
  124996. }
  124997. declare module BABYLON {
  124998. /**
  124999. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  125000. * @see https://doc.babylonjs.com/features/cameras
  125001. */
  125002. export class StereoscopicFreeCamera extends FreeCamera {
  125003. /**
  125004. * Creates a new StereoscopicFreeCamera
  125005. * @param name defines camera name
  125006. * @param position defines initial position
  125007. * @param interaxialDistance defines distance between each color axis
  125008. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125009. * @param scene defines the hosting scene
  125010. */
  125011. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125012. /**
  125013. * Gets camera class name
  125014. * @returns StereoscopicFreeCamera
  125015. */
  125016. getClassName(): string;
  125017. }
  125018. }
  125019. declare module BABYLON {
  125020. /**
  125021. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  125022. * @see https://doc.babylonjs.com/features/cameras
  125023. */
  125024. export class StereoscopicGamepadCamera extends GamepadCamera {
  125025. /**
  125026. * Creates a new StereoscopicGamepadCamera
  125027. * @param name defines camera name
  125028. * @param position defines initial position
  125029. * @param interaxialDistance defines distance between each color axis
  125030. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125031. * @param scene defines the hosting scene
  125032. */
  125033. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125034. /**
  125035. * Gets camera class name
  125036. * @returns StereoscopicGamepadCamera
  125037. */
  125038. getClassName(): string;
  125039. }
  125040. }
  125041. declare module BABYLON {
  125042. /**
  125043. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  125044. * @see https://doc.babylonjs.com/features/cameras
  125045. */
  125046. export class StereoscopicUniversalCamera extends UniversalCamera {
  125047. /**
  125048. * Creates a new StereoscopicUniversalCamera
  125049. * @param name defines camera name
  125050. * @param position defines initial position
  125051. * @param interaxialDistance defines distance between each color axis
  125052. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  125053. * @param scene defines the hosting scene
  125054. */
  125055. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  125056. /**
  125057. * Gets camera class name
  125058. * @returns StereoscopicUniversalCamera
  125059. */
  125060. getClassName(): string;
  125061. }
  125062. }
  125063. declare module BABYLON {
  125064. /**
  125065. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  125066. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125067. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125068. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125069. */
  125070. export class VirtualJoysticksCamera extends FreeCamera {
  125071. /**
  125072. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  125073. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  125074. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  125075. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  125076. * @param name Define the name of the camera in the scene
  125077. * @param position Define the start position of the camera in the scene
  125078. * @param scene Define the scene the camera belongs to
  125079. */
  125080. constructor(name: string, position: Vector3, scene: Scene);
  125081. /**
  125082. * Gets the current object class name.
  125083. * @return the class name
  125084. */
  125085. getClassName(): string;
  125086. }
  125087. }
  125088. declare module BABYLON {
  125089. /**
  125090. * This represents all the required metrics to create a VR camera.
  125091. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  125092. */
  125093. export class VRCameraMetrics {
  125094. /**
  125095. * Define the horizontal resolution off the screen.
  125096. */
  125097. hResolution: number;
  125098. /**
  125099. * Define the vertical resolution off the screen.
  125100. */
  125101. vResolution: number;
  125102. /**
  125103. * Define the horizontal screen size.
  125104. */
  125105. hScreenSize: number;
  125106. /**
  125107. * Define the vertical screen size.
  125108. */
  125109. vScreenSize: number;
  125110. /**
  125111. * Define the vertical screen center position.
  125112. */
  125113. vScreenCenter: number;
  125114. /**
  125115. * Define the distance of the eyes to the screen.
  125116. */
  125117. eyeToScreenDistance: number;
  125118. /**
  125119. * Define the distance between both lenses
  125120. */
  125121. lensSeparationDistance: number;
  125122. /**
  125123. * Define the distance between both viewer's eyes.
  125124. */
  125125. interpupillaryDistance: number;
  125126. /**
  125127. * Define the distortion factor of the VR postprocess.
  125128. * Please, touch with care.
  125129. */
  125130. distortionK: number[];
  125131. /**
  125132. * Define the chromatic aberration correction factors for the VR post process.
  125133. */
  125134. chromaAbCorrection: number[];
  125135. /**
  125136. * Define the scale factor of the post process.
  125137. * The smaller the better but the slower.
  125138. */
  125139. postProcessScaleFactor: number;
  125140. /**
  125141. * Define an offset for the lens center.
  125142. */
  125143. lensCenterOffset: number;
  125144. /**
  125145. * Define if the current vr camera should compensate the distortion of the lense or not.
  125146. */
  125147. compensateDistortion: boolean;
  125148. /**
  125149. * Defines if multiview should be enabled when rendering (Default: false)
  125150. */
  125151. multiviewEnabled: boolean;
  125152. /**
  125153. * Gets the rendering aspect ratio based on the provided resolutions.
  125154. */
  125155. get aspectRatio(): number;
  125156. /**
  125157. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  125158. */
  125159. get aspectRatioFov(): number;
  125160. /**
  125161. * @hidden
  125162. */
  125163. get leftHMatrix(): Matrix;
  125164. /**
  125165. * @hidden
  125166. */
  125167. get rightHMatrix(): Matrix;
  125168. /**
  125169. * @hidden
  125170. */
  125171. get leftPreViewMatrix(): Matrix;
  125172. /**
  125173. * @hidden
  125174. */
  125175. get rightPreViewMatrix(): Matrix;
  125176. /**
  125177. * Get the default VRMetrics based on the most generic setup.
  125178. * @returns the default vr metrics
  125179. */
  125180. static GetDefault(): VRCameraMetrics;
  125181. }
  125182. }
  125183. declare module BABYLON {
  125184. /** @hidden */
  125185. export var vrDistortionCorrectionPixelShader: {
  125186. name: string;
  125187. shader: string;
  125188. };
  125189. }
  125190. declare module BABYLON {
  125191. /**
  125192. * VRDistortionCorrectionPostProcess used for mobile VR
  125193. */
  125194. export class VRDistortionCorrectionPostProcess extends PostProcess {
  125195. private _isRightEye;
  125196. private _distortionFactors;
  125197. private _postProcessScaleFactor;
  125198. private _lensCenterOffset;
  125199. private _scaleIn;
  125200. private _scaleFactor;
  125201. private _lensCenter;
  125202. /**
  125203. * Initializes the VRDistortionCorrectionPostProcess
  125204. * @param name The name of the effect.
  125205. * @param camera The camera to apply the render pass to.
  125206. * @param isRightEye If this is for the right eye distortion
  125207. * @param vrMetrics All the required metrics for the VR camera
  125208. */
  125209. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  125210. }
  125211. }
  125212. declare module BABYLON {
  125213. /**
  125214. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  125215. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125216. */
  125217. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  125218. /**
  125219. * Creates a new VRDeviceOrientationArcRotateCamera
  125220. * @param name defines camera name
  125221. * @param alpha defines the camera rotation along the logitudinal axis
  125222. * @param beta defines the camera rotation along the latitudinal axis
  125223. * @param radius defines the camera distance from its target
  125224. * @param target defines the camera target
  125225. * @param scene defines the scene the camera belongs to
  125226. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125227. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125228. */
  125229. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125230. /**
  125231. * Gets camera class name
  125232. * @returns VRDeviceOrientationArcRotateCamera
  125233. */
  125234. getClassName(): string;
  125235. }
  125236. }
  125237. declare module BABYLON {
  125238. /**
  125239. * Camera used to simulate VR rendering (based on FreeCamera)
  125240. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125241. */
  125242. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  125243. /**
  125244. * Creates a new VRDeviceOrientationFreeCamera
  125245. * @param name defines camera name
  125246. * @param position defines the start position of the camera
  125247. * @param scene defines the scene the camera belongs to
  125248. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125249. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125250. */
  125251. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125252. /**
  125253. * Gets camera class name
  125254. * @returns VRDeviceOrientationFreeCamera
  125255. */
  125256. getClassName(): string;
  125257. }
  125258. }
  125259. declare module BABYLON {
  125260. /**
  125261. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  125262. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  125263. */
  125264. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  125265. /**
  125266. * Creates a new VRDeviceOrientationGamepadCamera
  125267. * @param name defines camera name
  125268. * @param position defines the start position of the camera
  125269. * @param scene defines the scene the camera belongs to
  125270. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  125271. * @param vrCameraMetrics defines the vr metrics associated to the camera
  125272. */
  125273. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  125274. /**
  125275. * Gets camera class name
  125276. * @returns VRDeviceOrientationGamepadCamera
  125277. */
  125278. getClassName(): string;
  125279. }
  125280. }
  125281. declare module BABYLON {
  125282. /**
  125283. * A class extending Texture allowing drawing on a texture
  125284. * @see https://doc.babylonjs.com/how_to/dynamictexture
  125285. */
  125286. export class DynamicTexture extends Texture {
  125287. private _generateMipMaps;
  125288. private _canvas;
  125289. private _context;
  125290. /**
  125291. * Creates a DynamicTexture
  125292. * @param name defines the name of the texture
  125293. * @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
  125294. * @param scene defines the scene where you want the texture
  125295. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  125296. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  125297. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  125298. */
  125299. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  125300. /**
  125301. * Get the current class name of the texture useful for serialization or dynamic coding.
  125302. * @returns "DynamicTexture"
  125303. */
  125304. getClassName(): string;
  125305. /**
  125306. * Gets the current state of canRescale
  125307. */
  125308. get canRescale(): boolean;
  125309. private _recreate;
  125310. /**
  125311. * Scales the texture
  125312. * @param ratio the scale factor to apply to both width and height
  125313. */
  125314. scale(ratio: number): void;
  125315. /**
  125316. * Resizes the texture
  125317. * @param width the new width
  125318. * @param height the new height
  125319. */
  125320. scaleTo(width: number, height: number): void;
  125321. /**
  125322. * Gets the context of the canvas used by the texture
  125323. * @returns the canvas context of the dynamic texture
  125324. */
  125325. getContext(): CanvasRenderingContext2D;
  125326. /**
  125327. * Clears the texture
  125328. */
  125329. clear(): void;
  125330. /**
  125331. * Updates the texture
  125332. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125333. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  125334. */
  125335. update(invertY?: boolean, premulAlpha?: boolean): void;
  125336. /**
  125337. * Draws text onto the texture
  125338. * @param text defines the text to be drawn
  125339. * @param x defines the placement of the text from the left
  125340. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  125341. * @param font defines the font to be used with font-style, font-size, font-name
  125342. * @param color defines the color used for the text
  125343. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  125344. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  125345. * @param update defines whether texture is immediately update (default is true)
  125346. */
  125347. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  125348. /**
  125349. * Clones the texture
  125350. * @returns the clone of the texture.
  125351. */
  125352. clone(): DynamicTexture;
  125353. /**
  125354. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  125355. * @returns a serialized dynamic texture object
  125356. */
  125357. serialize(): any;
  125358. private _IsCanvasElement;
  125359. /** @hidden */
  125360. _rebuild(): void;
  125361. }
  125362. }
  125363. declare module BABYLON {
  125364. /**
  125365. * Class containing static functions to help procedurally build meshes
  125366. */
  125367. export class GroundBuilder {
  125368. /**
  125369. * Creates a ground mesh
  125370. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  125371. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  125372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125373. * @param name defines the name of the mesh
  125374. * @param options defines the options used to create the mesh
  125375. * @param scene defines the hosting scene
  125376. * @returns the ground mesh
  125377. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  125378. */
  125379. static CreateGround(name: string, options: {
  125380. width?: number;
  125381. height?: number;
  125382. subdivisions?: number;
  125383. subdivisionsX?: number;
  125384. subdivisionsY?: number;
  125385. updatable?: boolean;
  125386. }, scene: any): Mesh;
  125387. /**
  125388. * Creates a tiled ground mesh
  125389. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  125390. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  125391. * * 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
  125392. * * 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
  125393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125394. * @param name defines the name of the mesh
  125395. * @param options defines the options used to create the mesh
  125396. * @param scene defines the hosting scene
  125397. * @returns the tiled ground mesh
  125398. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  125399. */
  125400. static CreateTiledGround(name: string, options: {
  125401. xmin: number;
  125402. zmin: number;
  125403. xmax: number;
  125404. zmax: number;
  125405. subdivisions?: {
  125406. w: number;
  125407. h: number;
  125408. };
  125409. precision?: {
  125410. w: number;
  125411. h: number;
  125412. };
  125413. updatable?: boolean;
  125414. }, scene?: Nullable<Scene>): Mesh;
  125415. /**
  125416. * Creates a ground mesh from a height map
  125417. * * The parameter `url` sets the URL of the height map image resource.
  125418. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  125419. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  125420. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  125421. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  125422. * * 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.
  125423. * * 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).
  125424. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  125425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125426. * @param name defines the name of the mesh
  125427. * @param url defines the url to the height map
  125428. * @param options defines the options used to create the mesh
  125429. * @param scene defines the hosting scene
  125430. * @returns the ground mesh
  125431. * @see https://doc.babylonjs.com/babylon101/height_map
  125432. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  125433. */
  125434. static CreateGroundFromHeightMap(name: string, url: string, options: {
  125435. width?: number;
  125436. height?: number;
  125437. subdivisions?: number;
  125438. minHeight?: number;
  125439. maxHeight?: number;
  125440. colorFilter?: Color3;
  125441. alphaFilter?: number;
  125442. updatable?: boolean;
  125443. onReady?: (mesh: GroundMesh) => void;
  125444. }, scene?: Nullable<Scene>): GroundMesh;
  125445. }
  125446. }
  125447. declare module BABYLON {
  125448. /**
  125449. * Class containing static functions to help procedurally build meshes
  125450. */
  125451. export class TorusBuilder {
  125452. /**
  125453. * Creates a torus mesh
  125454. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125455. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125456. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125460. * @param name defines the name of the mesh
  125461. * @param options defines the options used to create the mesh
  125462. * @param scene defines the hosting scene
  125463. * @returns the torus mesh
  125464. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  125465. */
  125466. static CreateTorus(name: string, options: {
  125467. diameter?: number;
  125468. thickness?: number;
  125469. tessellation?: number;
  125470. updatable?: boolean;
  125471. sideOrientation?: number;
  125472. frontUVs?: Vector4;
  125473. backUVs?: Vector4;
  125474. }, scene: any): Mesh;
  125475. }
  125476. }
  125477. declare module BABYLON {
  125478. /**
  125479. * Class containing static functions to help procedurally build meshes
  125480. */
  125481. export class CylinderBuilder {
  125482. /**
  125483. * Creates a cylinder or a cone mesh
  125484. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125485. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125486. * * 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.
  125487. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125488. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125489. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125490. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125491. * * 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).
  125492. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125493. * * 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).
  125494. * * 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
  125495. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125496. * * 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
  125497. * * 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.
  125498. * * If `enclose` is false, a ring surface is one element.
  125499. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125500. * * 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
  125501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125504. * @param name defines the name of the mesh
  125505. * @param options defines the options used to create the mesh
  125506. * @param scene defines the hosting scene
  125507. * @returns the cylinder mesh
  125508. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125509. */
  125510. static CreateCylinder(name: string, options: {
  125511. height?: number;
  125512. diameterTop?: number;
  125513. diameterBottom?: number;
  125514. diameter?: number;
  125515. tessellation?: number;
  125516. subdivisions?: number;
  125517. arc?: number;
  125518. faceColors?: Color4[];
  125519. faceUV?: Vector4[];
  125520. updatable?: boolean;
  125521. hasRings?: boolean;
  125522. enclose?: boolean;
  125523. cap?: number;
  125524. sideOrientation?: number;
  125525. frontUVs?: Vector4;
  125526. backUVs?: Vector4;
  125527. }, scene: any): Mesh;
  125528. }
  125529. }
  125530. declare module BABYLON {
  125531. /**
  125532. * States of the webXR experience
  125533. */
  125534. export enum WebXRState {
  125535. /**
  125536. * Transitioning to being in XR mode
  125537. */
  125538. ENTERING_XR = 0,
  125539. /**
  125540. * Transitioning to non XR mode
  125541. */
  125542. EXITING_XR = 1,
  125543. /**
  125544. * In XR mode and presenting
  125545. */
  125546. IN_XR = 2,
  125547. /**
  125548. * Not entered XR mode
  125549. */
  125550. NOT_IN_XR = 3
  125551. }
  125552. /**
  125553. * Abstraction of the XR render target
  125554. */
  125555. export interface WebXRRenderTarget extends IDisposable {
  125556. /**
  125557. * xrpresent context of the canvas which can be used to display/mirror xr content
  125558. */
  125559. canvasContext: WebGLRenderingContext;
  125560. /**
  125561. * xr layer for the canvas
  125562. */
  125563. xrLayer: Nullable<XRWebGLLayer>;
  125564. /**
  125565. * Initializes the xr layer for the session
  125566. * @param xrSession xr session
  125567. * @returns a promise that will resolve once the XR Layer has been created
  125568. */
  125569. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125570. }
  125571. }
  125572. declare module BABYLON {
  125573. /**
  125574. * COnfiguration object for WebXR output canvas
  125575. */
  125576. export class WebXRManagedOutputCanvasOptions {
  125577. /**
  125578. * An optional canvas in case you wish to create it yourself and provide it here.
  125579. * If not provided, a new canvas will be created
  125580. */
  125581. canvasElement?: HTMLCanvasElement;
  125582. /**
  125583. * Options for this XR Layer output
  125584. */
  125585. canvasOptions?: XRWebGLLayerOptions;
  125586. /**
  125587. * CSS styling for a newly created canvas (if not provided)
  125588. */
  125589. newCanvasCssStyle?: string;
  125590. /**
  125591. * Get the default values of the configuration object
  125592. * @returns default values of this configuration object
  125593. */
  125594. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  125595. }
  125596. /**
  125597. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  125598. */
  125599. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  125600. private _options;
  125601. private _canvas;
  125602. private _engine;
  125603. private _originalCanvasSize;
  125604. /**
  125605. * Rendering context of the canvas which can be used to display/mirror xr content
  125606. */
  125607. canvasContext: WebGLRenderingContext;
  125608. /**
  125609. * xr layer for the canvas
  125610. */
  125611. xrLayer: Nullable<XRWebGLLayer>;
  125612. /**
  125613. * Obseervers registered here will be triggered when the xr layer was initialized
  125614. */
  125615. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  125616. /**
  125617. * Initializes the canvas to be added/removed upon entering/exiting xr
  125618. * @param _xrSessionManager The XR Session manager
  125619. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  125620. */
  125621. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  125622. /**
  125623. * Disposes of the object
  125624. */
  125625. dispose(): void;
  125626. /**
  125627. * Initializes the xr layer for the session
  125628. * @param xrSession xr session
  125629. * @returns a promise that will resolve once the XR Layer has been created
  125630. */
  125631. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  125632. private _addCanvas;
  125633. private _removeCanvas;
  125634. private _setCanvasSize;
  125635. private _setManagedOutputCanvas;
  125636. }
  125637. }
  125638. declare module BABYLON {
  125639. /**
  125640. * Manages an XRSession to work with Babylon's engine
  125641. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  125642. */
  125643. export class WebXRSessionManager implements IDisposable {
  125644. /** The scene which the session should be created for */
  125645. scene: Scene;
  125646. private _referenceSpace;
  125647. private _rttProvider;
  125648. private _sessionEnded;
  125649. private _xrNavigator;
  125650. private baseLayer;
  125651. /**
  125652. * The base reference space from which the session started. good if you want to reset your
  125653. * reference space
  125654. */
  125655. baseReferenceSpace: XRReferenceSpace;
  125656. /**
  125657. * Current XR frame
  125658. */
  125659. currentFrame: Nullable<XRFrame>;
  125660. /** WebXR timestamp updated every frame */
  125661. currentTimestamp: number;
  125662. /**
  125663. * Used just in case of a failure to initialize an immersive session.
  125664. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  125665. */
  125666. defaultHeightCompensation: number;
  125667. /**
  125668. * Fires every time a new xrFrame arrives which can be used to update the camera
  125669. */
  125670. onXRFrameObservable: Observable<XRFrame>;
  125671. /**
  125672. * Fires when the reference space changed
  125673. */
  125674. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  125675. /**
  125676. * Fires when the xr session is ended either by the device or manually done
  125677. */
  125678. onXRSessionEnded: Observable<any>;
  125679. /**
  125680. * Fires when the xr session is ended either by the device or manually done
  125681. */
  125682. onXRSessionInit: Observable<XRSession>;
  125683. /**
  125684. * Underlying xr session
  125685. */
  125686. session: XRSession;
  125687. /**
  125688. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  125689. * or get the offset the player is currently at.
  125690. */
  125691. viewerReferenceSpace: XRReferenceSpace;
  125692. /**
  125693. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  125694. * @param scene The scene which the session should be created for
  125695. */
  125696. constructor(
  125697. /** The scene which the session should be created for */
  125698. scene: Scene);
  125699. /**
  125700. * The current reference space used in this session. This reference space can constantly change!
  125701. * It is mainly used to offset the camera's position.
  125702. */
  125703. get referenceSpace(): XRReferenceSpace;
  125704. /**
  125705. * Set a new reference space and triggers the observable
  125706. */
  125707. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  125708. /**
  125709. * Disposes of the session manager
  125710. */
  125711. dispose(): void;
  125712. /**
  125713. * Stops the xrSession and restores the render loop
  125714. * @returns Promise which resolves after it exits XR
  125715. */
  125716. exitXRAsync(): Promise<void>;
  125717. /**
  125718. * Gets the correct render target texture to be rendered this frame for this eye
  125719. * @param eye the eye for which to get the render target
  125720. * @returns the render target for the specified eye
  125721. */
  125722. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  125723. /**
  125724. * Creates a WebXRRenderTarget object for the XR session
  125725. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  125726. * @param options optional options to provide when creating a new render target
  125727. * @returns a WebXR render target to which the session can render
  125728. */
  125729. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  125730. /**
  125731. * Initializes the manager
  125732. * After initialization enterXR can be called to start an XR session
  125733. * @returns Promise which resolves after it is initialized
  125734. */
  125735. initializeAsync(): Promise<void>;
  125736. /**
  125737. * Initializes an xr session
  125738. * @param xrSessionMode mode to initialize
  125739. * @param xrSessionInit defines optional and required values to pass to the session builder
  125740. * @returns a promise which will resolve once the session has been initialized
  125741. */
  125742. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  125743. /**
  125744. * Checks if a session would be supported for the creation options specified
  125745. * @param sessionMode session mode to check if supported eg. immersive-vr
  125746. * @returns A Promise that resolves to true if supported and false if not
  125747. */
  125748. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125749. /**
  125750. * Resets the reference space to the one started the session
  125751. */
  125752. resetReferenceSpace(): void;
  125753. /**
  125754. * Starts rendering to the xr layer
  125755. */
  125756. runXRRenderLoop(): void;
  125757. /**
  125758. * Sets the reference space on the xr session
  125759. * @param referenceSpaceType space to set
  125760. * @returns a promise that will resolve once the reference space has been set
  125761. */
  125762. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125763. /**
  125764. * Updates the render state of the session
  125765. * @param state state to set
  125766. * @returns a promise that resolves once the render state has been updated
  125767. */
  125768. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  125769. /**
  125770. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  125771. * @param sessionMode defines the session to test
  125772. * @returns a promise with boolean as final value
  125773. */
  125774. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  125775. private _createRenderTargetTexture;
  125776. }
  125777. }
  125778. declare module BABYLON {
  125779. /**
  125780. * WebXR Camera which holds the views for the xrSession
  125781. * @see https://doc.babylonjs.com/how_to/webxr_camera
  125782. */
  125783. export class WebXRCamera extends FreeCamera {
  125784. private _xrSessionManager;
  125785. private _firstFrame;
  125786. private _referenceQuaternion;
  125787. private _referencedPosition;
  125788. private _xrInvPositionCache;
  125789. private _xrInvQuaternionCache;
  125790. /**
  125791. * Observable raised before camera teleportation
  125792. */
  125793. onBeforeCameraTeleport: Observable<Vector3>;
  125794. /**
  125795. * Observable raised after camera teleportation
  125796. */
  125797. onAfterCameraTeleport: Observable<Vector3>;
  125798. /**
  125799. * Should position compensation execute on first frame.
  125800. * This is used when copying the position from a native (non XR) camera
  125801. */
  125802. compensateOnFirstFrame: boolean;
  125803. /**
  125804. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  125805. * @param name the name of the camera
  125806. * @param scene the scene to add the camera to
  125807. * @param _xrSessionManager a constructed xr session manager
  125808. */
  125809. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  125810. /**
  125811. * Return the user's height, unrelated to the current ground.
  125812. * This will be the y position of this camera, when ground level is 0.
  125813. */
  125814. get realWorldHeight(): number;
  125815. /** @hidden */
  125816. _updateForDualEyeDebugging(): void;
  125817. /**
  125818. * Sets this camera's transformation based on a non-vr camera
  125819. * @param otherCamera the non-vr camera to copy the transformation from
  125820. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  125821. */
  125822. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  125823. /**
  125824. * Gets the current instance class name ("WebXRCamera").
  125825. * @returns the class name
  125826. */
  125827. getClassName(): string;
  125828. private _rotate180;
  125829. private _updateFromXRSession;
  125830. private _updateNumberOfRigCameras;
  125831. private _updateReferenceSpace;
  125832. private _updateReferenceSpaceOffset;
  125833. }
  125834. }
  125835. declare module BABYLON {
  125836. /**
  125837. * Defining the interface required for a (webxr) feature
  125838. */
  125839. export interface IWebXRFeature extends IDisposable {
  125840. /**
  125841. * Is this feature attached
  125842. */
  125843. attached: boolean;
  125844. /**
  125845. * Should auto-attach be disabled?
  125846. */
  125847. disableAutoAttach: boolean;
  125848. /**
  125849. * Attach the feature to the session
  125850. * Will usually be called by the features manager
  125851. *
  125852. * @param force should attachment be forced (even when already attached)
  125853. * @returns true if successful.
  125854. */
  125855. attach(force?: boolean): boolean;
  125856. /**
  125857. * Detach the feature from the session
  125858. * Will usually be called by the features manager
  125859. *
  125860. * @returns true if successful.
  125861. */
  125862. detach(): boolean;
  125863. /**
  125864. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  125865. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  125866. *
  125867. * @returns whether or not the feature is compatible in this environment
  125868. */
  125869. isCompatible(): boolean;
  125870. /**
  125871. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  125872. */
  125873. xrNativeFeatureName?: string;
  125874. }
  125875. /**
  125876. * A list of the currently available features without referencing them
  125877. */
  125878. export class WebXRFeatureName {
  125879. /**
  125880. * The name of the anchor system feature
  125881. */
  125882. static ANCHOR_SYSTEM: string;
  125883. /**
  125884. * The name of the background remover feature
  125885. */
  125886. static BACKGROUND_REMOVER: string;
  125887. /**
  125888. * The name of the hit test feature
  125889. */
  125890. static HIT_TEST: string;
  125891. /**
  125892. * physics impostors for xr controllers feature
  125893. */
  125894. static PHYSICS_CONTROLLERS: string;
  125895. /**
  125896. * The name of the plane detection feature
  125897. */
  125898. static PLANE_DETECTION: string;
  125899. /**
  125900. * The name of the pointer selection feature
  125901. */
  125902. static POINTER_SELECTION: string;
  125903. /**
  125904. * The name of the teleportation feature
  125905. */
  125906. static TELEPORTATION: string;
  125907. }
  125908. /**
  125909. * Defining the constructor of a feature. Used to register the modules.
  125910. */
  125911. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  125912. /**
  125913. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  125914. * It is mainly used in AR sessions.
  125915. *
  125916. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  125917. */
  125918. export class WebXRFeaturesManager implements IDisposable {
  125919. private _xrSessionManager;
  125920. private static readonly _AvailableFeatures;
  125921. private _features;
  125922. /**
  125923. * constructs a new features manages.
  125924. *
  125925. * @param _xrSessionManager an instance of WebXRSessionManager
  125926. */
  125927. constructor(_xrSessionManager: WebXRSessionManager);
  125928. /**
  125929. * Used to register a module. After calling this function a developer can use this feature in the scene.
  125930. * Mainly used internally.
  125931. *
  125932. * @param featureName the name of the feature to register
  125933. * @param constructorFunction the function used to construct the module
  125934. * @param version the (babylon) version of the module
  125935. * @param stable is that a stable version of this module
  125936. */
  125937. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  125938. /**
  125939. * Returns a constructor of a specific feature.
  125940. *
  125941. * @param featureName the name of the feature to construct
  125942. * @param version the version of the feature to load
  125943. * @param xrSessionManager the xrSessionManager. Used to construct the module
  125944. * @param options optional options provided to the module.
  125945. * @returns a function that, when called, will return a new instance of this feature
  125946. */
  125947. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  125948. /**
  125949. * Can be used to return the list of features currently registered
  125950. *
  125951. * @returns an Array of available features
  125952. */
  125953. static GetAvailableFeatures(): string[];
  125954. /**
  125955. * Gets the versions available for a specific feature
  125956. * @param featureName the name of the feature
  125957. * @returns an array with the available versions
  125958. */
  125959. static GetAvailableVersions(featureName: string): string[];
  125960. /**
  125961. * Return the latest unstable version of this feature
  125962. * @param featureName the name of the feature to search
  125963. * @returns the version number. if not found will return -1
  125964. */
  125965. static GetLatestVersionOfFeature(featureName: string): number;
  125966. /**
  125967. * Return the latest stable version of this feature
  125968. * @param featureName the name of the feature to search
  125969. * @returns the version number. if not found will return -1
  125970. */
  125971. static GetStableVersionOfFeature(featureName: string): number;
  125972. /**
  125973. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  125974. * Can be used during a session to start a feature
  125975. * @param featureName the name of feature to attach
  125976. */
  125977. attachFeature(featureName: string): void;
  125978. /**
  125979. * Can be used inside a session or when the session ends to detach a specific feature
  125980. * @param featureName the name of the feature to detach
  125981. */
  125982. detachFeature(featureName: string): void;
  125983. /**
  125984. * Used to disable an already-enabled feature
  125985. * The feature will be disposed and will be recreated once enabled.
  125986. * @param featureName the feature to disable
  125987. * @returns true if disable was successful
  125988. */
  125989. disableFeature(featureName: string | {
  125990. Name: string;
  125991. }): boolean;
  125992. /**
  125993. * dispose this features manager
  125994. */
  125995. dispose(): void;
  125996. /**
  125997. * 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.
  125998. * 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.
  125999. *
  126000. * @param featureName the name of the feature to load or the class of the feature
  126001. * @param version optional version to load. if not provided the latest version will be enabled
  126002. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  126003. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  126004. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  126005. * @returns a new constructed feature or throws an error if feature not found.
  126006. */
  126007. enableFeature(featureName: string | {
  126008. Name: string;
  126009. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  126010. /**
  126011. * get the implementation of an enabled feature.
  126012. * @param featureName the name of the feature to load
  126013. * @returns the feature class, if found
  126014. */
  126015. getEnabledFeature(featureName: string): IWebXRFeature;
  126016. /**
  126017. * Get the list of enabled features
  126018. * @returns an array of enabled features
  126019. */
  126020. getEnabledFeatures(): string[];
  126021. /**
  126022. * This function will exten the session creation configuration object with enabled features.
  126023. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  126024. * according to the defined "required" variable, provided during enableFeature call
  126025. * @param xrSessionInit the xr Session init object to extend
  126026. *
  126027. * @returns an extended XRSessionInit object
  126028. */
  126029. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  126030. }
  126031. }
  126032. declare module BABYLON {
  126033. /**
  126034. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  126035. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  126036. */
  126037. export class WebXRExperienceHelper implements IDisposable {
  126038. private scene;
  126039. private _nonVRCamera;
  126040. private _originalSceneAutoClear;
  126041. private _supported;
  126042. /**
  126043. * Camera used to render xr content
  126044. */
  126045. camera: WebXRCamera;
  126046. /** A features manager for this xr session */
  126047. featuresManager: WebXRFeaturesManager;
  126048. /**
  126049. * Observers registered here will be triggered after the camera's initial transformation is set
  126050. * This can be used to set a different ground level or an extra rotation.
  126051. *
  126052. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  126053. * to the position set after this observable is done executing.
  126054. */
  126055. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  126056. /**
  126057. * Fires when the state of the experience helper has changed
  126058. */
  126059. onStateChangedObservable: Observable<WebXRState>;
  126060. /** Session manager used to keep track of xr session */
  126061. sessionManager: WebXRSessionManager;
  126062. /**
  126063. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  126064. */
  126065. state: WebXRState;
  126066. /**
  126067. * Creates a WebXRExperienceHelper
  126068. * @param scene The scene the helper should be created in
  126069. */
  126070. private constructor();
  126071. /**
  126072. * Creates the experience helper
  126073. * @param scene the scene to attach the experience helper to
  126074. * @returns a promise for the experience helper
  126075. */
  126076. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  126077. /**
  126078. * Disposes of the experience helper
  126079. */
  126080. dispose(): void;
  126081. /**
  126082. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  126083. * @param sessionMode options for the XR session
  126084. * @param referenceSpaceType frame of reference of the XR session
  126085. * @param renderTarget the output canvas that will be used to enter XR mode
  126086. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  126087. * @returns promise that resolves after xr mode has entered
  126088. */
  126089. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  126090. /**
  126091. * Exits XR mode and returns the scene to its original state
  126092. * @returns promise that resolves after xr mode has exited
  126093. */
  126094. exitXRAsync(): Promise<void>;
  126095. private _nonXRToXRCamera;
  126096. private _setState;
  126097. }
  126098. }
  126099. declare module BABYLON {
  126100. /**
  126101. * X-Y values for axes in WebXR
  126102. */
  126103. export interface IWebXRMotionControllerAxesValue {
  126104. /**
  126105. * The value of the x axis
  126106. */
  126107. x: number;
  126108. /**
  126109. * The value of the y-axis
  126110. */
  126111. y: number;
  126112. }
  126113. /**
  126114. * changed / previous values for the values of this component
  126115. */
  126116. export interface IWebXRMotionControllerComponentChangesValues<T> {
  126117. /**
  126118. * current (this frame) value
  126119. */
  126120. current: T;
  126121. /**
  126122. * previous (last change) value
  126123. */
  126124. previous: T;
  126125. }
  126126. /**
  126127. * Represents changes in the component between current frame and last values recorded
  126128. */
  126129. export interface IWebXRMotionControllerComponentChanges {
  126130. /**
  126131. * will be populated with previous and current values if axes changed
  126132. */
  126133. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  126134. /**
  126135. * will be populated with previous and current values if pressed changed
  126136. */
  126137. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126138. /**
  126139. * will be populated with previous and current values if touched changed
  126140. */
  126141. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  126142. /**
  126143. * will be populated with previous and current values if value changed
  126144. */
  126145. value?: IWebXRMotionControllerComponentChangesValues<number>;
  126146. }
  126147. /**
  126148. * This class represents a single component (for example button or thumbstick) of a motion controller
  126149. */
  126150. export class WebXRControllerComponent implements IDisposable {
  126151. /**
  126152. * the id of this component
  126153. */
  126154. id: string;
  126155. /**
  126156. * the type of the component
  126157. */
  126158. type: MotionControllerComponentType;
  126159. private _buttonIndex;
  126160. private _axesIndices;
  126161. private _axes;
  126162. private _changes;
  126163. private _currentValue;
  126164. private _hasChanges;
  126165. private _pressed;
  126166. private _touched;
  126167. /**
  126168. * button component type
  126169. */
  126170. static BUTTON_TYPE: MotionControllerComponentType;
  126171. /**
  126172. * squeeze component type
  126173. */
  126174. static SQUEEZE_TYPE: MotionControllerComponentType;
  126175. /**
  126176. * Thumbstick component type
  126177. */
  126178. static THUMBSTICK_TYPE: MotionControllerComponentType;
  126179. /**
  126180. * Touchpad component type
  126181. */
  126182. static TOUCHPAD_TYPE: MotionControllerComponentType;
  126183. /**
  126184. * trigger component type
  126185. */
  126186. static TRIGGER_TYPE: MotionControllerComponentType;
  126187. /**
  126188. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  126189. * the axes data changes
  126190. */
  126191. onAxisValueChangedObservable: Observable<{
  126192. x: number;
  126193. y: number;
  126194. }>;
  126195. /**
  126196. * Observers registered here will be triggered when the state of a button changes
  126197. * State change is either pressed / touched / value
  126198. */
  126199. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  126200. /**
  126201. * Creates a new component for a motion controller.
  126202. * It is created by the motion controller itself
  126203. *
  126204. * @param id the id of this component
  126205. * @param type the type of the component
  126206. * @param _buttonIndex index in the buttons array of the gamepad
  126207. * @param _axesIndices indices of the values in the axes array of the gamepad
  126208. */
  126209. constructor(
  126210. /**
  126211. * the id of this component
  126212. */
  126213. id: string,
  126214. /**
  126215. * the type of the component
  126216. */
  126217. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  126218. /**
  126219. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  126220. */
  126221. get axes(): IWebXRMotionControllerAxesValue;
  126222. /**
  126223. * Get the changes. Elements will be populated only if they changed with their previous and current value
  126224. */
  126225. get changes(): IWebXRMotionControllerComponentChanges;
  126226. /**
  126227. * Return whether or not the component changed the last frame
  126228. */
  126229. get hasChanges(): boolean;
  126230. /**
  126231. * is the button currently pressed
  126232. */
  126233. get pressed(): boolean;
  126234. /**
  126235. * is the button currently touched
  126236. */
  126237. get touched(): boolean;
  126238. /**
  126239. * Get the current value of this component
  126240. */
  126241. get value(): number;
  126242. /**
  126243. * Dispose this component
  126244. */
  126245. dispose(): void;
  126246. /**
  126247. * Are there axes correlating to this component
  126248. * @return true is axes data is available
  126249. */
  126250. isAxes(): boolean;
  126251. /**
  126252. * Is this component a button (hence - pressable)
  126253. * @returns true if can be pressed
  126254. */
  126255. isButton(): boolean;
  126256. /**
  126257. * update this component using the gamepad object it is in. Called on every frame
  126258. * @param nativeController the native gamepad controller object
  126259. */
  126260. update(nativeController: IMinimalMotionControllerObject): void;
  126261. }
  126262. }
  126263. declare module BABYLON {
  126264. /**
  126265. * Interface used to represent data loading progression
  126266. */
  126267. export interface ISceneLoaderProgressEvent {
  126268. /**
  126269. * Defines if data length to load can be evaluated
  126270. */
  126271. readonly lengthComputable: boolean;
  126272. /**
  126273. * Defines the loaded data length
  126274. */
  126275. readonly loaded: number;
  126276. /**
  126277. * Defines the data length to load
  126278. */
  126279. readonly total: number;
  126280. }
  126281. /**
  126282. * Interface used by SceneLoader plugins to define supported file extensions
  126283. */
  126284. export interface ISceneLoaderPluginExtensions {
  126285. /**
  126286. * Defines the list of supported extensions
  126287. */
  126288. [extension: string]: {
  126289. isBinary: boolean;
  126290. };
  126291. }
  126292. /**
  126293. * Interface used by SceneLoader plugin factory
  126294. */
  126295. export interface ISceneLoaderPluginFactory {
  126296. /**
  126297. * Defines the name of the factory
  126298. */
  126299. name: string;
  126300. /**
  126301. * Function called to create a new plugin
  126302. * @return the new plugin
  126303. */
  126304. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  126305. /**
  126306. * The callback that returns true if the data can be directly loaded.
  126307. * @param data string containing the file data
  126308. * @returns if the data can be loaded directly
  126309. */
  126310. canDirectLoad?(data: string): boolean;
  126311. }
  126312. /**
  126313. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  126314. */
  126315. export interface ISceneLoaderPluginBase {
  126316. /**
  126317. * The friendly name of this plugin.
  126318. */
  126319. name: string;
  126320. /**
  126321. * The file extensions supported by this plugin.
  126322. */
  126323. extensions: string | ISceneLoaderPluginExtensions;
  126324. /**
  126325. * The callback called when loading from a url.
  126326. * @param scene scene loading this url
  126327. * @param url url to load
  126328. * @param onSuccess callback called when the file successfully loads
  126329. * @param onProgress callback called while file is loading (if the server supports this mode)
  126330. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  126331. * @param onError callback called when the file fails to load
  126332. * @returns a file request object
  126333. */
  126334. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126335. /**
  126336. * The callback called when loading from a file object.
  126337. * @param scene scene loading this file
  126338. * @param file defines the file to load
  126339. * @param onSuccess defines the callback to call when data is loaded
  126340. * @param onProgress defines the callback to call during loading process
  126341. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  126342. * @param onError defines the callback to call when an error occurs
  126343. * @returns a file request object
  126344. */
  126345. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  126346. /**
  126347. * The callback that returns true if the data can be directly loaded.
  126348. * @param data string containing the file data
  126349. * @returns if the data can be loaded directly
  126350. */
  126351. canDirectLoad?(data: string): boolean;
  126352. /**
  126353. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  126354. * @param scene scene loading this data
  126355. * @param data string containing the data
  126356. * @returns data to pass to the plugin
  126357. */
  126358. directLoad?(scene: Scene, data: string): any;
  126359. /**
  126360. * The callback that allows custom handling of the root url based on the response url.
  126361. * @param rootUrl the original root url
  126362. * @param responseURL the response url if available
  126363. * @returns the new root url
  126364. */
  126365. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  126366. }
  126367. /**
  126368. * Interface used to define a SceneLoader plugin
  126369. */
  126370. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  126371. /**
  126372. * Import meshes into a scene.
  126373. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126374. * @param scene The scene to import into
  126375. * @param data The data to import
  126376. * @param rootUrl The root url for scene and resources
  126377. * @param meshes The meshes array to import into
  126378. * @param particleSystems The particle systems array to import into
  126379. * @param skeletons The skeletons array to import into
  126380. * @param onError The callback when import fails
  126381. * @returns True if successful or false otherwise
  126382. */
  126383. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  126384. /**
  126385. * Load into a scene.
  126386. * @param scene The scene to load into
  126387. * @param data The data to import
  126388. * @param rootUrl The root url for scene and resources
  126389. * @param onError The callback when import fails
  126390. * @returns True if successful or false otherwise
  126391. */
  126392. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  126393. /**
  126394. * Load into an asset container.
  126395. * @param scene The scene to load into
  126396. * @param data The data to import
  126397. * @param rootUrl The root url for scene and resources
  126398. * @param onError The callback when import fails
  126399. * @returns The loaded asset container
  126400. */
  126401. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  126402. }
  126403. /**
  126404. * Interface used to define an async SceneLoader plugin
  126405. */
  126406. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  126407. /**
  126408. * Import meshes into a scene.
  126409. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126410. * @param scene The scene to import into
  126411. * @param data The data to import
  126412. * @param rootUrl The root url for scene and resources
  126413. * @param onProgress The callback when the load progresses
  126414. * @param fileName Defines the name of the file to load
  126415. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  126416. */
  126417. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  126418. meshes: AbstractMesh[];
  126419. particleSystems: IParticleSystem[];
  126420. skeletons: Skeleton[];
  126421. animationGroups: AnimationGroup[];
  126422. }>;
  126423. /**
  126424. * Load into a scene.
  126425. * @param scene The scene to load into
  126426. * @param data The data to import
  126427. * @param rootUrl The root url for scene and resources
  126428. * @param onProgress The callback when the load progresses
  126429. * @param fileName Defines the name of the file to load
  126430. * @returns Nothing
  126431. */
  126432. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  126433. /**
  126434. * Load into an asset container.
  126435. * @param scene The scene to load into
  126436. * @param data The data to import
  126437. * @param rootUrl The root url for scene and resources
  126438. * @param onProgress The callback when the load progresses
  126439. * @param fileName Defines the name of the file to load
  126440. * @returns The loaded asset container
  126441. */
  126442. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  126443. }
  126444. /**
  126445. * Mode that determines how to handle old animation groups before loading new ones.
  126446. */
  126447. export enum SceneLoaderAnimationGroupLoadingMode {
  126448. /**
  126449. * Reset all old animations to initial state then dispose them.
  126450. */
  126451. Clean = 0,
  126452. /**
  126453. * Stop all old animations.
  126454. */
  126455. Stop = 1,
  126456. /**
  126457. * Restart old animations from first frame.
  126458. */
  126459. Sync = 2,
  126460. /**
  126461. * Old animations remains untouched.
  126462. */
  126463. NoSync = 3
  126464. }
  126465. /**
  126466. * Defines a plugin registered by the SceneLoader
  126467. */
  126468. interface IRegisteredPlugin {
  126469. /**
  126470. * Defines the plugin to use
  126471. */
  126472. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126473. /**
  126474. * Defines if the plugin supports binary data
  126475. */
  126476. isBinary: boolean;
  126477. }
  126478. /**
  126479. * Class used to load scene from various file formats using registered plugins
  126480. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  126481. */
  126482. export class SceneLoader {
  126483. /**
  126484. * No logging while loading
  126485. */
  126486. static readonly NO_LOGGING: number;
  126487. /**
  126488. * Minimal logging while loading
  126489. */
  126490. static readonly MINIMAL_LOGGING: number;
  126491. /**
  126492. * Summary logging while loading
  126493. */
  126494. static readonly SUMMARY_LOGGING: number;
  126495. /**
  126496. * Detailled logging while loading
  126497. */
  126498. static readonly DETAILED_LOGGING: number;
  126499. /**
  126500. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  126501. */
  126502. static get ForceFullSceneLoadingForIncremental(): boolean;
  126503. static set ForceFullSceneLoadingForIncremental(value: boolean);
  126504. /**
  126505. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  126506. */
  126507. static get ShowLoadingScreen(): boolean;
  126508. static set ShowLoadingScreen(value: boolean);
  126509. /**
  126510. * Defines the current logging level (while loading the scene)
  126511. * @ignorenaming
  126512. */
  126513. static get loggingLevel(): number;
  126514. static set loggingLevel(value: number);
  126515. /**
  126516. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  126517. */
  126518. static get CleanBoneMatrixWeights(): boolean;
  126519. static set CleanBoneMatrixWeights(value: boolean);
  126520. /**
  126521. * Event raised when a plugin is used to load a scene
  126522. */
  126523. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  126524. private static _registeredPlugins;
  126525. private static _showingLoadingScreen;
  126526. /**
  126527. * Gets the default plugin (used to load Babylon files)
  126528. * @returns the .babylon plugin
  126529. */
  126530. static GetDefaultPlugin(): IRegisteredPlugin;
  126531. private static _GetPluginForExtension;
  126532. private static _GetPluginForDirectLoad;
  126533. private static _GetPluginForFilename;
  126534. private static _GetDirectLoad;
  126535. private static _LoadData;
  126536. private static _GetFileInfo;
  126537. /**
  126538. * Gets a plugin that can load the given extension
  126539. * @param extension defines the extension to load
  126540. * @returns a plugin or null if none works
  126541. */
  126542. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  126543. /**
  126544. * Gets a boolean indicating that the given extension can be loaded
  126545. * @param extension defines the extension to load
  126546. * @returns true if the extension is supported
  126547. */
  126548. static IsPluginForExtensionAvailable(extension: string): boolean;
  126549. /**
  126550. * Adds a new plugin to the list of registered plugins
  126551. * @param plugin defines the plugin to add
  126552. */
  126553. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  126554. /**
  126555. * Import meshes into a scene
  126556. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126557. * @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)
  126558. * @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)
  126559. * @param scene the instance of BABYLON.Scene to append to
  126560. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  126561. * @param onProgress a callback with a progress event for each file being loaded
  126562. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126563. * @param pluginExtension the extension used to determine the plugin
  126564. * @returns The loaded plugin
  126565. */
  126566. 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>;
  126567. /**
  126568. * Import meshes into a scene
  126569. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  126570. * @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)
  126571. * @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)
  126572. * @param scene the instance of BABYLON.Scene to append to
  126573. * @param onProgress a callback with a progress event for each file being loaded
  126574. * @param pluginExtension the extension used to determine the plugin
  126575. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  126576. */
  126577. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  126578. meshes: AbstractMesh[];
  126579. particleSystems: IParticleSystem[];
  126580. skeletons: Skeleton[];
  126581. animationGroups: AnimationGroup[];
  126582. }>;
  126583. /**
  126584. * Load a scene
  126585. * @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)
  126586. * @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)
  126587. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126588. * @param onSuccess a callback with the scene when import succeeds
  126589. * @param onProgress a callback with a progress event for each file being loaded
  126590. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126591. * @param pluginExtension the extension used to determine the plugin
  126592. * @returns The loaded plugin
  126593. */
  126594. 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>;
  126595. /**
  126596. * Load a scene
  126597. * @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)
  126598. * @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)
  126599. * @param engine is the instance of BABYLON.Engine to use to create the scene
  126600. * @param onProgress a callback with a progress event for each file being loaded
  126601. * @param pluginExtension the extension used to determine the plugin
  126602. * @returns The loaded scene
  126603. */
  126604. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126605. /**
  126606. * Append a scene
  126607. * @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)
  126608. * @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)
  126609. * @param scene is the instance of BABYLON.Scene to append to
  126610. * @param onSuccess a callback with the scene when import succeeds
  126611. * @param onProgress a callback with a progress event for each file being loaded
  126612. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126613. * @param pluginExtension the extension used to determine the plugin
  126614. * @returns The loaded plugin
  126615. */
  126616. 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>;
  126617. /**
  126618. * Append a scene
  126619. * @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)
  126620. * @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)
  126621. * @param scene is the instance of BABYLON.Scene to append to
  126622. * @param onProgress a callback with a progress event for each file being loaded
  126623. * @param pluginExtension the extension used to determine the plugin
  126624. * @returns The given scene
  126625. */
  126626. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  126627. /**
  126628. * Load a scene into an asset container
  126629. * @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)
  126630. * @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)
  126631. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126632. * @param onSuccess a callback with the scene when import succeeds
  126633. * @param onProgress a callback with a progress event for each file being loaded
  126634. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126635. * @param pluginExtension the extension used to determine the plugin
  126636. * @returns The loaded plugin
  126637. */
  126638. 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>;
  126639. /**
  126640. * Load a scene into an asset container
  126641. * @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)
  126642. * @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)
  126643. * @param scene is the instance of Scene to append to
  126644. * @param onProgress a callback with a progress event for each file being loaded
  126645. * @param pluginExtension the extension used to determine the plugin
  126646. * @returns The loaded asset container
  126647. */
  126648. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  126649. /**
  126650. * Import animations from a file into a scene
  126651. * @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)
  126652. * @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)
  126653. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126654. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126655. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126656. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126657. * @param onSuccess a callback with the scene when import succeeds
  126658. * @param onProgress a callback with a progress event for each file being loaded
  126659. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126660. * @param pluginExtension the extension used to determine the plugin
  126661. */
  126662. 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;
  126663. /**
  126664. * Import animations from a file into a scene
  126665. * @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)
  126666. * @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)
  126667. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126668. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  126669. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  126670. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  126671. * @param onSuccess a callback with the scene when import succeeds
  126672. * @param onProgress a callback with a progress event for each file being loaded
  126673. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  126674. * @param pluginExtension the extension used to determine the plugin
  126675. * @returns the updated scene with imported animations
  126676. */
  126677. 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>;
  126678. }
  126679. }
  126680. declare module BABYLON {
  126681. /**
  126682. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  126683. */
  126684. export type MotionControllerHandedness = "none" | "left" | "right";
  126685. /**
  126686. * The type of components available in motion controllers.
  126687. * This is not the name of the component.
  126688. */
  126689. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  126690. /**
  126691. * The state of a controller component
  126692. */
  126693. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  126694. /**
  126695. * The schema of motion controller layout.
  126696. * No object will be initialized using this interface
  126697. * This is used just to define the profile.
  126698. */
  126699. export interface IMotionControllerLayout {
  126700. /**
  126701. * Path to load the assets. Usually relative to the base path
  126702. */
  126703. assetPath: string;
  126704. /**
  126705. * Available components (unsorted)
  126706. */
  126707. components: {
  126708. /**
  126709. * A map of component Ids
  126710. */
  126711. [componentId: string]: {
  126712. /**
  126713. * The type of input the component outputs
  126714. */
  126715. type: MotionControllerComponentType;
  126716. /**
  126717. * The indices of this component in the gamepad object
  126718. */
  126719. gamepadIndices: {
  126720. /**
  126721. * Index of button
  126722. */
  126723. button?: number;
  126724. /**
  126725. * If available, index of x-axis
  126726. */
  126727. xAxis?: number;
  126728. /**
  126729. * If available, index of y-axis
  126730. */
  126731. yAxis?: number;
  126732. };
  126733. /**
  126734. * The mesh's root node name
  126735. */
  126736. rootNodeName: string;
  126737. /**
  126738. * Animation definitions for this model
  126739. */
  126740. visualResponses: {
  126741. [stateKey: string]: {
  126742. /**
  126743. * What property will be animated
  126744. */
  126745. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  126746. /**
  126747. * What states influence this visual response
  126748. */
  126749. states: MotionControllerComponentStateType[];
  126750. /**
  126751. * Type of animation - movement or visibility
  126752. */
  126753. valueNodeProperty: "transform" | "visibility";
  126754. /**
  126755. * Base node name to move. Its position will be calculated according to the min and max nodes
  126756. */
  126757. valueNodeName?: string;
  126758. /**
  126759. * Minimum movement node
  126760. */
  126761. minNodeName?: string;
  126762. /**
  126763. * Max movement node
  126764. */
  126765. maxNodeName?: string;
  126766. };
  126767. };
  126768. /**
  126769. * If touch enabled, what is the name of node to display user feedback
  126770. */
  126771. touchPointNodeName?: string;
  126772. };
  126773. };
  126774. /**
  126775. * Is it xr standard mapping or not
  126776. */
  126777. gamepadMapping: "" | "xr-standard";
  126778. /**
  126779. * Base root node of this entire model
  126780. */
  126781. rootNodeName: string;
  126782. /**
  126783. * Defines the main button component id
  126784. */
  126785. selectComponentId: string;
  126786. }
  126787. /**
  126788. * A definition for the layout map in the input profile
  126789. */
  126790. export interface IMotionControllerLayoutMap {
  126791. /**
  126792. * Layouts with handedness type as a key
  126793. */
  126794. [handedness: string]: IMotionControllerLayout;
  126795. }
  126796. /**
  126797. * The XR Input profile schema
  126798. * Profiles can be found here:
  126799. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  126800. */
  126801. export interface IMotionControllerProfile {
  126802. /**
  126803. * fallback profiles for this profileId
  126804. */
  126805. fallbackProfileIds: string[];
  126806. /**
  126807. * The layout map, with handedness as key
  126808. */
  126809. layouts: IMotionControllerLayoutMap;
  126810. /**
  126811. * The id of this profile
  126812. * correlates to the profile(s) in the xrInput.profiles array
  126813. */
  126814. profileId: string;
  126815. }
  126816. /**
  126817. * A helper-interface for the 3 meshes needed for controller button animation
  126818. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  126819. */
  126820. export interface IMotionControllerButtonMeshMap {
  126821. /**
  126822. * the mesh that defines the pressed value mesh position.
  126823. * This is used to find the max-position of this button
  126824. */
  126825. pressedMesh: AbstractMesh;
  126826. /**
  126827. * the mesh that defines the unpressed value mesh position.
  126828. * This is used to find the min (or initial) position of this button
  126829. */
  126830. unpressedMesh: AbstractMesh;
  126831. /**
  126832. * The mesh that will be changed when value changes
  126833. */
  126834. valueMesh: AbstractMesh;
  126835. }
  126836. /**
  126837. * A helper-interface for the 3 meshes needed for controller axis animation.
  126838. * This will be expanded when touchpad animations are fully supported
  126839. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  126840. */
  126841. export interface IMotionControllerMeshMap {
  126842. /**
  126843. * the mesh that defines the maximum value mesh position.
  126844. */
  126845. maxMesh?: AbstractMesh;
  126846. /**
  126847. * the mesh that defines the minimum value mesh position.
  126848. */
  126849. minMesh?: AbstractMesh;
  126850. /**
  126851. * The mesh that will be changed when axis value changes
  126852. */
  126853. valueMesh: AbstractMesh;
  126854. }
  126855. /**
  126856. * The elements needed for change-detection of the gamepad objects in motion controllers
  126857. */
  126858. export interface IMinimalMotionControllerObject {
  126859. /**
  126860. * Available axes of this controller
  126861. */
  126862. axes: number[];
  126863. /**
  126864. * An array of available buttons
  126865. */
  126866. buttons: Array<{
  126867. /**
  126868. * Value of the button/trigger
  126869. */
  126870. value: number;
  126871. /**
  126872. * If the button/trigger is currently touched
  126873. */
  126874. touched: boolean;
  126875. /**
  126876. * If the button/trigger is currently pressed
  126877. */
  126878. pressed: boolean;
  126879. }>;
  126880. /**
  126881. * EXPERIMENTAL haptic support.
  126882. */
  126883. hapticActuators?: Array<{
  126884. pulse: (value: number, duration: number) => Promise<boolean>;
  126885. }>;
  126886. }
  126887. /**
  126888. * An Abstract Motion controller
  126889. * This class receives an xrInput and a profile layout and uses those to initialize the components
  126890. * Each component has an observable to check for changes in value and state
  126891. */
  126892. export abstract class WebXRAbstractMotionController implements IDisposable {
  126893. protected scene: Scene;
  126894. protected layout: IMotionControllerLayout;
  126895. /**
  126896. * The gamepad object correlating to this controller
  126897. */
  126898. gamepadObject: IMinimalMotionControllerObject;
  126899. /**
  126900. * handedness (left/right/none) of this controller
  126901. */
  126902. handedness: MotionControllerHandedness;
  126903. private _initComponent;
  126904. private _modelReady;
  126905. /**
  126906. * A map of components (WebXRControllerComponent) in this motion controller
  126907. * Components have a ComponentType and can also have both button and axis definitions
  126908. */
  126909. readonly components: {
  126910. [id: string]: WebXRControllerComponent;
  126911. };
  126912. /**
  126913. * Disable the model's animation. Can be set at any time.
  126914. */
  126915. disableAnimation: boolean;
  126916. /**
  126917. * Observers registered here will be triggered when the model of this controller is done loading
  126918. */
  126919. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  126920. /**
  126921. * The profile id of this motion controller
  126922. */
  126923. abstract profileId: string;
  126924. /**
  126925. * The root mesh of the model. It is null if the model was not yet initialized
  126926. */
  126927. rootMesh: Nullable<AbstractMesh>;
  126928. /**
  126929. * constructs a new abstract motion controller
  126930. * @param scene the scene to which the model of the controller will be added
  126931. * @param layout The profile layout to load
  126932. * @param gamepadObject The gamepad object correlating to this controller
  126933. * @param handedness handedness (left/right/none) of this controller
  126934. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  126935. */
  126936. constructor(scene: Scene, layout: IMotionControllerLayout,
  126937. /**
  126938. * The gamepad object correlating to this controller
  126939. */
  126940. gamepadObject: IMinimalMotionControllerObject,
  126941. /**
  126942. * handedness (left/right/none) of this controller
  126943. */
  126944. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  126945. /**
  126946. * Dispose this controller, the model mesh and all its components
  126947. */
  126948. dispose(): void;
  126949. /**
  126950. * Returns all components of specific type
  126951. * @param type the type to search for
  126952. * @return an array of components with this type
  126953. */
  126954. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  126955. /**
  126956. * get a component based an its component id as defined in layout.components
  126957. * @param id the id of the component
  126958. * @returns the component correlates to the id or undefined if not found
  126959. */
  126960. getComponent(id: string): WebXRControllerComponent;
  126961. /**
  126962. * Get the list of components available in this motion controller
  126963. * @returns an array of strings correlating to available components
  126964. */
  126965. getComponentIds(): string[];
  126966. /**
  126967. * Get the first component of specific type
  126968. * @param type type of component to find
  126969. * @return a controller component or null if not found
  126970. */
  126971. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  126972. /**
  126973. * Get the main (Select) component of this controller as defined in the layout
  126974. * @returns the main component of this controller
  126975. */
  126976. getMainComponent(): WebXRControllerComponent;
  126977. /**
  126978. * Loads the model correlating to this controller
  126979. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  126980. * @returns A promise fulfilled with the result of the model loading
  126981. */
  126982. loadModel(): Promise<boolean>;
  126983. /**
  126984. * Update this model using the current XRFrame
  126985. * @param xrFrame the current xr frame to use and update the model
  126986. */
  126987. updateFromXRFrame(xrFrame: XRFrame): void;
  126988. /**
  126989. * Backwards compatibility due to a deeply-integrated typo
  126990. */
  126991. get handness(): XREye;
  126992. /**
  126993. * Pulse (vibrate) this controller
  126994. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  126995. * Consecutive calls to this function will cancel the last pulse call
  126996. *
  126997. * @param value the strength of the pulse in 0.0...1.0 range
  126998. * @param duration Duration of the pulse in milliseconds
  126999. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  127000. * @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
  127001. */
  127002. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  127003. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127004. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  127005. /**
  127006. * Moves the axis on the controller mesh based on its current state
  127007. * @param axis the index of the axis
  127008. * @param axisValue the value of the axis which determines the meshes new position
  127009. * @hidden
  127010. */
  127011. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  127012. /**
  127013. * Update the model itself with the current frame data
  127014. * @param xrFrame the frame to use for updating the model mesh
  127015. */
  127016. protected updateModel(xrFrame: XRFrame): void;
  127017. /**
  127018. * Get the filename and path for this controller's model
  127019. * @returns a map of filename and path
  127020. */
  127021. protected abstract _getFilenameAndPath(): {
  127022. filename: string;
  127023. path: string;
  127024. };
  127025. /**
  127026. * This function is called before the mesh is loaded. It checks for loading constraints.
  127027. * For example, this function can check if the GLB loader is available
  127028. * If this function returns false, the generic controller will be loaded instead
  127029. * @returns Is the client ready to load the mesh
  127030. */
  127031. protected abstract _getModelLoadingConstraints(): boolean;
  127032. /**
  127033. * This function will be called after the model was successfully loaded and can be used
  127034. * for mesh transformations before it is available for the user
  127035. * @param meshes the loaded meshes
  127036. */
  127037. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  127038. /**
  127039. * Set the root mesh for this controller. Important for the WebXR controller class
  127040. * @param meshes the loaded meshes
  127041. */
  127042. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  127043. /**
  127044. * A function executed each frame that updates the mesh (if needed)
  127045. * @param xrFrame the current xrFrame
  127046. */
  127047. protected abstract _updateModel(xrFrame: XRFrame): void;
  127048. private _getGenericFilenameAndPath;
  127049. private _getGenericParentMesh;
  127050. }
  127051. }
  127052. declare module BABYLON {
  127053. /**
  127054. * A generic trigger-only motion controller for WebXR
  127055. */
  127056. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  127057. /**
  127058. * Static version of the profile id of this controller
  127059. */
  127060. static ProfileId: string;
  127061. profileId: string;
  127062. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  127063. protected _getFilenameAndPath(): {
  127064. filename: string;
  127065. path: string;
  127066. };
  127067. protected _getModelLoadingConstraints(): boolean;
  127068. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  127069. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127070. protected _updateModel(): void;
  127071. }
  127072. }
  127073. declare module BABYLON {
  127074. /**
  127075. * Class containing static functions to help procedurally build meshes
  127076. */
  127077. export class SphereBuilder {
  127078. /**
  127079. * Creates a sphere mesh
  127080. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  127081. * * 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`)
  127082. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  127083. * * 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
  127084. * * 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)
  127085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127088. * @param name defines the name of the mesh
  127089. * @param options defines the options used to create the mesh
  127090. * @param scene defines the hosting scene
  127091. * @returns the sphere mesh
  127092. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127093. */
  127094. static CreateSphere(name: string, options: {
  127095. segments?: number;
  127096. diameter?: number;
  127097. diameterX?: number;
  127098. diameterY?: number;
  127099. diameterZ?: number;
  127100. arc?: number;
  127101. slice?: number;
  127102. sideOrientation?: number;
  127103. frontUVs?: Vector4;
  127104. backUVs?: Vector4;
  127105. updatable?: boolean;
  127106. }, scene?: Nullable<Scene>): Mesh;
  127107. }
  127108. }
  127109. declare module BABYLON {
  127110. /**
  127111. * A profiled motion controller has its profile loaded from an online repository.
  127112. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  127113. */
  127114. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  127115. private _repositoryUrl;
  127116. private _buttonMeshMapping;
  127117. private _touchDots;
  127118. /**
  127119. * The profile ID of this controller. Will be populated when the controller initializes.
  127120. */
  127121. profileId: string;
  127122. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  127123. dispose(): void;
  127124. protected _getFilenameAndPath(): {
  127125. filename: string;
  127126. path: string;
  127127. };
  127128. protected _getModelLoadingConstraints(): boolean;
  127129. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  127130. protected _setRootMesh(meshes: AbstractMesh[]): void;
  127131. protected _updateModel(_xrFrame: XRFrame): void;
  127132. }
  127133. }
  127134. declare module BABYLON {
  127135. /**
  127136. * A construction function type to create a new controller based on an xrInput object
  127137. */
  127138. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  127139. /**
  127140. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  127141. *
  127142. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  127143. * it should be replaced with auto-loaded controllers.
  127144. *
  127145. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  127146. */
  127147. export class WebXRMotionControllerManager {
  127148. private static _AvailableControllers;
  127149. private static _Fallbacks;
  127150. private static _ProfileLoadingPromises;
  127151. private static _ProfilesList;
  127152. /**
  127153. * The base URL of the online controller repository. Can be changed at any time.
  127154. */
  127155. static BaseRepositoryUrl: string;
  127156. /**
  127157. * Which repository gets priority - local or online
  127158. */
  127159. static PrioritizeOnlineRepository: boolean;
  127160. /**
  127161. * Use the online repository, or use only locally-defined controllers
  127162. */
  127163. static UseOnlineRepository: boolean;
  127164. /**
  127165. * Clear the cache used for profile loading and reload when requested again
  127166. */
  127167. static ClearProfilesCache(): void;
  127168. /**
  127169. * Register the default fallbacks.
  127170. * This function is called automatically when this file is imported.
  127171. */
  127172. static DefaultFallbacks(): void;
  127173. /**
  127174. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  127175. * @param profileId the profile to which a fallback needs to be found
  127176. * @return an array with corresponding fallback profiles
  127177. */
  127178. static FindFallbackWithProfileId(profileId: string): string[];
  127179. /**
  127180. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  127181. * The order of search:
  127182. *
  127183. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  127184. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  127185. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  127186. * 4) return the generic trigger controller if none were found
  127187. *
  127188. * @param xrInput the xrInput to which a new controller is initialized
  127189. * @param scene the scene to which the model will be added
  127190. * @param forceProfile force a certain profile for this controller
  127191. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  127192. */
  127193. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  127194. /**
  127195. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  127196. *
  127197. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  127198. *
  127199. * @param type the profile type to register
  127200. * @param constructFunction the function to be called when loading this profile
  127201. */
  127202. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  127203. /**
  127204. * Register a fallback to a specific profile.
  127205. * @param profileId the profileId that will receive the fallbacks
  127206. * @param fallbacks A list of fallback profiles
  127207. */
  127208. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  127209. /**
  127210. * Will update the list of profiles available in the repository
  127211. * @return a promise that resolves to a map of profiles available online
  127212. */
  127213. static UpdateProfilesList(): Promise<{
  127214. [profile: string]: string;
  127215. }>;
  127216. private static _LoadProfileFromRepository;
  127217. private static _LoadProfilesFromAvailableControllers;
  127218. }
  127219. }
  127220. declare module BABYLON {
  127221. /**
  127222. * Configuration options for the WebXR controller creation
  127223. */
  127224. export interface IWebXRControllerOptions {
  127225. /**
  127226. * Should the controller mesh be animated when a user interacts with it
  127227. * The pressed buttons / thumbstick and touchpad animations will be disabled
  127228. */
  127229. disableMotionControllerAnimation?: boolean;
  127230. /**
  127231. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  127232. */
  127233. doNotLoadControllerMesh?: boolean;
  127234. /**
  127235. * Force a specific controller type for this controller.
  127236. * This can be used when creating your own profile or when testing different controllers
  127237. */
  127238. forceControllerProfile?: string;
  127239. /**
  127240. * Defines a rendering group ID for meshes that will be loaded.
  127241. * This is for the default controllers only.
  127242. */
  127243. renderingGroupId?: number;
  127244. }
  127245. /**
  127246. * Represents an XR controller
  127247. */
  127248. export class WebXRInputSource {
  127249. private _scene;
  127250. /** The underlying input source for the controller */
  127251. inputSource: XRInputSource;
  127252. private _options;
  127253. private _tmpVector;
  127254. private _uniqueId;
  127255. /**
  127256. * 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
  127257. */
  127258. grip?: AbstractMesh;
  127259. /**
  127260. * If available, this is the gamepad object related to this controller.
  127261. * Using this object it is possible to get click events and trackpad changes of the
  127262. * webxr controller that is currently being used.
  127263. */
  127264. motionController?: WebXRAbstractMotionController;
  127265. /**
  127266. * Event that fires when the controller is removed/disposed.
  127267. * The object provided as event data is this controller, after associated assets were disposed.
  127268. * uniqueId is still available.
  127269. */
  127270. onDisposeObservable: Observable<WebXRInputSource>;
  127271. /**
  127272. * Will be triggered when the mesh associated with the motion controller is done loading.
  127273. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  127274. * A shortened version of controller -> motion controller -> on mesh loaded.
  127275. */
  127276. onMeshLoadedObservable: Observable<AbstractMesh>;
  127277. /**
  127278. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  127279. */
  127280. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  127281. /**
  127282. * Pointer which can be used to select objects or attach a visible laser to
  127283. */
  127284. pointer: AbstractMesh;
  127285. /**
  127286. * Creates the input source object
  127287. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  127288. * @param _scene the scene which the controller should be associated to
  127289. * @param inputSource the underlying input source for the controller
  127290. * @param _options options for this controller creation
  127291. */
  127292. constructor(_scene: Scene,
  127293. /** The underlying input source for the controller */
  127294. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  127295. /**
  127296. * Get this controllers unique id
  127297. */
  127298. get uniqueId(): string;
  127299. /**
  127300. * Disposes of the object
  127301. */
  127302. dispose(): void;
  127303. /**
  127304. * Gets a world space ray coming from the pointer or grip
  127305. * @param result the resulting ray
  127306. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  127307. */
  127308. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  127309. /**
  127310. * Updates the controller pose based on the given XRFrame
  127311. * @param xrFrame xr frame to update the pose with
  127312. * @param referenceSpace reference space to use
  127313. */
  127314. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  127315. }
  127316. }
  127317. declare module BABYLON {
  127318. /**
  127319. * The schema for initialization options of the XR Input class
  127320. */
  127321. export interface IWebXRInputOptions {
  127322. /**
  127323. * If set to true no model will be automatically loaded
  127324. */
  127325. doNotLoadControllerMeshes?: boolean;
  127326. /**
  127327. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  127328. * If not found, the xr input profile data will be used.
  127329. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  127330. */
  127331. forceInputProfile?: string;
  127332. /**
  127333. * Do not send a request to the controller repository to load the profile.
  127334. *
  127335. * Instead, use the controllers available in babylon itself.
  127336. */
  127337. disableOnlineControllerRepository?: boolean;
  127338. /**
  127339. * A custom URL for the controllers repository
  127340. */
  127341. customControllersRepositoryURL?: string;
  127342. /**
  127343. * Should the controller model's components not move according to the user input
  127344. */
  127345. disableControllerAnimation?: boolean;
  127346. /**
  127347. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  127348. */
  127349. controllerOptions?: IWebXRControllerOptions;
  127350. }
  127351. /**
  127352. * XR input used to track XR inputs such as controllers/rays
  127353. */
  127354. export class WebXRInput implements IDisposable {
  127355. /**
  127356. * the xr session manager for this session
  127357. */
  127358. xrSessionManager: WebXRSessionManager;
  127359. /**
  127360. * the WebXR camera for this session. Mainly used for teleportation
  127361. */
  127362. xrCamera: WebXRCamera;
  127363. private readonly options;
  127364. /**
  127365. * XR controllers being tracked
  127366. */
  127367. controllers: Array<WebXRInputSource>;
  127368. private _frameObserver;
  127369. private _sessionEndedObserver;
  127370. private _sessionInitObserver;
  127371. /**
  127372. * Event when a controller has been connected/added
  127373. */
  127374. onControllerAddedObservable: Observable<WebXRInputSource>;
  127375. /**
  127376. * Event when a controller has been removed/disconnected
  127377. */
  127378. onControllerRemovedObservable: Observable<WebXRInputSource>;
  127379. /**
  127380. * Initializes the WebXRInput
  127381. * @param xrSessionManager the xr session manager for this session
  127382. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  127383. * @param options = initialization options for this xr input
  127384. */
  127385. constructor(
  127386. /**
  127387. * the xr session manager for this session
  127388. */
  127389. xrSessionManager: WebXRSessionManager,
  127390. /**
  127391. * the WebXR camera for this session. Mainly used for teleportation
  127392. */
  127393. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  127394. private _onInputSourcesChange;
  127395. private _addAndRemoveControllers;
  127396. /**
  127397. * Disposes of the object
  127398. */
  127399. dispose(): void;
  127400. }
  127401. }
  127402. declare module BABYLON {
  127403. /**
  127404. * This is the base class for all WebXR features.
  127405. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  127406. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  127407. */
  127408. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  127409. protected _xrSessionManager: WebXRSessionManager;
  127410. private _attached;
  127411. private _removeOnDetach;
  127412. /**
  127413. * Should auto-attach be disabled?
  127414. */
  127415. disableAutoAttach: boolean;
  127416. /**
  127417. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  127418. */
  127419. xrNativeFeatureName: string;
  127420. /**
  127421. * Construct a new (abstract) WebXR feature
  127422. * @param _xrSessionManager the xr session manager for this feature
  127423. */
  127424. constructor(_xrSessionManager: WebXRSessionManager);
  127425. /**
  127426. * Is this feature attached
  127427. */
  127428. get attached(): boolean;
  127429. /**
  127430. * attach this feature
  127431. *
  127432. * @param force should attachment be forced (even when already attached)
  127433. * @returns true if successful, false is failed or already attached
  127434. */
  127435. attach(force?: boolean): boolean;
  127436. /**
  127437. * detach this feature.
  127438. *
  127439. * @returns true if successful, false if failed or already detached
  127440. */
  127441. detach(): boolean;
  127442. /**
  127443. * Dispose this feature and all of the resources attached
  127444. */
  127445. dispose(): void;
  127446. /**
  127447. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127448. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127449. *
  127450. * @returns whether or not the feature is compatible in this environment
  127451. */
  127452. isCompatible(): boolean;
  127453. /**
  127454. * This is used to register callbacks that will automatically be removed when detach is called.
  127455. * @param observable the observable to which the observer will be attached
  127456. * @param callback the callback to register
  127457. */
  127458. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  127459. /**
  127460. * Code in this function will be executed on each xrFrame received from the browser.
  127461. * This function will not execute after the feature is detached.
  127462. * @param _xrFrame the current frame
  127463. */
  127464. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  127465. }
  127466. }
  127467. declare module BABYLON {
  127468. /**
  127469. * Renders a layer on top of an existing scene
  127470. */
  127471. export class UtilityLayerRenderer implements IDisposable {
  127472. /** the original scene that will be rendered on top of */
  127473. originalScene: Scene;
  127474. private _pointerCaptures;
  127475. private _lastPointerEvents;
  127476. private static _DefaultUtilityLayer;
  127477. private static _DefaultKeepDepthUtilityLayer;
  127478. private _sharedGizmoLight;
  127479. private _renderCamera;
  127480. /**
  127481. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  127482. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  127483. * @returns the camera that is used when rendering the utility layer
  127484. */
  127485. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  127486. /**
  127487. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  127488. * @param cam the camera that should be used when rendering the utility layer
  127489. */
  127490. setRenderCamera(cam: Nullable<Camera>): void;
  127491. /**
  127492. * @hidden
  127493. * Light which used by gizmos to get light shading
  127494. */
  127495. _getSharedGizmoLight(): HemisphericLight;
  127496. /**
  127497. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  127498. */
  127499. pickUtilitySceneFirst: boolean;
  127500. /**
  127501. * 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)
  127502. */
  127503. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  127504. /**
  127505. * 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)
  127506. */
  127507. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  127508. /**
  127509. * The scene that is rendered on top of the original scene
  127510. */
  127511. utilityLayerScene: Scene;
  127512. /**
  127513. * If the utility layer should automatically be rendered on top of existing scene
  127514. */
  127515. shouldRender: boolean;
  127516. /**
  127517. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  127518. */
  127519. onlyCheckPointerDownEvents: boolean;
  127520. /**
  127521. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  127522. */
  127523. processAllEvents: boolean;
  127524. /**
  127525. * Observable raised when the pointer move from the utility layer scene to the main scene
  127526. */
  127527. onPointerOutObservable: Observable<number>;
  127528. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  127529. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  127530. private _afterRenderObserver;
  127531. private _sceneDisposeObserver;
  127532. private _originalPointerObserver;
  127533. /**
  127534. * Instantiates a UtilityLayerRenderer
  127535. * @param originalScene the original scene that will be rendered on top of
  127536. * @param handleEvents boolean indicating if the utility layer should handle events
  127537. */
  127538. constructor(
  127539. /** the original scene that will be rendered on top of */
  127540. originalScene: Scene, handleEvents?: boolean);
  127541. private _notifyObservers;
  127542. /**
  127543. * Renders the utility layers scene on top of the original scene
  127544. */
  127545. render(): void;
  127546. /**
  127547. * Disposes of the renderer
  127548. */
  127549. dispose(): void;
  127550. private _updateCamera;
  127551. }
  127552. }
  127553. declare module BABYLON {
  127554. /**
  127555. * Options interface for the pointer selection module
  127556. */
  127557. export interface IWebXRControllerPointerSelectionOptions {
  127558. /**
  127559. * if provided, this scene will be used to render meshes.
  127560. */
  127561. customUtilityLayerScene?: Scene;
  127562. /**
  127563. * 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)
  127564. * If not disabled, the last picked point will be used to execute a pointer up event
  127565. * If disabled, pointer up event will be triggered right after the pointer down event.
  127566. * Used in screen and gaze target ray mode only
  127567. */
  127568. disablePointerUpOnTouchOut: boolean;
  127569. /**
  127570. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  127571. */
  127572. forceGazeMode: boolean;
  127573. /**
  127574. * 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
  127575. * to start a new countdown to the pointer down event.
  127576. * Defaults to 1.
  127577. */
  127578. gazeModePointerMovedFactor?: number;
  127579. /**
  127580. * Different button type to use instead of the main component
  127581. */
  127582. overrideButtonId?: string;
  127583. /**
  127584. * use this rendering group id for the meshes (optional)
  127585. */
  127586. renderingGroupId?: number;
  127587. /**
  127588. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  127589. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  127590. * 3000 means 3 seconds between pointing at something and selecting it
  127591. */
  127592. timeToSelect?: number;
  127593. /**
  127594. * Should meshes created here be added to a utility layer or the main scene
  127595. */
  127596. useUtilityLayer?: boolean;
  127597. /**
  127598. * Optional WebXR camera to be used for gaze selection
  127599. */
  127600. gazeCamera?: WebXRCamera;
  127601. /**
  127602. * the xr input to use with this pointer selection
  127603. */
  127604. xrInput: WebXRInput;
  127605. }
  127606. /**
  127607. * A module that will enable pointer selection for motion controllers of XR Input Sources
  127608. */
  127609. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  127610. private readonly _options;
  127611. private static _idCounter;
  127612. private _attachController;
  127613. private _controllers;
  127614. private _scene;
  127615. private _tmpVectorForPickCompare;
  127616. /**
  127617. * The module's name
  127618. */
  127619. static readonly Name: string;
  127620. /**
  127621. * The (Babylon) version of this module.
  127622. * This is an integer representing the implementation version.
  127623. * This number does not correspond to the WebXR specs version
  127624. */
  127625. static readonly Version: number;
  127626. /**
  127627. * Disable lighting on the laser pointer (so it will always be visible)
  127628. */
  127629. disablePointerLighting: boolean;
  127630. /**
  127631. * Disable lighting on the selection mesh (so it will always be visible)
  127632. */
  127633. disableSelectionMeshLighting: boolean;
  127634. /**
  127635. * Should the laser pointer be displayed
  127636. */
  127637. displayLaserPointer: boolean;
  127638. /**
  127639. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  127640. */
  127641. displaySelectionMesh: boolean;
  127642. /**
  127643. * This color will be set to the laser pointer when selection is triggered
  127644. */
  127645. laserPointerPickedColor: Color3;
  127646. /**
  127647. * Default color of the laser pointer
  127648. */
  127649. laserPointerDefaultColor: Color3;
  127650. /**
  127651. * default color of the selection ring
  127652. */
  127653. selectionMeshDefaultColor: Color3;
  127654. /**
  127655. * This color will be applied to the selection ring when selection is triggered
  127656. */
  127657. selectionMeshPickedColor: Color3;
  127658. /**
  127659. * Optional filter to be used for ray selection. This predicate shares behavior with
  127660. * scene.pointerMovePredicate which takes priority if it is also assigned.
  127661. */
  127662. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127663. /**
  127664. * constructs a new background remover module
  127665. * @param _xrSessionManager the session manager for this module
  127666. * @param _options read-only options to be used in this module
  127667. */
  127668. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  127669. /**
  127670. * attach this feature
  127671. * Will usually be called by the features manager
  127672. *
  127673. * @returns true if successful.
  127674. */
  127675. attach(): boolean;
  127676. /**
  127677. * detach this feature.
  127678. * Will usually be called by the features manager
  127679. *
  127680. * @returns true if successful.
  127681. */
  127682. detach(): boolean;
  127683. /**
  127684. * Will get the mesh under a specific pointer.
  127685. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  127686. * @param controllerId the controllerId to check
  127687. * @returns The mesh under pointer or null if no mesh is under the pointer
  127688. */
  127689. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  127690. /**
  127691. * Get the xr controller that correlates to the pointer id in the pointer event
  127692. *
  127693. * @param id the pointer id to search for
  127694. * @returns the controller that correlates to this id or null if not found
  127695. */
  127696. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  127697. protected _onXRFrame(_xrFrame: XRFrame): void;
  127698. private _attachGazeMode;
  127699. private _attachScreenRayMode;
  127700. private _attachTrackedPointerRayMode;
  127701. private _convertNormalToDirectionOfRay;
  127702. private _detachController;
  127703. private _generateNewMeshPair;
  127704. private _pickingMoved;
  127705. private _updatePointerDistance;
  127706. /** @hidden */
  127707. get lasterPointerDefaultColor(): Color3;
  127708. }
  127709. }
  127710. declare module BABYLON {
  127711. /**
  127712. * Button which can be used to enter a different mode of XR
  127713. */
  127714. export class WebXREnterExitUIButton {
  127715. /** button element */
  127716. element: HTMLElement;
  127717. /** XR initialization options for the button */
  127718. sessionMode: XRSessionMode;
  127719. /** Reference space type */
  127720. referenceSpaceType: XRReferenceSpaceType;
  127721. /**
  127722. * Creates a WebXREnterExitUIButton
  127723. * @param element button element
  127724. * @param sessionMode XR initialization session mode
  127725. * @param referenceSpaceType the type of reference space to be used
  127726. */
  127727. constructor(
  127728. /** button element */
  127729. element: HTMLElement,
  127730. /** XR initialization options for the button */
  127731. sessionMode: XRSessionMode,
  127732. /** Reference space type */
  127733. referenceSpaceType: XRReferenceSpaceType);
  127734. /**
  127735. * Extendable function which can be used to update the button's visuals when the state changes
  127736. * @param activeButton the current active button in the UI
  127737. */
  127738. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  127739. }
  127740. /**
  127741. * Options to create the webXR UI
  127742. */
  127743. export class WebXREnterExitUIOptions {
  127744. /**
  127745. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  127746. */
  127747. customButtons?: Array<WebXREnterExitUIButton>;
  127748. /**
  127749. * A reference space type to use when creating the default button.
  127750. * Default is local-floor
  127751. */
  127752. referenceSpaceType?: XRReferenceSpaceType;
  127753. /**
  127754. * Context to enter xr with
  127755. */
  127756. renderTarget?: Nullable<WebXRRenderTarget>;
  127757. /**
  127758. * A session mode to use when creating the default button.
  127759. * Default is immersive-vr
  127760. */
  127761. sessionMode?: XRSessionMode;
  127762. /**
  127763. * A list of optional features to init the session with
  127764. */
  127765. optionalFeatures?: string[];
  127766. /**
  127767. * A list of optional features to init the session with
  127768. */
  127769. requiredFeatures?: string[];
  127770. }
  127771. /**
  127772. * UI to allow the user to enter/exit XR mode
  127773. */
  127774. export class WebXREnterExitUI implements IDisposable {
  127775. private scene;
  127776. /** version of the options passed to this UI */
  127777. options: WebXREnterExitUIOptions;
  127778. private _activeButton;
  127779. private _buttons;
  127780. private _overlay;
  127781. /**
  127782. * Fired every time the active button is changed.
  127783. *
  127784. * When xr is entered via a button that launches xr that button will be the callback parameter
  127785. *
  127786. * When exiting xr the callback parameter will be null)
  127787. */
  127788. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  127789. /**
  127790. *
  127791. * @param scene babylon scene object to use
  127792. * @param options (read-only) version of the options passed to this UI
  127793. */
  127794. private constructor();
  127795. /**
  127796. * Creates UI to allow the user to enter/exit XR mode
  127797. * @param scene the scene to add the ui to
  127798. * @param helper the xr experience helper to enter/exit xr with
  127799. * @param options options to configure the UI
  127800. * @returns the created ui
  127801. */
  127802. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  127803. /**
  127804. * Disposes of the XR UI component
  127805. */
  127806. dispose(): void;
  127807. private _updateButtons;
  127808. }
  127809. }
  127810. declare module BABYLON {
  127811. /**
  127812. * Class containing static functions to help procedurally build meshes
  127813. */
  127814. export class LinesBuilder {
  127815. /**
  127816. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127817. * * 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
  127818. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127819. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127820. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127821. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127822. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127823. * * 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
  127824. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127827. * @param name defines the name of the new line system
  127828. * @param options defines the options used to create the line system
  127829. * @param scene defines the hosting scene
  127830. * @returns a new line system mesh
  127831. */
  127832. static CreateLineSystem(name: string, options: {
  127833. lines: Vector3[][];
  127834. updatable?: boolean;
  127835. instance?: Nullable<LinesMesh>;
  127836. colors?: Nullable<Color4[][]>;
  127837. useVertexAlpha?: boolean;
  127838. }, scene: Nullable<Scene>): LinesMesh;
  127839. /**
  127840. * Creates a line mesh
  127841. * 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
  127842. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127843. * * The parameter `points` is an array successive Vector3
  127844. * * 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
  127845. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127846. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127847. * * When updating an instance, remember that only point positions can change, not the number of points
  127848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127850. * @param name defines the name of the new line system
  127851. * @param options defines the options used to create the line system
  127852. * @param scene defines the hosting scene
  127853. * @returns a new line mesh
  127854. */
  127855. static CreateLines(name: string, options: {
  127856. points: Vector3[];
  127857. updatable?: boolean;
  127858. instance?: Nullable<LinesMesh>;
  127859. colors?: Color4[];
  127860. useVertexAlpha?: boolean;
  127861. }, scene?: Nullable<Scene>): LinesMesh;
  127862. /**
  127863. * Creates a dashed line mesh
  127864. * * 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
  127865. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127866. * * The parameter `points` is an array successive Vector3
  127867. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127868. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127869. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127870. * * 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
  127871. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127872. * * When updating an instance, remember that only point positions can change, not the number of points
  127873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127874. * @param name defines the name of the mesh
  127875. * @param options defines the options used to create the mesh
  127876. * @param scene defines the hosting scene
  127877. * @returns the dashed line mesh
  127878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127879. */
  127880. static CreateDashedLines(name: string, options: {
  127881. points: Vector3[];
  127882. dashSize?: number;
  127883. gapSize?: number;
  127884. dashNb?: number;
  127885. updatable?: boolean;
  127886. instance?: LinesMesh;
  127887. useVertexAlpha?: boolean;
  127888. }, scene?: Nullable<Scene>): LinesMesh;
  127889. }
  127890. }
  127891. declare module BABYLON {
  127892. /**
  127893. * Construction options for a timer
  127894. */
  127895. export interface ITimerOptions<T> {
  127896. /**
  127897. * Time-to-end
  127898. */
  127899. timeout: number;
  127900. /**
  127901. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  127902. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  127903. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  127904. */
  127905. contextObservable: Observable<T>;
  127906. /**
  127907. * Optional parameters when adding an observer to the observable
  127908. */
  127909. observableParameters?: {
  127910. mask?: number;
  127911. insertFirst?: boolean;
  127912. scope?: any;
  127913. };
  127914. /**
  127915. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  127916. */
  127917. breakCondition?: (data?: ITimerData<T>) => boolean;
  127918. /**
  127919. * Will be triggered when the time condition has met
  127920. */
  127921. onEnded?: (data: ITimerData<any>) => void;
  127922. /**
  127923. * Will be triggered when the break condition has met (prematurely ended)
  127924. */
  127925. onAborted?: (data: ITimerData<any>) => void;
  127926. /**
  127927. * Optional function to execute on each tick (or count)
  127928. */
  127929. onTick?: (data: ITimerData<any>) => void;
  127930. }
  127931. /**
  127932. * An interface defining the data sent by the timer
  127933. */
  127934. export interface ITimerData<T> {
  127935. /**
  127936. * When did it start
  127937. */
  127938. startTime: number;
  127939. /**
  127940. * Time now
  127941. */
  127942. currentTime: number;
  127943. /**
  127944. * Time passed since started
  127945. */
  127946. deltaTime: number;
  127947. /**
  127948. * How much is completed, in [0.0...1.0].
  127949. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  127950. */
  127951. completeRate: number;
  127952. /**
  127953. * What the registered observable sent in the last count
  127954. */
  127955. payload: T;
  127956. }
  127957. /**
  127958. * The current state of the timer
  127959. */
  127960. export enum TimerState {
  127961. /**
  127962. * Timer initialized, not yet started
  127963. */
  127964. INIT = 0,
  127965. /**
  127966. * Timer started and counting
  127967. */
  127968. STARTED = 1,
  127969. /**
  127970. * Timer ended (whether aborted or time reached)
  127971. */
  127972. ENDED = 2
  127973. }
  127974. /**
  127975. * A simple version of the timer. Will take options and start the timer immediately after calling it
  127976. *
  127977. * @param options options with which to initialize this timer
  127978. */
  127979. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  127980. /**
  127981. * An advanced implementation of a timer class
  127982. */
  127983. export class AdvancedTimer<T = any> implements IDisposable {
  127984. /**
  127985. * Will notify each time the timer calculates the remaining time
  127986. */
  127987. onEachCountObservable: Observable<ITimerData<T>>;
  127988. /**
  127989. * Will trigger when the timer was aborted due to the break condition
  127990. */
  127991. onTimerAbortedObservable: Observable<ITimerData<T>>;
  127992. /**
  127993. * Will trigger when the timer ended successfully
  127994. */
  127995. onTimerEndedObservable: Observable<ITimerData<T>>;
  127996. /**
  127997. * Will trigger when the timer state has changed
  127998. */
  127999. onStateChangedObservable: Observable<TimerState>;
  128000. private _observer;
  128001. private _contextObservable;
  128002. private _observableParameters;
  128003. private _startTime;
  128004. private _timer;
  128005. private _state;
  128006. private _breakCondition;
  128007. private _timeToEnd;
  128008. private _breakOnNextTick;
  128009. /**
  128010. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  128011. * @param options construction options for this advanced timer
  128012. */
  128013. constructor(options: ITimerOptions<T>);
  128014. /**
  128015. * set a breaking condition for this timer. Default is to never break during count
  128016. * @param predicate the new break condition. Returns true to break, false otherwise
  128017. */
  128018. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  128019. /**
  128020. * Reset ALL associated observables in this advanced timer
  128021. */
  128022. clearObservables(): void;
  128023. /**
  128024. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  128025. *
  128026. * @param timeToEnd how much time to measure until timer ended
  128027. */
  128028. start(timeToEnd?: number): void;
  128029. /**
  128030. * Will force a stop on the next tick.
  128031. */
  128032. stop(): void;
  128033. /**
  128034. * Dispose this timer, clearing all resources
  128035. */
  128036. dispose(): void;
  128037. private _setState;
  128038. private _tick;
  128039. private _stop;
  128040. }
  128041. }
  128042. declare module BABYLON {
  128043. /**
  128044. * The options container for the teleportation module
  128045. */
  128046. export interface IWebXRTeleportationOptions {
  128047. /**
  128048. * if provided, this scene will be used to render meshes.
  128049. */
  128050. customUtilityLayerScene?: Scene;
  128051. /**
  128052. * Values to configure the default target mesh
  128053. */
  128054. defaultTargetMeshOptions?: {
  128055. /**
  128056. * Fill color of the teleportation area
  128057. */
  128058. teleportationFillColor?: string;
  128059. /**
  128060. * Border color for the teleportation area
  128061. */
  128062. teleportationBorderColor?: string;
  128063. /**
  128064. * Disable the mesh's animation sequence
  128065. */
  128066. disableAnimation?: boolean;
  128067. /**
  128068. * Disable lighting on the material or the ring and arrow
  128069. */
  128070. disableLighting?: boolean;
  128071. /**
  128072. * Override the default material of the torus and arrow
  128073. */
  128074. torusArrowMaterial?: Material;
  128075. };
  128076. /**
  128077. * A list of meshes to use as floor meshes.
  128078. * Meshes can be added and removed after initializing the feature using the
  128079. * addFloorMesh and removeFloorMesh functions
  128080. * If empty, rotation will still work
  128081. */
  128082. floorMeshes?: AbstractMesh[];
  128083. /**
  128084. * use this rendering group id for the meshes (optional)
  128085. */
  128086. renderingGroupId?: number;
  128087. /**
  128088. * Should teleportation move only to snap points
  128089. */
  128090. snapPointsOnly?: boolean;
  128091. /**
  128092. * An array of points to which the teleportation will snap to.
  128093. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  128094. */
  128095. snapPositions?: Vector3[];
  128096. /**
  128097. * How close should the teleportation ray be in order to snap to position.
  128098. * Default to 0.8 units (meters)
  128099. */
  128100. snapToPositionRadius?: number;
  128101. /**
  128102. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  128103. * If you want to support rotation, make sure your mesh has a direction indicator.
  128104. *
  128105. * When left untouched, the default mesh will be initialized.
  128106. */
  128107. teleportationTargetMesh?: AbstractMesh;
  128108. /**
  128109. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  128110. */
  128111. timeToTeleport?: number;
  128112. /**
  128113. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  128114. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  128115. */
  128116. useMainComponentOnly?: boolean;
  128117. /**
  128118. * Should meshes created here be added to a utility layer or the main scene
  128119. */
  128120. useUtilityLayer?: boolean;
  128121. /**
  128122. * Babylon XR Input class for controller
  128123. */
  128124. xrInput: WebXRInput;
  128125. }
  128126. /**
  128127. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  128128. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  128129. * the input of the attached controllers.
  128130. */
  128131. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  128132. private _options;
  128133. private _controllers;
  128134. private _currentTeleportationControllerId;
  128135. private _floorMeshes;
  128136. private _quadraticBezierCurve;
  128137. private _selectionFeature;
  128138. private _snapToPositions;
  128139. private _snappedToPoint;
  128140. private _teleportationRingMaterial?;
  128141. private _tmpRay;
  128142. private _tmpVector;
  128143. /**
  128144. * The module's name
  128145. */
  128146. static readonly Name: string;
  128147. /**
  128148. * The (Babylon) version of this module.
  128149. * This is an integer representing the implementation version.
  128150. * This number does not correspond to the webxr specs version
  128151. */
  128152. static readonly Version: number;
  128153. /**
  128154. * Is movement backwards enabled
  128155. */
  128156. backwardsMovementEnabled: boolean;
  128157. /**
  128158. * Distance to travel when moving backwards
  128159. */
  128160. backwardsTeleportationDistance: number;
  128161. /**
  128162. * The distance from the user to the inspection point in the direction of the controller
  128163. * A higher number will allow the user to move further
  128164. * defaults to 5 (meters, in xr units)
  128165. */
  128166. parabolicCheckRadius: number;
  128167. /**
  128168. * Should the module support parabolic ray on top of direct ray
  128169. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  128170. * Very helpful when moving between floors / different heights
  128171. */
  128172. parabolicRayEnabled: boolean;
  128173. /**
  128174. * How much rotation should be applied when rotating right and left
  128175. */
  128176. rotationAngle: number;
  128177. /**
  128178. * Is rotation enabled when moving forward?
  128179. * Disabling this feature will prevent the user from deciding the direction when teleporting
  128180. */
  128181. rotationEnabled: boolean;
  128182. /**
  128183. * constructs a new anchor system
  128184. * @param _xrSessionManager an instance of WebXRSessionManager
  128185. * @param _options configuration object for this feature
  128186. */
  128187. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  128188. /**
  128189. * Get the snapPointsOnly flag
  128190. */
  128191. get snapPointsOnly(): boolean;
  128192. /**
  128193. * Sets the snapPointsOnly flag
  128194. * @param snapToPoints should teleportation be exclusively to snap points
  128195. */
  128196. set snapPointsOnly(snapToPoints: boolean);
  128197. /**
  128198. * Add a new mesh to the floor meshes array
  128199. * @param mesh the mesh to use as floor mesh
  128200. */
  128201. addFloorMesh(mesh: AbstractMesh): void;
  128202. /**
  128203. * Add a new snap-to point to fix teleportation to this position
  128204. * @param newSnapPoint The new Snap-To point
  128205. */
  128206. addSnapPoint(newSnapPoint: Vector3): void;
  128207. attach(): boolean;
  128208. detach(): boolean;
  128209. dispose(): void;
  128210. /**
  128211. * Remove a mesh from the floor meshes array
  128212. * @param mesh the mesh to remove
  128213. */
  128214. removeFloorMesh(mesh: AbstractMesh): void;
  128215. /**
  128216. * Remove a mesh from the floor meshes array using its name
  128217. * @param name the mesh name to remove
  128218. */
  128219. removeFloorMeshByName(name: string): void;
  128220. /**
  128221. * 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
  128222. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  128223. * @returns was the point found and removed or not
  128224. */
  128225. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  128226. /**
  128227. * This function sets a selection feature that will be disabled when
  128228. * the forward ray is shown and will be reattached when hidden.
  128229. * This is used to remove the selection rays when moving.
  128230. * @param selectionFeature the feature to disable when forward movement is enabled
  128231. */
  128232. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  128233. protected _onXRFrame(_xrFrame: XRFrame): void;
  128234. private _attachController;
  128235. private _createDefaultTargetMesh;
  128236. private _detachController;
  128237. private _findClosestSnapPointWithRadius;
  128238. private _setTargetMeshPosition;
  128239. private _setTargetMeshVisibility;
  128240. private _showParabolicPath;
  128241. private _teleportForward;
  128242. }
  128243. }
  128244. declare module BABYLON {
  128245. /**
  128246. * Options for the default xr helper
  128247. */
  128248. export class WebXRDefaultExperienceOptions {
  128249. /**
  128250. * Enable or disable default UI to enter XR
  128251. */
  128252. disableDefaultUI?: boolean;
  128253. /**
  128254. * Should teleportation not initialize. defaults to false.
  128255. */
  128256. disableTeleportation?: boolean;
  128257. /**
  128258. * Floor meshes that will be used for teleport
  128259. */
  128260. floorMeshes?: Array<AbstractMesh>;
  128261. /**
  128262. * If set to true, the first frame will not be used to reset position
  128263. * The first frame is mainly used when copying transformation from the old camera
  128264. * Mainly used in AR
  128265. */
  128266. ignoreNativeCameraTransformation?: boolean;
  128267. /**
  128268. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  128269. */
  128270. inputOptions?: IWebXRInputOptions;
  128271. /**
  128272. * optional configuration for the output canvas
  128273. */
  128274. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  128275. /**
  128276. * optional UI options. This can be used among other to change session mode and reference space type
  128277. */
  128278. uiOptions?: WebXREnterExitUIOptions;
  128279. /**
  128280. * When loading teleportation and pointer select, use stable versions instead of latest.
  128281. */
  128282. useStablePlugins?: boolean;
  128283. /**
  128284. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  128285. */
  128286. renderingGroupId?: number;
  128287. /**
  128288. * A list of optional features to init the session with
  128289. * If set to true, all features we support will be added
  128290. */
  128291. optionalFeatures?: boolean | string[];
  128292. }
  128293. /**
  128294. * Default experience which provides a similar setup to the previous webVRExperience
  128295. */
  128296. export class WebXRDefaultExperience {
  128297. /**
  128298. * Base experience
  128299. */
  128300. baseExperience: WebXRExperienceHelper;
  128301. /**
  128302. * Enables ui for entering/exiting xr
  128303. */
  128304. enterExitUI: WebXREnterExitUI;
  128305. /**
  128306. * Input experience extension
  128307. */
  128308. input: WebXRInput;
  128309. /**
  128310. * Enables laser pointer and selection
  128311. */
  128312. pointerSelection: WebXRControllerPointerSelection;
  128313. /**
  128314. * Default target xr should render to
  128315. */
  128316. renderTarget: WebXRRenderTarget;
  128317. /**
  128318. * Enables teleportation
  128319. */
  128320. teleportation: WebXRMotionControllerTeleportation;
  128321. private constructor();
  128322. /**
  128323. * Creates the default xr experience
  128324. * @param scene scene
  128325. * @param options options for basic configuration
  128326. * @returns resulting WebXRDefaultExperience
  128327. */
  128328. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  128329. /**
  128330. * DIsposes of the experience helper
  128331. */
  128332. dispose(): void;
  128333. }
  128334. }
  128335. declare module BABYLON {
  128336. /**
  128337. * Options to modify the vr teleportation behavior.
  128338. */
  128339. export interface VRTeleportationOptions {
  128340. /**
  128341. * The name of the mesh which should be used as the teleportation floor. (default: null)
  128342. */
  128343. floorMeshName?: string;
  128344. /**
  128345. * A list of meshes to be used as the teleportation floor. (default: empty)
  128346. */
  128347. floorMeshes?: Mesh[];
  128348. /**
  128349. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  128350. */
  128351. teleportationMode?: number;
  128352. /**
  128353. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  128354. */
  128355. teleportationTime?: number;
  128356. /**
  128357. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  128358. */
  128359. teleportationSpeed?: number;
  128360. /**
  128361. * The easing function used in the animation or null for Linear. (default CircleEase)
  128362. */
  128363. easingFunction?: EasingFunction;
  128364. }
  128365. /**
  128366. * Options to modify the vr experience helper's behavior.
  128367. */
  128368. export interface VRExperienceHelperOptions extends WebVROptions {
  128369. /**
  128370. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  128371. */
  128372. createDeviceOrientationCamera?: boolean;
  128373. /**
  128374. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  128375. */
  128376. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  128377. /**
  128378. * Uses the main button on the controller to toggle the laser casted. (default: true)
  128379. */
  128380. laserToggle?: boolean;
  128381. /**
  128382. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  128383. */
  128384. floorMeshes?: Mesh[];
  128385. /**
  128386. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  128387. */
  128388. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  128389. /**
  128390. * Defines if WebXR should be used instead of WebVR (if available)
  128391. */
  128392. useXR?: boolean;
  128393. }
  128394. /**
  128395. * Event containing information after VR has been entered
  128396. */
  128397. export class OnAfterEnteringVRObservableEvent {
  128398. /**
  128399. * If entering vr was successful
  128400. */
  128401. success: boolean;
  128402. }
  128403. /**
  128404. * Helps to quickly add VR support to an existing scene.
  128405. * See https://doc.babylonjs.com/how_to/webvr_helper
  128406. */
  128407. export class VRExperienceHelper {
  128408. /** Options to modify the vr experience helper's behavior. */
  128409. webVROptions: VRExperienceHelperOptions;
  128410. private _scene;
  128411. private _position;
  128412. private _btnVR;
  128413. private _btnVRDisplayed;
  128414. private _webVRsupported;
  128415. private _webVRready;
  128416. private _webVRrequesting;
  128417. private _webVRpresenting;
  128418. private _hasEnteredVR;
  128419. private _fullscreenVRpresenting;
  128420. private _inputElement;
  128421. private _webVRCamera;
  128422. private _vrDeviceOrientationCamera;
  128423. private _deviceOrientationCamera;
  128424. private _existingCamera;
  128425. private _onKeyDown;
  128426. private _onVrDisplayPresentChange;
  128427. private _onVRDisplayChanged;
  128428. private _onVRRequestPresentStart;
  128429. private _onVRRequestPresentComplete;
  128430. /**
  128431. * 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)
  128432. */
  128433. enableGazeEvenWhenNoPointerLock: boolean;
  128434. /**
  128435. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  128436. */
  128437. exitVROnDoubleTap: boolean;
  128438. /**
  128439. * Observable raised right before entering VR.
  128440. */
  128441. onEnteringVRObservable: Observable<VRExperienceHelper>;
  128442. /**
  128443. * Observable raised when entering VR has completed.
  128444. */
  128445. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  128446. /**
  128447. * Observable raised when exiting VR.
  128448. */
  128449. onExitingVRObservable: Observable<VRExperienceHelper>;
  128450. /**
  128451. * Observable raised when controller mesh is loaded.
  128452. */
  128453. onControllerMeshLoadedObservable: Observable<WebVRController>;
  128454. /** Return this.onEnteringVRObservable
  128455. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  128456. */
  128457. get onEnteringVR(): Observable<VRExperienceHelper>;
  128458. /** Return this.onExitingVRObservable
  128459. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  128460. */
  128461. get onExitingVR(): Observable<VRExperienceHelper>;
  128462. /** Return this.onControllerMeshLoadedObservable
  128463. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  128464. */
  128465. get onControllerMeshLoaded(): Observable<WebVRController>;
  128466. private _rayLength;
  128467. private _useCustomVRButton;
  128468. private _teleportationRequested;
  128469. private _teleportActive;
  128470. private _floorMeshName;
  128471. private _floorMeshesCollection;
  128472. private _teleportationMode;
  128473. private _teleportationTime;
  128474. private _teleportationSpeed;
  128475. private _teleportationEasing;
  128476. private _rotationAllowed;
  128477. private _teleportBackwardsVector;
  128478. private _teleportationTarget;
  128479. private _isDefaultTeleportationTarget;
  128480. private _postProcessMove;
  128481. private _teleportationFillColor;
  128482. private _teleportationBorderColor;
  128483. private _rotationAngle;
  128484. private _haloCenter;
  128485. private _cameraGazer;
  128486. private _padSensibilityUp;
  128487. private _padSensibilityDown;
  128488. private _leftController;
  128489. private _rightController;
  128490. private _gazeColor;
  128491. private _laserColor;
  128492. private _pickedLaserColor;
  128493. private _pickedGazeColor;
  128494. /**
  128495. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  128496. */
  128497. onNewMeshSelected: Observable<AbstractMesh>;
  128498. /**
  128499. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  128500. * This observable will provide the mesh and the controller used to select the mesh
  128501. */
  128502. onMeshSelectedWithController: Observable<{
  128503. mesh: AbstractMesh;
  128504. controller: WebVRController;
  128505. }>;
  128506. /**
  128507. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  128508. */
  128509. onNewMeshPicked: Observable<PickingInfo>;
  128510. private _circleEase;
  128511. /**
  128512. * Observable raised before camera teleportation
  128513. */
  128514. onBeforeCameraTeleport: Observable<Vector3>;
  128515. /**
  128516. * Observable raised after camera teleportation
  128517. */
  128518. onAfterCameraTeleport: Observable<Vector3>;
  128519. /**
  128520. * Observable raised when current selected mesh gets unselected
  128521. */
  128522. onSelectedMeshUnselected: Observable<AbstractMesh>;
  128523. private _raySelectionPredicate;
  128524. /**
  128525. * To be optionaly changed by user to define custom ray selection
  128526. */
  128527. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128528. /**
  128529. * To be optionaly changed by user to define custom selection logic (after ray selection)
  128530. */
  128531. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128532. /**
  128533. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  128534. */
  128535. teleportationEnabled: boolean;
  128536. private _defaultHeight;
  128537. private _teleportationInitialized;
  128538. private _interactionsEnabled;
  128539. private _interactionsRequested;
  128540. private _displayGaze;
  128541. private _displayLaserPointer;
  128542. /**
  128543. * The mesh used to display where the user is going to teleport.
  128544. */
  128545. get teleportationTarget(): Mesh;
  128546. /**
  128547. * Sets the mesh to be used to display where the user is going to teleport.
  128548. */
  128549. set teleportationTarget(value: Mesh);
  128550. /**
  128551. * 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
  128552. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  128553. * See https://doc.babylonjs.com/resources/baking_transformations
  128554. */
  128555. get gazeTrackerMesh(): Mesh;
  128556. set gazeTrackerMesh(value: Mesh);
  128557. /**
  128558. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  128559. */
  128560. updateGazeTrackerScale: boolean;
  128561. /**
  128562. * If the gaze trackers color should be updated when selecting meshes
  128563. */
  128564. updateGazeTrackerColor: boolean;
  128565. /**
  128566. * If the controller laser color should be updated when selecting meshes
  128567. */
  128568. updateControllerLaserColor: boolean;
  128569. /**
  128570. * The gaze tracking mesh corresponding to the left controller
  128571. */
  128572. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  128573. /**
  128574. * The gaze tracking mesh corresponding to the right controller
  128575. */
  128576. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  128577. /**
  128578. * If the ray of the gaze should be displayed.
  128579. */
  128580. get displayGaze(): boolean;
  128581. /**
  128582. * Sets if the ray of the gaze should be displayed.
  128583. */
  128584. set displayGaze(value: boolean);
  128585. /**
  128586. * If the ray of the LaserPointer should be displayed.
  128587. */
  128588. get displayLaserPointer(): boolean;
  128589. /**
  128590. * Sets if the ray of the LaserPointer should be displayed.
  128591. */
  128592. set displayLaserPointer(value: boolean);
  128593. /**
  128594. * The deviceOrientationCamera used as the camera when not in VR.
  128595. */
  128596. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  128597. /**
  128598. * Based on the current WebVR support, returns the current VR camera used.
  128599. */
  128600. get currentVRCamera(): Nullable<Camera>;
  128601. /**
  128602. * The webVRCamera which is used when in VR.
  128603. */
  128604. get webVRCamera(): WebVRFreeCamera;
  128605. /**
  128606. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  128607. */
  128608. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  128609. /**
  128610. * The html button that is used to trigger entering into VR.
  128611. */
  128612. get vrButton(): Nullable<HTMLButtonElement>;
  128613. private get _teleportationRequestInitiated();
  128614. /**
  128615. * Defines whether or not Pointer lock should be requested when switching to
  128616. * full screen.
  128617. */
  128618. requestPointerLockOnFullScreen: boolean;
  128619. /**
  128620. * If asking to force XR, this will be populated with the default xr experience
  128621. */
  128622. xr: WebXRDefaultExperience;
  128623. /**
  128624. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  128625. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  128626. */
  128627. xrTestDone: boolean;
  128628. /**
  128629. * Instantiates a VRExperienceHelper.
  128630. * Helps to quickly add VR support to an existing scene.
  128631. * @param scene The scene the VRExperienceHelper belongs to.
  128632. * @param webVROptions Options to modify the vr experience helper's behavior.
  128633. */
  128634. constructor(scene: Scene,
  128635. /** Options to modify the vr experience helper's behavior. */
  128636. webVROptions?: VRExperienceHelperOptions);
  128637. private completeVRInit;
  128638. private _onDefaultMeshLoaded;
  128639. private _onResize;
  128640. private _onFullscreenChange;
  128641. /**
  128642. * Gets a value indicating if we are currently in VR mode.
  128643. */
  128644. get isInVRMode(): boolean;
  128645. private onVrDisplayPresentChange;
  128646. private onVRDisplayChanged;
  128647. private moveButtonToBottomRight;
  128648. private displayVRButton;
  128649. private updateButtonVisibility;
  128650. private _cachedAngularSensibility;
  128651. /**
  128652. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  128653. * Otherwise, will use the fullscreen API.
  128654. */
  128655. enterVR(): void;
  128656. /**
  128657. * Attempt to exit VR, or fullscreen.
  128658. */
  128659. exitVR(): void;
  128660. /**
  128661. * The position of the vr experience helper.
  128662. */
  128663. get position(): Vector3;
  128664. /**
  128665. * Sets the position of the vr experience helper.
  128666. */
  128667. set position(value: Vector3);
  128668. /**
  128669. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  128670. */
  128671. enableInteractions(): void;
  128672. private get _noControllerIsActive();
  128673. private beforeRender;
  128674. private _isTeleportationFloor;
  128675. /**
  128676. * Adds a floor mesh to be used for teleportation.
  128677. * @param floorMesh the mesh to be used for teleportation.
  128678. */
  128679. addFloorMesh(floorMesh: Mesh): void;
  128680. /**
  128681. * Removes a floor mesh from being used for teleportation.
  128682. * @param floorMesh the mesh to be removed.
  128683. */
  128684. removeFloorMesh(floorMesh: Mesh): void;
  128685. /**
  128686. * Enables interactions and teleportation using the VR controllers and gaze.
  128687. * @param vrTeleportationOptions options to modify teleportation behavior.
  128688. */
  128689. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  128690. private _onNewGamepadConnected;
  128691. private _tryEnableInteractionOnController;
  128692. private _onNewGamepadDisconnected;
  128693. private _enableInteractionOnController;
  128694. private _checkTeleportWithRay;
  128695. private _checkRotate;
  128696. private _checkTeleportBackwards;
  128697. private _enableTeleportationOnController;
  128698. private _createTeleportationCircles;
  128699. private _displayTeleportationTarget;
  128700. private _hideTeleportationTarget;
  128701. private _rotateCamera;
  128702. private _moveTeleportationSelectorTo;
  128703. private _workingVector;
  128704. private _workingQuaternion;
  128705. private _workingMatrix;
  128706. /**
  128707. * Time Constant Teleportation Mode
  128708. */
  128709. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  128710. /**
  128711. * Speed Constant Teleportation Mode
  128712. */
  128713. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  128714. /**
  128715. * Teleports the users feet to the desired location
  128716. * @param location The location where the user's feet should be placed
  128717. */
  128718. teleportCamera(location: Vector3): void;
  128719. private _convertNormalToDirectionOfRay;
  128720. private _castRayAndSelectObject;
  128721. private _notifySelectedMeshUnselected;
  128722. /**
  128723. * Permanently set new colors for the laser pointer
  128724. * @param color the new laser color
  128725. * @param pickedColor the new laser color when picked mesh detected
  128726. */
  128727. setLaserColor(color: Color3, pickedColor?: Color3): void;
  128728. /**
  128729. * Set lighting enabled / disabled on the laser pointer of both controllers
  128730. * @param enabled should the lighting be enabled on the laser pointer
  128731. */
  128732. setLaserLightingState(enabled?: boolean): void;
  128733. /**
  128734. * Permanently set new colors for the gaze pointer
  128735. * @param color the new gaze color
  128736. * @param pickedColor the new gaze color when picked mesh detected
  128737. */
  128738. setGazeColor(color: Color3, pickedColor?: Color3): void;
  128739. /**
  128740. * Sets the color of the laser ray from the vr controllers.
  128741. * @param color new color for the ray.
  128742. */
  128743. changeLaserColor(color: Color3): void;
  128744. /**
  128745. * Sets the color of the ray from the vr headsets gaze.
  128746. * @param color new color for the ray.
  128747. */
  128748. changeGazeColor(color: Color3): void;
  128749. /**
  128750. * Exits VR and disposes of the vr experience helper
  128751. */
  128752. dispose(): void;
  128753. /**
  128754. * Gets the name of the VRExperienceHelper class
  128755. * @returns "VRExperienceHelper"
  128756. */
  128757. getClassName(): string;
  128758. }
  128759. }
  128760. declare module BABYLON {
  128761. /**
  128762. * Contains an array of blocks representing the octree
  128763. */
  128764. export interface IOctreeContainer<T> {
  128765. /**
  128766. * Blocks within the octree
  128767. */
  128768. blocks: Array<OctreeBlock<T>>;
  128769. }
  128770. /**
  128771. * Class used to store a cell in an octree
  128772. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128773. */
  128774. export class OctreeBlock<T> {
  128775. /**
  128776. * Gets the content of the current block
  128777. */
  128778. entries: T[];
  128779. /**
  128780. * Gets the list of block children
  128781. */
  128782. blocks: Array<OctreeBlock<T>>;
  128783. private _depth;
  128784. private _maxDepth;
  128785. private _capacity;
  128786. private _minPoint;
  128787. private _maxPoint;
  128788. private _boundingVectors;
  128789. private _creationFunc;
  128790. /**
  128791. * Creates a new block
  128792. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  128793. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  128794. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128795. * @param depth defines the current depth of this block in the octree
  128796. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  128797. * @param creationFunc defines a callback to call when an element is added to the block
  128798. */
  128799. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  128800. /**
  128801. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  128802. */
  128803. get capacity(): number;
  128804. /**
  128805. * Gets the minimum vector (in world space) of the block's bounding box
  128806. */
  128807. get minPoint(): Vector3;
  128808. /**
  128809. * Gets the maximum vector (in world space) of the block's bounding box
  128810. */
  128811. get maxPoint(): Vector3;
  128812. /**
  128813. * Add a new element to this block
  128814. * @param entry defines the element to add
  128815. */
  128816. addEntry(entry: T): void;
  128817. /**
  128818. * Remove an element from this block
  128819. * @param entry defines the element to remove
  128820. */
  128821. removeEntry(entry: T): void;
  128822. /**
  128823. * Add an array of elements to this block
  128824. * @param entries defines the array of elements to add
  128825. */
  128826. addEntries(entries: T[]): void;
  128827. /**
  128828. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  128829. * @param frustumPlanes defines the frustum planes to test
  128830. * @param selection defines the array to store current content if selection is positive
  128831. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128832. */
  128833. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128834. /**
  128835. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  128836. * @param sphereCenter defines the bounding sphere center
  128837. * @param sphereRadius defines the bounding sphere radius
  128838. * @param selection defines the array to store current content if selection is positive
  128839. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128840. */
  128841. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  128842. /**
  128843. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  128844. * @param ray defines the ray to test with
  128845. * @param selection defines the array to store current content if selection is positive
  128846. */
  128847. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  128848. /**
  128849. * Subdivide the content into child blocks (this block will then be empty)
  128850. */
  128851. createInnerBlocks(): void;
  128852. /**
  128853. * @hidden
  128854. */
  128855. 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;
  128856. }
  128857. }
  128858. declare module BABYLON {
  128859. /**
  128860. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  128861. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128862. */
  128863. export class Octree<T> {
  128864. /** 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.) */
  128865. maxDepth: number;
  128866. /**
  128867. * Blocks within the octree containing objects
  128868. */
  128869. blocks: Array<OctreeBlock<T>>;
  128870. /**
  128871. * Content stored in the octree
  128872. */
  128873. dynamicContent: T[];
  128874. private _maxBlockCapacity;
  128875. private _selectionContent;
  128876. private _creationFunc;
  128877. /**
  128878. * Creates a octree
  128879. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128880. * @param creationFunc function to be used to instatiate the octree
  128881. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  128882. * @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.)
  128883. */
  128884. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  128885. /** 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.) */
  128886. maxDepth?: number);
  128887. /**
  128888. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  128889. * @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);
  128890. * @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);
  128891. * @param entries meshes to be added to the octree blocks
  128892. */
  128893. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  128894. /**
  128895. * Adds a mesh to the octree
  128896. * @param entry Mesh to add to the octree
  128897. */
  128898. addMesh(entry: T): void;
  128899. /**
  128900. * Remove an element from the octree
  128901. * @param entry defines the element to remove
  128902. */
  128903. removeMesh(entry: T): void;
  128904. /**
  128905. * Selects an array of meshes within the frustum
  128906. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  128907. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  128908. * @returns array of meshes within the frustum
  128909. */
  128910. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  128911. /**
  128912. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  128913. * @param sphereCenter defines the bounding sphere center
  128914. * @param sphereRadius defines the bounding sphere radius
  128915. * @param allowDuplicate defines if the selection array can contains duplicated entries
  128916. * @returns an array of objects that intersect the sphere
  128917. */
  128918. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  128919. /**
  128920. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  128921. * @param ray defines the ray to test with
  128922. * @returns array of intersected objects
  128923. */
  128924. intersectsRay(ray: Ray): SmartArray<T>;
  128925. /**
  128926. * Adds a mesh into the octree block if it intersects the block
  128927. */
  128928. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  128929. /**
  128930. * Adds a submesh into the octree block if it intersects the block
  128931. */
  128932. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  128933. }
  128934. }
  128935. declare module BABYLON {
  128936. interface Scene {
  128937. /**
  128938. * @hidden
  128939. * Backing Filed
  128940. */
  128941. _selectionOctree: Octree<AbstractMesh>;
  128942. /**
  128943. * Gets the octree used to boost mesh selection (picking)
  128944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128945. */
  128946. selectionOctree: Octree<AbstractMesh>;
  128947. /**
  128948. * Creates or updates the octree used to boost selection (picking)
  128949. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128950. * @param maxCapacity defines the maximum capacity per leaf
  128951. * @param maxDepth defines the maximum depth of the octree
  128952. * @returns an octree of AbstractMesh
  128953. */
  128954. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  128955. }
  128956. interface AbstractMesh {
  128957. /**
  128958. * @hidden
  128959. * Backing Field
  128960. */
  128961. _submeshesOctree: Octree<SubMesh>;
  128962. /**
  128963. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  128964. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  128965. * @param maxCapacity defines the maximum size of each block (64 by default)
  128966. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  128967. * @returns the new octree
  128968. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  128969. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  128970. */
  128971. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  128972. }
  128973. /**
  128974. * Defines the octree scene component responsible to manage any octrees
  128975. * in a given scene.
  128976. */
  128977. export class OctreeSceneComponent {
  128978. /**
  128979. * The component name help to identify the component in the list of scene components.
  128980. */
  128981. readonly name: string;
  128982. /**
  128983. * The scene the component belongs to.
  128984. */
  128985. scene: Scene;
  128986. /**
  128987. * Indicates if the meshes have been checked to make sure they are isEnabled()
  128988. */
  128989. readonly checksIsEnabled: boolean;
  128990. /**
  128991. * Creates a new instance of the component for the given scene
  128992. * @param scene Defines the scene to register the component in
  128993. */
  128994. constructor(scene: Scene);
  128995. /**
  128996. * Registers the component in a given scene
  128997. */
  128998. register(): void;
  128999. /**
  129000. * Return the list of active meshes
  129001. * @returns the list of active meshes
  129002. */
  129003. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  129004. /**
  129005. * Return the list of active sub meshes
  129006. * @param mesh The mesh to get the candidates sub meshes from
  129007. * @returns the list of active sub meshes
  129008. */
  129009. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  129010. private _tempRay;
  129011. /**
  129012. * Return the list of sub meshes intersecting with a given local ray
  129013. * @param mesh defines the mesh to find the submesh for
  129014. * @param localRay defines the ray in local space
  129015. * @returns the list of intersecting sub meshes
  129016. */
  129017. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  129018. /**
  129019. * Return the list of sub meshes colliding with a collider
  129020. * @param mesh defines the mesh to find the submesh for
  129021. * @param collider defines the collider to evaluate the collision against
  129022. * @returns the list of colliding sub meshes
  129023. */
  129024. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  129025. /**
  129026. * Rebuilds the elements related to this component in case of
  129027. * context lost for instance.
  129028. */
  129029. rebuild(): void;
  129030. /**
  129031. * Disposes the component and the associated ressources.
  129032. */
  129033. dispose(): void;
  129034. }
  129035. }
  129036. declare module BABYLON {
  129037. /**
  129038. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  129039. */
  129040. export class Gizmo implements IDisposable {
  129041. /** The utility layer the gizmo will be added to */
  129042. gizmoLayer: UtilityLayerRenderer;
  129043. /**
  129044. * The root mesh of the gizmo
  129045. */
  129046. _rootMesh: Mesh;
  129047. private _attachedMesh;
  129048. private _attachedNode;
  129049. /**
  129050. * Ratio for the scale of the gizmo (Default: 1)
  129051. */
  129052. scaleRatio: number;
  129053. /**
  129054. * If a custom mesh has been set (Default: false)
  129055. */
  129056. protected _customMeshSet: boolean;
  129057. /**
  129058. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  129059. * * When set, interactions will be enabled
  129060. */
  129061. get attachedMesh(): Nullable<AbstractMesh>;
  129062. set attachedMesh(value: Nullable<AbstractMesh>);
  129063. /**
  129064. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  129065. * * When set, interactions will be enabled
  129066. */
  129067. get attachedNode(): Nullable<Node>;
  129068. set attachedNode(value: Nullable<Node>);
  129069. /**
  129070. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  129071. * @param mesh The mesh to replace the default mesh of the gizmo
  129072. */
  129073. setCustomMesh(mesh: Mesh): void;
  129074. /**
  129075. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  129076. */
  129077. updateGizmoRotationToMatchAttachedMesh: boolean;
  129078. /**
  129079. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  129080. */
  129081. updateGizmoPositionToMatchAttachedMesh: boolean;
  129082. /**
  129083. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  129084. */
  129085. updateScale: boolean;
  129086. protected _interactionsEnabled: boolean;
  129087. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129088. private _beforeRenderObserver;
  129089. private _tempQuaternion;
  129090. private _tempVector;
  129091. private _tempVector2;
  129092. /**
  129093. * Creates a gizmo
  129094. * @param gizmoLayer The utility layer the gizmo will be added to
  129095. */
  129096. constructor(
  129097. /** The utility layer the gizmo will be added to */
  129098. gizmoLayer?: UtilityLayerRenderer);
  129099. /**
  129100. * Updates the gizmo to match the attached mesh's position/rotation
  129101. */
  129102. protected _update(): void;
  129103. /**
  129104. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  129105. * @param value Node, TransformNode or mesh
  129106. */
  129107. protected _matrixChanged(): void;
  129108. /**
  129109. * Disposes of the gizmo
  129110. */
  129111. dispose(): void;
  129112. }
  129113. }
  129114. declare module BABYLON {
  129115. /**
  129116. * Single plane drag gizmo
  129117. */
  129118. export class PlaneDragGizmo extends Gizmo {
  129119. /**
  129120. * Drag behavior responsible for the gizmos dragging interactions
  129121. */
  129122. dragBehavior: PointerDragBehavior;
  129123. private _pointerObserver;
  129124. /**
  129125. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129126. */
  129127. snapDistance: number;
  129128. /**
  129129. * Event that fires each time the gizmo snaps to a new location.
  129130. * * snapDistance is the the change in distance
  129131. */
  129132. onSnapObservable: Observable<{
  129133. snapDistance: number;
  129134. }>;
  129135. private _plane;
  129136. private _coloredMaterial;
  129137. private _hoverMaterial;
  129138. private _isEnabled;
  129139. private _parent;
  129140. /** @hidden */
  129141. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  129142. /** @hidden */
  129143. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129144. /**
  129145. * Creates a PlaneDragGizmo
  129146. * @param gizmoLayer The utility layer the gizmo will be added to
  129147. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  129148. * @param color The color of the gizmo
  129149. */
  129150. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  129151. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129152. /**
  129153. * If the gizmo is enabled
  129154. */
  129155. set isEnabled(value: boolean);
  129156. get isEnabled(): boolean;
  129157. /**
  129158. * Disposes of the gizmo
  129159. */
  129160. dispose(): void;
  129161. }
  129162. }
  129163. declare module BABYLON {
  129164. /**
  129165. * Gizmo that enables dragging a mesh along 3 axis
  129166. */
  129167. export class PositionGizmo extends Gizmo {
  129168. /**
  129169. * Internal gizmo used for interactions on the x axis
  129170. */
  129171. xGizmo: AxisDragGizmo;
  129172. /**
  129173. * Internal gizmo used for interactions on the y axis
  129174. */
  129175. yGizmo: AxisDragGizmo;
  129176. /**
  129177. * Internal gizmo used for interactions on the z axis
  129178. */
  129179. zGizmo: AxisDragGizmo;
  129180. /**
  129181. * Internal gizmo used for interactions on the yz plane
  129182. */
  129183. xPlaneGizmo: PlaneDragGizmo;
  129184. /**
  129185. * Internal gizmo used for interactions on the xz plane
  129186. */
  129187. yPlaneGizmo: PlaneDragGizmo;
  129188. /**
  129189. * Internal gizmo used for interactions on the xy plane
  129190. */
  129191. zPlaneGizmo: PlaneDragGizmo;
  129192. /**
  129193. * private variables
  129194. */
  129195. private _meshAttached;
  129196. private _nodeAttached;
  129197. private _updateGizmoRotationToMatchAttachedMesh;
  129198. private _snapDistance;
  129199. private _scaleRatio;
  129200. /** Fires an event when any of it's sub gizmos are dragged */
  129201. onDragStartObservable: Observable<unknown>;
  129202. /** Fires an event when any of it's sub gizmos are released from dragging */
  129203. onDragEndObservable: Observable<unknown>;
  129204. /**
  129205. * If set to true, planar drag is enabled
  129206. */
  129207. private _planarGizmoEnabled;
  129208. get attachedMesh(): Nullable<AbstractMesh>;
  129209. set attachedMesh(mesh: Nullable<AbstractMesh>);
  129210. get attachedNode(): Nullable<Node>;
  129211. set attachedNode(node: Nullable<Node>);
  129212. /**
  129213. * Creates a PositionGizmo
  129214. * @param gizmoLayer The utility layer the gizmo will be added to
  129215. @param thickness display gizmo axis thickness
  129216. */
  129217. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  129218. /**
  129219. * If the planar drag gizmo is enabled
  129220. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  129221. */
  129222. set planarGizmoEnabled(value: boolean);
  129223. get planarGizmoEnabled(): boolean;
  129224. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  129225. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  129226. /**
  129227. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129228. */
  129229. set snapDistance(value: number);
  129230. get snapDistance(): number;
  129231. /**
  129232. * Ratio for the scale of the gizmo (Default: 1)
  129233. */
  129234. set scaleRatio(value: number);
  129235. get scaleRatio(): number;
  129236. /**
  129237. * Disposes of the gizmo
  129238. */
  129239. dispose(): void;
  129240. /**
  129241. * CustomMeshes are not supported by this gizmo
  129242. * @param mesh The mesh to replace the default mesh of the gizmo
  129243. */
  129244. setCustomMesh(mesh: Mesh): void;
  129245. }
  129246. }
  129247. declare module BABYLON {
  129248. /**
  129249. * Single axis drag gizmo
  129250. */
  129251. export class AxisDragGizmo extends Gizmo {
  129252. /**
  129253. * Drag behavior responsible for the gizmos dragging interactions
  129254. */
  129255. dragBehavior: PointerDragBehavior;
  129256. private _pointerObserver;
  129257. /**
  129258. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  129259. */
  129260. snapDistance: number;
  129261. /**
  129262. * Event that fires each time the gizmo snaps to a new location.
  129263. * * snapDistance is the the change in distance
  129264. */
  129265. onSnapObservable: Observable<{
  129266. snapDistance: number;
  129267. }>;
  129268. private _isEnabled;
  129269. private _parent;
  129270. private _arrow;
  129271. private _coloredMaterial;
  129272. private _hoverMaterial;
  129273. /** @hidden */
  129274. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  129275. /** @hidden */
  129276. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  129277. /**
  129278. * Creates an AxisDragGizmo
  129279. * @param gizmoLayer The utility layer the gizmo will be added to
  129280. * @param dragAxis The axis which the gizmo will be able to drag on
  129281. * @param color The color of the gizmo
  129282. * @param thickness display gizmo axis thickness
  129283. */
  129284. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  129285. protected _attachedNodeChanged(value: Nullable<Node>): void;
  129286. /**
  129287. * If the gizmo is enabled
  129288. */
  129289. set isEnabled(value: boolean);
  129290. get isEnabled(): boolean;
  129291. /**
  129292. * Disposes of the gizmo
  129293. */
  129294. dispose(): void;
  129295. }
  129296. }
  129297. declare module BABYLON.Debug {
  129298. /**
  129299. * The Axes viewer will show 3 axes in a specific point in space
  129300. */
  129301. export class AxesViewer {
  129302. private _xAxis;
  129303. private _yAxis;
  129304. private _zAxis;
  129305. private _scaleLinesFactor;
  129306. private _instanced;
  129307. /**
  129308. * Gets the hosting scene
  129309. */
  129310. scene: Scene;
  129311. /**
  129312. * Gets or sets a number used to scale line length
  129313. */
  129314. scaleLines: number;
  129315. /** Gets the node hierarchy used to render x-axis */
  129316. get xAxis(): TransformNode;
  129317. /** Gets the node hierarchy used to render y-axis */
  129318. get yAxis(): TransformNode;
  129319. /** Gets the node hierarchy used to render z-axis */
  129320. get zAxis(): TransformNode;
  129321. /**
  129322. * Creates a new AxesViewer
  129323. * @param scene defines the hosting scene
  129324. * @param scaleLines defines a number used to scale line length (1 by default)
  129325. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  129326. * @param xAxis defines the node hierarchy used to render the x-axis
  129327. * @param yAxis defines the node hierarchy used to render the y-axis
  129328. * @param zAxis defines the node hierarchy used to render the z-axis
  129329. */
  129330. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  129331. /**
  129332. * Force the viewer to update
  129333. * @param position defines the position of the viewer
  129334. * @param xaxis defines the x axis of the viewer
  129335. * @param yaxis defines the y axis of the viewer
  129336. * @param zaxis defines the z axis of the viewer
  129337. */
  129338. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  129339. /**
  129340. * Creates an instance of this axes viewer.
  129341. * @returns a new axes viewer with instanced meshes
  129342. */
  129343. createInstance(): AxesViewer;
  129344. /** Releases resources */
  129345. dispose(): void;
  129346. private static _SetRenderingGroupId;
  129347. }
  129348. }
  129349. declare module BABYLON.Debug {
  129350. /**
  129351. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  129352. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  129353. */
  129354. export class BoneAxesViewer extends AxesViewer {
  129355. /**
  129356. * Gets or sets the target mesh where to display the axes viewer
  129357. */
  129358. mesh: Nullable<Mesh>;
  129359. /**
  129360. * Gets or sets the target bone where to display the axes viewer
  129361. */
  129362. bone: Nullable<Bone>;
  129363. /** Gets current position */
  129364. pos: Vector3;
  129365. /** Gets direction of X axis */
  129366. xaxis: Vector3;
  129367. /** Gets direction of Y axis */
  129368. yaxis: Vector3;
  129369. /** Gets direction of Z axis */
  129370. zaxis: Vector3;
  129371. /**
  129372. * Creates a new BoneAxesViewer
  129373. * @param scene defines the hosting scene
  129374. * @param bone defines the target bone
  129375. * @param mesh defines the target mesh
  129376. * @param scaleLines defines a scaling factor for line length (1 by default)
  129377. */
  129378. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  129379. /**
  129380. * Force the viewer to update
  129381. */
  129382. update(): void;
  129383. /** Releases resources */
  129384. dispose(): void;
  129385. }
  129386. }
  129387. declare module BABYLON {
  129388. /**
  129389. * Interface used to define scene explorer extensibility option
  129390. */
  129391. export interface IExplorerExtensibilityOption {
  129392. /**
  129393. * Define the option label
  129394. */
  129395. label: string;
  129396. /**
  129397. * Defines the action to execute on click
  129398. */
  129399. action: (entity: any) => void;
  129400. }
  129401. /**
  129402. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  129403. */
  129404. export interface IExplorerExtensibilityGroup {
  129405. /**
  129406. * Defines a predicate to test if a given type mut be extended
  129407. */
  129408. predicate: (entity: any) => boolean;
  129409. /**
  129410. * Gets the list of options added to a type
  129411. */
  129412. entries: IExplorerExtensibilityOption[];
  129413. }
  129414. /**
  129415. * Interface used to define the options to use to create the Inspector
  129416. */
  129417. export interface IInspectorOptions {
  129418. /**
  129419. * Display in overlay mode (default: false)
  129420. */
  129421. overlay?: boolean;
  129422. /**
  129423. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  129424. */
  129425. globalRoot?: HTMLElement;
  129426. /**
  129427. * Display the Scene explorer
  129428. */
  129429. showExplorer?: boolean;
  129430. /**
  129431. * Display the property inspector
  129432. */
  129433. showInspector?: boolean;
  129434. /**
  129435. * Display in embed mode (both panes on the right)
  129436. */
  129437. embedMode?: boolean;
  129438. /**
  129439. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  129440. */
  129441. handleResize?: boolean;
  129442. /**
  129443. * Allow the panes to popup (default: true)
  129444. */
  129445. enablePopup?: boolean;
  129446. /**
  129447. * Allow the panes to be closed by users (default: true)
  129448. */
  129449. enableClose?: boolean;
  129450. /**
  129451. * Optional list of extensibility entries
  129452. */
  129453. explorerExtensibility?: IExplorerExtensibilityGroup[];
  129454. /**
  129455. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  129456. */
  129457. inspectorURL?: string;
  129458. /**
  129459. * Optional initial tab (default to DebugLayerTab.Properties)
  129460. */
  129461. initialTab?: DebugLayerTab;
  129462. }
  129463. interface Scene {
  129464. /**
  129465. * @hidden
  129466. * Backing field
  129467. */
  129468. _debugLayer: DebugLayer;
  129469. /**
  129470. * Gets the debug layer (aka Inspector) associated with the scene
  129471. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129472. */
  129473. debugLayer: DebugLayer;
  129474. }
  129475. /**
  129476. * Enum of inspector action tab
  129477. */
  129478. export enum DebugLayerTab {
  129479. /**
  129480. * Properties tag (default)
  129481. */
  129482. Properties = 0,
  129483. /**
  129484. * Debug tab
  129485. */
  129486. Debug = 1,
  129487. /**
  129488. * Statistics tab
  129489. */
  129490. Statistics = 2,
  129491. /**
  129492. * Tools tab
  129493. */
  129494. Tools = 3,
  129495. /**
  129496. * Settings tab
  129497. */
  129498. Settings = 4
  129499. }
  129500. /**
  129501. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129502. * what is happening in your scene
  129503. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129504. */
  129505. export class DebugLayer {
  129506. /**
  129507. * Define the url to get the inspector script from.
  129508. * By default it uses the babylonjs CDN.
  129509. * @ignoreNaming
  129510. */
  129511. static InspectorURL: string;
  129512. private _scene;
  129513. private BJSINSPECTOR;
  129514. private _onPropertyChangedObservable?;
  129515. /**
  129516. * Observable triggered when a property is changed through the inspector.
  129517. */
  129518. get onPropertyChangedObservable(): any;
  129519. /**
  129520. * Instantiates a new debug layer.
  129521. * The debug layer (aka Inspector) is the go to tool in order to better understand
  129522. * what is happening in your scene
  129523. * @see https://doc.babylonjs.com/features/playground_debuglayer
  129524. * @param scene Defines the scene to inspect
  129525. */
  129526. constructor(scene: Scene);
  129527. /** Creates the inspector window. */
  129528. private _createInspector;
  129529. /**
  129530. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  129531. * @param entity defines the entity to select
  129532. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  129533. */
  129534. select(entity: any, lineContainerTitles?: string | string[]): void;
  129535. /** Get the inspector from bundle or global */
  129536. private _getGlobalInspector;
  129537. /**
  129538. * Get if the inspector is visible or not.
  129539. * @returns true if visible otherwise, false
  129540. */
  129541. isVisible(): boolean;
  129542. /**
  129543. * Hide the inspector and close its window.
  129544. */
  129545. hide(): void;
  129546. /**
  129547. * Update the scene in the inspector
  129548. */
  129549. setAsActiveScene(): void;
  129550. /**
  129551. * Launch the debugLayer.
  129552. * @param config Define the configuration of the inspector
  129553. * @return a promise fulfilled when the debug layer is visible
  129554. */
  129555. show(config?: IInspectorOptions): Promise<DebugLayer>;
  129556. }
  129557. }
  129558. declare module BABYLON {
  129559. /**
  129560. * Class containing static functions to help procedurally build meshes
  129561. */
  129562. export class BoxBuilder {
  129563. /**
  129564. * Creates a box mesh
  129565. * * The parameter `size` sets the size (float) of each box side (default 1)
  129566. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129567. * * 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)
  129568. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129572. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129573. * @param name defines the name of the mesh
  129574. * @param options defines the options used to create the mesh
  129575. * @param scene defines the hosting scene
  129576. * @returns the box mesh
  129577. */
  129578. static CreateBox(name: string, options: {
  129579. size?: number;
  129580. width?: number;
  129581. height?: number;
  129582. depth?: number;
  129583. faceUV?: Vector4[];
  129584. faceColors?: Color4[];
  129585. sideOrientation?: number;
  129586. frontUVs?: Vector4;
  129587. backUVs?: Vector4;
  129588. wrap?: boolean;
  129589. topBaseAt?: number;
  129590. bottomBaseAt?: number;
  129591. updatable?: boolean;
  129592. }, scene?: Nullable<Scene>): Mesh;
  129593. }
  129594. }
  129595. declare module BABYLON.Debug {
  129596. /**
  129597. * Used to show the physics impostor around the specific mesh
  129598. */
  129599. export class PhysicsViewer {
  129600. /** @hidden */
  129601. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  129602. /** @hidden */
  129603. protected _meshes: Array<Nullable<AbstractMesh>>;
  129604. /** @hidden */
  129605. protected _scene: Nullable<Scene>;
  129606. /** @hidden */
  129607. protected _numMeshes: number;
  129608. /** @hidden */
  129609. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  129610. private _renderFunction;
  129611. private _utilityLayer;
  129612. private _debugBoxMesh;
  129613. private _debugSphereMesh;
  129614. private _debugCylinderMesh;
  129615. private _debugMaterial;
  129616. private _debugMeshMeshes;
  129617. /**
  129618. * Creates a new PhysicsViewer
  129619. * @param scene defines the hosting scene
  129620. */
  129621. constructor(scene: Scene);
  129622. /** @hidden */
  129623. protected _updateDebugMeshes(): void;
  129624. /**
  129625. * Renders a specified physic impostor
  129626. * @param impostor defines the impostor to render
  129627. * @param targetMesh defines the mesh represented by the impostor
  129628. * @returns the new debug mesh used to render the impostor
  129629. */
  129630. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  129631. /**
  129632. * Hides a specified physic impostor
  129633. * @param impostor defines the impostor to hide
  129634. */
  129635. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  129636. private _getDebugMaterial;
  129637. private _getDebugBoxMesh;
  129638. private _getDebugSphereMesh;
  129639. private _getDebugCylinderMesh;
  129640. private _getDebugMeshMesh;
  129641. private _getDebugMesh;
  129642. /** Releases all resources */
  129643. dispose(): void;
  129644. }
  129645. }
  129646. declare module BABYLON {
  129647. /**
  129648. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129649. * in order to better appreciate the issue one might have.
  129650. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129651. */
  129652. export class RayHelper {
  129653. /**
  129654. * Defines the ray we are currently tryin to visualize.
  129655. */
  129656. ray: Nullable<Ray>;
  129657. private _renderPoints;
  129658. private _renderLine;
  129659. private _renderFunction;
  129660. private _scene;
  129661. private _updateToMeshFunction;
  129662. private _attachedToMesh;
  129663. private _meshSpaceDirection;
  129664. private _meshSpaceOrigin;
  129665. /**
  129666. * Helper function to create a colored helper in a scene in one line.
  129667. * @param ray Defines the ray we are currently tryin to visualize
  129668. * @param scene Defines the scene the ray is used in
  129669. * @param color Defines the color we want to see the ray in
  129670. * @returns The newly created ray helper.
  129671. */
  129672. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  129673. /**
  129674. * Instantiate a new ray helper.
  129675. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  129676. * in order to better appreciate the issue one might have.
  129677. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  129678. * @param ray Defines the ray we are currently tryin to visualize
  129679. */
  129680. constructor(ray: Ray);
  129681. /**
  129682. * Shows the ray we are willing to debug.
  129683. * @param scene Defines the scene the ray needs to be rendered in
  129684. * @param color Defines the color the ray needs to be rendered in
  129685. */
  129686. show(scene: Scene, color?: Color3): void;
  129687. /**
  129688. * Hides the ray we are debugging.
  129689. */
  129690. hide(): void;
  129691. private _render;
  129692. /**
  129693. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  129694. * @param mesh Defines the mesh we want the helper attached to
  129695. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  129696. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  129697. * @param length Defines the length of the ray
  129698. */
  129699. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  129700. /**
  129701. * Detach the ray helper from the mesh it has previously been attached to.
  129702. */
  129703. detachFromMesh(): void;
  129704. private _updateToMesh;
  129705. /**
  129706. * Dispose the helper and release its associated resources.
  129707. */
  129708. dispose(): void;
  129709. }
  129710. }
  129711. declare module BABYLON {
  129712. /**
  129713. * Defines the options associated with the creation of a SkeletonViewer.
  129714. */
  129715. export interface ISkeletonViewerOptions {
  129716. /** Should the system pause animations before building the Viewer? */
  129717. pauseAnimations: boolean;
  129718. /** Should the system return the skeleton to rest before building? */
  129719. returnToRest: boolean;
  129720. /** public Display Mode of the Viewer */
  129721. displayMode: number;
  129722. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129723. displayOptions: ISkeletonViewerDisplayOptions;
  129724. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  129725. computeBonesUsingShaders: boolean;
  129726. }
  129727. /**
  129728. * Defines how to display the various bone meshes for the viewer.
  129729. */
  129730. export interface ISkeletonViewerDisplayOptions {
  129731. /** How far down to start tapering the bone spurs */
  129732. midStep?: number;
  129733. /** How big is the midStep? */
  129734. midStepFactor?: number;
  129735. /** Base for the Sphere Size */
  129736. sphereBaseSize?: number;
  129737. /** The ratio of the sphere to the longest bone in units */
  129738. sphereScaleUnit?: number;
  129739. /** Ratio for the Sphere Size */
  129740. sphereFactor?: number;
  129741. }
  129742. }
  129743. declare module BABYLON {
  129744. /**
  129745. * Class containing static functions to help procedurally build meshes
  129746. */
  129747. export class RibbonBuilder {
  129748. /**
  129749. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129750. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129751. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129752. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129753. * * 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
  129754. * * 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
  129755. * * 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
  129756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129758. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129759. * * 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
  129760. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129761. * * 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
  129762. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129764. * @param name defines the name of the mesh
  129765. * @param options defines the options used to create the mesh
  129766. * @param scene defines the hosting scene
  129767. * @returns the ribbon mesh
  129768. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129769. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129770. */
  129771. static CreateRibbon(name: string, options: {
  129772. pathArray: Vector3[][];
  129773. closeArray?: boolean;
  129774. closePath?: boolean;
  129775. offset?: number;
  129776. updatable?: boolean;
  129777. sideOrientation?: number;
  129778. frontUVs?: Vector4;
  129779. backUVs?: Vector4;
  129780. instance?: Mesh;
  129781. invertUV?: boolean;
  129782. uvs?: Vector2[];
  129783. colors?: Color4[];
  129784. }, scene?: Nullable<Scene>): Mesh;
  129785. }
  129786. }
  129787. declare module BABYLON {
  129788. /**
  129789. * Class containing static functions to help procedurally build meshes
  129790. */
  129791. export class ShapeBuilder {
  129792. /**
  129793. * 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.
  129794. * * 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.
  129795. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129796. * * 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.
  129797. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129798. * * 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
  129799. * * 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
  129800. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129805. * @param name defines the name of the mesh
  129806. * @param options defines the options used to create the mesh
  129807. * @param scene defines the hosting scene
  129808. * @returns the extruded shape mesh
  129809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129811. */
  129812. static ExtrudeShape(name: string, options: {
  129813. shape: Vector3[];
  129814. path: Vector3[];
  129815. scale?: number;
  129816. rotation?: number;
  129817. cap?: number;
  129818. updatable?: boolean;
  129819. sideOrientation?: number;
  129820. frontUVs?: Vector4;
  129821. backUVs?: Vector4;
  129822. instance?: Mesh;
  129823. invertUV?: boolean;
  129824. }, scene?: Nullable<Scene>): Mesh;
  129825. /**
  129826. * Creates an custom extruded shape mesh.
  129827. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129828. * * 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.
  129829. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129830. * * 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
  129831. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129832. * * 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
  129833. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129834. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129835. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129836. * * 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
  129837. * * 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
  129838. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129841. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129843. * @param name defines the name of the mesh
  129844. * @param options defines the options used to create the mesh
  129845. * @param scene defines the hosting scene
  129846. * @returns the custom extruded shape mesh
  129847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129848. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129850. */
  129851. static ExtrudeShapeCustom(name: string, options: {
  129852. shape: Vector3[];
  129853. path: Vector3[];
  129854. scaleFunction?: any;
  129855. rotationFunction?: any;
  129856. ribbonCloseArray?: boolean;
  129857. ribbonClosePath?: boolean;
  129858. cap?: number;
  129859. updatable?: boolean;
  129860. sideOrientation?: number;
  129861. frontUVs?: Vector4;
  129862. backUVs?: Vector4;
  129863. instance?: Mesh;
  129864. invertUV?: boolean;
  129865. }, scene?: Nullable<Scene>): Mesh;
  129866. private static _ExtrudeShapeGeneric;
  129867. }
  129868. }
  129869. declare module BABYLON.Debug {
  129870. /**
  129871. * Class used to render a debug view of a given skeleton
  129872. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  129873. */
  129874. export class SkeletonViewer {
  129875. /** defines the skeleton to render */
  129876. skeleton: Skeleton;
  129877. /** defines the mesh attached to the skeleton */
  129878. mesh: AbstractMesh;
  129879. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129880. autoUpdateBonesMatrices: boolean;
  129881. /** defines the rendering group id to use with the viewer */
  129882. renderingGroupId: number;
  129883. /** is the options for the viewer */
  129884. options: Partial<ISkeletonViewerOptions>;
  129885. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  129886. static readonly DISPLAY_LINES: number;
  129887. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  129888. static readonly DISPLAY_SPHERES: number;
  129889. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  129890. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  129891. /** If SkeletonViewer scene scope. */
  129892. private _scene;
  129893. /** Gets or sets the color used to render the skeleton */
  129894. color: Color3;
  129895. /** Array of the points of the skeleton fo the line view. */
  129896. private _debugLines;
  129897. /** The SkeletonViewers Mesh. */
  129898. private _debugMesh;
  129899. /** If SkeletonViewer is enabled. */
  129900. private _isEnabled;
  129901. /** If SkeletonViewer is ready. */
  129902. private _ready;
  129903. /** SkeletonViewer render observable. */
  129904. private _obs;
  129905. /** The Utility Layer to render the gizmos in. */
  129906. private _utilityLayer;
  129907. private _boneIndices;
  129908. /** Gets the Scene. */
  129909. get scene(): Scene;
  129910. /** Gets the utilityLayer. */
  129911. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  129912. /** Checks Ready Status. */
  129913. get isReady(): Boolean;
  129914. /** Sets Ready Status. */
  129915. set ready(value: boolean);
  129916. /** Gets the debugMesh */
  129917. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  129918. /** Sets the debugMesh */
  129919. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  129920. /** Gets the material */
  129921. get material(): StandardMaterial;
  129922. /** Sets the material */
  129923. set material(value: StandardMaterial);
  129924. /** Gets the material */
  129925. get displayMode(): number;
  129926. /** Sets the material */
  129927. set displayMode(value: number);
  129928. /**
  129929. * Creates a new SkeletonViewer
  129930. * @param skeleton defines the skeleton to render
  129931. * @param mesh defines the mesh attached to the skeleton
  129932. * @param scene defines the hosting scene
  129933. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  129934. * @param renderingGroupId defines the rendering group id to use with the viewer
  129935. * @param options All of the extra constructor options for the SkeletonViewer
  129936. */
  129937. constructor(
  129938. /** defines the skeleton to render */
  129939. skeleton: Skeleton,
  129940. /** defines the mesh attached to the skeleton */
  129941. mesh: AbstractMesh,
  129942. /** The Scene scope*/
  129943. scene: Scene,
  129944. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  129945. autoUpdateBonesMatrices?: boolean,
  129946. /** defines the rendering group id to use with the viewer */
  129947. renderingGroupId?: number,
  129948. /** is the options for the viewer */
  129949. options?: Partial<ISkeletonViewerOptions>);
  129950. /** The Dynamic bindings for the update functions */
  129951. private _bindObs;
  129952. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  129953. update(): void;
  129954. /** Gets or sets a boolean indicating if the viewer is enabled */
  129955. set isEnabled(value: boolean);
  129956. get isEnabled(): boolean;
  129957. private _getBonePosition;
  129958. private _getLinesForBonesWithLength;
  129959. private _getLinesForBonesNoLength;
  129960. /** function to revert the mesh and scene back to the initial state. */
  129961. private _revert;
  129962. /** function to build and bind sphere joint points and spur bone representations. */
  129963. private _buildSpheresAndSpurs;
  129964. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  129965. private _displayLinesUpdate;
  129966. /** Changes the displayMode of the skeleton viewer
  129967. * @param mode The displayMode numerical value
  129968. */
  129969. changeDisplayMode(mode: number): void;
  129970. /** Release associated resources */
  129971. dispose(): void;
  129972. }
  129973. }
  129974. declare module BABYLON {
  129975. /**
  129976. * Enum for Device Types
  129977. */
  129978. export enum DeviceType {
  129979. /** Generic */
  129980. Generic = 0,
  129981. /** Keyboard */
  129982. Keyboard = 1,
  129983. /** Mouse */
  129984. Mouse = 2,
  129985. /** Touch Pointers */
  129986. Touch = 3,
  129987. /** PS4 Dual Shock */
  129988. DualShock = 4,
  129989. /** Xbox */
  129990. Xbox = 5,
  129991. /** Switch Controller */
  129992. Switch = 6
  129993. }
  129994. /**
  129995. * Enum for All Pointers (Touch/Mouse)
  129996. */
  129997. export enum PointerInput {
  129998. /** Horizontal Axis */
  129999. Horizontal = 0,
  130000. /** Vertical Axis */
  130001. Vertical = 1,
  130002. /** Left Click or Touch */
  130003. LeftClick = 2,
  130004. /** Middle Click */
  130005. MiddleClick = 3,
  130006. /** Right Click */
  130007. RightClick = 4,
  130008. /** Browser Back */
  130009. BrowserBack = 5,
  130010. /** Browser Forward */
  130011. BrowserForward = 6
  130012. }
  130013. /**
  130014. * Enum for Dual Shock Gamepad
  130015. */
  130016. export enum DualShockInput {
  130017. /** Cross */
  130018. Cross = 0,
  130019. /** Circle */
  130020. Circle = 1,
  130021. /** Square */
  130022. Square = 2,
  130023. /** Triangle */
  130024. Triangle = 3,
  130025. /** L1 */
  130026. L1 = 4,
  130027. /** R1 */
  130028. R1 = 5,
  130029. /** L2 */
  130030. L2 = 6,
  130031. /** R2 */
  130032. R2 = 7,
  130033. /** Share */
  130034. Share = 8,
  130035. /** Options */
  130036. Options = 9,
  130037. /** L3 */
  130038. L3 = 10,
  130039. /** R3 */
  130040. R3 = 11,
  130041. /** DPadUp */
  130042. DPadUp = 12,
  130043. /** DPadDown */
  130044. DPadDown = 13,
  130045. /** DPadLeft */
  130046. DPadLeft = 14,
  130047. /** DRight */
  130048. DPadRight = 15,
  130049. /** Home */
  130050. Home = 16,
  130051. /** TouchPad */
  130052. TouchPad = 17,
  130053. /** LStickXAxis */
  130054. LStickXAxis = 18,
  130055. /** LStickYAxis */
  130056. LStickYAxis = 19,
  130057. /** RStickXAxis */
  130058. RStickXAxis = 20,
  130059. /** RStickYAxis */
  130060. RStickYAxis = 21
  130061. }
  130062. /**
  130063. * Enum for Xbox Gamepad
  130064. */
  130065. export enum XboxInput {
  130066. /** A */
  130067. A = 0,
  130068. /** B */
  130069. B = 1,
  130070. /** X */
  130071. X = 2,
  130072. /** Y */
  130073. Y = 3,
  130074. /** LB */
  130075. LB = 4,
  130076. /** RB */
  130077. RB = 5,
  130078. /** LT */
  130079. LT = 6,
  130080. /** RT */
  130081. RT = 7,
  130082. /** Back */
  130083. Back = 8,
  130084. /** Start */
  130085. Start = 9,
  130086. /** LS */
  130087. LS = 10,
  130088. /** RS */
  130089. RS = 11,
  130090. /** DPadUp */
  130091. DPadUp = 12,
  130092. /** DPadDown */
  130093. DPadDown = 13,
  130094. /** DPadLeft */
  130095. DPadLeft = 14,
  130096. /** DRight */
  130097. DPadRight = 15,
  130098. /** Home */
  130099. Home = 16,
  130100. /** LStickXAxis */
  130101. LStickXAxis = 17,
  130102. /** LStickYAxis */
  130103. LStickYAxis = 18,
  130104. /** RStickXAxis */
  130105. RStickXAxis = 19,
  130106. /** RStickYAxis */
  130107. RStickYAxis = 20
  130108. }
  130109. /**
  130110. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  130111. */
  130112. export enum SwitchInput {
  130113. /** B */
  130114. B = 0,
  130115. /** A */
  130116. A = 1,
  130117. /** Y */
  130118. Y = 2,
  130119. /** X */
  130120. X = 3,
  130121. /** L */
  130122. L = 4,
  130123. /** R */
  130124. R = 5,
  130125. /** ZL */
  130126. ZL = 6,
  130127. /** ZR */
  130128. ZR = 7,
  130129. /** Minus */
  130130. Minus = 8,
  130131. /** Plus */
  130132. Plus = 9,
  130133. /** LS */
  130134. LS = 10,
  130135. /** RS */
  130136. RS = 11,
  130137. /** DPadUp */
  130138. DPadUp = 12,
  130139. /** DPadDown */
  130140. DPadDown = 13,
  130141. /** DPadLeft */
  130142. DPadLeft = 14,
  130143. /** DRight */
  130144. DPadRight = 15,
  130145. /** Home */
  130146. Home = 16,
  130147. /** Capture */
  130148. Capture = 17,
  130149. /** LStickXAxis */
  130150. LStickXAxis = 18,
  130151. /** LStickYAxis */
  130152. LStickYAxis = 19,
  130153. /** RStickXAxis */
  130154. RStickXAxis = 20,
  130155. /** RStickYAxis */
  130156. RStickYAxis = 21
  130157. }
  130158. }
  130159. declare module BABYLON {
  130160. /**
  130161. * This class will take all inputs from Keyboard, Pointer, and
  130162. * any Gamepads and provide a polling system that all devices
  130163. * will use. This class assumes that there will only be one
  130164. * pointer device and one keyboard.
  130165. */
  130166. export class DeviceInputSystem implements IDisposable {
  130167. /**
  130168. * Callback to be triggered when a device is connected
  130169. */
  130170. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130171. /**
  130172. * Callback to be triggered when a device is disconnected
  130173. */
  130174. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  130175. /**
  130176. * Callback to be triggered when event driven input is updated
  130177. */
  130178. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  130179. private _inputs;
  130180. private _gamepads;
  130181. private _keyboardActive;
  130182. private _pointerActive;
  130183. private _elementToAttachTo;
  130184. private _keyboardDownEvent;
  130185. private _keyboardUpEvent;
  130186. private _pointerMoveEvent;
  130187. private _pointerDownEvent;
  130188. private _pointerUpEvent;
  130189. private _gamepadConnectedEvent;
  130190. private _gamepadDisconnectedEvent;
  130191. private static _MAX_KEYCODES;
  130192. private static _MAX_POINTER_INPUTS;
  130193. private constructor();
  130194. /**
  130195. * Creates a new DeviceInputSystem instance
  130196. * @param engine Engine to pull input element from
  130197. * @returns The new instance
  130198. */
  130199. static Create(engine: Engine): DeviceInputSystem;
  130200. /**
  130201. * Checks for current device input value, given an id and input index
  130202. * @param deviceName Id of connected device
  130203. * @param inputIndex Index of device input
  130204. * @returns Current value of input
  130205. */
  130206. /**
  130207. * Checks for current device input value, given an id and input index
  130208. * @param deviceType Enum specifiying device type
  130209. * @param deviceSlot "Slot" or index that device is referenced in
  130210. * @param inputIndex Id of input to be checked
  130211. * @returns Current value of input
  130212. */
  130213. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  130214. /**
  130215. * Dispose of all the eventlisteners
  130216. */
  130217. dispose(): void;
  130218. /**
  130219. * Add device and inputs to device array
  130220. * @param deviceType Enum specifiying device type
  130221. * @param deviceSlot "Slot" or index that device is referenced in
  130222. * @param numberOfInputs Number of input entries to create for given device
  130223. */
  130224. private _registerDevice;
  130225. /**
  130226. * Given a specific device name, remove that device from the device map
  130227. * @param deviceType Enum specifiying device type
  130228. * @param deviceSlot "Slot" or index that device is referenced in
  130229. */
  130230. private _unregisterDevice;
  130231. /**
  130232. * Handle all actions that come from keyboard interaction
  130233. */
  130234. private _handleKeyActions;
  130235. /**
  130236. * Handle all actions that come from pointer interaction
  130237. */
  130238. private _handlePointerActions;
  130239. /**
  130240. * Handle all actions that come from gamepad interaction
  130241. */
  130242. private _handleGamepadActions;
  130243. /**
  130244. * Update all non-event based devices with each frame
  130245. * @param deviceType Enum specifiying device type
  130246. * @param deviceSlot "Slot" or index that device is referenced in
  130247. * @param inputIndex Id of input to be checked
  130248. */
  130249. private _updateDevice;
  130250. /**
  130251. * Gets DeviceType from the device name
  130252. * @param deviceName Name of Device from DeviceInputSystem
  130253. * @returns DeviceType enum value
  130254. */
  130255. private _getGamepadDeviceType;
  130256. }
  130257. }
  130258. declare module BABYLON {
  130259. /**
  130260. * Type to handle enforcement of inputs
  130261. */
  130262. 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;
  130263. }
  130264. declare module BABYLON {
  130265. /**
  130266. * Class that handles all input for a specific device
  130267. */
  130268. export class DeviceSource<T extends DeviceType> {
  130269. /** Type of device */
  130270. readonly deviceType: DeviceType;
  130271. /** "Slot" or index that device is referenced in */
  130272. readonly deviceSlot: number;
  130273. /**
  130274. * Observable to handle device input changes per device
  130275. */
  130276. readonly onInputChangedObservable: Observable<{
  130277. inputIndex: DeviceInput<T>;
  130278. previousState: Nullable<number>;
  130279. currentState: Nullable<number>;
  130280. }>;
  130281. private readonly _deviceInputSystem;
  130282. /**
  130283. * Default Constructor
  130284. * @param deviceInputSystem Reference to DeviceInputSystem
  130285. * @param deviceType Type of device
  130286. * @param deviceSlot "Slot" or index that device is referenced in
  130287. */
  130288. constructor(deviceInputSystem: DeviceInputSystem,
  130289. /** Type of device */
  130290. deviceType: DeviceType,
  130291. /** "Slot" or index that device is referenced in */
  130292. deviceSlot?: number);
  130293. /**
  130294. * Get input for specific input
  130295. * @param inputIndex index of specific input on device
  130296. * @returns Input value from DeviceInputSystem
  130297. */
  130298. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  130299. }
  130300. /**
  130301. * Class to keep track of devices
  130302. */
  130303. export class DeviceSourceManager implements IDisposable {
  130304. /**
  130305. * Observable to be triggered when before a device is connected
  130306. */
  130307. readonly onBeforeDeviceConnectedObservable: Observable<{
  130308. deviceType: DeviceType;
  130309. deviceSlot: number;
  130310. }>;
  130311. /**
  130312. * Observable to be triggered when before a device is disconnected
  130313. */
  130314. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  130315. deviceType: DeviceType;
  130316. deviceSlot: number;
  130317. }>;
  130318. /**
  130319. * Observable to be triggered when after a device is connected
  130320. */
  130321. readonly onAfterDeviceConnectedObservable: Observable<{
  130322. deviceType: DeviceType;
  130323. deviceSlot: number;
  130324. }>;
  130325. /**
  130326. * Observable to be triggered when after a device is disconnected
  130327. */
  130328. readonly onAfterDeviceDisconnectedObservable: Observable<{
  130329. deviceType: DeviceType;
  130330. deviceSlot: number;
  130331. }>;
  130332. private readonly _devices;
  130333. private readonly _firstDevice;
  130334. private readonly _deviceInputSystem;
  130335. /**
  130336. * Default Constructor
  130337. * @param engine engine to pull input element from
  130338. */
  130339. constructor(engine: Engine);
  130340. /**
  130341. * Gets a DeviceSource, given a type and slot
  130342. * @param deviceType Enum specifying device type
  130343. * @param deviceSlot "Slot" or index that device is referenced in
  130344. * @returns DeviceSource object
  130345. */
  130346. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  130347. /**
  130348. * Gets an array of DeviceSource objects for a given device type
  130349. * @param deviceType Enum specifying device type
  130350. * @returns Array of DeviceSource objects
  130351. */
  130352. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  130353. /**
  130354. * Dispose of DeviceInputSystem and other parts
  130355. */
  130356. dispose(): void;
  130357. /**
  130358. * Function to add device name to device list
  130359. * @param deviceType Enum specifying device type
  130360. * @param deviceSlot "Slot" or index that device is referenced in
  130361. */
  130362. private _addDevice;
  130363. /**
  130364. * Function to remove device name to device list
  130365. * @param deviceType Enum specifying device type
  130366. * @param deviceSlot "Slot" or index that device is referenced in
  130367. */
  130368. private _removeDevice;
  130369. /**
  130370. * Updates array storing first connected device of each type
  130371. * @param type Type of Device
  130372. */
  130373. private _updateFirstDevices;
  130374. }
  130375. }
  130376. declare module BABYLON {
  130377. /**
  130378. * Options to create the null engine
  130379. */
  130380. export class NullEngineOptions {
  130381. /**
  130382. * Render width (Default: 512)
  130383. */
  130384. renderWidth: number;
  130385. /**
  130386. * Render height (Default: 256)
  130387. */
  130388. renderHeight: number;
  130389. /**
  130390. * Texture size (Default: 512)
  130391. */
  130392. textureSize: number;
  130393. /**
  130394. * If delta time between frames should be constant
  130395. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130396. */
  130397. deterministicLockstep: boolean;
  130398. /**
  130399. * Maximum about of steps between frames (Default: 4)
  130400. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130401. */
  130402. lockstepMaxSteps: number;
  130403. /**
  130404. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  130405. */
  130406. useHighPrecisionMatrix?: boolean;
  130407. }
  130408. /**
  130409. * The null engine class provides support for headless version of babylon.js.
  130410. * This can be used in server side scenario or for testing purposes
  130411. */
  130412. export class NullEngine extends Engine {
  130413. private _options;
  130414. /**
  130415. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  130416. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130417. * @returns true if engine is in deterministic lock step mode
  130418. */
  130419. isDeterministicLockStep(): boolean;
  130420. /**
  130421. * Gets the max steps when engine is running in deterministic lock step
  130422. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  130423. * @returns the max steps
  130424. */
  130425. getLockstepMaxSteps(): number;
  130426. /**
  130427. * Gets the current hardware scaling level.
  130428. * By default the hardware scaling level is computed from the window device ratio.
  130429. * 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.
  130430. * @returns a number indicating the current hardware scaling level
  130431. */
  130432. getHardwareScalingLevel(): number;
  130433. constructor(options?: NullEngineOptions);
  130434. /**
  130435. * Creates a vertex buffer
  130436. * @param vertices the data for the vertex buffer
  130437. * @returns the new WebGL static buffer
  130438. */
  130439. createVertexBuffer(vertices: FloatArray): DataBuffer;
  130440. /**
  130441. * Creates a new index buffer
  130442. * @param indices defines the content of the index buffer
  130443. * @param updatable defines if the index buffer must be updatable
  130444. * @returns a new webGL buffer
  130445. */
  130446. createIndexBuffer(indices: IndicesArray): DataBuffer;
  130447. /**
  130448. * Clear the current render buffer or the current render target (if any is set up)
  130449. * @param color defines the color to use
  130450. * @param backBuffer defines if the back buffer must be cleared
  130451. * @param depth defines if the depth buffer must be cleared
  130452. * @param stencil defines if the stencil buffer must be cleared
  130453. */
  130454. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130455. /**
  130456. * Gets the current render width
  130457. * @param useScreen defines if screen size must be used (or the current render target if any)
  130458. * @returns a number defining the current render width
  130459. */
  130460. getRenderWidth(useScreen?: boolean): number;
  130461. /**
  130462. * Gets the current render height
  130463. * @param useScreen defines if screen size must be used (or the current render target if any)
  130464. * @returns a number defining the current render height
  130465. */
  130466. getRenderHeight(useScreen?: boolean): number;
  130467. /**
  130468. * Set the WebGL's viewport
  130469. * @param viewport defines the viewport element to be used
  130470. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  130471. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  130472. */
  130473. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  130474. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  130475. /**
  130476. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  130477. * @param pipelineContext defines the pipeline context to use
  130478. * @param uniformsNames defines the list of uniform names
  130479. * @returns an array of webGL uniform locations
  130480. */
  130481. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  130482. /**
  130483. * Gets the lsit of active attributes for a given webGL program
  130484. * @param pipelineContext defines the pipeline context to use
  130485. * @param attributesNames defines the list of attribute names to get
  130486. * @returns an array of indices indicating the offset of each attribute
  130487. */
  130488. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130489. /**
  130490. * Binds an effect to the webGL context
  130491. * @param effect defines the effect to bind
  130492. */
  130493. bindSamplers(effect: Effect): void;
  130494. /**
  130495. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  130496. * @param effect defines the effect to activate
  130497. */
  130498. enableEffect(effect: Effect): void;
  130499. /**
  130500. * Set various states to the webGL context
  130501. * @param culling defines backface culling state
  130502. * @param zOffset defines the value to apply to zOffset (0 by default)
  130503. * @param force defines if states must be applied even if cache is up to date
  130504. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  130505. */
  130506. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130507. /**
  130508. * Set the value of an uniform to an array of int32
  130509. * @param uniform defines the webGL uniform location where to store the value
  130510. * @param array defines the array of int32 to store
  130511. */
  130512. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130513. /**
  130514. * Set the value of an uniform to an array of int32 (stored as vec2)
  130515. * @param uniform defines the webGL uniform location where to store the value
  130516. * @param array defines the array of int32 to store
  130517. */
  130518. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130519. /**
  130520. * Set the value of an uniform to an array of int32 (stored as vec3)
  130521. * @param uniform defines the webGL uniform location where to store the value
  130522. * @param array defines the array of int32 to store
  130523. */
  130524. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130525. /**
  130526. * Set the value of an uniform to an array of int32 (stored as vec4)
  130527. * @param uniform defines the webGL uniform location where to store the value
  130528. * @param array defines the array of int32 to store
  130529. */
  130530. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130531. /**
  130532. * Set the value of an uniform to an array of float32
  130533. * @param uniform defines the webGL uniform location where to store the value
  130534. * @param array defines the array of float32 to store
  130535. */
  130536. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130537. /**
  130538. * Set the value of an uniform to an array of float32 (stored as vec2)
  130539. * @param uniform defines the webGL uniform location where to store the value
  130540. * @param array defines the array of float32 to store
  130541. */
  130542. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130543. /**
  130544. * Set the value of an uniform to an array of float32 (stored as vec3)
  130545. * @param uniform defines the webGL uniform location where to store the value
  130546. * @param array defines the array of float32 to store
  130547. */
  130548. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130549. /**
  130550. * Set the value of an uniform to an array of float32 (stored as vec4)
  130551. * @param uniform defines the webGL uniform location where to store the value
  130552. * @param array defines the array of float32 to store
  130553. */
  130554. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130555. /**
  130556. * Set the value of an uniform to an array of number
  130557. * @param uniform defines the webGL uniform location where to store the value
  130558. * @param array defines the array of number to store
  130559. */
  130560. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130561. /**
  130562. * Set the value of an uniform to an array of number (stored as vec2)
  130563. * @param uniform defines the webGL uniform location where to store the value
  130564. * @param array defines the array of number to store
  130565. */
  130566. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130567. /**
  130568. * Set the value of an uniform to an array of number (stored as vec3)
  130569. * @param uniform defines the webGL uniform location where to store the value
  130570. * @param array defines the array of number to store
  130571. */
  130572. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130573. /**
  130574. * Set the value of an uniform to an array of number (stored as vec4)
  130575. * @param uniform defines the webGL uniform location where to store the value
  130576. * @param array defines the array of number to store
  130577. */
  130578. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130579. /**
  130580. * Set the value of an uniform to an array of float32 (stored as matrices)
  130581. * @param uniform defines the webGL uniform location where to store the value
  130582. * @param matrices defines the array of float32 to store
  130583. */
  130584. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130585. /**
  130586. * Set the value of an uniform to a matrix (3x3)
  130587. * @param uniform defines the webGL uniform location where to store the value
  130588. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  130589. */
  130590. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130591. /**
  130592. * Set the value of an uniform to a matrix (2x2)
  130593. * @param uniform defines the webGL uniform location where to store the value
  130594. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  130595. */
  130596. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130597. /**
  130598. * Set the value of an uniform to a number (float)
  130599. * @param uniform defines the webGL uniform location where to store the value
  130600. * @param value defines the float number to store
  130601. */
  130602. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130603. /**
  130604. * Set the value of an uniform to a vec2
  130605. * @param uniform defines the webGL uniform location where to store the value
  130606. * @param x defines the 1st component of the value
  130607. * @param y defines the 2nd component of the value
  130608. */
  130609. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130610. /**
  130611. * Set the value of an uniform to a vec3
  130612. * @param uniform defines the webGL uniform location where to store the value
  130613. * @param x defines the 1st component of the value
  130614. * @param y defines the 2nd component of the value
  130615. * @param z defines the 3rd component of the value
  130616. */
  130617. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130618. /**
  130619. * Set the value of an uniform to a boolean
  130620. * @param uniform defines the webGL uniform location where to store the value
  130621. * @param bool defines the boolean to store
  130622. */
  130623. setBool(uniform: WebGLUniformLocation, bool: number): void;
  130624. /**
  130625. * Set the value of an uniform to a vec4
  130626. * @param uniform defines the webGL uniform location where to store the value
  130627. * @param x defines the 1st component of the value
  130628. * @param y defines the 2nd component of the value
  130629. * @param z defines the 3rd component of the value
  130630. * @param w defines the 4th component of the value
  130631. */
  130632. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130633. /**
  130634. * Sets the current alpha mode
  130635. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  130636. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130637. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130638. */
  130639. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130640. /**
  130641. * Bind webGl buffers directly to the webGL context
  130642. * @param vertexBuffers defines the vertex buffer to bind
  130643. * @param indexBuffer defines the index buffer to bind
  130644. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  130645. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  130646. * @param effect defines the effect associated with the vertex buffer
  130647. */
  130648. bindBuffers(vertexBuffers: {
  130649. [key: string]: VertexBuffer;
  130650. }, indexBuffer: DataBuffer, effect: Effect): void;
  130651. /**
  130652. * Force the entire cache to be cleared
  130653. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  130654. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  130655. */
  130656. wipeCaches(bruteForce?: boolean): void;
  130657. /**
  130658. * Send a draw order
  130659. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  130660. * @param indexStart defines the starting index
  130661. * @param indexCount defines the number of index to draw
  130662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130663. */
  130664. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  130665. /**
  130666. * Draw a list of indexed primitives
  130667. * @param fillMode defines the primitive to use
  130668. * @param indexStart defines the starting index
  130669. * @param indexCount defines the number of index to draw
  130670. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130671. */
  130672. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130673. /**
  130674. * Draw a list of unindexed primitives
  130675. * @param fillMode defines the primitive to use
  130676. * @param verticesStart defines the index of first vertex to draw
  130677. * @param verticesCount defines the count of vertices to draw
  130678. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130679. */
  130680. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130681. /** @hidden */
  130682. _createTexture(): WebGLTexture;
  130683. /** @hidden */
  130684. _releaseTexture(texture: InternalTexture): void;
  130685. /**
  130686. * Usually called from Texture.ts.
  130687. * Passed information to create a WebGLTexture
  130688. * @param urlArg defines a value which contains one of the following:
  130689. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130690. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130691. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130692. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130693. * @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)
  130694. * @param scene needed for loading to the correct scene
  130695. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130696. * @param onLoad optional callback to be called upon successful completion
  130697. * @param onError optional callback to be called upon failure
  130698. * @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
  130699. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130700. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130701. * @param forcedExtension defines the extension to use to pick the right loader
  130702. * @param mimeType defines an optional mime type
  130703. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130704. */
  130705. 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;
  130706. /**
  130707. * Creates a new render target texture
  130708. * @param size defines the size of the texture
  130709. * @param options defines the options used to create the texture
  130710. * @returns a new render target texture stored in an InternalTexture
  130711. */
  130712. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  130713. /**
  130714. * Update the sampling mode of a given texture
  130715. * @param samplingMode defines the required sampling mode
  130716. * @param texture defines the texture to update
  130717. */
  130718. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130719. /**
  130720. * Binds the frame buffer to the specified texture.
  130721. * @param texture The texture to render to or null for the default canvas
  130722. * @param faceIndex The face of the texture to render to in case of cube texture
  130723. * @param requiredWidth The width of the target to render to
  130724. * @param requiredHeight The height of the target to render to
  130725. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  130726. * @param lodLevel defines le lod level to bind to the frame buffer
  130727. */
  130728. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130729. /**
  130730. * Unbind the current render target texture from the webGL context
  130731. * @param texture defines the render target texture to unbind
  130732. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  130733. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  130734. */
  130735. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130736. /**
  130737. * Creates a dynamic vertex buffer
  130738. * @param vertices the data for the dynamic vertex buffer
  130739. * @returns the new WebGL dynamic buffer
  130740. */
  130741. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  130742. /**
  130743. * Update the content of a dynamic texture
  130744. * @param texture defines the texture to update
  130745. * @param canvas defines the canvas containing the source
  130746. * @param invertY defines if data must be stored with Y axis inverted
  130747. * @param premulAlpha defines if alpha is stored as premultiplied
  130748. * @param format defines the format of the data
  130749. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  130750. */
  130751. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  130752. /**
  130753. * Gets a boolean indicating if all created effects are ready
  130754. * @returns true if all effects are ready
  130755. */
  130756. areAllEffectsReady(): boolean;
  130757. /**
  130758. * @hidden
  130759. * Get the current error code of the webGL context
  130760. * @returns the error code
  130761. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  130762. */
  130763. getError(): number;
  130764. /** @hidden */
  130765. _getUnpackAlignement(): number;
  130766. /** @hidden */
  130767. _unpackFlipY(value: boolean): void;
  130768. /**
  130769. * Update a dynamic index buffer
  130770. * @param indexBuffer defines the target index buffer
  130771. * @param indices defines the data to update
  130772. * @param offset defines the offset in the target index buffer where update should start
  130773. */
  130774. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  130775. /**
  130776. * Updates a dynamic vertex buffer.
  130777. * @param vertexBuffer the vertex buffer to update
  130778. * @param vertices the data used to update the vertex buffer
  130779. * @param byteOffset the byte offset of the data (optional)
  130780. * @param byteLength the byte length of the data (optional)
  130781. */
  130782. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  130783. /** @hidden */
  130784. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  130785. /** @hidden */
  130786. _bindTexture(channel: number, texture: InternalTexture): void;
  130787. protected _deleteBuffer(buffer: WebGLBuffer): void;
  130788. /**
  130789. * 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
  130790. */
  130791. releaseEffects(): void;
  130792. displayLoadingUI(): void;
  130793. hideLoadingUI(): void;
  130794. /** @hidden */
  130795. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130796. /** @hidden */
  130797. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130798. /** @hidden */
  130799. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130800. /** @hidden */
  130801. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130802. }
  130803. }
  130804. declare module BABYLON {
  130805. /**
  130806. * @hidden
  130807. **/
  130808. export class _TimeToken {
  130809. _startTimeQuery: Nullable<WebGLQuery>;
  130810. _endTimeQuery: Nullable<WebGLQuery>;
  130811. _timeElapsedQuery: Nullable<WebGLQuery>;
  130812. _timeElapsedQueryEnded: boolean;
  130813. }
  130814. }
  130815. declare module BABYLON {
  130816. /** @hidden */
  130817. export class _OcclusionDataStorage {
  130818. /** @hidden */
  130819. occlusionInternalRetryCounter: number;
  130820. /** @hidden */
  130821. isOcclusionQueryInProgress: boolean;
  130822. /** @hidden */
  130823. isOccluded: boolean;
  130824. /** @hidden */
  130825. occlusionRetryCount: number;
  130826. /** @hidden */
  130827. occlusionType: number;
  130828. /** @hidden */
  130829. occlusionQueryAlgorithmType: number;
  130830. }
  130831. interface Engine {
  130832. /**
  130833. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  130834. * @return the new query
  130835. */
  130836. createQuery(): WebGLQuery;
  130837. /**
  130838. * Delete and release a webGL query
  130839. * @param query defines the query to delete
  130840. * @return the current engine
  130841. */
  130842. deleteQuery(query: WebGLQuery): Engine;
  130843. /**
  130844. * Check if a given query has resolved and got its value
  130845. * @param query defines the query to check
  130846. * @returns true if the query got its value
  130847. */
  130848. isQueryResultAvailable(query: WebGLQuery): boolean;
  130849. /**
  130850. * Gets the value of a given query
  130851. * @param query defines the query to check
  130852. * @returns the value of the query
  130853. */
  130854. getQueryResult(query: WebGLQuery): number;
  130855. /**
  130856. * Initiates an occlusion query
  130857. * @param algorithmType defines the algorithm to use
  130858. * @param query defines the query to use
  130859. * @returns the current engine
  130860. * @see https://doc.babylonjs.com/features/occlusionquery
  130861. */
  130862. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  130863. /**
  130864. * Ends an occlusion query
  130865. * @see https://doc.babylonjs.com/features/occlusionquery
  130866. * @param algorithmType defines the algorithm to use
  130867. * @returns the current engine
  130868. */
  130869. endOcclusionQuery(algorithmType: number): Engine;
  130870. /**
  130871. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  130872. * Please note that only one query can be issued at a time
  130873. * @returns a time token used to track the time span
  130874. */
  130875. startTimeQuery(): Nullable<_TimeToken>;
  130876. /**
  130877. * Ends a time query
  130878. * @param token defines the token used to measure the time span
  130879. * @returns the time spent (in ns)
  130880. */
  130881. endTimeQuery(token: _TimeToken): int;
  130882. /** @hidden */
  130883. _currentNonTimestampToken: Nullable<_TimeToken>;
  130884. /** @hidden */
  130885. _createTimeQuery(): WebGLQuery;
  130886. /** @hidden */
  130887. _deleteTimeQuery(query: WebGLQuery): void;
  130888. /** @hidden */
  130889. _getGlAlgorithmType(algorithmType: number): number;
  130890. /** @hidden */
  130891. _getTimeQueryResult(query: WebGLQuery): any;
  130892. /** @hidden */
  130893. _getTimeQueryAvailability(query: WebGLQuery): any;
  130894. }
  130895. interface AbstractMesh {
  130896. /**
  130897. * Backing filed
  130898. * @hidden
  130899. */
  130900. __occlusionDataStorage: _OcclusionDataStorage;
  130901. /**
  130902. * Access property
  130903. * @hidden
  130904. */
  130905. _occlusionDataStorage: _OcclusionDataStorage;
  130906. /**
  130907. * 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.
  130908. * The default value is -1 which means don't break the query and wait till the result
  130909. * @see https://doc.babylonjs.com/features/occlusionquery
  130910. */
  130911. occlusionRetryCount: number;
  130912. /**
  130913. * 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:
  130914. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  130915. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  130916. * * 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.
  130917. * @see https://doc.babylonjs.com/features/occlusionquery
  130918. */
  130919. occlusionType: number;
  130920. /**
  130921. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  130922. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  130923. * * 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.
  130924. * @see https://doc.babylonjs.com/features/occlusionquery
  130925. */
  130926. occlusionQueryAlgorithmType: number;
  130927. /**
  130928. * 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
  130929. * @see https://doc.babylonjs.com/features/occlusionquery
  130930. */
  130931. isOccluded: boolean;
  130932. /**
  130933. * Flag to check the progress status of the query
  130934. * @see https://doc.babylonjs.com/features/occlusionquery
  130935. */
  130936. isOcclusionQueryInProgress: boolean;
  130937. }
  130938. }
  130939. declare module BABYLON {
  130940. /** @hidden */
  130941. export var _forceTransformFeedbackToBundle: boolean;
  130942. interface Engine {
  130943. /**
  130944. * Creates a webGL transform feedback object
  130945. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  130946. * @returns the webGL transform feedback object
  130947. */
  130948. createTransformFeedback(): WebGLTransformFeedback;
  130949. /**
  130950. * Delete a webGL transform feedback object
  130951. * @param value defines the webGL transform feedback object to delete
  130952. */
  130953. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  130954. /**
  130955. * Bind a webGL transform feedback object to the webgl context
  130956. * @param value defines the webGL transform feedback object to bind
  130957. */
  130958. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  130959. /**
  130960. * Begins a transform feedback operation
  130961. * @param usePoints defines if points or triangles must be used
  130962. */
  130963. beginTransformFeedback(usePoints: boolean): void;
  130964. /**
  130965. * Ends a transform feedback operation
  130966. */
  130967. endTransformFeedback(): void;
  130968. /**
  130969. * Specify the varyings to use with transform feedback
  130970. * @param program defines the associated webGL program
  130971. * @param value defines the list of strings representing the varying names
  130972. */
  130973. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  130974. /**
  130975. * Bind a webGL buffer for a transform feedback operation
  130976. * @param value defines the webGL buffer to bind
  130977. */
  130978. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  130979. }
  130980. }
  130981. declare module BABYLON {
  130982. /**
  130983. * Class used to define an additional view for the engine
  130984. * @see https://doc.babylonjs.com/how_to/multi_canvases
  130985. */
  130986. export class EngineView {
  130987. /** Defines the canvas where to render the view */
  130988. target: HTMLCanvasElement;
  130989. /** Defines an optional camera used to render the view (will use active camera else) */
  130990. camera?: Camera;
  130991. }
  130992. interface Engine {
  130993. /**
  130994. * Gets or sets the HTML element to use for attaching events
  130995. */
  130996. inputElement: Nullable<HTMLElement>;
  130997. /**
  130998. * Gets the current engine view
  130999. * @see https://doc.babylonjs.com/how_to/multi_canvases
  131000. */
  131001. activeView: Nullable<EngineView>;
  131002. /** Gets or sets the list of views */
  131003. views: EngineView[];
  131004. /**
  131005. * Register a new child canvas
  131006. * @param canvas defines the canvas to register
  131007. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  131008. * @returns the associated view
  131009. */
  131010. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  131011. /**
  131012. * Remove a registered child canvas
  131013. * @param canvas defines the canvas to remove
  131014. * @returns the current engine
  131015. */
  131016. unRegisterView(canvas: HTMLCanvasElement): Engine;
  131017. }
  131018. }
  131019. declare module BABYLON {
  131020. interface Engine {
  131021. /** @hidden */
  131022. _excludedCompressedTextures: string[];
  131023. /** @hidden */
  131024. _textureFormatInUse: string;
  131025. /**
  131026. * Gets the list of texture formats supported
  131027. */
  131028. readonly texturesSupported: Array<string>;
  131029. /**
  131030. * Gets the texture format in use
  131031. */
  131032. readonly textureFormatInUse: Nullable<string>;
  131033. /**
  131034. * Set the compressed texture extensions or file names to skip.
  131035. *
  131036. * @param skippedFiles defines the list of those texture files you want to skip
  131037. * Example: [".dds", ".env", "myfile.png"]
  131038. */
  131039. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  131040. /**
  131041. * Set the compressed texture format to use, based on the formats you have, and the formats
  131042. * supported by the hardware / browser.
  131043. *
  131044. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  131045. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  131046. * to API arguments needed to compressed textures. This puts the burden on the container
  131047. * generator to house the arcane code for determining these for current & future formats.
  131048. *
  131049. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  131050. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  131051. *
  131052. * Note: The result of this call is not taken into account when a texture is base64.
  131053. *
  131054. * @param formatsAvailable defines the list of those format families you have created
  131055. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  131056. *
  131057. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  131058. * @returns The extension selected.
  131059. */
  131060. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  131061. }
  131062. }
  131063. declare module BABYLON {
  131064. /**
  131065. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  131066. */
  131067. export interface CubeMapInfo {
  131068. /**
  131069. * The pixel array for the front face.
  131070. * This is stored in format, left to right, up to down format.
  131071. */
  131072. front: Nullable<ArrayBufferView>;
  131073. /**
  131074. * The pixel array for the back face.
  131075. * This is stored in format, left to right, up to down format.
  131076. */
  131077. back: Nullable<ArrayBufferView>;
  131078. /**
  131079. * The pixel array for the left face.
  131080. * This is stored in format, left to right, up to down format.
  131081. */
  131082. left: Nullable<ArrayBufferView>;
  131083. /**
  131084. * The pixel array for the right face.
  131085. * This is stored in format, left to right, up to down format.
  131086. */
  131087. right: Nullable<ArrayBufferView>;
  131088. /**
  131089. * The pixel array for the up face.
  131090. * This is stored in format, left to right, up to down format.
  131091. */
  131092. up: Nullable<ArrayBufferView>;
  131093. /**
  131094. * The pixel array for the down face.
  131095. * This is stored in format, left to right, up to down format.
  131096. */
  131097. down: Nullable<ArrayBufferView>;
  131098. /**
  131099. * The size of the cubemap stored.
  131100. *
  131101. * Each faces will be size * size pixels.
  131102. */
  131103. size: number;
  131104. /**
  131105. * The format of the texture.
  131106. *
  131107. * RGBA, RGB.
  131108. */
  131109. format: number;
  131110. /**
  131111. * The type of the texture data.
  131112. *
  131113. * UNSIGNED_INT, FLOAT.
  131114. */
  131115. type: number;
  131116. /**
  131117. * Specifies whether the texture is in gamma space.
  131118. */
  131119. gammaSpace: boolean;
  131120. }
  131121. /**
  131122. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  131123. */
  131124. export class PanoramaToCubeMapTools {
  131125. private static FACE_LEFT;
  131126. private static FACE_RIGHT;
  131127. private static FACE_FRONT;
  131128. private static FACE_BACK;
  131129. private static FACE_DOWN;
  131130. private static FACE_UP;
  131131. /**
  131132. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  131133. *
  131134. * @param float32Array The source data.
  131135. * @param inputWidth The width of the input panorama.
  131136. * @param inputHeight The height of the input panorama.
  131137. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  131138. * @return The cubemap data
  131139. */
  131140. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  131141. private static CreateCubemapTexture;
  131142. private static CalcProjectionSpherical;
  131143. }
  131144. }
  131145. declare module BABYLON {
  131146. /**
  131147. * Helper class dealing with the extraction of spherical polynomial dataArray
  131148. * from a cube map.
  131149. */
  131150. export class CubeMapToSphericalPolynomialTools {
  131151. private static FileFaces;
  131152. /**
  131153. * Converts a texture to the according Spherical Polynomial data.
  131154. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131155. *
  131156. * @param texture The texture to extract the information from.
  131157. * @return The Spherical Polynomial data.
  131158. */
  131159. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  131160. /**
  131161. * Converts a cubemap to the according Spherical Polynomial data.
  131162. * This extracts the first 3 orders only as they are the only one used in the lighting.
  131163. *
  131164. * @param cubeInfo The Cube map to extract the information from.
  131165. * @return The Spherical Polynomial data.
  131166. */
  131167. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  131168. }
  131169. }
  131170. declare module BABYLON {
  131171. interface BaseTexture {
  131172. /**
  131173. * Get the polynomial representation of the texture data.
  131174. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  131175. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  131176. */
  131177. sphericalPolynomial: Nullable<SphericalPolynomial>;
  131178. }
  131179. }
  131180. declare module BABYLON {
  131181. /** @hidden */
  131182. export var rgbdEncodePixelShader: {
  131183. name: string;
  131184. shader: string;
  131185. };
  131186. }
  131187. declare module BABYLON {
  131188. /** @hidden */
  131189. export var rgbdDecodePixelShader: {
  131190. name: string;
  131191. shader: string;
  131192. };
  131193. }
  131194. declare module BABYLON {
  131195. /**
  131196. * Raw texture data and descriptor sufficient for WebGL texture upload
  131197. */
  131198. export interface EnvironmentTextureInfo {
  131199. /**
  131200. * Version of the environment map
  131201. */
  131202. version: number;
  131203. /**
  131204. * Width of image
  131205. */
  131206. width: number;
  131207. /**
  131208. * Irradiance information stored in the file.
  131209. */
  131210. irradiance: any;
  131211. /**
  131212. * Specular information stored in the file.
  131213. */
  131214. specular: any;
  131215. }
  131216. /**
  131217. * Defines One Image in the file. It requires only the position in the file
  131218. * as well as the length.
  131219. */
  131220. interface BufferImageData {
  131221. /**
  131222. * Length of the image data.
  131223. */
  131224. length: number;
  131225. /**
  131226. * Position of the data from the null terminator delimiting the end of the JSON.
  131227. */
  131228. position: number;
  131229. }
  131230. /**
  131231. * Defines the specular data enclosed in the file.
  131232. * This corresponds to the version 1 of the data.
  131233. */
  131234. export interface EnvironmentTextureSpecularInfoV1 {
  131235. /**
  131236. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  131237. */
  131238. specularDataPosition?: number;
  131239. /**
  131240. * This contains all the images data needed to reconstruct the cubemap.
  131241. */
  131242. mipmaps: Array<BufferImageData>;
  131243. /**
  131244. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  131245. */
  131246. lodGenerationScale: number;
  131247. }
  131248. /**
  131249. * Sets of helpers addressing the serialization and deserialization of environment texture
  131250. * stored in a BabylonJS env file.
  131251. * Those files are usually stored as .env files.
  131252. */
  131253. export class EnvironmentTextureTools {
  131254. /**
  131255. * Magic number identifying the env file.
  131256. */
  131257. private static _MagicBytes;
  131258. /**
  131259. * Gets the environment info from an env file.
  131260. * @param data The array buffer containing the .env bytes.
  131261. * @returns the environment file info (the json header) if successfully parsed.
  131262. */
  131263. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  131264. /**
  131265. * Creates an environment texture from a loaded cube texture.
  131266. * @param texture defines the cube texture to convert in env file
  131267. * @return a promise containing the environment data if succesfull.
  131268. */
  131269. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  131270. /**
  131271. * Creates a JSON representation of the spherical data.
  131272. * @param texture defines the texture containing the polynomials
  131273. * @return the JSON representation of the spherical info
  131274. */
  131275. private static _CreateEnvTextureIrradiance;
  131276. /**
  131277. * Creates the ArrayBufferViews used for initializing environment texture image data.
  131278. * @param data the image data
  131279. * @param info parameters that determine what views will be created for accessing the underlying buffer
  131280. * @return the views described by info providing access to the underlying buffer
  131281. */
  131282. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  131283. /**
  131284. * Uploads the texture info contained in the env file to the GPU.
  131285. * @param texture defines the internal texture to upload to
  131286. * @param data defines the data to load
  131287. * @param info defines the texture info retrieved through the GetEnvInfo method
  131288. * @returns a promise
  131289. */
  131290. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  131291. private static _OnImageReadyAsync;
  131292. /**
  131293. * Uploads the levels of image data to the GPU.
  131294. * @param texture defines the internal texture to upload to
  131295. * @param imageData defines the array buffer views of image data [mipmap][face]
  131296. * @returns a promise
  131297. */
  131298. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  131299. /**
  131300. * Uploads spherical polynomials information to the texture.
  131301. * @param texture defines the texture we are trying to upload the information to
  131302. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  131303. */
  131304. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  131305. /** @hidden */
  131306. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131307. }
  131308. }
  131309. declare module BABYLON {
  131310. /**
  131311. * Class used to inline functions in shader code
  131312. */
  131313. export class ShaderCodeInliner {
  131314. private static readonly _RegexpFindFunctionNameAndType;
  131315. private _sourceCode;
  131316. private _functionDescr;
  131317. private _numMaxIterations;
  131318. /** Gets or sets the token used to mark the functions to inline */
  131319. inlineToken: string;
  131320. /** Gets or sets the debug mode */
  131321. debug: boolean;
  131322. /** Gets the code after the inlining process */
  131323. get code(): string;
  131324. /**
  131325. * Initializes the inliner
  131326. * @param sourceCode shader code source to inline
  131327. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  131328. */
  131329. constructor(sourceCode: string, numMaxIterations?: number);
  131330. /**
  131331. * Start the processing of the shader code
  131332. */
  131333. processCode(): void;
  131334. private _collectFunctions;
  131335. private _processInlining;
  131336. private _extractBetweenMarkers;
  131337. private _skipWhitespaces;
  131338. private _removeComments;
  131339. private _replaceFunctionCallsByCode;
  131340. private _findBackward;
  131341. private _escapeRegExp;
  131342. private _replaceNames;
  131343. }
  131344. }
  131345. declare module BABYLON {
  131346. /**
  131347. * Container for accessors for natively-stored mesh data buffers.
  131348. */
  131349. class NativeDataBuffer extends DataBuffer {
  131350. /**
  131351. * Accessor value used to identify/retrieve a natively-stored index buffer.
  131352. */
  131353. nativeIndexBuffer?: any;
  131354. /**
  131355. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  131356. */
  131357. nativeVertexBuffer?: any;
  131358. }
  131359. /** @hidden */
  131360. class NativeTexture extends InternalTexture {
  131361. getInternalTexture(): InternalTexture;
  131362. getViewCount(): number;
  131363. }
  131364. /** @hidden */
  131365. export class NativeEngine extends Engine {
  131366. private readonly _native;
  131367. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  131368. private readonly INVALID_HANDLE;
  131369. private _boundBuffersVertexArray;
  131370. getHardwareScalingLevel(): number;
  131371. constructor();
  131372. dispose(): void;
  131373. /**
  131374. * Can be used to override the current requestAnimationFrame requester.
  131375. * @hidden
  131376. */
  131377. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  131378. /**
  131379. * Override default engine behavior.
  131380. * @param color
  131381. * @param backBuffer
  131382. * @param depth
  131383. * @param stencil
  131384. */
  131385. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  131386. /**
  131387. * Gets host document
  131388. * @returns the host document object
  131389. */
  131390. getHostDocument(): Nullable<Document>;
  131391. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131392. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  131393. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  131394. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  131395. [key: string]: VertexBuffer;
  131396. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131397. bindBuffers(vertexBuffers: {
  131398. [key: string]: VertexBuffer;
  131399. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  131400. recordVertexArrayObject(vertexBuffers: {
  131401. [key: string]: VertexBuffer;
  131402. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  131403. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131404. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  131405. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131406. /**
  131407. * Draw a list of indexed primitives
  131408. * @param fillMode defines the primitive to use
  131409. * @param indexStart defines the starting index
  131410. * @param indexCount defines the number of index to draw
  131411. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131412. */
  131413. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131414. /**
  131415. * Draw a list of unindexed primitives
  131416. * @param fillMode defines the primitive to use
  131417. * @param verticesStart defines the index of first vertex to draw
  131418. * @param verticesCount defines the count of vertices to draw
  131419. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131420. */
  131421. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131422. createPipelineContext(): IPipelineContext;
  131423. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  131424. /** @hidden */
  131425. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  131426. /** @hidden */
  131427. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  131428. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131429. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  131430. protected _setProgram(program: WebGLProgram): void;
  131431. _releaseEffect(effect: Effect): void;
  131432. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  131433. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  131434. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  131435. bindSamplers(effect: Effect): void;
  131436. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  131437. getRenderWidth(useScreen?: boolean): number;
  131438. getRenderHeight(useScreen?: boolean): number;
  131439. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  131440. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131441. /**
  131442. * Set the z offset to apply to current rendering
  131443. * @param value defines the offset to apply
  131444. */
  131445. setZOffset(value: number): void;
  131446. /**
  131447. * Gets the current value of the zOffset
  131448. * @returns the current zOffset state
  131449. */
  131450. getZOffset(): number;
  131451. /**
  131452. * Enable or disable depth buffering
  131453. * @param enable defines the state to set
  131454. */
  131455. setDepthBuffer(enable: boolean): void;
  131456. /**
  131457. * Gets a boolean indicating if depth writing is enabled
  131458. * @returns the current depth writing state
  131459. */
  131460. getDepthWrite(): boolean;
  131461. /**
  131462. * Enable or disable depth writing
  131463. * @param enable defines the state to set
  131464. */
  131465. setDepthWrite(enable: boolean): void;
  131466. /**
  131467. * Enable or disable color writing
  131468. * @param enable defines the state to set
  131469. */
  131470. setColorWrite(enable: boolean): void;
  131471. /**
  131472. * Gets a boolean indicating if color writing is enabled
  131473. * @returns the current color writing state
  131474. */
  131475. getColorWrite(): boolean;
  131476. /**
  131477. * Sets alpha constants used by some alpha blending modes
  131478. * @param r defines the red component
  131479. * @param g defines the green component
  131480. * @param b defines the blue component
  131481. * @param a defines the alpha component
  131482. */
  131483. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  131484. /**
  131485. * Sets the current alpha mode
  131486. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  131487. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131488. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131489. */
  131490. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131491. /**
  131492. * Gets the current alpha mode
  131493. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131494. * @returns the current alpha mode
  131495. */
  131496. getAlphaMode(): number;
  131497. setInt(uniform: WebGLUniformLocation, int: number): void;
  131498. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131499. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131500. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131501. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131502. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131503. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131504. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131505. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131506. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131507. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131508. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131509. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131510. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131511. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131512. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131513. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131514. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131515. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131516. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131517. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  131518. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  131519. wipeCaches(bruteForce?: boolean): void;
  131520. _createTexture(): WebGLTexture;
  131521. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  131522. /**
  131523. * Usually called from Texture.ts.
  131524. * Passed information to create a WebGLTexture
  131525. * @param url defines a value which contains one of the following:
  131526. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131527. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131528. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131529. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131530. * @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)
  131531. * @param scene needed for loading to the correct scene
  131532. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131533. * @param onLoad optional callback to be called upon successful completion
  131534. * @param onError optional callback to be called upon failure
  131535. * @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
  131536. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131537. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131538. * @param forcedExtension defines the extension to use to pick the right loader
  131539. * @param mimeType defines an optional mime type
  131540. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131541. */
  131542. 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;
  131543. /**
  131544. * Creates a cube texture
  131545. * @param rootUrl defines the url where the files to load is located
  131546. * @param scene defines the current scene
  131547. * @param files defines the list of files to load (1 per face)
  131548. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  131549. * @param onLoad defines an optional callback raised when the texture is loaded
  131550. * @param onError defines an optional callback raised if there is an issue to load the texture
  131551. * @param format defines the format of the data
  131552. * @param forcedExtension defines the extension to use to pick the right loader
  131553. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  131554. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131555. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131556. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  131557. * @returns the cube texture as an InternalTexture
  131558. */
  131559. 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;
  131560. private _getSamplingFilter;
  131561. private static _GetNativeTextureFormat;
  131562. createRenderTargetTexture(size: number | {
  131563. width: number;
  131564. height: number;
  131565. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  131566. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131567. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131568. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131569. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  131570. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  131571. /**
  131572. * Updates a dynamic vertex buffer.
  131573. * @param vertexBuffer the vertex buffer to update
  131574. * @param data the data used to update the vertex buffer
  131575. * @param byteOffset the byte offset of the data (optional)
  131576. * @param byteLength the byte length of the data (optional)
  131577. */
  131578. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  131579. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  131580. private _updateAnisotropicLevel;
  131581. private _getAddressMode;
  131582. /** @hidden */
  131583. _bindTexture(channel: number, texture: InternalTexture): void;
  131584. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  131585. releaseEffects(): void;
  131586. /** @hidden */
  131587. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131588. /** @hidden */
  131589. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131590. /** @hidden */
  131591. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131592. /** @hidden */
  131593. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131594. }
  131595. }
  131596. declare module BABYLON {
  131597. /**
  131598. * Gather the list of clipboard event types as constants.
  131599. */
  131600. export class ClipboardEventTypes {
  131601. /**
  131602. * The clipboard event is fired when a copy command is active (pressed).
  131603. */
  131604. static readonly COPY: number;
  131605. /**
  131606. * The clipboard event is fired when a cut command is active (pressed).
  131607. */
  131608. static readonly CUT: number;
  131609. /**
  131610. * The clipboard event is fired when a paste command is active (pressed).
  131611. */
  131612. static readonly PASTE: number;
  131613. }
  131614. /**
  131615. * This class is used to store clipboard related info for the onClipboardObservable event.
  131616. */
  131617. export class ClipboardInfo {
  131618. /**
  131619. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131620. */
  131621. type: number;
  131622. /**
  131623. * Defines the related dom event
  131624. */
  131625. event: ClipboardEvent;
  131626. /**
  131627. *Creates an instance of ClipboardInfo.
  131628. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  131629. * @param event Defines the related dom event
  131630. */
  131631. constructor(
  131632. /**
  131633. * Defines the type of event (BABYLON.ClipboardEventTypes)
  131634. */
  131635. type: number,
  131636. /**
  131637. * Defines the related dom event
  131638. */
  131639. event: ClipboardEvent);
  131640. /**
  131641. * Get the clipboard event's type from the keycode.
  131642. * @param keyCode Defines the keyCode for the current keyboard event.
  131643. * @return {number}
  131644. */
  131645. static GetTypeFromCharacter(keyCode: number): number;
  131646. }
  131647. }
  131648. declare module BABYLON {
  131649. /**
  131650. * Google Daydream controller
  131651. */
  131652. export class DaydreamController extends WebVRController {
  131653. /**
  131654. * Base Url for the controller model.
  131655. */
  131656. static MODEL_BASE_URL: string;
  131657. /**
  131658. * File name for the controller model.
  131659. */
  131660. static MODEL_FILENAME: string;
  131661. /**
  131662. * Gamepad Id prefix used to identify Daydream Controller.
  131663. */
  131664. static readonly GAMEPAD_ID_PREFIX: string;
  131665. /**
  131666. * Creates a new DaydreamController from a gamepad
  131667. * @param vrGamepad the gamepad that the controller should be created from
  131668. */
  131669. constructor(vrGamepad: any);
  131670. /**
  131671. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131672. * @param scene scene in which to add meshes
  131673. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131674. */
  131675. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131676. /**
  131677. * Called once for each button that changed state since the last frame
  131678. * @param buttonIdx Which button index changed
  131679. * @param state New state of the button
  131680. * @param changes Which properties on the state changed since last frame
  131681. */
  131682. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131683. }
  131684. }
  131685. declare module BABYLON {
  131686. /**
  131687. * Gear VR Controller
  131688. */
  131689. export class GearVRController extends WebVRController {
  131690. /**
  131691. * Base Url for the controller model.
  131692. */
  131693. static MODEL_BASE_URL: string;
  131694. /**
  131695. * File name for the controller model.
  131696. */
  131697. static MODEL_FILENAME: string;
  131698. /**
  131699. * Gamepad Id prefix used to identify this controller.
  131700. */
  131701. static readonly GAMEPAD_ID_PREFIX: string;
  131702. private readonly _buttonIndexToObservableNameMap;
  131703. /**
  131704. * Creates a new GearVRController from a gamepad
  131705. * @param vrGamepad the gamepad that the controller should be created from
  131706. */
  131707. constructor(vrGamepad: any);
  131708. /**
  131709. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131710. * @param scene scene in which to add meshes
  131711. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131712. */
  131713. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131714. /**
  131715. * Called once for each button that changed state since the last frame
  131716. * @param buttonIdx Which button index changed
  131717. * @param state New state of the button
  131718. * @param changes Which properties on the state changed since last frame
  131719. */
  131720. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131721. }
  131722. }
  131723. declare module BABYLON {
  131724. /**
  131725. * Generic Controller
  131726. */
  131727. export class GenericController extends WebVRController {
  131728. /**
  131729. * Base Url for the controller model.
  131730. */
  131731. static readonly MODEL_BASE_URL: string;
  131732. /**
  131733. * File name for the controller model.
  131734. */
  131735. static readonly MODEL_FILENAME: string;
  131736. /**
  131737. * Creates a new GenericController from a gamepad
  131738. * @param vrGamepad the gamepad that the controller should be created from
  131739. */
  131740. constructor(vrGamepad: any);
  131741. /**
  131742. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131743. * @param scene scene in which to add meshes
  131744. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131745. */
  131746. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131747. /**
  131748. * Called once for each button that changed state since the last frame
  131749. * @param buttonIdx Which button index changed
  131750. * @param state New state of the button
  131751. * @param changes Which properties on the state changed since last frame
  131752. */
  131753. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131754. }
  131755. }
  131756. declare module BABYLON {
  131757. /**
  131758. * Oculus Touch Controller
  131759. */
  131760. export class OculusTouchController extends WebVRController {
  131761. /**
  131762. * Base Url for the controller model.
  131763. */
  131764. static MODEL_BASE_URL: string;
  131765. /**
  131766. * File name for the left controller model.
  131767. */
  131768. static MODEL_LEFT_FILENAME: string;
  131769. /**
  131770. * File name for the right controller model.
  131771. */
  131772. static MODEL_RIGHT_FILENAME: string;
  131773. /**
  131774. * Base Url for the Quest controller model.
  131775. */
  131776. static QUEST_MODEL_BASE_URL: string;
  131777. /**
  131778. * @hidden
  131779. * If the controllers are running on a device that needs the updated Quest controller models
  131780. */
  131781. static _IsQuest: boolean;
  131782. /**
  131783. * Fired when the secondary trigger on this controller is modified
  131784. */
  131785. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  131786. /**
  131787. * Fired when the thumb rest on this controller is modified
  131788. */
  131789. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  131790. /**
  131791. * Creates a new OculusTouchController from a gamepad
  131792. * @param vrGamepad the gamepad that the controller should be created from
  131793. */
  131794. constructor(vrGamepad: any);
  131795. /**
  131796. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131797. * @param scene scene in which to add meshes
  131798. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131799. */
  131800. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131801. /**
  131802. * Fired when the A button on this controller is modified
  131803. */
  131804. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131805. /**
  131806. * Fired when the B button on this controller is modified
  131807. */
  131808. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131809. /**
  131810. * Fired when the X button on this controller is modified
  131811. */
  131812. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131813. /**
  131814. * Fired when the Y button on this controller is modified
  131815. */
  131816. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131817. /**
  131818. * Called once for each button that changed state since the last frame
  131819. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  131820. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  131821. * 2) secondary trigger (same)
  131822. * 3) A (right) X (left), touch, pressed = value
  131823. * 4) B / Y
  131824. * 5) thumb rest
  131825. * @param buttonIdx Which button index changed
  131826. * @param state New state of the button
  131827. * @param changes Which properties on the state changed since last frame
  131828. */
  131829. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131830. }
  131831. }
  131832. declare module BABYLON {
  131833. /**
  131834. * Vive Controller
  131835. */
  131836. export class ViveController extends WebVRController {
  131837. /**
  131838. * Base Url for the controller model.
  131839. */
  131840. static MODEL_BASE_URL: string;
  131841. /**
  131842. * File name for the controller model.
  131843. */
  131844. static MODEL_FILENAME: string;
  131845. /**
  131846. * Creates a new ViveController from a gamepad
  131847. * @param vrGamepad the gamepad that the controller should be created from
  131848. */
  131849. constructor(vrGamepad: any);
  131850. /**
  131851. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131852. * @param scene scene in which to add meshes
  131853. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131854. */
  131855. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  131856. /**
  131857. * Fired when the left button on this controller is modified
  131858. */
  131859. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131860. /**
  131861. * Fired when the right button on this controller is modified
  131862. */
  131863. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131864. /**
  131865. * Fired when the menu button on this controller is modified
  131866. */
  131867. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131868. /**
  131869. * Called once for each button that changed state since the last frame
  131870. * Vive mapping:
  131871. * 0: touchpad
  131872. * 1: trigger
  131873. * 2: left AND right buttons
  131874. * 3: menu button
  131875. * @param buttonIdx Which button index changed
  131876. * @param state New state of the button
  131877. * @param changes Which properties on the state changed since last frame
  131878. */
  131879. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131880. }
  131881. }
  131882. declare module BABYLON {
  131883. /**
  131884. * Defines the WindowsMotionController object that the state of the windows motion controller
  131885. */
  131886. export class WindowsMotionController extends WebVRController {
  131887. /**
  131888. * The base url used to load the left and right controller models
  131889. */
  131890. static MODEL_BASE_URL: string;
  131891. /**
  131892. * The name of the left controller model file
  131893. */
  131894. static MODEL_LEFT_FILENAME: string;
  131895. /**
  131896. * The name of the right controller model file
  131897. */
  131898. static MODEL_RIGHT_FILENAME: string;
  131899. /**
  131900. * The controller name prefix for this controller type
  131901. */
  131902. static readonly GAMEPAD_ID_PREFIX: string;
  131903. /**
  131904. * The controller id pattern for this controller type
  131905. */
  131906. private static readonly GAMEPAD_ID_PATTERN;
  131907. private _loadedMeshInfo;
  131908. protected readonly _mapping: {
  131909. buttons: string[];
  131910. buttonMeshNames: {
  131911. trigger: string;
  131912. menu: string;
  131913. grip: string;
  131914. thumbstick: string;
  131915. trackpad: string;
  131916. };
  131917. buttonObservableNames: {
  131918. trigger: string;
  131919. menu: string;
  131920. grip: string;
  131921. thumbstick: string;
  131922. trackpad: string;
  131923. };
  131924. axisMeshNames: string[];
  131925. pointingPoseMeshName: string;
  131926. };
  131927. /**
  131928. * Fired when the trackpad on this controller is clicked
  131929. */
  131930. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  131931. /**
  131932. * Fired when the trackpad on this controller is modified
  131933. */
  131934. onTrackpadValuesChangedObservable: Observable<StickValues>;
  131935. /**
  131936. * The current x and y values of this controller's trackpad
  131937. */
  131938. trackpad: StickValues;
  131939. /**
  131940. * Creates a new WindowsMotionController from a gamepad
  131941. * @param vrGamepad the gamepad that the controller should be created from
  131942. */
  131943. constructor(vrGamepad: any);
  131944. /**
  131945. * Fired when the trigger on this controller is modified
  131946. */
  131947. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131948. /**
  131949. * Fired when the menu button on this controller is modified
  131950. */
  131951. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131952. /**
  131953. * Fired when the grip button on this controller is modified
  131954. */
  131955. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131956. /**
  131957. * Fired when the thumbstick button on this controller is modified
  131958. */
  131959. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131960. /**
  131961. * Fired when the touchpad button on this controller is modified
  131962. */
  131963. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  131964. /**
  131965. * Fired when the touchpad values on this controller are modified
  131966. */
  131967. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  131968. protected _updateTrackpad(): void;
  131969. /**
  131970. * Called once per frame by the engine.
  131971. */
  131972. update(): void;
  131973. /**
  131974. * Called once for each button that changed state since the last frame
  131975. * @param buttonIdx Which button index changed
  131976. * @param state New state of the button
  131977. * @param changes Which properties on the state changed since last frame
  131978. */
  131979. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  131980. /**
  131981. * Moves the buttons on the controller mesh based on their current state
  131982. * @param buttonName the name of the button to move
  131983. * @param buttonValue the value of the button which determines the buttons new position
  131984. */
  131985. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  131986. /**
  131987. * Moves the axis on the controller mesh based on its current state
  131988. * @param axis the index of the axis
  131989. * @param axisValue the value of the axis which determines the meshes new position
  131990. * @hidden
  131991. */
  131992. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  131993. /**
  131994. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  131995. * @param scene scene in which to add meshes
  131996. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  131997. */
  131998. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  131999. /**
  132000. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  132001. * can be transformed by button presses and axes values, based on this._mapping.
  132002. *
  132003. * @param scene scene in which the meshes exist
  132004. * @param meshes list of meshes that make up the controller model to process
  132005. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  132006. */
  132007. private processModel;
  132008. private createMeshInfo;
  132009. /**
  132010. * Gets the ray of the controller in the direction the controller is pointing
  132011. * @param length the length the resulting ray should be
  132012. * @returns a ray in the direction the controller is pointing
  132013. */
  132014. getForwardRay(length?: number): Ray;
  132015. /**
  132016. * Disposes of the controller
  132017. */
  132018. dispose(): void;
  132019. }
  132020. /**
  132021. * This class represents a new windows motion controller in XR.
  132022. */
  132023. export class XRWindowsMotionController extends WindowsMotionController {
  132024. /**
  132025. * Changing the original WIndowsMotionController mapping to fir the new mapping
  132026. */
  132027. protected readonly _mapping: {
  132028. buttons: string[];
  132029. buttonMeshNames: {
  132030. trigger: string;
  132031. menu: string;
  132032. grip: string;
  132033. thumbstick: string;
  132034. trackpad: string;
  132035. };
  132036. buttonObservableNames: {
  132037. trigger: string;
  132038. menu: string;
  132039. grip: string;
  132040. thumbstick: string;
  132041. trackpad: string;
  132042. };
  132043. axisMeshNames: string[];
  132044. pointingPoseMeshName: string;
  132045. };
  132046. /**
  132047. * Construct a new XR-Based windows motion controller
  132048. *
  132049. * @param gamepadInfo the gamepad object from the browser
  132050. */
  132051. constructor(gamepadInfo: any);
  132052. /**
  132053. * holds the thumbstick values (X,Y)
  132054. */
  132055. thumbstickValues: StickValues;
  132056. /**
  132057. * Fired when the thumbstick on this controller is clicked
  132058. */
  132059. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  132060. /**
  132061. * Fired when the thumbstick on this controller is modified
  132062. */
  132063. onThumbstickValuesChangedObservable: Observable<StickValues>;
  132064. /**
  132065. * Fired when the touchpad button on this controller is modified
  132066. */
  132067. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  132068. /**
  132069. * Fired when the touchpad values on this controller are modified
  132070. */
  132071. onTrackpadValuesChangedObservable: Observable<StickValues>;
  132072. /**
  132073. * Fired when the thumbstick button on this controller is modified
  132074. * here to prevent breaking changes
  132075. */
  132076. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132077. /**
  132078. * updating the thumbstick(!) and not the trackpad.
  132079. * This is named this way due to the difference between WebVR and XR and to avoid
  132080. * changing the parent class.
  132081. */
  132082. protected _updateTrackpad(): void;
  132083. /**
  132084. * Disposes the class with joy
  132085. */
  132086. dispose(): void;
  132087. }
  132088. }
  132089. declare module BABYLON {
  132090. /**
  132091. * Class containing static functions to help procedurally build meshes
  132092. */
  132093. export class PolyhedronBuilder {
  132094. /**
  132095. * Creates a polyhedron mesh
  132096. * * 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
  132097. * * The parameter `size` (positive float, default 1) sets the polygon size
  132098. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  132099. * * 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`
  132100. * * 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
  132101. * * 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)`)
  132102. * * 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
  132103. * * 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
  132104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132107. * @param name defines the name of the mesh
  132108. * @param options defines the options used to create the mesh
  132109. * @param scene defines the hosting scene
  132110. * @returns the polyhedron mesh
  132111. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132112. */
  132113. static CreatePolyhedron(name: string, options: {
  132114. type?: number;
  132115. size?: number;
  132116. sizeX?: number;
  132117. sizeY?: number;
  132118. sizeZ?: number;
  132119. custom?: any;
  132120. faceUV?: Vector4[];
  132121. faceColors?: Color4[];
  132122. flat?: boolean;
  132123. updatable?: boolean;
  132124. sideOrientation?: number;
  132125. frontUVs?: Vector4;
  132126. backUVs?: Vector4;
  132127. }, scene?: Nullable<Scene>): Mesh;
  132128. }
  132129. }
  132130. declare module BABYLON {
  132131. /**
  132132. * Gizmo that enables scaling a mesh along 3 axis
  132133. */
  132134. export class ScaleGizmo extends Gizmo {
  132135. /**
  132136. * Internal gizmo used for interactions on the x axis
  132137. */
  132138. xGizmo: AxisScaleGizmo;
  132139. /**
  132140. * Internal gizmo used for interactions on the y axis
  132141. */
  132142. yGizmo: AxisScaleGizmo;
  132143. /**
  132144. * Internal gizmo used for interactions on the z axis
  132145. */
  132146. zGizmo: AxisScaleGizmo;
  132147. /**
  132148. * Internal gizmo used to scale all axis equally
  132149. */
  132150. uniformScaleGizmo: AxisScaleGizmo;
  132151. private _meshAttached;
  132152. private _nodeAttached;
  132153. private _updateGizmoRotationToMatchAttachedMesh;
  132154. private _snapDistance;
  132155. private _scaleRatio;
  132156. private _uniformScalingMesh;
  132157. private _octahedron;
  132158. private _sensitivity;
  132159. /** Fires an event when any of it's sub gizmos are dragged */
  132160. onDragStartObservable: Observable<unknown>;
  132161. /** Fires an event when any of it's sub gizmos are released from dragging */
  132162. onDragEndObservable: Observable<unknown>;
  132163. get attachedMesh(): Nullable<AbstractMesh>;
  132164. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132165. get attachedNode(): Nullable<Node>;
  132166. set attachedNode(node: Nullable<Node>);
  132167. /**
  132168. * Creates a ScaleGizmo
  132169. * @param gizmoLayer The utility layer the gizmo will be added to
  132170. * @param thickness display gizmo axis thickness
  132171. */
  132172. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  132173. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132174. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132175. /**
  132176. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132177. */
  132178. set snapDistance(value: number);
  132179. get snapDistance(): number;
  132180. /**
  132181. * Ratio for the scale of the gizmo (Default: 1)
  132182. */
  132183. set scaleRatio(value: number);
  132184. get scaleRatio(): number;
  132185. /**
  132186. * Sensitivity factor for dragging (Default: 1)
  132187. */
  132188. set sensitivity(value: number);
  132189. get sensitivity(): number;
  132190. /**
  132191. * Disposes of the gizmo
  132192. */
  132193. dispose(): void;
  132194. }
  132195. }
  132196. declare module BABYLON {
  132197. /**
  132198. * Single axis scale gizmo
  132199. */
  132200. export class AxisScaleGizmo extends Gizmo {
  132201. /**
  132202. * Drag behavior responsible for the gizmos dragging interactions
  132203. */
  132204. dragBehavior: PointerDragBehavior;
  132205. private _pointerObserver;
  132206. /**
  132207. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132208. */
  132209. snapDistance: number;
  132210. /**
  132211. * Event that fires each time the gizmo snaps to a new location.
  132212. * * snapDistance is the the change in distance
  132213. */
  132214. onSnapObservable: Observable<{
  132215. snapDistance: number;
  132216. }>;
  132217. /**
  132218. * If the scaling operation should be done on all axis (default: false)
  132219. */
  132220. uniformScaling: boolean;
  132221. /**
  132222. * Custom sensitivity value for the drag strength
  132223. */
  132224. sensitivity: number;
  132225. private _isEnabled;
  132226. private _parent;
  132227. private _arrow;
  132228. private _coloredMaterial;
  132229. private _hoverMaterial;
  132230. /**
  132231. * Creates an AxisScaleGizmo
  132232. * @param gizmoLayer The utility layer the gizmo will be added to
  132233. * @param dragAxis The axis which the gizmo will be able to scale on
  132234. * @param color The color of the gizmo
  132235. * @param thickness display gizmo axis thickness
  132236. */
  132237. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  132238. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132239. /**
  132240. * If the gizmo is enabled
  132241. */
  132242. set isEnabled(value: boolean);
  132243. get isEnabled(): boolean;
  132244. /**
  132245. * Disposes of the gizmo
  132246. */
  132247. dispose(): void;
  132248. /**
  132249. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  132250. * @param mesh The mesh to replace the default mesh of the gizmo
  132251. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  132252. */
  132253. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  132254. }
  132255. }
  132256. declare module BABYLON {
  132257. /**
  132258. * Bounding box gizmo
  132259. */
  132260. export class BoundingBoxGizmo extends Gizmo {
  132261. private _lineBoundingBox;
  132262. private _rotateSpheresParent;
  132263. private _scaleBoxesParent;
  132264. private _boundingDimensions;
  132265. private _renderObserver;
  132266. private _pointerObserver;
  132267. private _scaleDragSpeed;
  132268. private _tmpQuaternion;
  132269. private _tmpVector;
  132270. private _tmpRotationMatrix;
  132271. /**
  132272. * 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)
  132273. */
  132274. ignoreChildren: boolean;
  132275. /**
  132276. * 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)
  132277. */
  132278. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  132279. /**
  132280. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  132281. */
  132282. rotationSphereSize: number;
  132283. /**
  132284. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  132285. */
  132286. scaleBoxSize: number;
  132287. /**
  132288. * 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)
  132289. */
  132290. fixedDragMeshScreenSize: boolean;
  132291. /**
  132292. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  132293. */
  132294. fixedDragMeshScreenSizeDistanceFactor: number;
  132295. /**
  132296. * Fired when a rotation sphere or scale box is dragged
  132297. */
  132298. onDragStartObservable: Observable<{}>;
  132299. /**
  132300. * Fired when a scale box is dragged
  132301. */
  132302. onScaleBoxDragObservable: Observable<{}>;
  132303. /**
  132304. * Fired when a scale box drag is ended
  132305. */
  132306. onScaleBoxDragEndObservable: Observable<{}>;
  132307. /**
  132308. * Fired when a rotation sphere is dragged
  132309. */
  132310. onRotationSphereDragObservable: Observable<{}>;
  132311. /**
  132312. * Fired when a rotation sphere drag is ended
  132313. */
  132314. onRotationSphereDragEndObservable: Observable<{}>;
  132315. /**
  132316. * 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)
  132317. */
  132318. scalePivot: Nullable<Vector3>;
  132319. /**
  132320. * Mesh used as a pivot to rotate the attached node
  132321. */
  132322. private _anchorMesh;
  132323. private _existingMeshScale;
  132324. private _dragMesh;
  132325. private pointerDragBehavior;
  132326. private coloredMaterial;
  132327. private hoverColoredMaterial;
  132328. /**
  132329. * Sets the color of the bounding box gizmo
  132330. * @param color the color to set
  132331. */
  132332. setColor(color: Color3): void;
  132333. /**
  132334. * Creates an BoundingBoxGizmo
  132335. * @param gizmoLayer The utility layer the gizmo will be added to
  132336. * @param color The color of the gizmo
  132337. */
  132338. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  132339. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  132340. private _selectNode;
  132341. /**
  132342. * Updates the bounding box information for the Gizmo
  132343. */
  132344. updateBoundingBox(): void;
  132345. private _updateRotationSpheres;
  132346. private _updateScaleBoxes;
  132347. /**
  132348. * Enables rotation on the specified axis and disables rotation on the others
  132349. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  132350. */
  132351. setEnabledRotationAxis(axis: string): void;
  132352. /**
  132353. * Enables/disables scaling
  132354. * @param enable if scaling should be enabled
  132355. * @param homogeneousScaling defines if scaling should only be homogeneous
  132356. */
  132357. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  132358. private _updateDummy;
  132359. /**
  132360. * Enables a pointer drag behavior on the bounding box of the gizmo
  132361. */
  132362. enableDragBehavior(): void;
  132363. /**
  132364. * Disposes of the gizmo
  132365. */
  132366. dispose(): void;
  132367. /**
  132368. * 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)
  132369. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  132370. * @returns the bounding box mesh with the passed in mesh as a child
  132371. */
  132372. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  132373. /**
  132374. * CustomMeshes are not supported by this gizmo
  132375. * @param mesh The mesh to replace the default mesh of the gizmo
  132376. */
  132377. setCustomMesh(mesh: Mesh): void;
  132378. }
  132379. }
  132380. declare module BABYLON {
  132381. /**
  132382. * Single plane rotation gizmo
  132383. */
  132384. export class PlaneRotationGizmo extends Gizmo {
  132385. /**
  132386. * Drag behavior responsible for the gizmos dragging interactions
  132387. */
  132388. dragBehavior: PointerDragBehavior;
  132389. private _pointerObserver;
  132390. /**
  132391. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  132392. */
  132393. snapDistance: number;
  132394. /**
  132395. * Event that fires each time the gizmo snaps to a new location.
  132396. * * snapDistance is the the change in distance
  132397. */
  132398. onSnapObservable: Observable<{
  132399. snapDistance: number;
  132400. }>;
  132401. private _isEnabled;
  132402. private _parent;
  132403. /**
  132404. * Creates a PlaneRotationGizmo
  132405. * @param gizmoLayer The utility layer the gizmo will be added to
  132406. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  132407. * @param color The color of the gizmo
  132408. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132409. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132410. * @param thickness display gizmo axis thickness
  132411. */
  132412. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  132413. protected _attachedNodeChanged(value: Nullable<Node>): void;
  132414. /**
  132415. * If the gizmo is enabled
  132416. */
  132417. set isEnabled(value: boolean);
  132418. get isEnabled(): boolean;
  132419. /**
  132420. * Disposes of the gizmo
  132421. */
  132422. dispose(): void;
  132423. }
  132424. }
  132425. declare module BABYLON {
  132426. /**
  132427. * Gizmo that enables rotating a mesh along 3 axis
  132428. */
  132429. export class RotationGizmo extends Gizmo {
  132430. /**
  132431. * Internal gizmo used for interactions on the x axis
  132432. */
  132433. xGizmo: PlaneRotationGizmo;
  132434. /**
  132435. * Internal gizmo used for interactions on the y axis
  132436. */
  132437. yGizmo: PlaneRotationGizmo;
  132438. /**
  132439. * Internal gizmo used for interactions on the z axis
  132440. */
  132441. zGizmo: PlaneRotationGizmo;
  132442. /** Fires an event when any of it's sub gizmos are dragged */
  132443. onDragStartObservable: Observable<unknown>;
  132444. /** Fires an event when any of it's sub gizmos are released from dragging */
  132445. onDragEndObservable: Observable<unknown>;
  132446. private _meshAttached;
  132447. private _nodeAttached;
  132448. get attachedMesh(): Nullable<AbstractMesh>;
  132449. set attachedMesh(mesh: Nullable<AbstractMesh>);
  132450. get attachedNode(): Nullable<Node>;
  132451. set attachedNode(node: Nullable<Node>);
  132452. /**
  132453. * Creates a RotationGizmo
  132454. * @param gizmoLayer The utility layer the gizmo will be added to
  132455. * @param tessellation Amount of tessellation to be used when creating rotation circles
  132456. * @param useEulerRotation Use and update Euler angle instead of quaternion
  132457. * @param thickness display gizmo axis thickness
  132458. */
  132459. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  132460. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  132461. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  132462. /**
  132463. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  132464. */
  132465. set snapDistance(value: number);
  132466. get snapDistance(): number;
  132467. /**
  132468. * Ratio for the scale of the gizmo (Default: 1)
  132469. */
  132470. set scaleRatio(value: number);
  132471. get scaleRatio(): number;
  132472. /**
  132473. * Disposes of the gizmo
  132474. */
  132475. dispose(): void;
  132476. /**
  132477. * CustomMeshes are not supported by this gizmo
  132478. * @param mesh The mesh to replace the default mesh of the gizmo
  132479. */
  132480. setCustomMesh(mesh: Mesh): void;
  132481. }
  132482. }
  132483. declare module BABYLON {
  132484. /**
  132485. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  132486. */
  132487. export class GizmoManager implements IDisposable {
  132488. private scene;
  132489. /**
  132490. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  132491. */
  132492. gizmos: {
  132493. positionGizmo: Nullable<PositionGizmo>;
  132494. rotationGizmo: Nullable<RotationGizmo>;
  132495. scaleGizmo: Nullable<ScaleGizmo>;
  132496. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  132497. };
  132498. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  132499. clearGizmoOnEmptyPointerEvent: boolean;
  132500. /** Fires an event when the manager is attached to a mesh */
  132501. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  132502. private _gizmosEnabled;
  132503. private _pointerObserver;
  132504. private _attachedMesh;
  132505. private _boundingBoxColor;
  132506. private _defaultUtilityLayer;
  132507. private _defaultKeepDepthUtilityLayer;
  132508. private _thickness;
  132509. /**
  132510. * When bounding box gizmo is enabled, this can be used to track drag/end events
  132511. */
  132512. boundingBoxDragBehavior: SixDofDragBehavior;
  132513. /**
  132514. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  132515. */
  132516. attachableMeshes: Nullable<Array<AbstractMesh>>;
  132517. /**
  132518. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  132519. */
  132520. usePointerToAttachGizmos: boolean;
  132521. /**
  132522. * Utility layer that the bounding box gizmo belongs to
  132523. */
  132524. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  132525. /**
  132526. * Utility layer that all gizmos besides bounding box belong to
  132527. */
  132528. get utilityLayer(): UtilityLayerRenderer;
  132529. /**
  132530. * Instatiates a gizmo manager
  132531. * @param scene the scene to overlay the gizmos on top of
  132532. * @param thickness display gizmo axis thickness
  132533. */
  132534. constructor(scene: Scene, thickness?: number);
  132535. /**
  132536. * Attaches a set of gizmos to the specified mesh
  132537. * @param mesh The mesh the gizmo's should be attached to
  132538. */
  132539. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  132540. /**
  132541. * If the position gizmo is enabled
  132542. */
  132543. set positionGizmoEnabled(value: boolean);
  132544. get positionGizmoEnabled(): boolean;
  132545. /**
  132546. * If the rotation gizmo is enabled
  132547. */
  132548. set rotationGizmoEnabled(value: boolean);
  132549. get rotationGizmoEnabled(): boolean;
  132550. /**
  132551. * If the scale gizmo is enabled
  132552. */
  132553. set scaleGizmoEnabled(value: boolean);
  132554. get scaleGizmoEnabled(): boolean;
  132555. /**
  132556. * If the boundingBox gizmo is enabled
  132557. */
  132558. set boundingBoxGizmoEnabled(value: boolean);
  132559. get boundingBoxGizmoEnabled(): boolean;
  132560. /**
  132561. * Disposes of the gizmo manager
  132562. */
  132563. dispose(): void;
  132564. }
  132565. }
  132566. declare module BABYLON {
  132567. /**
  132568. * A directional light is defined by a direction (what a surprise!).
  132569. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  132570. * 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.
  132571. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132572. */
  132573. export class DirectionalLight extends ShadowLight {
  132574. private _shadowFrustumSize;
  132575. /**
  132576. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  132577. */
  132578. get shadowFrustumSize(): number;
  132579. /**
  132580. * Specifies a fix frustum size for the shadow generation.
  132581. */
  132582. set shadowFrustumSize(value: number);
  132583. private _shadowOrthoScale;
  132584. /**
  132585. * Gets the shadow projection scale against the optimal computed one.
  132586. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132587. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132588. */
  132589. get shadowOrthoScale(): number;
  132590. /**
  132591. * Sets the shadow projection scale against the optimal computed one.
  132592. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  132593. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  132594. */
  132595. set shadowOrthoScale(value: number);
  132596. /**
  132597. * Automatically compute the projection matrix to best fit (including all the casters)
  132598. * on each frame.
  132599. */
  132600. autoUpdateExtends: boolean;
  132601. /**
  132602. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  132603. * on each frame. autoUpdateExtends must be set to true for this to work
  132604. */
  132605. autoCalcShadowZBounds: boolean;
  132606. private _orthoLeft;
  132607. private _orthoRight;
  132608. private _orthoTop;
  132609. private _orthoBottom;
  132610. /**
  132611. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  132612. * The directional light is emitted from everywhere in the given direction.
  132613. * It can cast shadows.
  132614. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132615. * @param name The friendly name of the light
  132616. * @param direction The direction of the light
  132617. * @param scene The scene the light belongs to
  132618. */
  132619. constructor(name: string, direction: Vector3, scene: Scene);
  132620. /**
  132621. * Returns the string "DirectionalLight".
  132622. * @return The class name
  132623. */
  132624. getClassName(): string;
  132625. /**
  132626. * Returns the integer 1.
  132627. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132628. */
  132629. getTypeID(): number;
  132630. /**
  132631. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  132632. * Returns the DirectionalLight Shadow projection matrix.
  132633. */
  132634. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132635. /**
  132636. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  132637. * Returns the DirectionalLight Shadow projection matrix.
  132638. */
  132639. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  132640. /**
  132641. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  132642. * Returns the DirectionalLight Shadow projection matrix.
  132643. */
  132644. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132645. protected _buildUniformLayout(): void;
  132646. /**
  132647. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  132648. * @param effect The effect to update
  132649. * @param lightIndex The index of the light in the effect to update
  132650. * @returns The directional light
  132651. */
  132652. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  132653. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  132654. /**
  132655. * Gets the minZ used for shadow according to both the scene and the light.
  132656. *
  132657. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132658. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132659. * @param activeCamera The camera we are returning the min for
  132660. * @returns the depth min z
  132661. */
  132662. getDepthMinZ(activeCamera: Camera): number;
  132663. /**
  132664. * Gets the maxZ used for shadow according to both the scene and the light.
  132665. *
  132666. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  132667. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  132668. * @param activeCamera The camera we are returning the max for
  132669. * @returns the depth max z
  132670. */
  132671. getDepthMaxZ(activeCamera: Camera): number;
  132672. /**
  132673. * Prepares the list of defines specific to the light type.
  132674. * @param defines the list of defines
  132675. * @param lightIndex defines the index of the light for the effect
  132676. */
  132677. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132678. }
  132679. }
  132680. declare module BABYLON {
  132681. /**
  132682. * Class containing static functions to help procedurally build meshes
  132683. */
  132684. export class HemisphereBuilder {
  132685. /**
  132686. * Creates a hemisphere mesh
  132687. * @param name defines the name of the mesh
  132688. * @param options defines the options used to create the mesh
  132689. * @param scene defines the hosting scene
  132690. * @returns the hemisphere mesh
  132691. */
  132692. static CreateHemisphere(name: string, options: {
  132693. segments?: number;
  132694. diameter?: number;
  132695. sideOrientation?: number;
  132696. }, scene: any): Mesh;
  132697. }
  132698. }
  132699. declare module BABYLON {
  132700. /**
  132701. * A spot light is defined by a position, a direction, an angle, and an exponent.
  132702. * These values define a cone of light starting from the position, emitting toward the direction.
  132703. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  132704. * and the exponent defines the speed of the decay of the light with distance (reach).
  132705. * Documentation: https://doc.babylonjs.com/babylon101/lights
  132706. */
  132707. export class SpotLight extends ShadowLight {
  132708. private _angle;
  132709. private _innerAngle;
  132710. private _cosHalfAngle;
  132711. private _lightAngleScale;
  132712. private _lightAngleOffset;
  132713. /**
  132714. * Gets the cone angle of the spot light in Radians.
  132715. */
  132716. get angle(): number;
  132717. /**
  132718. * Sets the cone angle of the spot light in Radians.
  132719. */
  132720. set angle(value: number);
  132721. /**
  132722. * Only used in gltf falloff mode, this defines the angle where
  132723. * the directional falloff will start before cutting at angle which could be seen
  132724. * as outer angle.
  132725. */
  132726. get innerAngle(): number;
  132727. /**
  132728. * Only used in gltf falloff mode, this defines the angle where
  132729. * the directional falloff will start before cutting at angle which could be seen
  132730. * as outer angle.
  132731. */
  132732. set innerAngle(value: number);
  132733. private _shadowAngleScale;
  132734. /**
  132735. * Allows scaling the angle of the light for shadow generation only.
  132736. */
  132737. get shadowAngleScale(): number;
  132738. /**
  132739. * Allows scaling the angle of the light for shadow generation only.
  132740. */
  132741. set shadowAngleScale(value: number);
  132742. /**
  132743. * The light decay speed with the distance from the emission spot.
  132744. */
  132745. exponent: number;
  132746. private _projectionTextureMatrix;
  132747. /**
  132748. * Allows reading the projecton texture
  132749. */
  132750. get projectionTextureMatrix(): Matrix;
  132751. protected _projectionTextureLightNear: number;
  132752. /**
  132753. * Gets the near clip of the Spotlight for texture projection.
  132754. */
  132755. get projectionTextureLightNear(): number;
  132756. /**
  132757. * Sets the near clip of the Spotlight for texture projection.
  132758. */
  132759. set projectionTextureLightNear(value: number);
  132760. protected _projectionTextureLightFar: number;
  132761. /**
  132762. * Gets the far clip of the Spotlight for texture projection.
  132763. */
  132764. get projectionTextureLightFar(): number;
  132765. /**
  132766. * Sets the far clip of the Spotlight for texture projection.
  132767. */
  132768. set projectionTextureLightFar(value: number);
  132769. protected _projectionTextureUpDirection: Vector3;
  132770. /**
  132771. * Gets the Up vector of the Spotlight for texture projection.
  132772. */
  132773. get projectionTextureUpDirection(): Vector3;
  132774. /**
  132775. * Sets the Up vector of the Spotlight for texture projection.
  132776. */
  132777. set projectionTextureUpDirection(value: Vector3);
  132778. private _projectionTexture;
  132779. /**
  132780. * Gets the projection texture of the light.
  132781. */
  132782. get projectionTexture(): Nullable<BaseTexture>;
  132783. /**
  132784. * Sets the projection texture of the light.
  132785. */
  132786. set projectionTexture(value: Nullable<BaseTexture>);
  132787. private _projectionTextureViewLightDirty;
  132788. private _projectionTextureProjectionLightDirty;
  132789. private _projectionTextureDirty;
  132790. private _projectionTextureViewTargetVector;
  132791. private _projectionTextureViewLightMatrix;
  132792. private _projectionTextureProjectionLightMatrix;
  132793. private _projectionTextureScalingMatrix;
  132794. /**
  132795. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  132796. * It can cast shadows.
  132797. * Documentation : https://doc.babylonjs.com/babylon101/lights
  132798. * @param name The light friendly name
  132799. * @param position The position of the spot light in the scene
  132800. * @param direction The direction of the light in the scene
  132801. * @param angle The cone angle of the light in Radians
  132802. * @param exponent The light decay speed with the distance from the emission spot
  132803. * @param scene The scene the lights belongs to
  132804. */
  132805. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  132806. /**
  132807. * Returns the string "SpotLight".
  132808. * @returns the class name
  132809. */
  132810. getClassName(): string;
  132811. /**
  132812. * Returns the integer 2.
  132813. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  132814. */
  132815. getTypeID(): number;
  132816. /**
  132817. * Overrides the direction setter to recompute the projection texture view light Matrix.
  132818. */
  132819. protected _setDirection(value: Vector3): void;
  132820. /**
  132821. * Overrides the position setter to recompute the projection texture view light Matrix.
  132822. */
  132823. protected _setPosition(value: Vector3): void;
  132824. /**
  132825. * 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.
  132826. * Returns the SpotLight.
  132827. */
  132828. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  132829. protected _computeProjectionTextureViewLightMatrix(): void;
  132830. protected _computeProjectionTextureProjectionLightMatrix(): void;
  132831. /**
  132832. * Main function for light texture projection matrix computing.
  132833. */
  132834. protected _computeProjectionTextureMatrix(): void;
  132835. protected _buildUniformLayout(): void;
  132836. private _computeAngleValues;
  132837. /**
  132838. * Sets the passed Effect "effect" with the Light textures.
  132839. * @param effect The effect to update
  132840. * @param lightIndex The index of the light in the effect to update
  132841. * @returns The light
  132842. */
  132843. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  132844. /**
  132845. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  132846. * @param effect The effect to update
  132847. * @param lightIndex The index of the light in the effect to update
  132848. * @returns The spot light
  132849. */
  132850. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  132851. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  132852. /**
  132853. * Disposes the light and the associated resources.
  132854. */
  132855. dispose(): void;
  132856. /**
  132857. * Prepares the list of defines specific to the light type.
  132858. * @param defines the list of defines
  132859. * @param lightIndex defines the index of the light for the effect
  132860. */
  132861. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  132862. }
  132863. }
  132864. declare module BABYLON {
  132865. /**
  132866. * Gizmo that enables viewing a light
  132867. */
  132868. export class LightGizmo extends Gizmo {
  132869. private _lightMesh;
  132870. private _material;
  132871. private _cachedPosition;
  132872. private _cachedForward;
  132873. private _attachedMeshParent;
  132874. /**
  132875. * Creates a LightGizmo
  132876. * @param gizmoLayer The utility layer the gizmo will be added to
  132877. */
  132878. constructor(gizmoLayer?: UtilityLayerRenderer);
  132879. private _light;
  132880. /**
  132881. * The light that the gizmo is attached to
  132882. */
  132883. set light(light: Nullable<Light>);
  132884. get light(): Nullable<Light>;
  132885. /**
  132886. * Gets the material used to render the light gizmo
  132887. */
  132888. get material(): StandardMaterial;
  132889. /**
  132890. * @hidden
  132891. * Updates the gizmo to match the attached mesh's position/rotation
  132892. */
  132893. protected _update(): void;
  132894. private static _Scale;
  132895. /**
  132896. * Creates the lines for a light mesh
  132897. */
  132898. private static _CreateLightLines;
  132899. /**
  132900. * Disposes of the light gizmo
  132901. */
  132902. dispose(): void;
  132903. private static _CreateHemisphericLightMesh;
  132904. private static _CreatePointLightMesh;
  132905. private static _CreateSpotLightMesh;
  132906. private static _CreateDirectionalLightMesh;
  132907. }
  132908. }
  132909. declare module BABYLON {
  132910. /** @hidden */
  132911. export var backgroundFragmentDeclaration: {
  132912. name: string;
  132913. shader: string;
  132914. };
  132915. }
  132916. declare module BABYLON {
  132917. /** @hidden */
  132918. export var backgroundUboDeclaration: {
  132919. name: string;
  132920. shader: string;
  132921. };
  132922. }
  132923. declare module BABYLON {
  132924. /** @hidden */
  132925. export var backgroundPixelShader: {
  132926. name: string;
  132927. shader: string;
  132928. };
  132929. }
  132930. declare module BABYLON {
  132931. /** @hidden */
  132932. export var backgroundVertexDeclaration: {
  132933. name: string;
  132934. shader: string;
  132935. };
  132936. }
  132937. declare module BABYLON {
  132938. /** @hidden */
  132939. export var backgroundVertexShader: {
  132940. name: string;
  132941. shader: string;
  132942. };
  132943. }
  132944. declare module BABYLON {
  132945. /**
  132946. * Background material used to create an efficient environement around your scene.
  132947. */
  132948. export class BackgroundMaterial extends PushMaterial {
  132949. /**
  132950. * Standard reflectance value at parallel view angle.
  132951. */
  132952. static StandardReflectance0: number;
  132953. /**
  132954. * Standard reflectance value at grazing angle.
  132955. */
  132956. static StandardReflectance90: number;
  132957. protected _primaryColor: Color3;
  132958. /**
  132959. * Key light Color (multiply against the environement texture)
  132960. */
  132961. primaryColor: Color3;
  132962. protected __perceptualColor: Nullable<Color3>;
  132963. /**
  132964. * Experimental Internal Use Only.
  132965. *
  132966. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  132967. * This acts as a helper to set the primary color to a more "human friendly" value.
  132968. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  132969. * output color as close as possible from the chosen value.
  132970. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  132971. * part of lighting setup.)
  132972. */
  132973. get _perceptualColor(): Nullable<Color3>;
  132974. set _perceptualColor(value: Nullable<Color3>);
  132975. protected _primaryColorShadowLevel: float;
  132976. /**
  132977. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  132978. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  132979. */
  132980. get primaryColorShadowLevel(): float;
  132981. set primaryColorShadowLevel(value: float);
  132982. protected _primaryColorHighlightLevel: float;
  132983. /**
  132984. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  132985. * The primary color is used at the level chosen to define what the white area would look.
  132986. */
  132987. get primaryColorHighlightLevel(): float;
  132988. set primaryColorHighlightLevel(value: float);
  132989. protected _reflectionTexture: Nullable<BaseTexture>;
  132990. /**
  132991. * Reflection Texture used in the material.
  132992. * Should be author in a specific way for the best result (refer to the documentation).
  132993. */
  132994. reflectionTexture: Nullable<BaseTexture>;
  132995. protected _reflectionBlur: float;
  132996. /**
  132997. * Reflection Texture level of blur.
  132998. *
  132999. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  133000. * texture twice.
  133001. */
  133002. reflectionBlur: float;
  133003. protected _diffuseTexture: Nullable<BaseTexture>;
  133004. /**
  133005. * Diffuse Texture used in the material.
  133006. * Should be author in a specific way for the best result (refer to the documentation).
  133007. */
  133008. diffuseTexture: Nullable<BaseTexture>;
  133009. protected _shadowLights: Nullable<IShadowLight[]>;
  133010. /**
  133011. * Specify the list of lights casting shadow on the material.
  133012. * All scene shadow lights will be included if null.
  133013. */
  133014. shadowLights: Nullable<IShadowLight[]>;
  133015. protected _shadowLevel: float;
  133016. /**
  133017. * Helps adjusting the shadow to a softer level if required.
  133018. * 0 means black shadows and 1 means no shadows.
  133019. */
  133020. shadowLevel: float;
  133021. protected _sceneCenter: Vector3;
  133022. /**
  133023. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  133024. * It is usually zero but might be interesting to modify according to your setup.
  133025. */
  133026. sceneCenter: Vector3;
  133027. protected _opacityFresnel: boolean;
  133028. /**
  133029. * This helps specifying that the material is falling off to the sky box at grazing angle.
  133030. * This helps ensuring a nice transition when the camera goes under the ground.
  133031. */
  133032. opacityFresnel: boolean;
  133033. protected _reflectionFresnel: boolean;
  133034. /**
  133035. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  133036. * This helps adding a mirror texture on the ground.
  133037. */
  133038. reflectionFresnel: boolean;
  133039. protected _reflectionFalloffDistance: number;
  133040. /**
  133041. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  133042. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  133043. */
  133044. reflectionFalloffDistance: number;
  133045. protected _reflectionAmount: number;
  133046. /**
  133047. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  133048. */
  133049. reflectionAmount: number;
  133050. protected _reflectionReflectance0: number;
  133051. /**
  133052. * This specifies the weight of the reflection at grazing angle.
  133053. */
  133054. reflectionReflectance0: number;
  133055. protected _reflectionReflectance90: number;
  133056. /**
  133057. * This specifies the weight of the reflection at a perpendicular point of view.
  133058. */
  133059. reflectionReflectance90: number;
  133060. /**
  133061. * Sets the reflection reflectance fresnel values according to the default standard
  133062. * empirically know to work well :-)
  133063. */
  133064. set reflectionStandardFresnelWeight(value: number);
  133065. protected _useRGBColor: boolean;
  133066. /**
  133067. * Helps to directly use the maps channels instead of their level.
  133068. */
  133069. useRGBColor: boolean;
  133070. protected _enableNoise: boolean;
  133071. /**
  133072. * This helps reducing the banding effect that could occur on the background.
  133073. */
  133074. enableNoise: boolean;
  133075. /**
  133076. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133077. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  133078. * Recommended to be keep at 1.0 except for special cases.
  133079. */
  133080. get fovMultiplier(): number;
  133081. set fovMultiplier(value: number);
  133082. private _fovMultiplier;
  133083. /**
  133084. * Enable the FOV adjustment feature controlled by fovMultiplier.
  133085. */
  133086. useEquirectangularFOV: boolean;
  133087. private _maxSimultaneousLights;
  133088. /**
  133089. * Number of Simultaneous lights allowed on the material.
  133090. */
  133091. maxSimultaneousLights: int;
  133092. private _shadowOnly;
  133093. /**
  133094. * Make the material only render shadows
  133095. */
  133096. shadowOnly: boolean;
  133097. /**
  133098. * Default configuration related to image processing available in the Background Material.
  133099. */
  133100. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133101. /**
  133102. * Keep track of the image processing observer to allow dispose and replace.
  133103. */
  133104. private _imageProcessingObserver;
  133105. /**
  133106. * Attaches a new image processing configuration to the PBR Material.
  133107. * @param configuration (if null the scene configuration will be use)
  133108. */
  133109. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133110. /**
  133111. * Gets the image processing configuration used either in this material.
  133112. */
  133113. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  133114. /**
  133115. * Sets the Default image processing configuration used either in the this material.
  133116. *
  133117. * If sets to null, the scene one is in use.
  133118. */
  133119. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  133120. /**
  133121. * Gets wether the color curves effect is enabled.
  133122. */
  133123. get cameraColorCurvesEnabled(): boolean;
  133124. /**
  133125. * Sets wether the color curves effect is enabled.
  133126. */
  133127. set cameraColorCurvesEnabled(value: boolean);
  133128. /**
  133129. * Gets wether the color grading effect is enabled.
  133130. */
  133131. get cameraColorGradingEnabled(): boolean;
  133132. /**
  133133. * Gets wether the color grading effect is enabled.
  133134. */
  133135. set cameraColorGradingEnabled(value: boolean);
  133136. /**
  133137. * Gets wether tonemapping is enabled or not.
  133138. */
  133139. get cameraToneMappingEnabled(): boolean;
  133140. /**
  133141. * Sets wether tonemapping is enabled or not
  133142. */
  133143. set cameraToneMappingEnabled(value: boolean);
  133144. /**
  133145. * The camera exposure used on this material.
  133146. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133147. * This corresponds to a photographic exposure.
  133148. */
  133149. get cameraExposure(): float;
  133150. /**
  133151. * The camera exposure used on this material.
  133152. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133153. * This corresponds to a photographic exposure.
  133154. */
  133155. set cameraExposure(value: float);
  133156. /**
  133157. * Gets The camera contrast used on this material.
  133158. */
  133159. get cameraContrast(): float;
  133160. /**
  133161. * Sets The camera contrast used on this material.
  133162. */
  133163. set cameraContrast(value: float);
  133164. /**
  133165. * Gets the Color Grading 2D Lookup Texture.
  133166. */
  133167. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133168. /**
  133169. * Sets the Color Grading 2D Lookup Texture.
  133170. */
  133171. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133172. /**
  133173. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133174. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133175. * 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;
  133176. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133177. */
  133178. get cameraColorCurves(): Nullable<ColorCurves>;
  133179. /**
  133180. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133181. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133182. * 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;
  133183. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133184. */
  133185. set cameraColorCurves(value: Nullable<ColorCurves>);
  133186. /**
  133187. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  133188. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  133189. */
  133190. switchToBGR: boolean;
  133191. private _renderTargets;
  133192. private _reflectionControls;
  133193. private _white;
  133194. private _primaryShadowColor;
  133195. private _primaryHighlightColor;
  133196. /**
  133197. * Instantiates a Background Material in the given scene
  133198. * @param name The friendly name of the material
  133199. * @param scene The scene to add the material to
  133200. */
  133201. constructor(name: string, scene: Scene);
  133202. /**
  133203. * Gets a boolean indicating that current material needs to register RTT
  133204. */
  133205. get hasRenderTargetTextures(): boolean;
  133206. /**
  133207. * The entire material has been created in order to prevent overdraw.
  133208. * @returns false
  133209. */
  133210. needAlphaTesting(): boolean;
  133211. /**
  133212. * The entire material has been created in order to prevent overdraw.
  133213. * @returns true if blending is enable
  133214. */
  133215. needAlphaBlending(): boolean;
  133216. /**
  133217. * Checks wether the material is ready to be rendered for a given mesh.
  133218. * @param mesh The mesh to render
  133219. * @param subMesh The submesh to check against
  133220. * @param useInstances Specify wether or not the material is used with instances
  133221. * @returns true if all the dependencies are ready (Textures, Effects...)
  133222. */
  133223. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133224. /**
  133225. * Compute the primary color according to the chosen perceptual color.
  133226. */
  133227. private _computePrimaryColorFromPerceptualColor;
  133228. /**
  133229. * Compute the highlights and shadow colors according to their chosen levels.
  133230. */
  133231. private _computePrimaryColors;
  133232. /**
  133233. * Build the uniform buffer used in the material.
  133234. */
  133235. buildUniformLayout(): void;
  133236. /**
  133237. * Unbind the material.
  133238. */
  133239. unbind(): void;
  133240. /**
  133241. * Bind only the world matrix to the material.
  133242. * @param world The world matrix to bind.
  133243. */
  133244. bindOnlyWorldMatrix(world: Matrix): void;
  133245. /**
  133246. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  133247. * @param world The world matrix to bind.
  133248. * @param subMesh The submesh to bind for.
  133249. */
  133250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133251. /**
  133252. * Checks to see if a texture is used in the material.
  133253. * @param texture - Base texture to use.
  133254. * @returns - Boolean specifying if a texture is used in the material.
  133255. */
  133256. hasTexture(texture: BaseTexture): boolean;
  133257. /**
  133258. * Dispose the material.
  133259. * @param forceDisposeEffect Force disposal of the associated effect.
  133260. * @param forceDisposeTextures Force disposal of the associated textures.
  133261. */
  133262. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133263. /**
  133264. * Clones the material.
  133265. * @param name The cloned name.
  133266. * @returns The cloned material.
  133267. */
  133268. clone(name: string): BackgroundMaterial;
  133269. /**
  133270. * Serializes the current material to its JSON representation.
  133271. * @returns The JSON representation.
  133272. */
  133273. serialize(): any;
  133274. /**
  133275. * Gets the class name of the material
  133276. * @returns "BackgroundMaterial"
  133277. */
  133278. getClassName(): string;
  133279. /**
  133280. * Parse a JSON input to create back a background material.
  133281. * @param source The JSON data to parse
  133282. * @param scene The scene to create the parsed material in
  133283. * @param rootUrl The root url of the assets the material depends upon
  133284. * @returns the instantiated BackgroundMaterial.
  133285. */
  133286. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  133287. }
  133288. }
  133289. declare module BABYLON {
  133290. /**
  133291. * Represents the different options available during the creation of
  133292. * a Environment helper.
  133293. *
  133294. * This can control the default ground, skybox and image processing setup of your scene.
  133295. */
  133296. export interface IEnvironmentHelperOptions {
  133297. /**
  133298. * Specifies whether or not to create a ground.
  133299. * True by default.
  133300. */
  133301. createGround: boolean;
  133302. /**
  133303. * Specifies the ground size.
  133304. * 15 by default.
  133305. */
  133306. groundSize: number;
  133307. /**
  133308. * The texture used on the ground for the main color.
  133309. * Comes from the BabylonJS CDN by default.
  133310. *
  133311. * Remarks: Can be either a texture or a url.
  133312. */
  133313. groundTexture: string | BaseTexture;
  133314. /**
  133315. * The color mixed in the ground texture by default.
  133316. * BabylonJS clearColor by default.
  133317. */
  133318. groundColor: Color3;
  133319. /**
  133320. * Specifies the ground opacity.
  133321. * 1 by default.
  133322. */
  133323. groundOpacity: number;
  133324. /**
  133325. * Enables the ground to receive shadows.
  133326. * True by default.
  133327. */
  133328. enableGroundShadow: boolean;
  133329. /**
  133330. * Helps preventing the shadow to be fully black on the ground.
  133331. * 0.5 by default.
  133332. */
  133333. groundShadowLevel: number;
  133334. /**
  133335. * Creates a mirror texture attach to the ground.
  133336. * false by default.
  133337. */
  133338. enableGroundMirror: boolean;
  133339. /**
  133340. * Specifies the ground mirror size ratio.
  133341. * 0.3 by default as the default kernel is 64.
  133342. */
  133343. groundMirrorSizeRatio: number;
  133344. /**
  133345. * Specifies the ground mirror blur kernel size.
  133346. * 64 by default.
  133347. */
  133348. groundMirrorBlurKernel: number;
  133349. /**
  133350. * Specifies the ground mirror visibility amount.
  133351. * 1 by default
  133352. */
  133353. groundMirrorAmount: number;
  133354. /**
  133355. * Specifies the ground mirror reflectance weight.
  133356. * This uses the standard weight of the background material to setup the fresnel effect
  133357. * of the mirror.
  133358. * 1 by default.
  133359. */
  133360. groundMirrorFresnelWeight: number;
  133361. /**
  133362. * Specifies the ground mirror Falloff distance.
  133363. * This can helps reducing the size of the reflection.
  133364. * 0 by Default.
  133365. */
  133366. groundMirrorFallOffDistance: number;
  133367. /**
  133368. * Specifies the ground mirror texture type.
  133369. * Unsigned Int by Default.
  133370. */
  133371. groundMirrorTextureType: number;
  133372. /**
  133373. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  133374. * the shown objects.
  133375. */
  133376. groundYBias: number;
  133377. /**
  133378. * Specifies whether or not to create a skybox.
  133379. * True by default.
  133380. */
  133381. createSkybox: boolean;
  133382. /**
  133383. * Specifies the skybox size.
  133384. * 20 by default.
  133385. */
  133386. skyboxSize: number;
  133387. /**
  133388. * The texture used on the skybox for the main color.
  133389. * Comes from the BabylonJS CDN by default.
  133390. *
  133391. * Remarks: Can be either a texture or a url.
  133392. */
  133393. skyboxTexture: string | BaseTexture;
  133394. /**
  133395. * The color mixed in the skybox texture by default.
  133396. * BabylonJS clearColor by default.
  133397. */
  133398. skyboxColor: Color3;
  133399. /**
  133400. * The background rotation around the Y axis of the scene.
  133401. * This helps aligning the key lights of your scene with the background.
  133402. * 0 by default.
  133403. */
  133404. backgroundYRotation: number;
  133405. /**
  133406. * Compute automatically the size of the elements to best fit with the scene.
  133407. */
  133408. sizeAuto: boolean;
  133409. /**
  133410. * Default position of the rootMesh if autoSize is not true.
  133411. */
  133412. rootPosition: Vector3;
  133413. /**
  133414. * Sets up the image processing in the scene.
  133415. * true by default.
  133416. */
  133417. setupImageProcessing: boolean;
  133418. /**
  133419. * The texture used as your environment texture in the scene.
  133420. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  133421. *
  133422. * Remarks: Can be either a texture or a url.
  133423. */
  133424. environmentTexture: string | BaseTexture;
  133425. /**
  133426. * The value of the exposure to apply to the scene.
  133427. * 0.6 by default if setupImageProcessing is true.
  133428. */
  133429. cameraExposure: number;
  133430. /**
  133431. * The value of the contrast to apply to the scene.
  133432. * 1.6 by default if setupImageProcessing is true.
  133433. */
  133434. cameraContrast: number;
  133435. /**
  133436. * Specifies whether or not tonemapping should be enabled in the scene.
  133437. * true by default if setupImageProcessing is true.
  133438. */
  133439. toneMappingEnabled: boolean;
  133440. }
  133441. /**
  133442. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  133443. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  133444. * It also helps with the default setup of your imageProcessing configuration.
  133445. */
  133446. export class EnvironmentHelper {
  133447. /**
  133448. * Default ground texture URL.
  133449. */
  133450. private static _groundTextureCDNUrl;
  133451. /**
  133452. * Default skybox texture URL.
  133453. */
  133454. private static _skyboxTextureCDNUrl;
  133455. /**
  133456. * Default environment texture URL.
  133457. */
  133458. private static _environmentTextureCDNUrl;
  133459. /**
  133460. * Creates the default options for the helper.
  133461. */
  133462. private static _getDefaultOptions;
  133463. private _rootMesh;
  133464. /**
  133465. * Gets the root mesh created by the helper.
  133466. */
  133467. get rootMesh(): Mesh;
  133468. private _skybox;
  133469. /**
  133470. * Gets the skybox created by the helper.
  133471. */
  133472. get skybox(): Nullable<Mesh>;
  133473. private _skyboxTexture;
  133474. /**
  133475. * Gets the skybox texture created by the helper.
  133476. */
  133477. get skyboxTexture(): Nullable<BaseTexture>;
  133478. private _skyboxMaterial;
  133479. /**
  133480. * Gets the skybox material created by the helper.
  133481. */
  133482. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  133483. private _ground;
  133484. /**
  133485. * Gets the ground mesh created by the helper.
  133486. */
  133487. get ground(): Nullable<Mesh>;
  133488. private _groundTexture;
  133489. /**
  133490. * Gets the ground texture created by the helper.
  133491. */
  133492. get groundTexture(): Nullable<BaseTexture>;
  133493. private _groundMirror;
  133494. /**
  133495. * Gets the ground mirror created by the helper.
  133496. */
  133497. get groundMirror(): Nullable<MirrorTexture>;
  133498. /**
  133499. * Gets the ground mirror render list to helps pushing the meshes
  133500. * you wish in the ground reflection.
  133501. */
  133502. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  133503. private _groundMaterial;
  133504. /**
  133505. * Gets the ground material created by the helper.
  133506. */
  133507. get groundMaterial(): Nullable<BackgroundMaterial>;
  133508. /**
  133509. * Stores the creation options.
  133510. */
  133511. private readonly _scene;
  133512. private _options;
  133513. /**
  133514. * This observable will be notified with any error during the creation of the environment,
  133515. * mainly texture creation errors.
  133516. */
  133517. onErrorObservable: Observable<{
  133518. message?: string;
  133519. exception?: any;
  133520. }>;
  133521. /**
  133522. * constructor
  133523. * @param options Defines the options we want to customize the helper
  133524. * @param scene The scene to add the material to
  133525. */
  133526. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  133527. /**
  133528. * Updates the background according to the new options
  133529. * @param options
  133530. */
  133531. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  133532. /**
  133533. * Sets the primary color of all the available elements.
  133534. * @param color the main color to affect to the ground and the background
  133535. */
  133536. setMainColor(color: Color3): void;
  133537. /**
  133538. * Setup the image processing according to the specified options.
  133539. */
  133540. private _setupImageProcessing;
  133541. /**
  133542. * Setup the environment texture according to the specified options.
  133543. */
  133544. private _setupEnvironmentTexture;
  133545. /**
  133546. * Setup the background according to the specified options.
  133547. */
  133548. private _setupBackground;
  133549. /**
  133550. * Get the scene sizes according to the setup.
  133551. */
  133552. private _getSceneSize;
  133553. /**
  133554. * Setup the ground according to the specified options.
  133555. */
  133556. private _setupGround;
  133557. /**
  133558. * Setup the ground material according to the specified options.
  133559. */
  133560. private _setupGroundMaterial;
  133561. /**
  133562. * Setup the ground diffuse texture according to the specified options.
  133563. */
  133564. private _setupGroundDiffuseTexture;
  133565. /**
  133566. * Setup the ground mirror texture according to the specified options.
  133567. */
  133568. private _setupGroundMirrorTexture;
  133569. /**
  133570. * Setup the ground to receive the mirror texture.
  133571. */
  133572. private _setupMirrorInGroundMaterial;
  133573. /**
  133574. * Setup the skybox according to the specified options.
  133575. */
  133576. private _setupSkybox;
  133577. /**
  133578. * Setup the skybox material according to the specified options.
  133579. */
  133580. private _setupSkyboxMaterial;
  133581. /**
  133582. * Setup the skybox reflection texture according to the specified options.
  133583. */
  133584. private _setupSkyboxReflectionTexture;
  133585. private _errorHandler;
  133586. /**
  133587. * Dispose all the elements created by the Helper.
  133588. */
  133589. dispose(): void;
  133590. }
  133591. }
  133592. declare module BABYLON {
  133593. /**
  133594. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  133595. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  133596. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  133597. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  133598. */
  133599. export class PhotoDome extends TransformNode {
  133600. /**
  133601. * Define the image as a Monoscopic panoramic 360 image.
  133602. */
  133603. static readonly MODE_MONOSCOPIC: number;
  133604. /**
  133605. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133606. */
  133607. static readonly MODE_TOPBOTTOM: number;
  133608. /**
  133609. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133610. */
  133611. static readonly MODE_SIDEBYSIDE: number;
  133612. private _useDirectMapping;
  133613. /**
  133614. * The texture being displayed on the sphere
  133615. */
  133616. protected _photoTexture: Texture;
  133617. /**
  133618. * Gets or sets the texture being displayed on the sphere
  133619. */
  133620. get photoTexture(): Texture;
  133621. set photoTexture(value: Texture);
  133622. /**
  133623. * Observable raised when an error occured while loading the 360 image
  133624. */
  133625. onLoadErrorObservable: Observable<string>;
  133626. /**
  133627. * The skybox material
  133628. */
  133629. protected _material: BackgroundMaterial;
  133630. /**
  133631. * The surface used for the skybox
  133632. */
  133633. protected _mesh: Mesh;
  133634. /**
  133635. * Gets the mesh used for the skybox.
  133636. */
  133637. get mesh(): Mesh;
  133638. /**
  133639. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  133640. * Also see the options.resolution property.
  133641. */
  133642. get fovMultiplier(): number;
  133643. set fovMultiplier(value: number);
  133644. private _imageMode;
  133645. /**
  133646. * Gets or set the current video mode for the video. It can be:
  133647. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  133648. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  133649. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  133650. */
  133651. get imageMode(): number;
  133652. set imageMode(value: number);
  133653. /**
  133654. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  133655. * @param name Element's name, child elements will append suffixes for their own names.
  133656. * @param urlsOfPhoto defines the url of the photo to display
  133657. * @param options defines an object containing optional or exposed sub element properties
  133658. * @param onError defines a callback called when an error occured while loading the texture
  133659. */
  133660. constructor(name: string, urlOfPhoto: string, options: {
  133661. resolution?: number;
  133662. size?: number;
  133663. useDirectMapping?: boolean;
  133664. faceForward?: boolean;
  133665. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  133666. private _onBeforeCameraRenderObserver;
  133667. private _changeImageMode;
  133668. /**
  133669. * Releases resources associated with this node.
  133670. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133671. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133672. */
  133673. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  133674. }
  133675. }
  133676. declare module BABYLON {
  133677. /**
  133678. * Class used to host RGBD texture specific utilities
  133679. */
  133680. export class RGBDTextureTools {
  133681. /**
  133682. * Expand the RGBD Texture from RGBD to Half Float if possible.
  133683. * @param texture the texture to expand.
  133684. */
  133685. static ExpandRGBDTexture(texture: Texture): void;
  133686. }
  133687. }
  133688. declare module BABYLON {
  133689. /**
  133690. * Class used to host texture specific utilities
  133691. */
  133692. export class BRDFTextureTools {
  133693. /**
  133694. * Prevents texture cache collision
  133695. */
  133696. private static _instanceNumber;
  133697. /**
  133698. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  133699. * @param scene defines the hosting scene
  133700. * @returns the environment BRDF texture
  133701. */
  133702. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  133703. private static _environmentBRDFBase64Texture;
  133704. }
  133705. }
  133706. declare module BABYLON {
  133707. /**
  133708. * @hidden
  133709. */
  133710. export interface IMaterialClearCoatDefines {
  133711. CLEARCOAT: boolean;
  133712. CLEARCOAT_DEFAULTIOR: boolean;
  133713. CLEARCOAT_TEXTURE: boolean;
  133714. CLEARCOAT_TEXTUREDIRECTUV: number;
  133715. CLEARCOAT_BUMP: boolean;
  133716. CLEARCOAT_BUMPDIRECTUV: number;
  133717. CLEARCOAT_TINT: boolean;
  133718. CLEARCOAT_TINT_TEXTURE: boolean;
  133719. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133720. /** @hidden */
  133721. _areTexturesDirty: boolean;
  133722. }
  133723. /**
  133724. * Define the code related to the clear coat parameters of the pbr material.
  133725. */
  133726. export class PBRClearCoatConfiguration {
  133727. /**
  133728. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133729. * The default fits with a polyurethane material.
  133730. */
  133731. private static readonly _DefaultIndexOfRefraction;
  133732. private _isEnabled;
  133733. /**
  133734. * Defines if the clear coat is enabled in the material.
  133735. */
  133736. isEnabled: boolean;
  133737. /**
  133738. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  133739. */
  133740. intensity: number;
  133741. /**
  133742. * Defines the clear coat layer roughness.
  133743. */
  133744. roughness: number;
  133745. private _indexOfRefraction;
  133746. /**
  133747. * Defines the index of refraction of the clear coat.
  133748. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  133749. * The default fits with a polyurethane material.
  133750. * Changing the default value is more performance intensive.
  133751. */
  133752. indexOfRefraction: number;
  133753. private _texture;
  133754. /**
  133755. * Stores the clear coat values in a texture.
  133756. */
  133757. texture: Nullable<BaseTexture>;
  133758. private _bumpTexture;
  133759. /**
  133760. * Define the clear coat specific bump texture.
  133761. */
  133762. bumpTexture: Nullable<BaseTexture>;
  133763. private _isTintEnabled;
  133764. /**
  133765. * Defines if the clear coat tint is enabled in the material.
  133766. */
  133767. isTintEnabled: boolean;
  133768. /**
  133769. * Defines the clear coat tint of the material.
  133770. * This is only use if tint is enabled
  133771. */
  133772. tintColor: Color3;
  133773. /**
  133774. * Defines the distance at which the tint color should be found in the
  133775. * clear coat media.
  133776. * This is only use if tint is enabled
  133777. */
  133778. tintColorAtDistance: number;
  133779. /**
  133780. * Defines the clear coat layer thickness.
  133781. * This is only use if tint is enabled
  133782. */
  133783. tintThickness: number;
  133784. private _tintTexture;
  133785. /**
  133786. * Stores the clear tint values in a texture.
  133787. * rgb is tint
  133788. * a is a thickness factor
  133789. */
  133790. tintTexture: Nullable<BaseTexture>;
  133791. /** @hidden */
  133792. private _internalMarkAllSubMeshesAsTexturesDirty;
  133793. /** @hidden */
  133794. _markAllSubMeshesAsTexturesDirty(): void;
  133795. /**
  133796. * Instantiate a new istance of clear coat configuration.
  133797. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133798. */
  133799. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133800. /**
  133801. * Gets wehter the submesh is ready to be used or not.
  133802. * @param defines the list of "defines" to update.
  133803. * @param scene defines the scene the material belongs to.
  133804. * @param engine defines the engine the material belongs to.
  133805. * @param disableBumpMap defines wether the material disables bump or not.
  133806. * @returns - boolean indicating that the submesh is ready or not.
  133807. */
  133808. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  133809. /**
  133810. * Checks to see if a texture is used in the material.
  133811. * @param defines the list of "defines" to update.
  133812. * @param scene defines the scene to the material belongs to.
  133813. */
  133814. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  133815. /**
  133816. * Binds the material data.
  133817. * @param uniformBuffer defines the Uniform buffer to fill in.
  133818. * @param scene defines the scene the material belongs to.
  133819. * @param engine defines the engine the material belongs to.
  133820. * @param disableBumpMap defines wether the material disables bump or not.
  133821. * @param isFrozen defines wether the material is frozen or not.
  133822. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133823. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133824. */
  133825. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  133826. /**
  133827. * Checks to see if a texture is used in the material.
  133828. * @param texture - Base texture to use.
  133829. * @returns - Boolean specifying if a texture is used in the material.
  133830. */
  133831. hasTexture(texture: BaseTexture): boolean;
  133832. /**
  133833. * Returns an array of the actively used textures.
  133834. * @param activeTextures Array of BaseTextures
  133835. */
  133836. getActiveTextures(activeTextures: BaseTexture[]): void;
  133837. /**
  133838. * Returns the animatable textures.
  133839. * @param animatables Array of animatable textures.
  133840. */
  133841. getAnimatables(animatables: IAnimatable[]): void;
  133842. /**
  133843. * Disposes the resources of the material.
  133844. * @param forceDisposeTextures - Forces the disposal of all textures.
  133845. */
  133846. dispose(forceDisposeTextures?: boolean): void;
  133847. /**
  133848. * Get the current class name of the texture useful for serialization or dynamic coding.
  133849. * @returns "PBRClearCoatConfiguration"
  133850. */
  133851. getClassName(): string;
  133852. /**
  133853. * Add fallbacks to the effect fallbacks list.
  133854. * @param defines defines the Base texture to use.
  133855. * @param fallbacks defines the current fallback list.
  133856. * @param currentRank defines the current fallback rank.
  133857. * @returns the new fallback rank.
  133858. */
  133859. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133860. /**
  133861. * Add the required uniforms to the current list.
  133862. * @param uniforms defines the current uniform list.
  133863. */
  133864. static AddUniforms(uniforms: string[]): void;
  133865. /**
  133866. * Add the required samplers to the current list.
  133867. * @param samplers defines the current sampler list.
  133868. */
  133869. static AddSamplers(samplers: string[]): void;
  133870. /**
  133871. * Add the required uniforms to the current buffer.
  133872. * @param uniformBuffer defines the current uniform buffer.
  133873. */
  133874. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133875. /**
  133876. * Makes a duplicate of the current configuration into another one.
  133877. * @param clearCoatConfiguration define the config where to copy the info
  133878. */
  133879. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  133880. /**
  133881. * Serializes this clear coat configuration.
  133882. * @returns - An object with the serialized config.
  133883. */
  133884. serialize(): any;
  133885. /**
  133886. * Parses a anisotropy Configuration from a serialized object.
  133887. * @param source - Serialized object.
  133888. * @param scene Defines the scene we are parsing for
  133889. * @param rootUrl Defines the rootUrl to load from
  133890. */
  133891. parse(source: any, scene: Scene, rootUrl: string): void;
  133892. }
  133893. }
  133894. declare module BABYLON {
  133895. /**
  133896. * @hidden
  133897. */
  133898. export interface IMaterialAnisotropicDefines {
  133899. ANISOTROPIC: boolean;
  133900. ANISOTROPIC_TEXTURE: boolean;
  133901. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133902. MAINUV1: boolean;
  133903. _areTexturesDirty: boolean;
  133904. _needUVs: boolean;
  133905. }
  133906. /**
  133907. * Define the code related to the anisotropic parameters of the pbr material.
  133908. */
  133909. export class PBRAnisotropicConfiguration {
  133910. private _isEnabled;
  133911. /**
  133912. * Defines if the anisotropy is enabled in the material.
  133913. */
  133914. isEnabled: boolean;
  133915. /**
  133916. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  133917. */
  133918. intensity: number;
  133919. /**
  133920. * Defines if the effect is along the tangents, bitangents or in between.
  133921. * By default, the effect is "strectching" the highlights along the tangents.
  133922. */
  133923. direction: Vector2;
  133924. private _texture;
  133925. /**
  133926. * Stores the anisotropy values in a texture.
  133927. * rg is direction (like normal from -1 to 1)
  133928. * b is a intensity
  133929. */
  133930. texture: Nullable<BaseTexture>;
  133931. /** @hidden */
  133932. private _internalMarkAllSubMeshesAsTexturesDirty;
  133933. /** @hidden */
  133934. _markAllSubMeshesAsTexturesDirty(): void;
  133935. /**
  133936. * Instantiate a new istance of anisotropy configuration.
  133937. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133938. */
  133939. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  133940. /**
  133941. * Specifies that the submesh is ready to be used.
  133942. * @param defines the list of "defines" to update.
  133943. * @param scene defines the scene the material belongs to.
  133944. * @returns - boolean indicating that the submesh is ready or not.
  133945. */
  133946. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  133947. /**
  133948. * Checks to see if a texture is used in the material.
  133949. * @param defines the list of "defines" to update.
  133950. * @param mesh the mesh we are preparing the defines for.
  133951. * @param scene defines the scene the material belongs to.
  133952. */
  133953. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  133954. /**
  133955. * Binds the material data.
  133956. * @param uniformBuffer defines the Uniform buffer to fill in.
  133957. * @param scene defines the scene the material belongs to.
  133958. * @param isFrozen defines wether the material is frozen or not.
  133959. */
  133960. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  133961. /**
  133962. * Checks to see if a texture is used in the material.
  133963. * @param texture - Base texture to use.
  133964. * @returns - Boolean specifying if a texture is used in the material.
  133965. */
  133966. hasTexture(texture: BaseTexture): boolean;
  133967. /**
  133968. * Returns an array of the actively used textures.
  133969. * @param activeTextures Array of BaseTextures
  133970. */
  133971. getActiveTextures(activeTextures: BaseTexture[]): void;
  133972. /**
  133973. * Returns the animatable textures.
  133974. * @param animatables Array of animatable textures.
  133975. */
  133976. getAnimatables(animatables: IAnimatable[]): void;
  133977. /**
  133978. * Disposes the resources of the material.
  133979. * @param forceDisposeTextures - Forces the disposal of all textures.
  133980. */
  133981. dispose(forceDisposeTextures?: boolean): void;
  133982. /**
  133983. * Get the current class name of the texture useful for serialization or dynamic coding.
  133984. * @returns "PBRAnisotropicConfiguration"
  133985. */
  133986. getClassName(): string;
  133987. /**
  133988. * Add fallbacks to the effect fallbacks list.
  133989. * @param defines defines the Base texture to use.
  133990. * @param fallbacks defines the current fallback list.
  133991. * @param currentRank defines the current fallback rank.
  133992. * @returns the new fallback rank.
  133993. */
  133994. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133995. /**
  133996. * Add the required uniforms to the current list.
  133997. * @param uniforms defines the current uniform list.
  133998. */
  133999. static AddUniforms(uniforms: string[]): void;
  134000. /**
  134001. * Add the required uniforms to the current buffer.
  134002. * @param uniformBuffer defines the current uniform buffer.
  134003. */
  134004. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134005. /**
  134006. * Add the required samplers to the current list.
  134007. * @param samplers defines the current sampler list.
  134008. */
  134009. static AddSamplers(samplers: string[]): void;
  134010. /**
  134011. * Makes a duplicate of the current configuration into another one.
  134012. * @param anisotropicConfiguration define the config where to copy the info
  134013. */
  134014. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  134015. /**
  134016. * Serializes this anisotropy configuration.
  134017. * @returns - An object with the serialized config.
  134018. */
  134019. serialize(): any;
  134020. /**
  134021. * Parses a anisotropy Configuration from a serialized object.
  134022. * @param source - Serialized object.
  134023. * @param scene Defines the scene we are parsing for
  134024. * @param rootUrl Defines the rootUrl to load from
  134025. */
  134026. parse(source: any, scene: Scene, rootUrl: string): void;
  134027. }
  134028. }
  134029. declare module BABYLON {
  134030. /**
  134031. * @hidden
  134032. */
  134033. export interface IMaterialBRDFDefines {
  134034. BRDF_V_HEIGHT_CORRELATED: boolean;
  134035. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134036. SPHERICAL_HARMONICS: boolean;
  134037. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134038. /** @hidden */
  134039. _areMiscDirty: boolean;
  134040. }
  134041. /**
  134042. * Define the code related to the BRDF parameters of the pbr material.
  134043. */
  134044. export class PBRBRDFConfiguration {
  134045. /**
  134046. * Default value used for the energy conservation.
  134047. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134048. */
  134049. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  134050. /**
  134051. * Default value used for the Smith Visibility Height Correlated mode.
  134052. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  134053. */
  134054. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  134055. /**
  134056. * Default value used for the IBL diffuse part.
  134057. * This can help switching back to the polynomials mode globally which is a tiny bit
  134058. * less GPU intensive at the drawback of a lower quality.
  134059. */
  134060. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  134061. /**
  134062. * Default value used for activating energy conservation for the specular workflow.
  134063. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134064. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134065. */
  134066. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  134067. private _useEnergyConservation;
  134068. /**
  134069. * Defines if the material uses energy conservation.
  134070. */
  134071. useEnergyConservation: boolean;
  134072. private _useSmithVisibilityHeightCorrelated;
  134073. /**
  134074. * LEGACY Mode set to false
  134075. * Defines if the material uses height smith correlated visibility term.
  134076. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  134077. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  134078. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  134079. * Not relying on height correlated will also disable energy conservation.
  134080. */
  134081. useSmithVisibilityHeightCorrelated: boolean;
  134082. private _useSphericalHarmonics;
  134083. /**
  134084. * LEGACY Mode set to false
  134085. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  134086. * diffuse part of the IBL.
  134087. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  134088. * to the ground truth.
  134089. */
  134090. useSphericalHarmonics: boolean;
  134091. private _useSpecularGlossinessInputEnergyConservation;
  134092. /**
  134093. * Defines if the material uses energy conservation, when the specular workflow is active.
  134094. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  134095. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  134096. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  134097. */
  134098. useSpecularGlossinessInputEnergyConservation: boolean;
  134099. /** @hidden */
  134100. private _internalMarkAllSubMeshesAsMiscDirty;
  134101. /** @hidden */
  134102. _markAllSubMeshesAsMiscDirty(): void;
  134103. /**
  134104. * Instantiate a new istance of clear coat configuration.
  134105. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  134106. */
  134107. constructor(markAllSubMeshesAsMiscDirty: () => void);
  134108. /**
  134109. * Checks to see if a texture is used in the material.
  134110. * @param defines the list of "defines" to update.
  134111. */
  134112. prepareDefines(defines: IMaterialBRDFDefines): void;
  134113. /**
  134114. * Get the current class name of the texture useful for serialization or dynamic coding.
  134115. * @returns "PBRClearCoatConfiguration"
  134116. */
  134117. getClassName(): string;
  134118. /**
  134119. * Makes a duplicate of the current configuration into another one.
  134120. * @param brdfConfiguration define the config where to copy the info
  134121. */
  134122. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  134123. /**
  134124. * Serializes this BRDF configuration.
  134125. * @returns - An object with the serialized config.
  134126. */
  134127. serialize(): any;
  134128. /**
  134129. * Parses a anisotropy Configuration from a serialized object.
  134130. * @param source - Serialized object.
  134131. * @param scene Defines the scene we are parsing for
  134132. * @param rootUrl Defines the rootUrl to load from
  134133. */
  134134. parse(source: any, scene: Scene, rootUrl: string): void;
  134135. }
  134136. }
  134137. declare module BABYLON {
  134138. /**
  134139. * @hidden
  134140. */
  134141. export interface IMaterialSheenDefines {
  134142. SHEEN: boolean;
  134143. SHEEN_TEXTURE: boolean;
  134144. SHEEN_TEXTUREDIRECTUV: number;
  134145. SHEEN_LINKWITHALBEDO: boolean;
  134146. SHEEN_ROUGHNESS: boolean;
  134147. SHEEN_ALBEDOSCALING: boolean;
  134148. /** @hidden */
  134149. _areTexturesDirty: boolean;
  134150. }
  134151. /**
  134152. * Define the code related to the Sheen parameters of the pbr material.
  134153. */
  134154. export class PBRSheenConfiguration {
  134155. private _isEnabled;
  134156. /**
  134157. * Defines if the material uses sheen.
  134158. */
  134159. isEnabled: boolean;
  134160. private _linkSheenWithAlbedo;
  134161. /**
  134162. * Defines if the sheen is linked to the sheen color.
  134163. */
  134164. linkSheenWithAlbedo: boolean;
  134165. /**
  134166. * Defines the sheen intensity.
  134167. */
  134168. intensity: number;
  134169. /**
  134170. * Defines the sheen color.
  134171. */
  134172. color: Color3;
  134173. private _texture;
  134174. /**
  134175. * Stores the sheen tint values in a texture.
  134176. * rgb is tint
  134177. * a is a intensity or roughness if roughness has been defined
  134178. */
  134179. texture: Nullable<BaseTexture>;
  134180. private _roughness;
  134181. /**
  134182. * Defines the sheen roughness.
  134183. * It is not taken into account if linkSheenWithAlbedo is true.
  134184. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  134185. */
  134186. roughness: Nullable<number>;
  134187. private _albedoScaling;
  134188. /**
  134189. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  134190. * It allows the strength of the sheen effect to not depend on the base color of the material,
  134191. * making it easier to setup and tweak the effect
  134192. */
  134193. albedoScaling: boolean;
  134194. /** @hidden */
  134195. private _internalMarkAllSubMeshesAsTexturesDirty;
  134196. /** @hidden */
  134197. _markAllSubMeshesAsTexturesDirty(): void;
  134198. /**
  134199. * Instantiate a new istance of clear coat configuration.
  134200. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134201. */
  134202. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  134203. /**
  134204. * Specifies that the submesh is ready to be used.
  134205. * @param defines the list of "defines" to update.
  134206. * @param scene defines the scene the material belongs to.
  134207. * @returns - boolean indicating that the submesh is ready or not.
  134208. */
  134209. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  134210. /**
  134211. * Checks to see if a texture is used in the material.
  134212. * @param defines the list of "defines" to update.
  134213. * @param scene defines the scene the material belongs to.
  134214. */
  134215. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  134216. /**
  134217. * Binds the material data.
  134218. * @param uniformBuffer defines the Uniform buffer to fill in.
  134219. * @param scene defines the scene the material belongs to.
  134220. * @param isFrozen defines wether the material is frozen or not.
  134221. */
  134222. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  134223. /**
  134224. * Checks to see if a texture is used in the material.
  134225. * @param texture - Base texture to use.
  134226. * @returns - Boolean specifying if a texture is used in the material.
  134227. */
  134228. hasTexture(texture: BaseTexture): boolean;
  134229. /**
  134230. * Returns an array of the actively used textures.
  134231. * @param activeTextures Array of BaseTextures
  134232. */
  134233. getActiveTextures(activeTextures: BaseTexture[]): void;
  134234. /**
  134235. * Returns the animatable textures.
  134236. * @param animatables Array of animatable textures.
  134237. */
  134238. getAnimatables(animatables: IAnimatable[]): void;
  134239. /**
  134240. * Disposes the resources of the material.
  134241. * @param forceDisposeTextures - Forces the disposal of all textures.
  134242. */
  134243. dispose(forceDisposeTextures?: boolean): void;
  134244. /**
  134245. * Get the current class name of the texture useful for serialization or dynamic coding.
  134246. * @returns "PBRSheenConfiguration"
  134247. */
  134248. getClassName(): string;
  134249. /**
  134250. * Add fallbacks to the effect fallbacks list.
  134251. * @param defines defines the Base texture to use.
  134252. * @param fallbacks defines the current fallback list.
  134253. * @param currentRank defines the current fallback rank.
  134254. * @returns the new fallback rank.
  134255. */
  134256. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134257. /**
  134258. * Add the required uniforms to the current list.
  134259. * @param uniforms defines the current uniform list.
  134260. */
  134261. static AddUniforms(uniforms: string[]): void;
  134262. /**
  134263. * Add the required uniforms to the current buffer.
  134264. * @param uniformBuffer defines the current uniform buffer.
  134265. */
  134266. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134267. /**
  134268. * Add the required samplers to the current list.
  134269. * @param samplers defines the current sampler list.
  134270. */
  134271. static AddSamplers(samplers: string[]): void;
  134272. /**
  134273. * Makes a duplicate of the current configuration into another one.
  134274. * @param sheenConfiguration define the config where to copy the info
  134275. */
  134276. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  134277. /**
  134278. * Serializes this BRDF configuration.
  134279. * @returns - An object with the serialized config.
  134280. */
  134281. serialize(): any;
  134282. /**
  134283. * Parses a anisotropy Configuration from a serialized object.
  134284. * @param source - Serialized object.
  134285. * @param scene Defines the scene we are parsing for
  134286. * @param rootUrl Defines the rootUrl to load from
  134287. */
  134288. parse(source: any, scene: Scene, rootUrl: string): void;
  134289. }
  134290. }
  134291. declare module BABYLON {
  134292. /**
  134293. * @hidden
  134294. */
  134295. export interface IMaterialSubSurfaceDefines {
  134296. SUBSURFACE: boolean;
  134297. SS_REFRACTION: boolean;
  134298. SS_TRANSLUCENCY: boolean;
  134299. SS_SCATTERING: boolean;
  134300. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134301. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134302. SS_REFRACTIONMAP_3D: boolean;
  134303. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134304. SS_LODINREFRACTIONALPHA: boolean;
  134305. SS_GAMMAREFRACTION: boolean;
  134306. SS_RGBDREFRACTION: boolean;
  134307. SS_LINEARSPECULARREFRACTION: boolean;
  134308. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134309. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134310. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134311. /** @hidden */
  134312. _areTexturesDirty: boolean;
  134313. }
  134314. /**
  134315. * Define the code related to the sub surface parameters of the pbr material.
  134316. */
  134317. export class PBRSubSurfaceConfiguration {
  134318. private _isRefractionEnabled;
  134319. /**
  134320. * Defines if the refraction is enabled in the material.
  134321. */
  134322. isRefractionEnabled: boolean;
  134323. private _isTranslucencyEnabled;
  134324. /**
  134325. * Defines if the translucency is enabled in the material.
  134326. */
  134327. isTranslucencyEnabled: boolean;
  134328. private _isScatteringEnabled;
  134329. /**
  134330. * Defines if the sub surface scattering is enabled in the material.
  134331. */
  134332. isScatteringEnabled: boolean;
  134333. private _scatteringDiffusionProfileIndex;
  134334. /**
  134335. * Diffusion profile for subsurface scattering.
  134336. * Useful for better scattering in the skins or foliages.
  134337. */
  134338. get scatteringDiffusionProfile(): Nullable<Color3>;
  134339. set scatteringDiffusionProfile(c: Nullable<Color3>);
  134340. /**
  134341. * Defines the refraction intensity of the material.
  134342. * The refraction when enabled replaces the Diffuse part of the material.
  134343. * The intensity helps transitionning between diffuse and refraction.
  134344. */
  134345. refractionIntensity: number;
  134346. /**
  134347. * Defines the translucency intensity of the material.
  134348. * When translucency has been enabled, this defines how much of the "translucency"
  134349. * is addded to the diffuse part of the material.
  134350. */
  134351. translucencyIntensity: number;
  134352. /**
  134353. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  134354. */
  134355. useAlbedoToTintRefraction: boolean;
  134356. private _thicknessTexture;
  134357. /**
  134358. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  134359. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  134360. * 0 would mean minimumThickness
  134361. * 1 would mean maximumThickness
  134362. * The other channels might be use as a mask to vary the different effects intensity.
  134363. */
  134364. thicknessTexture: Nullable<BaseTexture>;
  134365. private _refractionTexture;
  134366. /**
  134367. * Defines the texture to use for refraction.
  134368. */
  134369. refractionTexture: Nullable<BaseTexture>;
  134370. private _indexOfRefraction;
  134371. /**
  134372. * Index of refraction of the material base layer.
  134373. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134374. *
  134375. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134376. *
  134377. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134378. */
  134379. indexOfRefraction: number;
  134380. private _volumeIndexOfRefraction;
  134381. /**
  134382. * Index of refraction of the material's volume.
  134383. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134384. *
  134385. * This ONLY impacts refraction. If not provided or given a non-valid value,
  134386. * the volume will use the same IOR as the surface.
  134387. */
  134388. get volumeIndexOfRefraction(): number;
  134389. set volumeIndexOfRefraction(value: number);
  134390. private _invertRefractionY;
  134391. /**
  134392. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134393. */
  134394. invertRefractionY: boolean;
  134395. private _linkRefractionWithTransparency;
  134396. /**
  134397. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134398. * Materials half opaque for instance using refraction could benefit from this control.
  134399. */
  134400. linkRefractionWithTransparency: boolean;
  134401. /**
  134402. * Defines the minimum thickness stored in the thickness map.
  134403. * If no thickness map is defined, this value will be used to simulate thickness.
  134404. */
  134405. minimumThickness: number;
  134406. /**
  134407. * Defines the maximum thickness stored in the thickness map.
  134408. */
  134409. maximumThickness: number;
  134410. /**
  134411. * Defines the volume tint of the material.
  134412. * This is used for both translucency and scattering.
  134413. */
  134414. tintColor: Color3;
  134415. /**
  134416. * Defines the distance at which the tint color should be found in the media.
  134417. * This is used for refraction only.
  134418. */
  134419. tintColorAtDistance: number;
  134420. /**
  134421. * Defines how far each channel transmit through the media.
  134422. * It is defined as a color to simplify it selection.
  134423. */
  134424. diffusionDistance: Color3;
  134425. private _useMaskFromThicknessTexture;
  134426. /**
  134427. * Stores the intensity of the different subsurface effects in the thickness texture.
  134428. * * the green channel is the translucency intensity.
  134429. * * the blue channel is the scattering intensity.
  134430. * * the alpha channel is the refraction intensity.
  134431. */
  134432. useMaskFromThicknessTexture: boolean;
  134433. private _scene;
  134434. /** @hidden */
  134435. private _internalMarkAllSubMeshesAsTexturesDirty;
  134436. private _internalMarkScenePrePassDirty;
  134437. /** @hidden */
  134438. _markAllSubMeshesAsTexturesDirty(): void;
  134439. /** @hidden */
  134440. _markScenePrePassDirty(): void;
  134441. /**
  134442. * Instantiate a new istance of sub surface configuration.
  134443. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  134444. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  134445. * @param scene The scene
  134446. */
  134447. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  134448. /**
  134449. * Gets wehter the submesh is ready to be used or not.
  134450. * @param defines the list of "defines" to update.
  134451. * @param scene defines the scene the material belongs to.
  134452. * @returns - boolean indicating that the submesh is ready or not.
  134453. */
  134454. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  134455. /**
  134456. * Checks to see if a texture is used in the material.
  134457. * @param defines the list of "defines" to update.
  134458. * @param scene defines the scene to the material belongs to.
  134459. */
  134460. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  134461. /**
  134462. * Binds the material data.
  134463. * @param uniformBuffer defines the Uniform buffer to fill in.
  134464. * @param scene defines the scene the material belongs to.
  134465. * @param engine defines the engine the material belongs to.
  134466. * @param isFrozen defines whether the material is frozen or not.
  134467. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  134468. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  134469. */
  134470. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  134471. /**
  134472. * Unbinds the material from the mesh.
  134473. * @param activeEffect defines the effect that should be unbound from.
  134474. * @returns true if unbound, otherwise false
  134475. */
  134476. unbind(activeEffect: Effect): boolean;
  134477. /**
  134478. * Returns the texture used for refraction or null if none is used.
  134479. * @param scene defines the scene the material belongs to.
  134480. * @returns - Refraction texture if present. If no refraction texture and refraction
  134481. * is linked with transparency, returns environment texture. Otherwise, returns null.
  134482. */
  134483. private _getRefractionTexture;
  134484. /**
  134485. * Returns true if alpha blending should be disabled.
  134486. */
  134487. get disableAlphaBlending(): boolean;
  134488. /**
  134489. * Fills the list of render target textures.
  134490. * @param renderTargets the list of render targets to update
  134491. */
  134492. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  134493. /**
  134494. * Checks to see if a texture is used in the material.
  134495. * @param texture - Base texture to use.
  134496. * @returns - Boolean specifying if a texture is used in the material.
  134497. */
  134498. hasTexture(texture: BaseTexture): boolean;
  134499. /**
  134500. * Gets a boolean indicating that current material needs to register RTT
  134501. * @returns true if this uses a render target otherwise false.
  134502. */
  134503. hasRenderTargetTextures(): boolean;
  134504. /**
  134505. * Returns an array of the actively used textures.
  134506. * @param activeTextures Array of BaseTextures
  134507. */
  134508. getActiveTextures(activeTextures: BaseTexture[]): void;
  134509. /**
  134510. * Returns the animatable textures.
  134511. * @param animatables Array of animatable textures.
  134512. */
  134513. getAnimatables(animatables: IAnimatable[]): void;
  134514. /**
  134515. * Disposes the resources of the material.
  134516. * @param forceDisposeTextures - Forces the disposal of all textures.
  134517. */
  134518. dispose(forceDisposeTextures?: boolean): void;
  134519. /**
  134520. * Get the current class name of the texture useful for serialization or dynamic coding.
  134521. * @returns "PBRSubSurfaceConfiguration"
  134522. */
  134523. getClassName(): string;
  134524. /**
  134525. * Add fallbacks to the effect fallbacks list.
  134526. * @param defines defines the Base texture to use.
  134527. * @param fallbacks defines the current fallback list.
  134528. * @param currentRank defines the current fallback rank.
  134529. * @returns the new fallback rank.
  134530. */
  134531. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  134532. /**
  134533. * Add the required uniforms to the current list.
  134534. * @param uniforms defines the current uniform list.
  134535. */
  134536. static AddUniforms(uniforms: string[]): void;
  134537. /**
  134538. * Add the required samplers to the current list.
  134539. * @param samplers defines the current sampler list.
  134540. */
  134541. static AddSamplers(samplers: string[]): void;
  134542. /**
  134543. * Add the required uniforms to the current buffer.
  134544. * @param uniformBuffer defines the current uniform buffer.
  134545. */
  134546. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  134547. /**
  134548. * Makes a duplicate of the current configuration into another one.
  134549. * @param configuration define the config where to copy the info
  134550. */
  134551. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  134552. /**
  134553. * Serializes this Sub Surface configuration.
  134554. * @returns - An object with the serialized config.
  134555. */
  134556. serialize(): any;
  134557. /**
  134558. * Parses a anisotropy Configuration from a serialized object.
  134559. * @param source - Serialized object.
  134560. * @param scene Defines the scene we are parsing for
  134561. * @param rootUrl Defines the rootUrl to load from
  134562. */
  134563. parse(source: any, scene: Scene, rootUrl: string): void;
  134564. }
  134565. }
  134566. declare module BABYLON {
  134567. /** @hidden */
  134568. export var pbrFragmentDeclaration: {
  134569. name: string;
  134570. shader: string;
  134571. };
  134572. }
  134573. declare module BABYLON {
  134574. /** @hidden */
  134575. export var pbrUboDeclaration: {
  134576. name: string;
  134577. shader: string;
  134578. };
  134579. }
  134580. declare module BABYLON {
  134581. /** @hidden */
  134582. export var pbrFragmentExtraDeclaration: {
  134583. name: string;
  134584. shader: string;
  134585. };
  134586. }
  134587. declare module BABYLON {
  134588. /** @hidden */
  134589. export var pbrFragmentSamplersDeclaration: {
  134590. name: string;
  134591. shader: string;
  134592. };
  134593. }
  134594. declare module BABYLON {
  134595. /** @hidden */
  134596. export var importanceSampling: {
  134597. name: string;
  134598. shader: string;
  134599. };
  134600. }
  134601. declare module BABYLON {
  134602. /** @hidden */
  134603. export var pbrHelperFunctions: {
  134604. name: string;
  134605. shader: string;
  134606. };
  134607. }
  134608. declare module BABYLON {
  134609. /** @hidden */
  134610. export var harmonicsFunctions: {
  134611. name: string;
  134612. shader: string;
  134613. };
  134614. }
  134615. declare module BABYLON {
  134616. /** @hidden */
  134617. export var pbrDirectLightingSetupFunctions: {
  134618. name: string;
  134619. shader: string;
  134620. };
  134621. }
  134622. declare module BABYLON {
  134623. /** @hidden */
  134624. export var pbrDirectLightingFalloffFunctions: {
  134625. name: string;
  134626. shader: string;
  134627. };
  134628. }
  134629. declare module BABYLON {
  134630. /** @hidden */
  134631. export var pbrBRDFFunctions: {
  134632. name: string;
  134633. shader: string;
  134634. };
  134635. }
  134636. declare module BABYLON {
  134637. /** @hidden */
  134638. export var hdrFilteringFunctions: {
  134639. name: string;
  134640. shader: string;
  134641. };
  134642. }
  134643. declare module BABYLON {
  134644. /** @hidden */
  134645. export var pbrDirectLightingFunctions: {
  134646. name: string;
  134647. shader: string;
  134648. };
  134649. }
  134650. declare module BABYLON {
  134651. /** @hidden */
  134652. export var pbrIBLFunctions: {
  134653. name: string;
  134654. shader: string;
  134655. };
  134656. }
  134657. declare module BABYLON {
  134658. /** @hidden */
  134659. export var pbrBlockAlbedoOpacity: {
  134660. name: string;
  134661. shader: string;
  134662. };
  134663. }
  134664. declare module BABYLON {
  134665. /** @hidden */
  134666. export var pbrBlockReflectivity: {
  134667. name: string;
  134668. shader: string;
  134669. };
  134670. }
  134671. declare module BABYLON {
  134672. /** @hidden */
  134673. export var pbrBlockAmbientOcclusion: {
  134674. name: string;
  134675. shader: string;
  134676. };
  134677. }
  134678. declare module BABYLON {
  134679. /** @hidden */
  134680. export var pbrBlockAlphaFresnel: {
  134681. name: string;
  134682. shader: string;
  134683. };
  134684. }
  134685. declare module BABYLON {
  134686. /** @hidden */
  134687. export var pbrBlockAnisotropic: {
  134688. name: string;
  134689. shader: string;
  134690. };
  134691. }
  134692. declare module BABYLON {
  134693. /** @hidden */
  134694. export var pbrBlockReflection: {
  134695. name: string;
  134696. shader: string;
  134697. };
  134698. }
  134699. declare module BABYLON {
  134700. /** @hidden */
  134701. export var pbrBlockSheen: {
  134702. name: string;
  134703. shader: string;
  134704. };
  134705. }
  134706. declare module BABYLON {
  134707. /** @hidden */
  134708. export var pbrBlockClearcoat: {
  134709. name: string;
  134710. shader: string;
  134711. };
  134712. }
  134713. declare module BABYLON {
  134714. /** @hidden */
  134715. export var pbrBlockSubSurface: {
  134716. name: string;
  134717. shader: string;
  134718. };
  134719. }
  134720. declare module BABYLON {
  134721. /** @hidden */
  134722. export var pbrBlockNormalGeometric: {
  134723. name: string;
  134724. shader: string;
  134725. };
  134726. }
  134727. declare module BABYLON {
  134728. /** @hidden */
  134729. export var pbrBlockNormalFinal: {
  134730. name: string;
  134731. shader: string;
  134732. };
  134733. }
  134734. declare module BABYLON {
  134735. /** @hidden */
  134736. export var pbrBlockLightmapInit: {
  134737. name: string;
  134738. shader: string;
  134739. };
  134740. }
  134741. declare module BABYLON {
  134742. /** @hidden */
  134743. export var pbrBlockGeometryInfo: {
  134744. name: string;
  134745. shader: string;
  134746. };
  134747. }
  134748. declare module BABYLON {
  134749. /** @hidden */
  134750. export var pbrBlockReflectance0: {
  134751. name: string;
  134752. shader: string;
  134753. };
  134754. }
  134755. declare module BABYLON {
  134756. /** @hidden */
  134757. export var pbrBlockReflectance: {
  134758. name: string;
  134759. shader: string;
  134760. };
  134761. }
  134762. declare module BABYLON {
  134763. /** @hidden */
  134764. export var pbrBlockDirectLighting: {
  134765. name: string;
  134766. shader: string;
  134767. };
  134768. }
  134769. declare module BABYLON {
  134770. /** @hidden */
  134771. export var pbrBlockFinalLitComponents: {
  134772. name: string;
  134773. shader: string;
  134774. };
  134775. }
  134776. declare module BABYLON {
  134777. /** @hidden */
  134778. export var pbrBlockFinalUnlitComponents: {
  134779. name: string;
  134780. shader: string;
  134781. };
  134782. }
  134783. declare module BABYLON {
  134784. /** @hidden */
  134785. export var pbrBlockFinalColorComposition: {
  134786. name: string;
  134787. shader: string;
  134788. };
  134789. }
  134790. declare module BABYLON {
  134791. /** @hidden */
  134792. export var pbrBlockImageProcessing: {
  134793. name: string;
  134794. shader: string;
  134795. };
  134796. }
  134797. declare module BABYLON {
  134798. /** @hidden */
  134799. export var pbrDebug: {
  134800. name: string;
  134801. shader: string;
  134802. };
  134803. }
  134804. declare module BABYLON {
  134805. /** @hidden */
  134806. export var pbrPixelShader: {
  134807. name: string;
  134808. shader: string;
  134809. };
  134810. }
  134811. declare module BABYLON {
  134812. /** @hidden */
  134813. export var pbrVertexDeclaration: {
  134814. name: string;
  134815. shader: string;
  134816. };
  134817. }
  134818. declare module BABYLON {
  134819. /** @hidden */
  134820. export var pbrVertexShader: {
  134821. name: string;
  134822. shader: string;
  134823. };
  134824. }
  134825. declare module BABYLON {
  134826. /**
  134827. * Manages the defines for the PBR Material.
  134828. * @hidden
  134829. */
  134830. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  134831. PBR: boolean;
  134832. NUM_SAMPLES: string;
  134833. REALTIME_FILTERING: boolean;
  134834. MAINUV1: boolean;
  134835. MAINUV2: boolean;
  134836. UV1: boolean;
  134837. UV2: boolean;
  134838. ALBEDO: boolean;
  134839. GAMMAALBEDO: boolean;
  134840. ALBEDODIRECTUV: number;
  134841. VERTEXCOLOR: boolean;
  134842. DETAIL: boolean;
  134843. DETAILDIRECTUV: number;
  134844. DETAIL_NORMALBLENDMETHOD: number;
  134845. AMBIENT: boolean;
  134846. AMBIENTDIRECTUV: number;
  134847. AMBIENTINGRAYSCALE: boolean;
  134848. OPACITY: boolean;
  134849. VERTEXALPHA: boolean;
  134850. OPACITYDIRECTUV: number;
  134851. OPACITYRGB: boolean;
  134852. ALPHATEST: boolean;
  134853. DEPTHPREPASS: boolean;
  134854. ALPHABLEND: boolean;
  134855. ALPHAFROMALBEDO: boolean;
  134856. ALPHATESTVALUE: string;
  134857. SPECULAROVERALPHA: boolean;
  134858. RADIANCEOVERALPHA: boolean;
  134859. ALPHAFRESNEL: boolean;
  134860. LINEARALPHAFRESNEL: boolean;
  134861. PREMULTIPLYALPHA: boolean;
  134862. EMISSIVE: boolean;
  134863. EMISSIVEDIRECTUV: number;
  134864. REFLECTIVITY: boolean;
  134865. REFLECTIVITYDIRECTUV: number;
  134866. SPECULARTERM: boolean;
  134867. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  134868. MICROSURFACEAUTOMATIC: boolean;
  134869. LODBASEDMICROSFURACE: boolean;
  134870. MICROSURFACEMAP: boolean;
  134871. MICROSURFACEMAPDIRECTUV: number;
  134872. METALLICWORKFLOW: boolean;
  134873. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  134874. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  134875. METALLNESSSTOREINMETALMAPBLUE: boolean;
  134876. AOSTOREINMETALMAPRED: boolean;
  134877. METALLIC_REFLECTANCE: boolean;
  134878. METALLIC_REFLECTANCEDIRECTUV: number;
  134879. ENVIRONMENTBRDF: boolean;
  134880. ENVIRONMENTBRDF_RGBD: boolean;
  134881. NORMAL: boolean;
  134882. TANGENT: boolean;
  134883. BUMP: boolean;
  134884. BUMPDIRECTUV: number;
  134885. OBJECTSPACE_NORMALMAP: boolean;
  134886. PARALLAX: boolean;
  134887. PARALLAXOCCLUSION: boolean;
  134888. NORMALXYSCALE: boolean;
  134889. LIGHTMAP: boolean;
  134890. LIGHTMAPDIRECTUV: number;
  134891. USELIGHTMAPASSHADOWMAP: boolean;
  134892. GAMMALIGHTMAP: boolean;
  134893. RGBDLIGHTMAP: boolean;
  134894. REFLECTION: boolean;
  134895. REFLECTIONMAP_3D: boolean;
  134896. REFLECTIONMAP_SPHERICAL: boolean;
  134897. REFLECTIONMAP_PLANAR: boolean;
  134898. REFLECTIONMAP_CUBIC: boolean;
  134899. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  134900. REFLECTIONMAP_PROJECTION: boolean;
  134901. REFLECTIONMAP_SKYBOX: boolean;
  134902. REFLECTIONMAP_EXPLICIT: boolean;
  134903. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  134904. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  134905. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  134906. INVERTCUBICMAP: boolean;
  134907. USESPHERICALFROMREFLECTIONMAP: boolean;
  134908. USEIRRADIANCEMAP: boolean;
  134909. SPHERICAL_HARMONICS: boolean;
  134910. USESPHERICALINVERTEX: boolean;
  134911. REFLECTIONMAP_OPPOSITEZ: boolean;
  134912. LODINREFLECTIONALPHA: boolean;
  134913. GAMMAREFLECTION: boolean;
  134914. RGBDREFLECTION: boolean;
  134915. LINEARSPECULARREFLECTION: boolean;
  134916. RADIANCEOCCLUSION: boolean;
  134917. HORIZONOCCLUSION: boolean;
  134918. INSTANCES: boolean;
  134919. THIN_INSTANCES: boolean;
  134920. PREPASS: boolean;
  134921. SCENE_MRT_COUNT: number;
  134922. NUM_BONE_INFLUENCERS: number;
  134923. BonesPerMesh: number;
  134924. BONETEXTURE: boolean;
  134925. NONUNIFORMSCALING: boolean;
  134926. MORPHTARGETS: boolean;
  134927. MORPHTARGETS_NORMAL: boolean;
  134928. MORPHTARGETS_TANGENT: boolean;
  134929. MORPHTARGETS_UV: boolean;
  134930. NUM_MORPH_INFLUENCERS: number;
  134931. IMAGEPROCESSING: boolean;
  134932. VIGNETTE: boolean;
  134933. VIGNETTEBLENDMODEMULTIPLY: boolean;
  134934. VIGNETTEBLENDMODEOPAQUE: boolean;
  134935. TONEMAPPING: boolean;
  134936. TONEMAPPING_ACES: boolean;
  134937. CONTRAST: boolean;
  134938. COLORCURVES: boolean;
  134939. COLORGRADING: boolean;
  134940. COLORGRADING3D: boolean;
  134941. SAMPLER3DGREENDEPTH: boolean;
  134942. SAMPLER3DBGRMAP: boolean;
  134943. IMAGEPROCESSINGPOSTPROCESS: boolean;
  134944. EXPOSURE: boolean;
  134945. MULTIVIEW: boolean;
  134946. USEPHYSICALLIGHTFALLOFF: boolean;
  134947. USEGLTFLIGHTFALLOFF: boolean;
  134948. TWOSIDEDLIGHTING: boolean;
  134949. SHADOWFLOAT: boolean;
  134950. CLIPPLANE: boolean;
  134951. CLIPPLANE2: boolean;
  134952. CLIPPLANE3: boolean;
  134953. CLIPPLANE4: boolean;
  134954. CLIPPLANE5: boolean;
  134955. CLIPPLANE6: boolean;
  134956. POINTSIZE: boolean;
  134957. FOG: boolean;
  134958. LOGARITHMICDEPTH: boolean;
  134959. FORCENORMALFORWARD: boolean;
  134960. SPECULARAA: boolean;
  134961. CLEARCOAT: boolean;
  134962. CLEARCOAT_DEFAULTIOR: boolean;
  134963. CLEARCOAT_TEXTURE: boolean;
  134964. CLEARCOAT_TEXTUREDIRECTUV: number;
  134965. CLEARCOAT_BUMP: boolean;
  134966. CLEARCOAT_BUMPDIRECTUV: number;
  134967. CLEARCOAT_TINT: boolean;
  134968. CLEARCOAT_TINT_TEXTURE: boolean;
  134969. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  134970. ANISOTROPIC: boolean;
  134971. ANISOTROPIC_TEXTURE: boolean;
  134972. ANISOTROPIC_TEXTUREDIRECTUV: number;
  134973. BRDF_V_HEIGHT_CORRELATED: boolean;
  134974. MS_BRDF_ENERGY_CONSERVATION: boolean;
  134975. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  134976. SHEEN: boolean;
  134977. SHEEN_TEXTURE: boolean;
  134978. SHEEN_TEXTUREDIRECTUV: number;
  134979. SHEEN_LINKWITHALBEDO: boolean;
  134980. SHEEN_ROUGHNESS: boolean;
  134981. SHEEN_ALBEDOSCALING: boolean;
  134982. SUBSURFACE: boolean;
  134983. SS_REFRACTION: boolean;
  134984. SS_TRANSLUCENCY: boolean;
  134985. SS_SCATTERING: boolean;
  134986. SS_THICKNESSANDMASK_TEXTURE: boolean;
  134987. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  134988. SS_REFRACTIONMAP_3D: boolean;
  134989. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  134990. SS_LODINREFRACTIONALPHA: boolean;
  134991. SS_GAMMAREFRACTION: boolean;
  134992. SS_RGBDREFRACTION: boolean;
  134993. SS_LINEARSPECULARREFRACTION: boolean;
  134994. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  134995. SS_ALBEDOFORREFRACTIONTINT: boolean;
  134996. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  134997. UNLIT: boolean;
  134998. DEBUGMODE: number;
  134999. /**
  135000. * Initializes the PBR Material defines.
  135001. */
  135002. constructor();
  135003. /**
  135004. * Resets the PBR Material defines.
  135005. */
  135006. reset(): void;
  135007. }
  135008. /**
  135009. * The Physically based material base class of BJS.
  135010. *
  135011. * This offers the main features of a standard PBR material.
  135012. * For more information, please refer to the documentation :
  135013. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135014. */
  135015. export abstract class PBRBaseMaterial extends PushMaterial {
  135016. /**
  135017. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135018. */
  135019. static readonly PBRMATERIAL_OPAQUE: number;
  135020. /**
  135021. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135022. */
  135023. static readonly PBRMATERIAL_ALPHATEST: number;
  135024. /**
  135025. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135026. */
  135027. static readonly PBRMATERIAL_ALPHABLEND: number;
  135028. /**
  135029. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135030. * They are also discarded below the alpha cutoff threshold to improve performances.
  135031. */
  135032. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135033. /**
  135034. * Defines the default value of how much AO map is occluding the analytical lights
  135035. * (point spot...).
  135036. */
  135037. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135038. /**
  135039. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  135040. */
  135041. static readonly LIGHTFALLOFF_PHYSICAL: number;
  135042. /**
  135043. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  135044. * to enhance interoperability with other engines.
  135045. */
  135046. static readonly LIGHTFALLOFF_GLTF: number;
  135047. /**
  135048. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  135049. * to enhance interoperability with other materials.
  135050. */
  135051. static readonly LIGHTFALLOFF_STANDARD: number;
  135052. /**
  135053. * Intensity of the direct lights e.g. the four lights available in your scene.
  135054. * This impacts both the direct diffuse and specular highlights.
  135055. */
  135056. protected _directIntensity: number;
  135057. /**
  135058. * Intensity of the emissive part of the material.
  135059. * This helps controlling the emissive effect without modifying the emissive color.
  135060. */
  135061. protected _emissiveIntensity: number;
  135062. /**
  135063. * Intensity of the environment e.g. how much the environment will light the object
  135064. * either through harmonics for rough material or through the refelction for shiny ones.
  135065. */
  135066. protected _environmentIntensity: number;
  135067. /**
  135068. * This is a special control allowing the reduction of the specular highlights coming from the
  135069. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135070. */
  135071. protected _specularIntensity: number;
  135072. /**
  135073. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  135074. */
  135075. private _lightingInfos;
  135076. /**
  135077. * Debug Control allowing disabling the bump map on this material.
  135078. */
  135079. protected _disableBumpMap: boolean;
  135080. /**
  135081. * AKA Diffuse Texture in standard nomenclature.
  135082. */
  135083. protected _albedoTexture: Nullable<BaseTexture>;
  135084. /**
  135085. * AKA Occlusion Texture in other nomenclature.
  135086. */
  135087. protected _ambientTexture: Nullable<BaseTexture>;
  135088. /**
  135089. * AKA Occlusion Texture Intensity in other nomenclature.
  135090. */
  135091. protected _ambientTextureStrength: number;
  135092. /**
  135093. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135094. * 1 means it completely occludes it
  135095. * 0 mean it has no impact
  135096. */
  135097. protected _ambientTextureImpactOnAnalyticalLights: number;
  135098. /**
  135099. * Stores the alpha values in a texture.
  135100. */
  135101. protected _opacityTexture: Nullable<BaseTexture>;
  135102. /**
  135103. * Stores the reflection values in a texture.
  135104. */
  135105. protected _reflectionTexture: Nullable<BaseTexture>;
  135106. /**
  135107. * Stores the emissive values in a texture.
  135108. */
  135109. protected _emissiveTexture: Nullable<BaseTexture>;
  135110. /**
  135111. * AKA Specular texture in other nomenclature.
  135112. */
  135113. protected _reflectivityTexture: Nullable<BaseTexture>;
  135114. /**
  135115. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135116. */
  135117. protected _metallicTexture: Nullable<BaseTexture>;
  135118. /**
  135119. * Specifies the metallic scalar of the metallic/roughness workflow.
  135120. * Can also be used to scale the metalness values of the metallic texture.
  135121. */
  135122. protected _metallic: Nullable<number>;
  135123. /**
  135124. * Specifies the roughness scalar of the metallic/roughness workflow.
  135125. * Can also be used to scale the roughness values of the metallic texture.
  135126. */
  135127. protected _roughness: Nullable<number>;
  135128. /**
  135129. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135130. * By default the indexOfrefraction is used to compute F0;
  135131. *
  135132. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135133. *
  135134. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135135. * F90 = metallicReflectanceColor;
  135136. */
  135137. protected _metallicF0Factor: number;
  135138. /**
  135139. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135140. * By default the F90 is always 1;
  135141. *
  135142. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135143. *
  135144. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135145. * F90 = metallicReflectanceColor;
  135146. */
  135147. protected _metallicReflectanceColor: Color3;
  135148. /**
  135149. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135150. * This is multiply against the scalar values defined in the material.
  135151. */
  135152. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  135153. /**
  135154. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135155. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135156. */
  135157. protected _microSurfaceTexture: Nullable<BaseTexture>;
  135158. /**
  135159. * Stores surface normal data used to displace a mesh in a texture.
  135160. */
  135161. protected _bumpTexture: Nullable<BaseTexture>;
  135162. /**
  135163. * Stores the pre-calculated light information of a mesh in a texture.
  135164. */
  135165. protected _lightmapTexture: Nullable<BaseTexture>;
  135166. /**
  135167. * The color of a material in ambient lighting.
  135168. */
  135169. protected _ambientColor: Color3;
  135170. /**
  135171. * AKA Diffuse Color in other nomenclature.
  135172. */
  135173. protected _albedoColor: Color3;
  135174. /**
  135175. * AKA Specular Color in other nomenclature.
  135176. */
  135177. protected _reflectivityColor: Color3;
  135178. /**
  135179. * The color applied when light is reflected from a material.
  135180. */
  135181. protected _reflectionColor: Color3;
  135182. /**
  135183. * The color applied when light is emitted from a material.
  135184. */
  135185. protected _emissiveColor: Color3;
  135186. /**
  135187. * AKA Glossiness in other nomenclature.
  135188. */
  135189. protected _microSurface: number;
  135190. /**
  135191. * Specifies that the material will use the light map as a show map.
  135192. */
  135193. protected _useLightmapAsShadowmap: boolean;
  135194. /**
  135195. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135196. * makes the reflect vector face the model (under horizon).
  135197. */
  135198. protected _useHorizonOcclusion: boolean;
  135199. /**
  135200. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135201. * too much the area relying on ambient texture to define their ambient occlusion.
  135202. */
  135203. protected _useRadianceOcclusion: boolean;
  135204. /**
  135205. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135206. */
  135207. protected _useAlphaFromAlbedoTexture: boolean;
  135208. /**
  135209. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  135210. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135211. */
  135212. protected _useSpecularOverAlpha: boolean;
  135213. /**
  135214. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135215. */
  135216. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135217. /**
  135218. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135219. */
  135220. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  135221. /**
  135222. * Specifies if the metallic texture contains the roughness information in its green channel.
  135223. */
  135224. protected _useRoughnessFromMetallicTextureGreen: boolean;
  135225. /**
  135226. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135227. */
  135228. protected _useMetallnessFromMetallicTextureBlue: boolean;
  135229. /**
  135230. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135231. */
  135232. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  135233. /**
  135234. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135235. */
  135236. protected _useAmbientInGrayScale: boolean;
  135237. /**
  135238. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135239. * The material will try to infer what glossiness each pixel should be.
  135240. */
  135241. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  135242. /**
  135243. * Defines the falloff type used in this material.
  135244. * It by default is Physical.
  135245. */
  135246. protected _lightFalloff: number;
  135247. /**
  135248. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135249. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135250. */
  135251. protected _useRadianceOverAlpha: boolean;
  135252. /**
  135253. * Allows using an object space normal map (instead of tangent space).
  135254. */
  135255. protected _useObjectSpaceNormalMap: boolean;
  135256. /**
  135257. * Allows using the bump map in parallax mode.
  135258. */
  135259. protected _useParallax: boolean;
  135260. /**
  135261. * Allows using the bump map in parallax occlusion mode.
  135262. */
  135263. protected _useParallaxOcclusion: boolean;
  135264. /**
  135265. * Controls the scale bias of the parallax mode.
  135266. */
  135267. protected _parallaxScaleBias: number;
  135268. /**
  135269. * If sets to true, disables all the lights affecting the material.
  135270. */
  135271. protected _disableLighting: boolean;
  135272. /**
  135273. * Number of Simultaneous lights allowed on the material.
  135274. */
  135275. protected _maxSimultaneousLights: number;
  135276. /**
  135277. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135278. */
  135279. protected _invertNormalMapX: boolean;
  135280. /**
  135281. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135282. */
  135283. protected _invertNormalMapY: boolean;
  135284. /**
  135285. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135286. */
  135287. protected _twoSidedLighting: boolean;
  135288. /**
  135289. * Defines the alpha limits in alpha test mode.
  135290. */
  135291. protected _alphaCutOff: number;
  135292. /**
  135293. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135294. */
  135295. protected _forceAlphaTest: boolean;
  135296. /**
  135297. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135298. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135299. */
  135300. protected _useAlphaFresnel: boolean;
  135301. /**
  135302. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135303. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135304. */
  135305. protected _useLinearAlphaFresnel: boolean;
  135306. /**
  135307. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  135308. * from cos thetav and roughness:
  135309. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  135310. */
  135311. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  135312. /**
  135313. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135314. */
  135315. protected _forceIrradianceInFragment: boolean;
  135316. private _realTimeFiltering;
  135317. /**
  135318. * Enables realtime filtering on the texture.
  135319. */
  135320. get realTimeFiltering(): boolean;
  135321. set realTimeFiltering(b: boolean);
  135322. private _realTimeFilteringQuality;
  135323. /**
  135324. * Quality switch for realtime filtering
  135325. */
  135326. get realTimeFilteringQuality(): number;
  135327. set realTimeFilteringQuality(n: number);
  135328. /**
  135329. * Can this material render to several textures at once
  135330. */
  135331. get canRenderToMRT(): boolean;
  135332. /**
  135333. * Force normal to face away from face.
  135334. */
  135335. protected _forceNormalForward: boolean;
  135336. /**
  135337. * Enables specular anti aliasing in the PBR shader.
  135338. * It will both interacts on the Geometry for analytical and IBL lighting.
  135339. * It also prefilter the roughness map based on the bump values.
  135340. */
  135341. protected _enableSpecularAntiAliasing: boolean;
  135342. /**
  135343. * Default configuration related to image processing available in the PBR Material.
  135344. */
  135345. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135346. /**
  135347. * Keep track of the image processing observer to allow dispose and replace.
  135348. */
  135349. private _imageProcessingObserver;
  135350. /**
  135351. * Attaches a new image processing configuration to the PBR Material.
  135352. * @param configuration
  135353. */
  135354. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135355. /**
  135356. * Stores the available render targets.
  135357. */
  135358. private _renderTargets;
  135359. /**
  135360. * Sets the global ambient color for the material used in lighting calculations.
  135361. */
  135362. private _globalAmbientColor;
  135363. /**
  135364. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  135365. */
  135366. private _useLogarithmicDepth;
  135367. /**
  135368. * If set to true, no lighting calculations will be applied.
  135369. */
  135370. private _unlit;
  135371. private _debugMode;
  135372. /**
  135373. * @hidden
  135374. * This is reserved for the inspector.
  135375. * Defines the material debug mode.
  135376. * It helps seeing only some components of the material while troubleshooting.
  135377. */
  135378. debugMode: number;
  135379. /**
  135380. * @hidden
  135381. * This is reserved for the inspector.
  135382. * Specify from where on screen the debug mode should start.
  135383. * The value goes from -1 (full screen) to 1 (not visible)
  135384. * It helps with side by side comparison against the final render
  135385. * This defaults to -1
  135386. */
  135387. private debugLimit;
  135388. /**
  135389. * @hidden
  135390. * This is reserved for the inspector.
  135391. * As the default viewing range might not be enough (if the ambient is really small for instance)
  135392. * You can use the factor to better multiply the final value.
  135393. */
  135394. private debugFactor;
  135395. /**
  135396. * Defines the clear coat layer parameters for the material.
  135397. */
  135398. readonly clearCoat: PBRClearCoatConfiguration;
  135399. /**
  135400. * Defines the anisotropic parameters for the material.
  135401. */
  135402. readonly anisotropy: PBRAnisotropicConfiguration;
  135403. /**
  135404. * Defines the BRDF parameters for the material.
  135405. */
  135406. readonly brdf: PBRBRDFConfiguration;
  135407. /**
  135408. * Defines the Sheen parameters for the material.
  135409. */
  135410. readonly sheen: PBRSheenConfiguration;
  135411. /**
  135412. * Defines the SubSurface parameters for the material.
  135413. */
  135414. readonly subSurface: PBRSubSurfaceConfiguration;
  135415. /**
  135416. * Defines the detail map parameters for the material.
  135417. */
  135418. readonly detailMap: DetailMapConfiguration;
  135419. protected _rebuildInParallel: boolean;
  135420. /**
  135421. * Instantiates a new PBRMaterial instance.
  135422. *
  135423. * @param name The material name
  135424. * @param scene The scene the material will be use in.
  135425. */
  135426. constructor(name: string, scene: Scene);
  135427. /**
  135428. * Gets a boolean indicating that current material needs to register RTT
  135429. */
  135430. get hasRenderTargetTextures(): boolean;
  135431. /**
  135432. * Gets the name of the material class.
  135433. */
  135434. getClassName(): string;
  135435. /**
  135436. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135437. */
  135438. get useLogarithmicDepth(): boolean;
  135439. /**
  135440. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  135441. */
  135442. set useLogarithmicDepth(value: boolean);
  135443. /**
  135444. * Returns true if alpha blending should be disabled.
  135445. */
  135446. protected get _disableAlphaBlending(): boolean;
  135447. /**
  135448. * Specifies whether or not this material should be rendered in alpha blend mode.
  135449. */
  135450. needAlphaBlending(): boolean;
  135451. /**
  135452. * Specifies whether or not this material should be rendered in alpha test mode.
  135453. */
  135454. needAlphaTesting(): boolean;
  135455. /**
  135456. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  135457. */
  135458. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  135459. /**
  135460. * Gets the texture used for the alpha test.
  135461. */
  135462. getAlphaTestTexture(): Nullable<BaseTexture>;
  135463. /**
  135464. * Specifies that the submesh is ready to be used.
  135465. * @param mesh - BJS mesh.
  135466. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  135467. * @param useInstances - Specifies that instances should be used.
  135468. * @returns - boolean indicating that the submesh is ready or not.
  135469. */
  135470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135471. /**
  135472. * Specifies if the material uses metallic roughness workflow.
  135473. * @returns boolean specifiying if the material uses metallic roughness workflow.
  135474. */
  135475. isMetallicWorkflow(): boolean;
  135476. private _prepareEffect;
  135477. private _prepareDefines;
  135478. /**
  135479. * Force shader compilation
  135480. */
  135481. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  135482. /**
  135483. * Initializes the uniform buffer layout for the shader.
  135484. */
  135485. buildUniformLayout(): void;
  135486. /**
  135487. * Unbinds the material from the mesh
  135488. */
  135489. unbind(): void;
  135490. /**
  135491. * Binds the submesh data.
  135492. * @param world - The world matrix.
  135493. * @param mesh - The BJS mesh.
  135494. * @param subMesh - A submesh of the BJS mesh.
  135495. */
  135496. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135497. /**
  135498. * Returns the animatable textures.
  135499. * @returns - Array of animatable textures.
  135500. */
  135501. getAnimatables(): IAnimatable[];
  135502. /**
  135503. * Returns the texture used for reflections.
  135504. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  135505. */
  135506. private _getReflectionTexture;
  135507. /**
  135508. * Returns an array of the actively used textures.
  135509. * @returns - Array of BaseTextures
  135510. */
  135511. getActiveTextures(): BaseTexture[];
  135512. /**
  135513. * Checks to see if a texture is used in the material.
  135514. * @param texture - Base texture to use.
  135515. * @returns - Boolean specifying if a texture is used in the material.
  135516. */
  135517. hasTexture(texture: BaseTexture): boolean;
  135518. /**
  135519. * Sets the required values to the prepass renderer.
  135520. * @param prePassRenderer defines the prepass renderer to setup
  135521. */
  135522. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  135523. /**
  135524. * Disposes the resources of the material.
  135525. * @param forceDisposeEffect - Forces the disposal of effects.
  135526. * @param forceDisposeTextures - Forces the disposal of all textures.
  135527. */
  135528. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135529. }
  135530. }
  135531. declare module BABYLON {
  135532. /**
  135533. * The Physically based material of BJS.
  135534. *
  135535. * This offers the main features of a standard PBR material.
  135536. * For more information, please refer to the documentation :
  135537. * https://doc.babylonjs.com/how_to/physically_based_rendering
  135538. */
  135539. export class PBRMaterial extends PBRBaseMaterial {
  135540. /**
  135541. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  135542. */
  135543. static readonly PBRMATERIAL_OPAQUE: number;
  135544. /**
  135545. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  135546. */
  135547. static readonly PBRMATERIAL_ALPHATEST: number;
  135548. /**
  135549. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135550. */
  135551. static readonly PBRMATERIAL_ALPHABLEND: number;
  135552. /**
  135553. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  135554. * They are also discarded below the alpha cutoff threshold to improve performances.
  135555. */
  135556. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  135557. /**
  135558. * Defines the default value of how much AO map is occluding the analytical lights
  135559. * (point spot...).
  135560. */
  135561. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  135562. /**
  135563. * Intensity of the direct lights e.g. the four lights available in your scene.
  135564. * This impacts both the direct diffuse and specular highlights.
  135565. */
  135566. directIntensity: number;
  135567. /**
  135568. * Intensity of the emissive part of the material.
  135569. * This helps controlling the emissive effect without modifying the emissive color.
  135570. */
  135571. emissiveIntensity: number;
  135572. /**
  135573. * Intensity of the environment e.g. how much the environment will light the object
  135574. * either through harmonics for rough material or through the refelction for shiny ones.
  135575. */
  135576. environmentIntensity: number;
  135577. /**
  135578. * This is a special control allowing the reduction of the specular highlights coming from the
  135579. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  135580. */
  135581. specularIntensity: number;
  135582. /**
  135583. * Debug Control allowing disabling the bump map on this material.
  135584. */
  135585. disableBumpMap: boolean;
  135586. /**
  135587. * AKA Diffuse Texture in standard nomenclature.
  135588. */
  135589. albedoTexture: BaseTexture;
  135590. /**
  135591. * AKA Occlusion Texture in other nomenclature.
  135592. */
  135593. ambientTexture: BaseTexture;
  135594. /**
  135595. * AKA Occlusion Texture Intensity in other nomenclature.
  135596. */
  135597. ambientTextureStrength: number;
  135598. /**
  135599. * Defines how much the AO map is occluding the analytical lights (point spot...).
  135600. * 1 means it completely occludes it
  135601. * 0 mean it has no impact
  135602. */
  135603. ambientTextureImpactOnAnalyticalLights: number;
  135604. /**
  135605. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  135606. */
  135607. opacityTexture: BaseTexture;
  135608. /**
  135609. * Stores the reflection values in a texture.
  135610. */
  135611. reflectionTexture: Nullable<BaseTexture>;
  135612. /**
  135613. * Stores the emissive values in a texture.
  135614. */
  135615. emissiveTexture: BaseTexture;
  135616. /**
  135617. * AKA Specular texture in other nomenclature.
  135618. */
  135619. reflectivityTexture: BaseTexture;
  135620. /**
  135621. * Used to switch from specular/glossiness to metallic/roughness workflow.
  135622. */
  135623. metallicTexture: BaseTexture;
  135624. /**
  135625. * Specifies the metallic scalar of the metallic/roughness workflow.
  135626. * Can also be used to scale the metalness values of the metallic texture.
  135627. */
  135628. metallic: Nullable<number>;
  135629. /**
  135630. * Specifies the roughness scalar of the metallic/roughness workflow.
  135631. * Can also be used to scale the roughness values of the metallic texture.
  135632. */
  135633. roughness: Nullable<number>;
  135634. /**
  135635. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  135636. * By default the indexOfrefraction is used to compute F0;
  135637. *
  135638. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  135639. *
  135640. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  135641. * F90 = metallicReflectanceColor;
  135642. */
  135643. metallicF0Factor: number;
  135644. /**
  135645. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  135646. * By default the F90 is always 1;
  135647. *
  135648. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  135649. *
  135650. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  135651. * F90 = metallicReflectanceColor;
  135652. */
  135653. metallicReflectanceColor: Color3;
  135654. /**
  135655. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  135656. * This is multiply against the scalar values defined in the material.
  135657. */
  135658. metallicReflectanceTexture: Nullable<BaseTexture>;
  135659. /**
  135660. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  135661. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  135662. */
  135663. microSurfaceTexture: BaseTexture;
  135664. /**
  135665. * Stores surface normal data used to displace a mesh in a texture.
  135666. */
  135667. bumpTexture: BaseTexture;
  135668. /**
  135669. * Stores the pre-calculated light information of a mesh in a texture.
  135670. */
  135671. lightmapTexture: BaseTexture;
  135672. /**
  135673. * Stores the refracted light information in a texture.
  135674. */
  135675. get refractionTexture(): Nullable<BaseTexture>;
  135676. set refractionTexture(value: Nullable<BaseTexture>);
  135677. /**
  135678. * The color of a material in ambient lighting.
  135679. */
  135680. ambientColor: Color3;
  135681. /**
  135682. * AKA Diffuse Color in other nomenclature.
  135683. */
  135684. albedoColor: Color3;
  135685. /**
  135686. * AKA Specular Color in other nomenclature.
  135687. */
  135688. reflectivityColor: Color3;
  135689. /**
  135690. * The color reflected from the material.
  135691. */
  135692. reflectionColor: Color3;
  135693. /**
  135694. * The color emitted from the material.
  135695. */
  135696. emissiveColor: Color3;
  135697. /**
  135698. * AKA Glossiness in other nomenclature.
  135699. */
  135700. microSurface: number;
  135701. /**
  135702. * Index of refraction of the material base layer.
  135703. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135704. *
  135705. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135706. *
  135707. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135708. */
  135709. get indexOfRefraction(): number;
  135710. set indexOfRefraction(value: number);
  135711. /**
  135712. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135713. */
  135714. get invertRefractionY(): boolean;
  135715. set invertRefractionY(value: boolean);
  135716. /**
  135717. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135718. * Materials half opaque for instance using refraction could benefit from this control.
  135719. */
  135720. get linkRefractionWithTransparency(): boolean;
  135721. set linkRefractionWithTransparency(value: boolean);
  135722. /**
  135723. * If true, the light map contains occlusion information instead of lighting info.
  135724. */
  135725. useLightmapAsShadowmap: boolean;
  135726. /**
  135727. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  135728. */
  135729. useAlphaFromAlbedoTexture: boolean;
  135730. /**
  135731. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  135732. */
  135733. forceAlphaTest: boolean;
  135734. /**
  135735. * Defines the alpha limits in alpha test mode.
  135736. */
  135737. alphaCutOff: number;
  135738. /**
  135739. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  135740. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  135741. */
  135742. useSpecularOverAlpha: boolean;
  135743. /**
  135744. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  135745. */
  135746. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  135747. /**
  135748. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  135749. */
  135750. useRoughnessFromMetallicTextureAlpha: boolean;
  135751. /**
  135752. * Specifies if the metallic texture contains the roughness information in its green channel.
  135753. */
  135754. useRoughnessFromMetallicTextureGreen: boolean;
  135755. /**
  135756. * Specifies if the metallic texture contains the metallness information in its blue channel.
  135757. */
  135758. useMetallnessFromMetallicTextureBlue: boolean;
  135759. /**
  135760. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  135761. */
  135762. useAmbientOcclusionFromMetallicTextureRed: boolean;
  135763. /**
  135764. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  135765. */
  135766. useAmbientInGrayScale: boolean;
  135767. /**
  135768. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  135769. * The material will try to infer what glossiness each pixel should be.
  135770. */
  135771. useAutoMicroSurfaceFromReflectivityMap: boolean;
  135772. /**
  135773. * BJS is using an harcoded light falloff based on a manually sets up range.
  135774. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135775. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135776. */
  135777. get usePhysicalLightFalloff(): boolean;
  135778. /**
  135779. * BJS is using an harcoded light falloff based on a manually sets up range.
  135780. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  135781. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  135782. */
  135783. set usePhysicalLightFalloff(value: boolean);
  135784. /**
  135785. * In order to support the falloff compatibility with gltf, a special mode has been added
  135786. * to reproduce the gltf light falloff.
  135787. */
  135788. get useGLTFLightFalloff(): boolean;
  135789. /**
  135790. * In order to support the falloff compatibility with gltf, a special mode has been added
  135791. * to reproduce the gltf light falloff.
  135792. */
  135793. set useGLTFLightFalloff(value: boolean);
  135794. /**
  135795. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  135796. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  135797. */
  135798. useRadianceOverAlpha: boolean;
  135799. /**
  135800. * Allows using an object space normal map (instead of tangent space).
  135801. */
  135802. useObjectSpaceNormalMap: boolean;
  135803. /**
  135804. * Allows using the bump map in parallax mode.
  135805. */
  135806. useParallax: boolean;
  135807. /**
  135808. * Allows using the bump map in parallax occlusion mode.
  135809. */
  135810. useParallaxOcclusion: boolean;
  135811. /**
  135812. * Controls the scale bias of the parallax mode.
  135813. */
  135814. parallaxScaleBias: number;
  135815. /**
  135816. * If sets to true, disables all the lights affecting the material.
  135817. */
  135818. disableLighting: boolean;
  135819. /**
  135820. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  135821. */
  135822. forceIrradianceInFragment: boolean;
  135823. /**
  135824. * Number of Simultaneous lights allowed on the material.
  135825. */
  135826. maxSimultaneousLights: number;
  135827. /**
  135828. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  135829. */
  135830. invertNormalMapX: boolean;
  135831. /**
  135832. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  135833. */
  135834. invertNormalMapY: boolean;
  135835. /**
  135836. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  135837. */
  135838. twoSidedLighting: boolean;
  135839. /**
  135840. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135841. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  135842. */
  135843. useAlphaFresnel: boolean;
  135844. /**
  135845. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  135846. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  135847. */
  135848. useLinearAlphaFresnel: boolean;
  135849. /**
  135850. * Let user defines the brdf lookup texture used for IBL.
  135851. * A default 8bit version is embedded but you could point at :
  135852. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  135853. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  135854. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  135855. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  135856. */
  135857. environmentBRDFTexture: Nullable<BaseTexture>;
  135858. /**
  135859. * Force normal to face away from face.
  135860. */
  135861. forceNormalForward: boolean;
  135862. /**
  135863. * Enables specular anti aliasing in the PBR shader.
  135864. * It will both interacts on the Geometry for analytical and IBL lighting.
  135865. * It also prefilter the roughness map based on the bump values.
  135866. */
  135867. enableSpecularAntiAliasing: boolean;
  135868. /**
  135869. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  135870. * makes the reflect vector face the model (under horizon).
  135871. */
  135872. useHorizonOcclusion: boolean;
  135873. /**
  135874. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  135875. * too much the area relying on ambient texture to define their ambient occlusion.
  135876. */
  135877. useRadianceOcclusion: boolean;
  135878. /**
  135879. * If set to true, no lighting calculations will be applied.
  135880. */
  135881. unlit: boolean;
  135882. /**
  135883. * Gets the image processing configuration used either in this material.
  135884. */
  135885. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  135886. /**
  135887. * Sets the Default image processing configuration used either in the this material.
  135888. *
  135889. * If sets to null, the scene one is in use.
  135890. */
  135891. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  135892. /**
  135893. * Gets wether the color curves effect is enabled.
  135894. */
  135895. get cameraColorCurvesEnabled(): boolean;
  135896. /**
  135897. * Sets wether the color curves effect is enabled.
  135898. */
  135899. set cameraColorCurvesEnabled(value: boolean);
  135900. /**
  135901. * Gets wether the color grading effect is enabled.
  135902. */
  135903. get cameraColorGradingEnabled(): boolean;
  135904. /**
  135905. * Gets wether the color grading effect is enabled.
  135906. */
  135907. set cameraColorGradingEnabled(value: boolean);
  135908. /**
  135909. * Gets wether tonemapping is enabled or not.
  135910. */
  135911. get cameraToneMappingEnabled(): boolean;
  135912. /**
  135913. * Sets wether tonemapping is enabled or not
  135914. */
  135915. set cameraToneMappingEnabled(value: boolean);
  135916. /**
  135917. * The camera exposure used on this material.
  135918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135919. * This corresponds to a photographic exposure.
  135920. */
  135921. get cameraExposure(): number;
  135922. /**
  135923. * The camera exposure used on this material.
  135924. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135925. * This corresponds to a photographic exposure.
  135926. */
  135927. set cameraExposure(value: number);
  135928. /**
  135929. * Gets The camera contrast used on this material.
  135930. */
  135931. get cameraContrast(): number;
  135932. /**
  135933. * Sets The camera contrast used on this material.
  135934. */
  135935. set cameraContrast(value: number);
  135936. /**
  135937. * Gets the Color Grading 2D Lookup Texture.
  135938. */
  135939. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135940. /**
  135941. * Sets the Color Grading 2D Lookup Texture.
  135942. */
  135943. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135944. /**
  135945. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135946. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135947. * 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;
  135948. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135949. */
  135950. get cameraColorCurves(): Nullable<ColorCurves>;
  135951. /**
  135952. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135953. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135954. * 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;
  135955. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135956. */
  135957. set cameraColorCurves(value: Nullable<ColorCurves>);
  135958. /**
  135959. * Instantiates a new PBRMaterial instance.
  135960. *
  135961. * @param name The material name
  135962. * @param scene The scene the material will be use in.
  135963. */
  135964. constructor(name: string, scene: Scene);
  135965. /**
  135966. * Returns the name of this material class.
  135967. */
  135968. getClassName(): string;
  135969. /**
  135970. * Makes a duplicate of the current material.
  135971. * @param name - name to use for the new material.
  135972. */
  135973. clone(name: string): PBRMaterial;
  135974. /**
  135975. * Serializes this PBR Material.
  135976. * @returns - An object with the serialized material.
  135977. */
  135978. serialize(): any;
  135979. /**
  135980. * Parses a PBR Material from a serialized object.
  135981. * @param source - Serialized object.
  135982. * @param scene - BJS scene instance.
  135983. * @param rootUrl - url for the scene object
  135984. * @returns - PBRMaterial
  135985. */
  135986. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  135987. }
  135988. }
  135989. declare module BABYLON {
  135990. /**
  135991. * Direct draw surface info
  135992. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  135993. */
  135994. export interface DDSInfo {
  135995. /**
  135996. * Width of the texture
  135997. */
  135998. width: number;
  135999. /**
  136000. * Width of the texture
  136001. */
  136002. height: number;
  136003. /**
  136004. * Number of Mipmaps for the texture
  136005. * @see https://en.wikipedia.org/wiki/Mipmap
  136006. */
  136007. mipmapCount: number;
  136008. /**
  136009. * If the textures format is a known fourCC format
  136010. * @see https://www.fourcc.org/
  136011. */
  136012. isFourCC: boolean;
  136013. /**
  136014. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  136015. */
  136016. isRGB: boolean;
  136017. /**
  136018. * If the texture is a lumincance format
  136019. */
  136020. isLuminance: boolean;
  136021. /**
  136022. * If this is a cube texture
  136023. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  136024. */
  136025. isCube: boolean;
  136026. /**
  136027. * If the texture is a compressed format eg. FOURCC_DXT1
  136028. */
  136029. isCompressed: boolean;
  136030. /**
  136031. * The dxgiFormat of the texture
  136032. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  136033. */
  136034. dxgiFormat: number;
  136035. /**
  136036. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  136037. */
  136038. textureType: number;
  136039. /**
  136040. * Sphericle polynomial created for the dds texture
  136041. */
  136042. sphericalPolynomial?: SphericalPolynomial;
  136043. }
  136044. /**
  136045. * Class used to provide DDS decompression tools
  136046. */
  136047. export class DDSTools {
  136048. /**
  136049. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  136050. */
  136051. static StoreLODInAlphaChannel: boolean;
  136052. /**
  136053. * Gets DDS information from an array buffer
  136054. * @param data defines the array buffer view to read data from
  136055. * @returns the DDS information
  136056. */
  136057. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  136058. private static _FloatView;
  136059. private static _Int32View;
  136060. private static _ToHalfFloat;
  136061. private static _FromHalfFloat;
  136062. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  136063. private static _GetHalfFloatRGBAArrayBuffer;
  136064. private static _GetFloatRGBAArrayBuffer;
  136065. private static _GetFloatAsUIntRGBAArrayBuffer;
  136066. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  136067. private static _GetRGBAArrayBuffer;
  136068. private static _ExtractLongWordOrder;
  136069. private static _GetRGBArrayBuffer;
  136070. private static _GetLuminanceArrayBuffer;
  136071. /**
  136072. * Uploads DDS Levels to a Babylon Texture
  136073. * @hidden
  136074. */
  136075. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  136076. }
  136077. interface ThinEngine {
  136078. /**
  136079. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  136080. * @param rootUrl defines the url where the file to load is located
  136081. * @param scene defines the current scene
  136082. * @param lodScale defines scale to apply to the mip map selection
  136083. * @param lodOffset defines offset to apply to the mip map selection
  136084. * @param onLoad defines an optional callback raised when the texture is loaded
  136085. * @param onError defines an optional callback raised if there is an issue to load the texture
  136086. * @param format defines the format of the data
  136087. * @param forcedExtension defines the extension to use to pick the right loader
  136088. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  136089. * @returns the cube texture as an InternalTexture
  136090. */
  136091. 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;
  136092. }
  136093. }
  136094. declare module BABYLON {
  136095. /**
  136096. * Implementation of the DDS Texture Loader.
  136097. * @hidden
  136098. */
  136099. export class _DDSTextureLoader implements IInternalTextureLoader {
  136100. /**
  136101. * Defines wether the loader supports cascade loading the different faces.
  136102. */
  136103. readonly supportCascades: boolean;
  136104. /**
  136105. * This returns if the loader support the current file information.
  136106. * @param extension defines the file extension of the file being loaded
  136107. * @returns true if the loader can load the specified file
  136108. */
  136109. canLoad(extension: string): boolean;
  136110. /**
  136111. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136112. * @param data contains the texture data
  136113. * @param texture defines the BabylonJS internal texture
  136114. * @param createPolynomials will be true if polynomials have been requested
  136115. * @param onLoad defines the callback to trigger once the texture is ready
  136116. * @param onError defines the callback to trigger in case of error
  136117. */
  136118. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136119. /**
  136120. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136121. * @param data contains the texture data
  136122. * @param texture defines the BabylonJS internal texture
  136123. * @param callback defines the method to call once ready to upload
  136124. */
  136125. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136126. }
  136127. }
  136128. declare module BABYLON {
  136129. /**
  136130. * Implementation of the ENV Texture Loader.
  136131. * @hidden
  136132. */
  136133. export class _ENVTextureLoader implements IInternalTextureLoader {
  136134. /**
  136135. * Defines wether the loader supports cascade loading the different faces.
  136136. */
  136137. readonly supportCascades: boolean;
  136138. /**
  136139. * This returns if the loader support the current file information.
  136140. * @param extension defines the file extension of the file being loaded
  136141. * @returns true if the loader can load the specified file
  136142. */
  136143. canLoad(extension: string): boolean;
  136144. /**
  136145. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136146. * @param data contains the texture data
  136147. * @param texture defines the BabylonJS internal texture
  136148. * @param createPolynomials will be true if polynomials have been requested
  136149. * @param onLoad defines the callback to trigger once the texture is ready
  136150. * @param onError defines the callback to trigger in case of error
  136151. */
  136152. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136153. /**
  136154. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136155. * @param data contains the texture data
  136156. * @param texture defines the BabylonJS internal texture
  136157. * @param callback defines the method to call once ready to upload
  136158. */
  136159. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  136160. }
  136161. }
  136162. declare module BABYLON {
  136163. /**
  136164. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  136165. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  136166. */
  136167. export class KhronosTextureContainer {
  136168. /** contents of the KTX container file */
  136169. data: ArrayBufferView;
  136170. private static HEADER_LEN;
  136171. private static COMPRESSED_2D;
  136172. private static COMPRESSED_3D;
  136173. private static TEX_2D;
  136174. private static TEX_3D;
  136175. /**
  136176. * Gets the openGL type
  136177. */
  136178. glType: number;
  136179. /**
  136180. * Gets the openGL type size
  136181. */
  136182. glTypeSize: number;
  136183. /**
  136184. * Gets the openGL format
  136185. */
  136186. glFormat: number;
  136187. /**
  136188. * Gets the openGL internal format
  136189. */
  136190. glInternalFormat: number;
  136191. /**
  136192. * Gets the base internal format
  136193. */
  136194. glBaseInternalFormat: number;
  136195. /**
  136196. * Gets image width in pixel
  136197. */
  136198. pixelWidth: number;
  136199. /**
  136200. * Gets image height in pixel
  136201. */
  136202. pixelHeight: number;
  136203. /**
  136204. * Gets image depth in pixels
  136205. */
  136206. pixelDepth: number;
  136207. /**
  136208. * Gets the number of array elements
  136209. */
  136210. numberOfArrayElements: number;
  136211. /**
  136212. * Gets the number of faces
  136213. */
  136214. numberOfFaces: number;
  136215. /**
  136216. * Gets the number of mipmap levels
  136217. */
  136218. numberOfMipmapLevels: number;
  136219. /**
  136220. * Gets the bytes of key value data
  136221. */
  136222. bytesOfKeyValueData: number;
  136223. /**
  136224. * Gets the load type
  136225. */
  136226. loadType: number;
  136227. /**
  136228. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  136229. */
  136230. isInvalid: boolean;
  136231. /**
  136232. * Creates a new KhronosTextureContainer
  136233. * @param data contents of the KTX container file
  136234. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  136235. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  136236. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  136237. */
  136238. constructor(
  136239. /** contents of the KTX container file */
  136240. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  136241. /**
  136242. * Uploads KTX content to a Babylon Texture.
  136243. * It is assumed that the texture has already been created & is currently bound
  136244. * @hidden
  136245. */
  136246. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  136247. private _upload2DCompressedLevels;
  136248. /**
  136249. * Checks if the given data starts with a KTX file identifier.
  136250. * @param data the data to check
  136251. * @returns true if the data is a KTX file or false otherwise
  136252. */
  136253. static IsValid(data: ArrayBufferView): boolean;
  136254. }
  136255. }
  136256. declare module BABYLON {
  136257. /**
  136258. * Class for loading KTX2 files
  136259. * !!! Experimental Extension Subject to Changes !!!
  136260. * @hidden
  136261. */
  136262. export class KhronosTextureContainer2 {
  136263. private static _ModulePromise;
  136264. private static _TranscodeFormat;
  136265. constructor(engine: ThinEngine);
  136266. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  136267. private _determineTranscodeFormat;
  136268. /**
  136269. * Checks if the given data starts with a KTX2 file identifier.
  136270. * @param data the data to check
  136271. * @returns true if the data is a KTX2 file or false otherwise
  136272. */
  136273. static IsValid(data: ArrayBufferView): boolean;
  136274. }
  136275. }
  136276. declare module BABYLON {
  136277. /**
  136278. * Implementation of the KTX Texture Loader.
  136279. * @hidden
  136280. */
  136281. export class _KTXTextureLoader implements IInternalTextureLoader {
  136282. /**
  136283. * Defines wether the loader supports cascade loading the different faces.
  136284. */
  136285. readonly supportCascades: boolean;
  136286. /**
  136287. * This returns if the loader support the current file information.
  136288. * @param extension defines the file extension of the file being loaded
  136289. * @param mimeType defines the optional mime type of the file being loaded
  136290. * @returns true if the loader can load the specified file
  136291. */
  136292. canLoad(extension: string, mimeType?: string): boolean;
  136293. /**
  136294. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  136295. * @param data contains the texture data
  136296. * @param texture defines the BabylonJS internal texture
  136297. * @param createPolynomials will be true if polynomials have been requested
  136298. * @param onLoad defines the callback to trigger once the texture is ready
  136299. * @param onError defines the callback to trigger in case of error
  136300. */
  136301. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  136302. /**
  136303. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  136304. * @param data contains the texture data
  136305. * @param texture defines the BabylonJS internal texture
  136306. * @param callback defines the method to call once ready to upload
  136307. */
  136308. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  136309. }
  136310. }
  136311. declare module BABYLON {
  136312. /** @hidden */
  136313. export var _forceSceneHelpersToBundle: boolean;
  136314. interface Scene {
  136315. /**
  136316. * Creates a default light for the scene.
  136317. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  136318. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  136319. */
  136320. createDefaultLight(replace?: boolean): void;
  136321. /**
  136322. * Creates a default camera for the scene.
  136323. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  136324. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136325. * @param replace has default false, when true replaces the active camera in the scene
  136326. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  136327. */
  136328. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136329. /**
  136330. * Creates a default camera and a default light.
  136331. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  136332. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  136333. * @param replace has the default false, when true replaces the active camera/light in the scene
  136334. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  136335. */
  136336. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  136337. /**
  136338. * Creates a new sky box
  136339. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  136340. * @param environmentTexture defines the texture to use as environment texture
  136341. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  136342. * @param scale defines the overall scale of the skybox
  136343. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  136344. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  136345. * @returns a new mesh holding the sky box
  136346. */
  136347. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  136348. /**
  136349. * Creates a new environment
  136350. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  136351. * @param options defines the options you can use to configure the environment
  136352. * @returns the new EnvironmentHelper
  136353. */
  136354. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  136355. /**
  136356. * Creates a new VREXperienceHelper
  136357. * @see https://doc.babylonjs.com/how_to/webvr_helper
  136358. * @param webVROptions defines the options used to create the new VREXperienceHelper
  136359. * @returns a new VREXperienceHelper
  136360. */
  136361. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  136362. /**
  136363. * Creates a new WebXRDefaultExperience
  136364. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  136365. * @param options experience options
  136366. * @returns a promise for a new WebXRDefaultExperience
  136367. */
  136368. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  136369. }
  136370. }
  136371. declare module BABYLON {
  136372. /**
  136373. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  136374. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  136375. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  136376. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  136377. */
  136378. export class VideoDome extends TransformNode {
  136379. /**
  136380. * Define the video source as a Monoscopic panoramic 360 video.
  136381. */
  136382. static readonly MODE_MONOSCOPIC: number;
  136383. /**
  136384. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136385. */
  136386. static readonly MODE_TOPBOTTOM: number;
  136387. /**
  136388. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136389. */
  136390. static readonly MODE_SIDEBYSIDE: number;
  136391. private _halfDome;
  136392. private _useDirectMapping;
  136393. /**
  136394. * The video texture being displayed on the sphere
  136395. */
  136396. protected _videoTexture: VideoTexture;
  136397. /**
  136398. * Gets the video texture being displayed on the sphere
  136399. */
  136400. get videoTexture(): VideoTexture;
  136401. /**
  136402. * The skybox material
  136403. */
  136404. protected _material: BackgroundMaterial;
  136405. /**
  136406. * The surface used for the video dome
  136407. */
  136408. protected _mesh: Mesh;
  136409. /**
  136410. * Gets the mesh used for the video dome.
  136411. */
  136412. get mesh(): Mesh;
  136413. /**
  136414. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  136415. */
  136416. private _halfDomeMask;
  136417. /**
  136418. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  136419. * Also see the options.resolution property.
  136420. */
  136421. get fovMultiplier(): number;
  136422. set fovMultiplier(value: number);
  136423. private _videoMode;
  136424. /**
  136425. * Gets or set the current video mode for the video. It can be:
  136426. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  136427. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  136428. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  136429. */
  136430. get videoMode(): number;
  136431. set videoMode(value: number);
  136432. /**
  136433. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  136434. *
  136435. */
  136436. get halfDome(): boolean;
  136437. /**
  136438. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  136439. */
  136440. set halfDome(enabled: boolean);
  136441. /**
  136442. * Oberserver used in Stereoscopic VR Mode.
  136443. */
  136444. private _onBeforeCameraRenderObserver;
  136445. /**
  136446. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  136447. * @param name Element's name, child elements will append suffixes for their own names.
  136448. * @param urlsOrVideo defines the url(s) or the video element to use
  136449. * @param options An object containing optional or exposed sub element properties
  136450. */
  136451. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  136452. resolution?: number;
  136453. clickToPlay?: boolean;
  136454. autoPlay?: boolean;
  136455. loop?: boolean;
  136456. size?: number;
  136457. poster?: string;
  136458. faceForward?: boolean;
  136459. useDirectMapping?: boolean;
  136460. halfDomeMode?: boolean;
  136461. }, scene: Scene);
  136462. private _changeVideoMode;
  136463. /**
  136464. * Releases resources associated with this node.
  136465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  136466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  136467. */
  136468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  136469. }
  136470. }
  136471. declare module BABYLON {
  136472. /**
  136473. * This class can be used to get instrumentation data from a Babylon engine
  136474. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136475. */
  136476. export class EngineInstrumentation implements IDisposable {
  136477. /**
  136478. * Define the instrumented engine.
  136479. */
  136480. engine: Engine;
  136481. private _captureGPUFrameTime;
  136482. private _gpuFrameTimeToken;
  136483. private _gpuFrameTime;
  136484. private _captureShaderCompilationTime;
  136485. private _shaderCompilationTime;
  136486. private _onBeginFrameObserver;
  136487. private _onEndFrameObserver;
  136488. private _onBeforeShaderCompilationObserver;
  136489. private _onAfterShaderCompilationObserver;
  136490. /**
  136491. * Gets the perf counter used for GPU frame time
  136492. */
  136493. get gpuFrameTimeCounter(): PerfCounter;
  136494. /**
  136495. * Gets the GPU frame time capture status
  136496. */
  136497. get captureGPUFrameTime(): boolean;
  136498. /**
  136499. * Enable or disable the GPU frame time capture
  136500. */
  136501. set captureGPUFrameTime(value: boolean);
  136502. /**
  136503. * Gets the perf counter used for shader compilation time
  136504. */
  136505. get shaderCompilationTimeCounter(): PerfCounter;
  136506. /**
  136507. * Gets the shader compilation time capture status
  136508. */
  136509. get captureShaderCompilationTime(): boolean;
  136510. /**
  136511. * Enable or disable the shader compilation time capture
  136512. */
  136513. set captureShaderCompilationTime(value: boolean);
  136514. /**
  136515. * Instantiates a new engine instrumentation.
  136516. * This class can be used to get instrumentation data from a Babylon engine
  136517. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  136518. * @param engine Defines the engine to instrument
  136519. */
  136520. constructor(
  136521. /**
  136522. * Define the instrumented engine.
  136523. */
  136524. engine: Engine);
  136525. /**
  136526. * Dispose and release associated resources.
  136527. */
  136528. dispose(): void;
  136529. }
  136530. }
  136531. declare module BABYLON {
  136532. /**
  136533. * This class can be used to get instrumentation data from a Babylon engine
  136534. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136535. */
  136536. export class SceneInstrumentation implements IDisposable {
  136537. /**
  136538. * Defines the scene to instrument
  136539. */
  136540. scene: Scene;
  136541. private _captureActiveMeshesEvaluationTime;
  136542. private _activeMeshesEvaluationTime;
  136543. private _captureRenderTargetsRenderTime;
  136544. private _renderTargetsRenderTime;
  136545. private _captureFrameTime;
  136546. private _frameTime;
  136547. private _captureRenderTime;
  136548. private _renderTime;
  136549. private _captureInterFrameTime;
  136550. private _interFrameTime;
  136551. private _captureParticlesRenderTime;
  136552. private _particlesRenderTime;
  136553. private _captureSpritesRenderTime;
  136554. private _spritesRenderTime;
  136555. private _capturePhysicsTime;
  136556. private _physicsTime;
  136557. private _captureAnimationsTime;
  136558. private _animationsTime;
  136559. private _captureCameraRenderTime;
  136560. private _cameraRenderTime;
  136561. private _onBeforeActiveMeshesEvaluationObserver;
  136562. private _onAfterActiveMeshesEvaluationObserver;
  136563. private _onBeforeRenderTargetsRenderObserver;
  136564. private _onAfterRenderTargetsRenderObserver;
  136565. private _onAfterRenderObserver;
  136566. private _onBeforeDrawPhaseObserver;
  136567. private _onAfterDrawPhaseObserver;
  136568. private _onBeforeAnimationsObserver;
  136569. private _onBeforeParticlesRenderingObserver;
  136570. private _onAfterParticlesRenderingObserver;
  136571. private _onBeforeSpritesRenderingObserver;
  136572. private _onAfterSpritesRenderingObserver;
  136573. private _onBeforePhysicsObserver;
  136574. private _onAfterPhysicsObserver;
  136575. private _onAfterAnimationsObserver;
  136576. private _onBeforeCameraRenderObserver;
  136577. private _onAfterCameraRenderObserver;
  136578. /**
  136579. * Gets the perf counter used for active meshes evaluation time
  136580. */
  136581. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  136582. /**
  136583. * Gets the active meshes evaluation time capture status
  136584. */
  136585. get captureActiveMeshesEvaluationTime(): boolean;
  136586. /**
  136587. * Enable or disable the active meshes evaluation time capture
  136588. */
  136589. set captureActiveMeshesEvaluationTime(value: boolean);
  136590. /**
  136591. * Gets the perf counter used for render targets render time
  136592. */
  136593. get renderTargetsRenderTimeCounter(): PerfCounter;
  136594. /**
  136595. * Gets the render targets render time capture status
  136596. */
  136597. get captureRenderTargetsRenderTime(): boolean;
  136598. /**
  136599. * Enable or disable the render targets render time capture
  136600. */
  136601. set captureRenderTargetsRenderTime(value: boolean);
  136602. /**
  136603. * Gets the perf counter used for particles render time
  136604. */
  136605. get particlesRenderTimeCounter(): PerfCounter;
  136606. /**
  136607. * Gets the particles render time capture status
  136608. */
  136609. get captureParticlesRenderTime(): boolean;
  136610. /**
  136611. * Enable or disable the particles render time capture
  136612. */
  136613. set captureParticlesRenderTime(value: boolean);
  136614. /**
  136615. * Gets the perf counter used for sprites render time
  136616. */
  136617. get spritesRenderTimeCounter(): PerfCounter;
  136618. /**
  136619. * Gets the sprites render time capture status
  136620. */
  136621. get captureSpritesRenderTime(): boolean;
  136622. /**
  136623. * Enable or disable the sprites render time capture
  136624. */
  136625. set captureSpritesRenderTime(value: boolean);
  136626. /**
  136627. * Gets the perf counter used for physics time
  136628. */
  136629. get physicsTimeCounter(): PerfCounter;
  136630. /**
  136631. * Gets the physics time capture status
  136632. */
  136633. get capturePhysicsTime(): boolean;
  136634. /**
  136635. * Enable or disable the physics time capture
  136636. */
  136637. set capturePhysicsTime(value: boolean);
  136638. /**
  136639. * Gets the perf counter used for animations time
  136640. */
  136641. get animationsTimeCounter(): PerfCounter;
  136642. /**
  136643. * Gets the animations time capture status
  136644. */
  136645. get captureAnimationsTime(): boolean;
  136646. /**
  136647. * Enable or disable the animations time capture
  136648. */
  136649. set captureAnimationsTime(value: boolean);
  136650. /**
  136651. * Gets the perf counter used for frame time capture
  136652. */
  136653. get frameTimeCounter(): PerfCounter;
  136654. /**
  136655. * Gets the frame time capture status
  136656. */
  136657. get captureFrameTime(): boolean;
  136658. /**
  136659. * Enable or disable the frame time capture
  136660. */
  136661. set captureFrameTime(value: boolean);
  136662. /**
  136663. * Gets the perf counter used for inter-frames time capture
  136664. */
  136665. get interFrameTimeCounter(): PerfCounter;
  136666. /**
  136667. * Gets the inter-frames time capture status
  136668. */
  136669. get captureInterFrameTime(): boolean;
  136670. /**
  136671. * Enable or disable the inter-frames time capture
  136672. */
  136673. set captureInterFrameTime(value: boolean);
  136674. /**
  136675. * Gets the perf counter used for render time capture
  136676. */
  136677. get renderTimeCounter(): PerfCounter;
  136678. /**
  136679. * Gets the render time capture status
  136680. */
  136681. get captureRenderTime(): boolean;
  136682. /**
  136683. * Enable or disable the render time capture
  136684. */
  136685. set captureRenderTime(value: boolean);
  136686. /**
  136687. * Gets the perf counter used for camera render time capture
  136688. */
  136689. get cameraRenderTimeCounter(): PerfCounter;
  136690. /**
  136691. * Gets the camera render time capture status
  136692. */
  136693. get captureCameraRenderTime(): boolean;
  136694. /**
  136695. * Enable or disable the camera render time capture
  136696. */
  136697. set captureCameraRenderTime(value: boolean);
  136698. /**
  136699. * Gets the perf counter used for draw calls
  136700. */
  136701. get drawCallsCounter(): PerfCounter;
  136702. /**
  136703. * Instantiates a new scene instrumentation.
  136704. * This class can be used to get instrumentation data from a Babylon engine
  136705. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  136706. * @param scene Defines the scene to instrument
  136707. */
  136708. constructor(
  136709. /**
  136710. * Defines the scene to instrument
  136711. */
  136712. scene: Scene);
  136713. /**
  136714. * Dispose and release associated resources.
  136715. */
  136716. dispose(): void;
  136717. }
  136718. }
  136719. declare module BABYLON {
  136720. /** @hidden */
  136721. export var glowMapGenerationPixelShader: {
  136722. name: string;
  136723. shader: string;
  136724. };
  136725. }
  136726. declare module BABYLON {
  136727. /** @hidden */
  136728. export var glowMapGenerationVertexShader: {
  136729. name: string;
  136730. shader: string;
  136731. };
  136732. }
  136733. declare module BABYLON {
  136734. /**
  136735. * Effect layer options. This helps customizing the behaviour
  136736. * of the effect layer.
  136737. */
  136738. export interface IEffectLayerOptions {
  136739. /**
  136740. * Multiplication factor apply to the canvas size to compute the render target size
  136741. * used to generated the objects (the smaller the faster).
  136742. */
  136743. mainTextureRatio: number;
  136744. /**
  136745. * Enforces a fixed size texture to ensure effect stability across devices.
  136746. */
  136747. mainTextureFixedSize?: number;
  136748. /**
  136749. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  136750. */
  136751. alphaBlendingMode: number;
  136752. /**
  136753. * The camera attached to the layer.
  136754. */
  136755. camera: Nullable<Camera>;
  136756. /**
  136757. * The rendering group to draw the layer in.
  136758. */
  136759. renderingGroupId: number;
  136760. }
  136761. /**
  136762. * The effect layer Helps adding post process effect blended with the main pass.
  136763. *
  136764. * This can be for instance use to generate glow or higlight effects on the scene.
  136765. *
  136766. * The effect layer class can not be used directly and is intented to inherited from to be
  136767. * customized per effects.
  136768. */
  136769. export abstract class EffectLayer {
  136770. private _vertexBuffers;
  136771. private _indexBuffer;
  136772. private _cachedDefines;
  136773. private _effectLayerMapGenerationEffect;
  136774. private _effectLayerOptions;
  136775. private _mergeEffect;
  136776. protected _scene: Scene;
  136777. protected _engine: Engine;
  136778. protected _maxSize: number;
  136779. protected _mainTextureDesiredSize: ISize;
  136780. protected _mainTexture: RenderTargetTexture;
  136781. protected _shouldRender: boolean;
  136782. protected _postProcesses: PostProcess[];
  136783. protected _textures: BaseTexture[];
  136784. protected _emissiveTextureAndColor: {
  136785. texture: Nullable<BaseTexture>;
  136786. color: Color4;
  136787. };
  136788. /**
  136789. * The name of the layer
  136790. */
  136791. name: string;
  136792. /**
  136793. * The clear color of the texture used to generate the glow map.
  136794. */
  136795. neutralColor: Color4;
  136796. /**
  136797. * Specifies whether the highlight layer is enabled or not.
  136798. */
  136799. isEnabled: boolean;
  136800. /**
  136801. * Gets the camera attached to the layer.
  136802. */
  136803. get camera(): Nullable<Camera>;
  136804. /**
  136805. * Gets the rendering group id the layer should render in.
  136806. */
  136807. get renderingGroupId(): number;
  136808. set renderingGroupId(renderingGroupId: number);
  136809. /**
  136810. * An event triggered when the effect layer has been disposed.
  136811. */
  136812. onDisposeObservable: Observable<EffectLayer>;
  136813. /**
  136814. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  136815. */
  136816. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  136817. /**
  136818. * An event triggered when the generated texture is being merged in the scene.
  136819. */
  136820. onBeforeComposeObservable: Observable<EffectLayer>;
  136821. /**
  136822. * An event triggered when the mesh is rendered into the effect render target.
  136823. */
  136824. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  136825. /**
  136826. * An event triggered after the mesh has been rendered into the effect render target.
  136827. */
  136828. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  136829. /**
  136830. * An event triggered when the generated texture has been merged in the scene.
  136831. */
  136832. onAfterComposeObservable: Observable<EffectLayer>;
  136833. /**
  136834. * An event triggered when the efffect layer changes its size.
  136835. */
  136836. onSizeChangedObservable: Observable<EffectLayer>;
  136837. /** @hidden */
  136838. static _SceneComponentInitialization: (scene: Scene) => void;
  136839. /**
  136840. * Instantiates a new effect Layer and references it in the scene.
  136841. * @param name The name of the layer
  136842. * @param scene The scene to use the layer in
  136843. */
  136844. constructor(
  136845. /** The Friendly of the effect in the scene */
  136846. name: string, scene: Scene);
  136847. /**
  136848. * Get the effect name of the layer.
  136849. * @return The effect name
  136850. */
  136851. abstract getEffectName(): string;
  136852. /**
  136853. * Checks for the readiness of the element composing the layer.
  136854. * @param subMesh the mesh to check for
  136855. * @param useInstances specify whether or not to use instances to render the mesh
  136856. * @return true if ready otherwise, false
  136857. */
  136858. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136859. /**
  136860. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  136861. * @returns true if the effect requires stencil during the main canvas render pass.
  136862. */
  136863. abstract needStencil(): boolean;
  136864. /**
  136865. * Create the merge effect. This is the shader use to blit the information back
  136866. * to the main canvas at the end of the scene rendering.
  136867. * @returns The effect containing the shader used to merge the effect on the main canvas
  136868. */
  136869. protected abstract _createMergeEffect(): Effect;
  136870. /**
  136871. * Creates the render target textures and post processes used in the effect layer.
  136872. */
  136873. protected abstract _createTextureAndPostProcesses(): void;
  136874. /**
  136875. * Implementation specific of rendering the generating effect on the main canvas.
  136876. * @param effect The effect used to render through
  136877. */
  136878. protected abstract _internalRender(effect: Effect): void;
  136879. /**
  136880. * Sets the required values for both the emissive texture and and the main color.
  136881. */
  136882. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136883. /**
  136884. * Free any resources and references associated to a mesh.
  136885. * Internal use
  136886. * @param mesh The mesh to free.
  136887. */
  136888. abstract _disposeMesh(mesh: Mesh): void;
  136889. /**
  136890. * Serializes this layer (Glow or Highlight for example)
  136891. * @returns a serialized layer object
  136892. */
  136893. abstract serialize?(): any;
  136894. /**
  136895. * Initializes the effect layer with the required options.
  136896. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  136897. */
  136898. protected _init(options: Partial<IEffectLayerOptions>): void;
  136899. /**
  136900. * Generates the index buffer of the full screen quad blending to the main canvas.
  136901. */
  136902. private _generateIndexBuffer;
  136903. /**
  136904. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  136905. */
  136906. private _generateVertexBuffer;
  136907. /**
  136908. * Sets the main texture desired size which is the closest power of two
  136909. * of the engine canvas size.
  136910. */
  136911. private _setMainTextureSize;
  136912. /**
  136913. * Creates the main texture for the effect layer.
  136914. */
  136915. protected _createMainTexture(): void;
  136916. /**
  136917. * Adds specific effects defines.
  136918. * @param defines The defines to add specifics to.
  136919. */
  136920. protected _addCustomEffectDefines(defines: string[]): void;
  136921. /**
  136922. * Checks for the readiness of the element composing the layer.
  136923. * @param subMesh the mesh to check for
  136924. * @param useInstances specify whether or not to use instances to render the mesh
  136925. * @param emissiveTexture the associated emissive texture used to generate the glow
  136926. * @return true if ready otherwise, false
  136927. */
  136928. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  136929. /**
  136930. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  136931. */
  136932. render(): void;
  136933. /**
  136934. * Determine if a given mesh will be used in the current effect.
  136935. * @param mesh mesh to test
  136936. * @returns true if the mesh will be used
  136937. */
  136938. hasMesh(mesh: AbstractMesh): boolean;
  136939. /**
  136940. * Returns true if the layer contains information to display, otherwise false.
  136941. * @returns true if the glow layer should be rendered
  136942. */
  136943. shouldRender(): boolean;
  136944. /**
  136945. * Returns true if the mesh should render, otherwise false.
  136946. * @param mesh The mesh to render
  136947. * @returns true if it should render otherwise false
  136948. */
  136949. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  136950. /**
  136951. * Returns true if the mesh can be rendered, otherwise false.
  136952. * @param mesh The mesh to render
  136953. * @param material The material used on the mesh
  136954. * @returns true if it can be rendered otherwise false
  136955. */
  136956. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136957. /**
  136958. * Returns true if the mesh should render, otherwise false.
  136959. * @param mesh The mesh to render
  136960. * @returns true if it should render otherwise false
  136961. */
  136962. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  136963. /**
  136964. * Renders the submesh passed in parameter to the generation map.
  136965. */
  136966. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  136967. /**
  136968. * Defines whether the current material of the mesh should be use to render the effect.
  136969. * @param mesh defines the current mesh to render
  136970. */
  136971. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136972. /**
  136973. * Rebuild the required buffers.
  136974. * @hidden Internal use only.
  136975. */
  136976. _rebuild(): void;
  136977. /**
  136978. * Dispose only the render target textures and post process.
  136979. */
  136980. private _disposeTextureAndPostProcesses;
  136981. /**
  136982. * Dispose the highlight layer and free resources.
  136983. */
  136984. dispose(): void;
  136985. /**
  136986. * Gets the class name of the effect layer
  136987. * @returns the string with the class name of the effect layer
  136988. */
  136989. getClassName(): string;
  136990. /**
  136991. * Creates an effect layer from parsed effect layer data
  136992. * @param parsedEffectLayer defines effect layer data
  136993. * @param scene defines the current scene
  136994. * @param rootUrl defines the root URL containing the effect layer information
  136995. * @returns a parsed effect Layer
  136996. */
  136997. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  136998. }
  136999. }
  137000. declare module BABYLON {
  137001. interface AbstractScene {
  137002. /**
  137003. * The list of effect layers (highlights/glow) added to the scene
  137004. * @see https://doc.babylonjs.com/how_to/highlight_layer
  137005. * @see https://doc.babylonjs.com/how_to/glow_layer
  137006. */
  137007. effectLayers: Array<EffectLayer>;
  137008. /**
  137009. * Removes the given effect layer from this scene.
  137010. * @param toRemove defines the effect layer to remove
  137011. * @returns the index of the removed effect layer
  137012. */
  137013. removeEffectLayer(toRemove: EffectLayer): number;
  137014. /**
  137015. * Adds the given effect layer to this scene
  137016. * @param newEffectLayer defines the effect layer to add
  137017. */
  137018. addEffectLayer(newEffectLayer: EffectLayer): void;
  137019. }
  137020. /**
  137021. * Defines the layer scene component responsible to manage any effect layers
  137022. * in a given scene.
  137023. */
  137024. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  137025. /**
  137026. * The component name helpfull to identify the component in the list of scene components.
  137027. */
  137028. readonly name: string;
  137029. /**
  137030. * The scene the component belongs to.
  137031. */
  137032. scene: Scene;
  137033. private _engine;
  137034. private _renderEffects;
  137035. private _needStencil;
  137036. private _previousStencilState;
  137037. /**
  137038. * Creates a new instance of the component for the given scene
  137039. * @param scene Defines the scene to register the component in
  137040. */
  137041. constructor(scene: Scene);
  137042. /**
  137043. * Registers the component in a given scene
  137044. */
  137045. register(): void;
  137046. /**
  137047. * Rebuilds the elements related to this component in case of
  137048. * context lost for instance.
  137049. */
  137050. rebuild(): void;
  137051. /**
  137052. * Serializes the component data to the specified json object
  137053. * @param serializationObject The object to serialize to
  137054. */
  137055. serialize(serializationObject: any): void;
  137056. /**
  137057. * Adds all the elements from the container to the scene
  137058. * @param container the container holding the elements
  137059. */
  137060. addFromContainer(container: AbstractScene): void;
  137061. /**
  137062. * Removes all the elements in the container from the scene
  137063. * @param container contains the elements to remove
  137064. * @param dispose if the removed element should be disposed (default: false)
  137065. */
  137066. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137067. /**
  137068. * Disposes the component and the associated ressources.
  137069. */
  137070. dispose(): void;
  137071. private _isReadyForMesh;
  137072. private _renderMainTexture;
  137073. private _setStencil;
  137074. private _setStencilBack;
  137075. private _draw;
  137076. private _drawCamera;
  137077. private _drawRenderingGroup;
  137078. }
  137079. }
  137080. declare module BABYLON {
  137081. /** @hidden */
  137082. export var glowMapMergePixelShader: {
  137083. name: string;
  137084. shader: string;
  137085. };
  137086. }
  137087. declare module BABYLON {
  137088. /** @hidden */
  137089. export var glowMapMergeVertexShader: {
  137090. name: string;
  137091. shader: string;
  137092. };
  137093. }
  137094. declare module BABYLON {
  137095. interface AbstractScene {
  137096. /**
  137097. * Return a the first highlight layer of the scene with a given name.
  137098. * @param name The name of the highlight layer to look for.
  137099. * @return The highlight layer if found otherwise null.
  137100. */
  137101. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  137102. }
  137103. /**
  137104. * Glow layer options. This helps customizing the behaviour
  137105. * of the glow layer.
  137106. */
  137107. export interface IGlowLayerOptions {
  137108. /**
  137109. * Multiplication factor apply to the canvas size to compute the render target size
  137110. * used to generated the glowing objects (the smaller the faster).
  137111. */
  137112. mainTextureRatio: number;
  137113. /**
  137114. * Enforces a fixed size texture to ensure resize independant blur.
  137115. */
  137116. mainTextureFixedSize?: number;
  137117. /**
  137118. * How big is the kernel of the blur texture.
  137119. */
  137120. blurKernelSize: number;
  137121. /**
  137122. * The camera attached to the layer.
  137123. */
  137124. camera: Nullable<Camera>;
  137125. /**
  137126. * Enable MSAA by chosing the number of samples.
  137127. */
  137128. mainTextureSamples?: number;
  137129. /**
  137130. * The rendering group to draw the layer in.
  137131. */
  137132. renderingGroupId: number;
  137133. }
  137134. /**
  137135. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  137136. *
  137137. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  137138. *
  137139. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  137140. */
  137141. export class GlowLayer extends EffectLayer {
  137142. /**
  137143. * Effect Name of the layer.
  137144. */
  137145. static readonly EffectName: string;
  137146. /**
  137147. * The default blur kernel size used for the glow.
  137148. */
  137149. static DefaultBlurKernelSize: number;
  137150. /**
  137151. * The default texture size ratio used for the glow.
  137152. */
  137153. static DefaultTextureRatio: number;
  137154. /**
  137155. * Sets the kernel size of the blur.
  137156. */
  137157. set blurKernelSize(value: number);
  137158. /**
  137159. * Gets the kernel size of the blur.
  137160. */
  137161. get blurKernelSize(): number;
  137162. /**
  137163. * Sets the glow intensity.
  137164. */
  137165. set intensity(value: number);
  137166. /**
  137167. * Gets the glow intensity.
  137168. */
  137169. get intensity(): number;
  137170. private _options;
  137171. private _intensity;
  137172. private _horizontalBlurPostprocess1;
  137173. private _verticalBlurPostprocess1;
  137174. private _horizontalBlurPostprocess2;
  137175. private _verticalBlurPostprocess2;
  137176. private _blurTexture1;
  137177. private _blurTexture2;
  137178. private _postProcesses1;
  137179. private _postProcesses2;
  137180. private _includedOnlyMeshes;
  137181. private _excludedMeshes;
  137182. private _meshesUsingTheirOwnMaterials;
  137183. /**
  137184. * Callback used to let the user override the color selection on a per mesh basis
  137185. */
  137186. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  137187. /**
  137188. * Callback used to let the user override the texture selection on a per mesh basis
  137189. */
  137190. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  137191. /**
  137192. * Instantiates a new glow Layer and references it to the scene.
  137193. * @param name The name of the layer
  137194. * @param scene The scene to use the layer in
  137195. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  137196. */
  137197. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  137198. /**
  137199. * Get the effect name of the layer.
  137200. * @return The effect name
  137201. */
  137202. getEffectName(): string;
  137203. /**
  137204. * Create the merge effect. This is the shader use to blit the information back
  137205. * to the main canvas at the end of the scene rendering.
  137206. */
  137207. protected _createMergeEffect(): Effect;
  137208. /**
  137209. * Creates the render target textures and post processes used in the glow layer.
  137210. */
  137211. protected _createTextureAndPostProcesses(): void;
  137212. /**
  137213. * Checks for the readiness of the element composing the layer.
  137214. * @param subMesh the mesh to check for
  137215. * @param useInstances specify wether or not to use instances to render the mesh
  137216. * @param emissiveTexture the associated emissive texture used to generate the glow
  137217. * @return true if ready otherwise, false
  137218. */
  137219. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137220. /**
  137221. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  137222. */
  137223. needStencil(): boolean;
  137224. /**
  137225. * Returns true if the mesh can be rendered, otherwise false.
  137226. * @param mesh The mesh to render
  137227. * @param material The material used on the mesh
  137228. * @returns true if it can be rendered otherwise false
  137229. */
  137230. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137231. /**
  137232. * Implementation specific of rendering the generating effect on the main canvas.
  137233. * @param effect The effect used to render through
  137234. */
  137235. protected _internalRender(effect: Effect): void;
  137236. /**
  137237. * Sets the required values for both the emissive texture and and the main color.
  137238. */
  137239. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137240. /**
  137241. * Returns true if the mesh should render, otherwise false.
  137242. * @param mesh The mesh to render
  137243. * @returns true if it should render otherwise false
  137244. */
  137245. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137246. /**
  137247. * Adds specific effects defines.
  137248. * @param defines The defines to add specifics to.
  137249. */
  137250. protected _addCustomEffectDefines(defines: string[]): void;
  137251. /**
  137252. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  137253. * @param mesh The mesh to exclude from the glow layer
  137254. */
  137255. addExcludedMesh(mesh: Mesh): void;
  137256. /**
  137257. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  137258. * @param mesh The mesh to remove
  137259. */
  137260. removeExcludedMesh(mesh: Mesh): void;
  137261. /**
  137262. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  137263. * @param mesh The mesh to include in the glow layer
  137264. */
  137265. addIncludedOnlyMesh(mesh: Mesh): void;
  137266. /**
  137267. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  137268. * @param mesh The mesh to remove
  137269. */
  137270. removeIncludedOnlyMesh(mesh: Mesh): void;
  137271. /**
  137272. * Determine if a given mesh will be used in the glow layer
  137273. * @param mesh The mesh to test
  137274. * @returns true if the mesh will be highlighted by the current glow layer
  137275. */
  137276. hasMesh(mesh: AbstractMesh): boolean;
  137277. /**
  137278. * Defines whether the current material of the mesh should be use to render the effect.
  137279. * @param mesh defines the current mesh to render
  137280. */
  137281. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  137282. /**
  137283. * Add a mesh to be rendered through its own material and not with emissive only.
  137284. * @param mesh The mesh for which we need to use its material
  137285. */
  137286. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  137287. /**
  137288. * Remove a mesh from being rendered through its own material and not with emissive only.
  137289. * @param mesh The mesh for which we need to not use its material
  137290. */
  137291. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  137292. /**
  137293. * Free any resources and references associated to a mesh.
  137294. * Internal use
  137295. * @param mesh The mesh to free.
  137296. * @hidden
  137297. */
  137298. _disposeMesh(mesh: Mesh): void;
  137299. /**
  137300. * Gets the class name of the effect layer
  137301. * @returns the string with the class name of the effect layer
  137302. */
  137303. getClassName(): string;
  137304. /**
  137305. * Serializes this glow layer
  137306. * @returns a serialized glow layer object
  137307. */
  137308. serialize(): any;
  137309. /**
  137310. * Creates a Glow Layer from parsed glow layer data
  137311. * @param parsedGlowLayer defines glow layer data
  137312. * @param scene defines the current scene
  137313. * @param rootUrl defines the root URL containing the glow layer information
  137314. * @returns a parsed Glow Layer
  137315. */
  137316. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  137317. }
  137318. }
  137319. declare module BABYLON {
  137320. /** @hidden */
  137321. export var glowBlurPostProcessPixelShader: {
  137322. name: string;
  137323. shader: string;
  137324. };
  137325. }
  137326. declare module BABYLON {
  137327. interface AbstractScene {
  137328. /**
  137329. * Return a the first highlight layer of the scene with a given name.
  137330. * @param name The name of the highlight layer to look for.
  137331. * @return The highlight layer if found otherwise null.
  137332. */
  137333. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  137334. }
  137335. /**
  137336. * Highlight layer options. This helps customizing the behaviour
  137337. * of the highlight layer.
  137338. */
  137339. export interface IHighlightLayerOptions {
  137340. /**
  137341. * Multiplication factor apply to the canvas size to compute the render target size
  137342. * used to generated the glowing objects (the smaller the faster).
  137343. */
  137344. mainTextureRatio: number;
  137345. /**
  137346. * Enforces a fixed size texture to ensure resize independant blur.
  137347. */
  137348. mainTextureFixedSize?: number;
  137349. /**
  137350. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  137351. * of the picture to blur (the smaller the faster).
  137352. */
  137353. blurTextureSizeRatio: number;
  137354. /**
  137355. * How big in texel of the blur texture is the vertical blur.
  137356. */
  137357. blurVerticalSize: number;
  137358. /**
  137359. * How big in texel of the blur texture is the horizontal blur.
  137360. */
  137361. blurHorizontalSize: number;
  137362. /**
  137363. * Alpha blending mode used to apply the blur. Default is combine.
  137364. */
  137365. alphaBlendingMode: number;
  137366. /**
  137367. * The camera attached to the layer.
  137368. */
  137369. camera: Nullable<Camera>;
  137370. /**
  137371. * Should we display highlight as a solid stroke?
  137372. */
  137373. isStroke?: boolean;
  137374. /**
  137375. * The rendering group to draw the layer in.
  137376. */
  137377. renderingGroupId: number;
  137378. }
  137379. /**
  137380. * The highlight layer Helps adding a glow effect around a mesh.
  137381. *
  137382. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  137383. * glowy meshes to your scene.
  137384. *
  137385. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  137386. */
  137387. export class HighlightLayer extends EffectLayer {
  137388. name: string;
  137389. /**
  137390. * Effect Name of the highlight layer.
  137391. */
  137392. static readonly EffectName: string;
  137393. /**
  137394. * The neutral color used during the preparation of the glow effect.
  137395. * This is black by default as the blend operation is a blend operation.
  137396. */
  137397. static NeutralColor: Color4;
  137398. /**
  137399. * Stencil value used for glowing meshes.
  137400. */
  137401. static GlowingMeshStencilReference: number;
  137402. /**
  137403. * Stencil value used for the other meshes in the scene.
  137404. */
  137405. static NormalMeshStencilReference: number;
  137406. /**
  137407. * Specifies whether or not the inner glow is ACTIVE in the layer.
  137408. */
  137409. innerGlow: boolean;
  137410. /**
  137411. * Specifies whether or not the outer glow is ACTIVE in the layer.
  137412. */
  137413. outerGlow: boolean;
  137414. /**
  137415. * Specifies the horizontal size of the blur.
  137416. */
  137417. set blurHorizontalSize(value: number);
  137418. /**
  137419. * Specifies the vertical size of the blur.
  137420. */
  137421. set blurVerticalSize(value: number);
  137422. /**
  137423. * Gets the horizontal size of the blur.
  137424. */
  137425. get blurHorizontalSize(): number;
  137426. /**
  137427. * Gets the vertical size of the blur.
  137428. */
  137429. get blurVerticalSize(): number;
  137430. /**
  137431. * An event triggered when the highlight layer is being blurred.
  137432. */
  137433. onBeforeBlurObservable: Observable<HighlightLayer>;
  137434. /**
  137435. * An event triggered when the highlight layer has been blurred.
  137436. */
  137437. onAfterBlurObservable: Observable<HighlightLayer>;
  137438. private _instanceGlowingMeshStencilReference;
  137439. private _options;
  137440. private _downSamplePostprocess;
  137441. private _horizontalBlurPostprocess;
  137442. private _verticalBlurPostprocess;
  137443. private _blurTexture;
  137444. private _meshes;
  137445. private _excludedMeshes;
  137446. /**
  137447. * Instantiates a new highlight Layer and references it to the scene..
  137448. * @param name The name of the layer
  137449. * @param scene The scene to use the layer in
  137450. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  137451. */
  137452. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  137453. /**
  137454. * Get the effect name of the layer.
  137455. * @return The effect name
  137456. */
  137457. getEffectName(): string;
  137458. /**
  137459. * Create the merge effect. This is the shader use to blit the information back
  137460. * to the main canvas at the end of the scene rendering.
  137461. */
  137462. protected _createMergeEffect(): Effect;
  137463. /**
  137464. * Creates the render target textures and post processes used in the highlight layer.
  137465. */
  137466. protected _createTextureAndPostProcesses(): void;
  137467. /**
  137468. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  137469. */
  137470. needStencil(): boolean;
  137471. /**
  137472. * Checks for the readiness of the element composing the layer.
  137473. * @param subMesh the mesh to check for
  137474. * @param useInstances specify wether or not to use instances to render the mesh
  137475. * @param emissiveTexture the associated emissive texture used to generate the glow
  137476. * @return true if ready otherwise, false
  137477. */
  137478. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137479. /**
  137480. * Implementation specific of rendering the generating effect on the main canvas.
  137481. * @param effect The effect used to render through
  137482. */
  137483. protected _internalRender(effect: Effect): void;
  137484. /**
  137485. * Returns true if the layer contains information to display, otherwise false.
  137486. */
  137487. shouldRender(): boolean;
  137488. /**
  137489. * Returns true if the mesh should render, otherwise false.
  137490. * @param mesh The mesh to render
  137491. * @returns true if it should render otherwise false
  137492. */
  137493. protected _shouldRenderMesh(mesh: Mesh): boolean;
  137494. /**
  137495. * Returns true if the mesh can be rendered, otherwise false.
  137496. * @param mesh The mesh to render
  137497. * @param material The material used on the mesh
  137498. * @returns true if it can be rendered otherwise false
  137499. */
  137500. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  137501. /**
  137502. * Adds specific effects defines.
  137503. * @param defines The defines to add specifics to.
  137504. */
  137505. protected _addCustomEffectDefines(defines: string[]): void;
  137506. /**
  137507. * Sets the required values for both the emissive texture and and the main color.
  137508. */
  137509. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  137510. /**
  137511. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  137512. * @param mesh The mesh to exclude from the highlight layer
  137513. */
  137514. addExcludedMesh(mesh: Mesh): void;
  137515. /**
  137516. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  137517. * @param mesh The mesh to highlight
  137518. */
  137519. removeExcludedMesh(mesh: Mesh): void;
  137520. /**
  137521. * Determine if a given mesh will be highlighted by the current HighlightLayer
  137522. * @param mesh mesh to test
  137523. * @returns true if the mesh will be highlighted by the current HighlightLayer
  137524. */
  137525. hasMesh(mesh: AbstractMesh): boolean;
  137526. /**
  137527. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  137528. * @param mesh The mesh to highlight
  137529. * @param color The color of the highlight
  137530. * @param glowEmissiveOnly Extract the glow from the emissive texture
  137531. */
  137532. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  137533. /**
  137534. * Remove a mesh from the highlight layer in order to make it stop glowing.
  137535. * @param mesh The mesh to highlight
  137536. */
  137537. removeMesh(mesh: Mesh): void;
  137538. /**
  137539. * Remove all the meshes currently referenced in the highlight layer
  137540. */
  137541. removeAllMeshes(): void;
  137542. /**
  137543. * Force the stencil to the normal expected value for none glowing parts
  137544. */
  137545. private _defaultStencilReference;
  137546. /**
  137547. * Free any resources and references associated to a mesh.
  137548. * Internal use
  137549. * @param mesh The mesh to free.
  137550. * @hidden
  137551. */
  137552. _disposeMesh(mesh: Mesh): void;
  137553. /**
  137554. * Dispose the highlight layer and free resources.
  137555. */
  137556. dispose(): void;
  137557. /**
  137558. * Gets the class name of the effect layer
  137559. * @returns the string with the class name of the effect layer
  137560. */
  137561. getClassName(): string;
  137562. /**
  137563. * Serializes this Highlight layer
  137564. * @returns a serialized Highlight layer object
  137565. */
  137566. serialize(): any;
  137567. /**
  137568. * Creates a Highlight layer from parsed Highlight layer data
  137569. * @param parsedHightlightLayer defines the Highlight layer data
  137570. * @param scene defines the current scene
  137571. * @param rootUrl defines the root URL containing the Highlight layer information
  137572. * @returns a parsed Highlight layer
  137573. */
  137574. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  137575. }
  137576. }
  137577. declare module BABYLON {
  137578. interface AbstractScene {
  137579. /**
  137580. * The list of layers (background and foreground) of the scene
  137581. */
  137582. layers: Array<Layer>;
  137583. }
  137584. /**
  137585. * Defines the layer scene component responsible to manage any layers
  137586. * in a given scene.
  137587. */
  137588. export class LayerSceneComponent implements ISceneComponent {
  137589. /**
  137590. * The component name helpfull to identify the component in the list of scene components.
  137591. */
  137592. readonly name: string;
  137593. /**
  137594. * The scene the component belongs to.
  137595. */
  137596. scene: Scene;
  137597. private _engine;
  137598. /**
  137599. * Creates a new instance of the component for the given scene
  137600. * @param scene Defines the scene to register the component in
  137601. */
  137602. constructor(scene: Scene);
  137603. /**
  137604. * Registers the component in a given scene
  137605. */
  137606. register(): void;
  137607. /**
  137608. * Rebuilds the elements related to this component in case of
  137609. * context lost for instance.
  137610. */
  137611. rebuild(): void;
  137612. /**
  137613. * Disposes the component and the associated ressources.
  137614. */
  137615. dispose(): void;
  137616. private _draw;
  137617. private _drawCameraPredicate;
  137618. private _drawCameraBackground;
  137619. private _drawCameraForeground;
  137620. private _drawRenderTargetPredicate;
  137621. private _drawRenderTargetBackground;
  137622. private _drawRenderTargetForeground;
  137623. /**
  137624. * Adds all the elements from the container to the scene
  137625. * @param container the container holding the elements
  137626. */
  137627. addFromContainer(container: AbstractScene): void;
  137628. /**
  137629. * Removes all the elements in the container from the scene
  137630. * @param container contains the elements to remove
  137631. * @param dispose if the removed element should be disposed (default: false)
  137632. */
  137633. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137634. }
  137635. }
  137636. declare module BABYLON {
  137637. /** @hidden */
  137638. export var layerPixelShader: {
  137639. name: string;
  137640. shader: string;
  137641. };
  137642. }
  137643. declare module BABYLON {
  137644. /** @hidden */
  137645. export var layerVertexShader: {
  137646. name: string;
  137647. shader: string;
  137648. };
  137649. }
  137650. declare module BABYLON {
  137651. /**
  137652. * This represents a full screen 2d layer.
  137653. * This can be useful to display a picture in the background of your scene for instance.
  137654. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137655. */
  137656. export class Layer {
  137657. /**
  137658. * Define the name of the layer.
  137659. */
  137660. name: string;
  137661. /**
  137662. * Define the texture the layer should display.
  137663. */
  137664. texture: Nullable<Texture>;
  137665. /**
  137666. * Is the layer in background or foreground.
  137667. */
  137668. isBackground: boolean;
  137669. /**
  137670. * Define the color of the layer (instead of texture).
  137671. */
  137672. color: Color4;
  137673. /**
  137674. * Define the scale of the layer in order to zoom in out of the texture.
  137675. */
  137676. scale: Vector2;
  137677. /**
  137678. * Define an offset for the layer in order to shift the texture.
  137679. */
  137680. offset: Vector2;
  137681. /**
  137682. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  137683. */
  137684. alphaBlendingMode: number;
  137685. /**
  137686. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  137687. * Alpha test will not mix with the background color in case of transparency.
  137688. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  137689. */
  137690. alphaTest: boolean;
  137691. /**
  137692. * Define a mask to restrict the layer to only some of the scene cameras.
  137693. */
  137694. layerMask: number;
  137695. /**
  137696. * Define the list of render target the layer is visible into.
  137697. */
  137698. renderTargetTextures: RenderTargetTexture[];
  137699. /**
  137700. * Define if the layer is only used in renderTarget or if it also
  137701. * renders in the main frame buffer of the canvas.
  137702. */
  137703. renderOnlyInRenderTargetTextures: boolean;
  137704. private _scene;
  137705. private _vertexBuffers;
  137706. private _indexBuffer;
  137707. private _effect;
  137708. private _previousDefines;
  137709. /**
  137710. * An event triggered when the layer is disposed.
  137711. */
  137712. onDisposeObservable: Observable<Layer>;
  137713. private _onDisposeObserver;
  137714. /**
  137715. * Back compatibility with callback before the onDisposeObservable existed.
  137716. * The set callback will be triggered when the layer has been disposed.
  137717. */
  137718. set onDispose(callback: () => void);
  137719. /**
  137720. * An event triggered before rendering the scene
  137721. */
  137722. onBeforeRenderObservable: Observable<Layer>;
  137723. private _onBeforeRenderObserver;
  137724. /**
  137725. * Back compatibility with callback before the onBeforeRenderObservable existed.
  137726. * The set callback will be triggered just before rendering the layer.
  137727. */
  137728. set onBeforeRender(callback: () => void);
  137729. /**
  137730. * An event triggered after rendering the scene
  137731. */
  137732. onAfterRenderObservable: Observable<Layer>;
  137733. private _onAfterRenderObserver;
  137734. /**
  137735. * Back compatibility with callback before the onAfterRenderObservable existed.
  137736. * The set callback will be triggered just after rendering the layer.
  137737. */
  137738. set onAfterRender(callback: () => void);
  137739. /**
  137740. * Instantiates a new layer.
  137741. * This represents a full screen 2d layer.
  137742. * This can be useful to display a picture in the background of your scene for instance.
  137743. * @see https://www.babylonjs-playground.com/#08A2BS#1
  137744. * @param name Define the name of the layer in the scene
  137745. * @param imgUrl Define the url of the texture to display in the layer
  137746. * @param scene Define the scene the layer belongs to
  137747. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  137748. * @param color Defines a color for the layer
  137749. */
  137750. constructor(
  137751. /**
  137752. * Define the name of the layer.
  137753. */
  137754. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  137755. private _createIndexBuffer;
  137756. /** @hidden */
  137757. _rebuild(): void;
  137758. /**
  137759. * Renders the layer in the scene.
  137760. */
  137761. render(): void;
  137762. /**
  137763. * Disposes and releases the associated ressources.
  137764. */
  137765. dispose(): void;
  137766. }
  137767. }
  137768. declare module BABYLON {
  137769. /** @hidden */
  137770. export var lensFlarePixelShader: {
  137771. name: string;
  137772. shader: string;
  137773. };
  137774. }
  137775. declare module BABYLON {
  137776. /** @hidden */
  137777. export var lensFlareVertexShader: {
  137778. name: string;
  137779. shader: string;
  137780. };
  137781. }
  137782. declare module BABYLON {
  137783. /**
  137784. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137785. * It is usually composed of several `lensFlare`.
  137786. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137787. */
  137788. export class LensFlareSystem {
  137789. /**
  137790. * Define the name of the lens flare system
  137791. */
  137792. name: string;
  137793. /**
  137794. * List of lens flares used in this system.
  137795. */
  137796. lensFlares: LensFlare[];
  137797. /**
  137798. * Define a limit from the border the lens flare can be visible.
  137799. */
  137800. borderLimit: number;
  137801. /**
  137802. * Define a viewport border we do not want to see the lens flare in.
  137803. */
  137804. viewportBorder: number;
  137805. /**
  137806. * Define a predicate which could limit the list of meshes able to occlude the effect.
  137807. */
  137808. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  137809. /**
  137810. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  137811. */
  137812. layerMask: number;
  137813. /**
  137814. * Define the id of the lens flare system in the scene.
  137815. * (equal to name by default)
  137816. */
  137817. id: string;
  137818. private _scene;
  137819. private _emitter;
  137820. private _vertexBuffers;
  137821. private _indexBuffer;
  137822. private _effect;
  137823. private _positionX;
  137824. private _positionY;
  137825. private _isEnabled;
  137826. /** @hidden */
  137827. static _SceneComponentInitialization: (scene: Scene) => void;
  137828. /**
  137829. * Instantiates a lens flare system.
  137830. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  137831. * It is usually composed of several `lensFlare`.
  137832. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137833. * @param name Define the name of the lens flare system in the scene
  137834. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  137835. * @param scene Define the scene the lens flare system belongs to
  137836. */
  137837. constructor(
  137838. /**
  137839. * Define the name of the lens flare system
  137840. */
  137841. name: string, emitter: any, scene: Scene);
  137842. /**
  137843. * Define if the lens flare system is enabled.
  137844. */
  137845. get isEnabled(): boolean;
  137846. set isEnabled(value: boolean);
  137847. /**
  137848. * Get the scene the effects belongs to.
  137849. * @returns the scene holding the lens flare system
  137850. */
  137851. getScene(): Scene;
  137852. /**
  137853. * Get the emitter of the lens flare system.
  137854. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137855. * @returns the emitter of the lens flare system
  137856. */
  137857. getEmitter(): any;
  137858. /**
  137859. * Set the emitter of the lens flare system.
  137860. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  137861. * @param newEmitter Define the new emitter of the system
  137862. */
  137863. setEmitter(newEmitter: any): void;
  137864. /**
  137865. * Get the lens flare system emitter position.
  137866. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  137867. * @returns the position
  137868. */
  137869. getEmitterPosition(): Vector3;
  137870. /**
  137871. * @hidden
  137872. */
  137873. computeEffectivePosition(globalViewport: Viewport): boolean;
  137874. /** @hidden */
  137875. _isVisible(): boolean;
  137876. /**
  137877. * @hidden
  137878. */
  137879. render(): boolean;
  137880. /**
  137881. * Dispose and release the lens flare with its associated resources.
  137882. */
  137883. dispose(): void;
  137884. /**
  137885. * Parse a lens flare system from a JSON repressentation
  137886. * @param parsedLensFlareSystem Define the JSON to parse
  137887. * @param scene Define the scene the parsed system should be instantiated in
  137888. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  137889. * @returns the parsed system
  137890. */
  137891. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  137892. /**
  137893. * Serialize the current Lens Flare System into a JSON representation.
  137894. * @returns the serialized JSON
  137895. */
  137896. serialize(): any;
  137897. }
  137898. }
  137899. declare module BABYLON {
  137900. /**
  137901. * This represents one of the lens effect in a `lensFlareSystem`.
  137902. * It controls one of the indiviual texture used in the effect.
  137903. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137904. */
  137905. export class LensFlare {
  137906. /**
  137907. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137908. */
  137909. size: number;
  137910. /**
  137911. * 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.
  137912. */
  137913. position: number;
  137914. /**
  137915. * Define the lens color.
  137916. */
  137917. color: Color3;
  137918. /**
  137919. * Define the lens texture.
  137920. */
  137921. texture: Nullable<Texture>;
  137922. /**
  137923. * Define the alpha mode to render this particular lens.
  137924. */
  137925. alphaMode: number;
  137926. private _system;
  137927. /**
  137928. * Creates a new Lens Flare.
  137929. * This represents one of the lens effect in a `lensFlareSystem`.
  137930. * It controls one of the indiviual texture used in the effect.
  137931. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137932. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  137933. * @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.
  137934. * @param color Define the lens color
  137935. * @param imgUrl Define the lens texture url
  137936. * @param system Define the `lensFlareSystem` this flare is part of
  137937. * @returns The newly created Lens Flare
  137938. */
  137939. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  137940. /**
  137941. * Instantiates a new Lens Flare.
  137942. * This represents one of the lens effect in a `lensFlareSystem`.
  137943. * It controls one of the indiviual texture used in the effect.
  137944. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137945. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  137946. * @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.
  137947. * @param color Define the lens color
  137948. * @param imgUrl Define the lens texture url
  137949. * @param system Define the `lensFlareSystem` this flare is part of
  137950. */
  137951. constructor(
  137952. /**
  137953. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  137954. */
  137955. size: number,
  137956. /**
  137957. * 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.
  137958. */
  137959. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  137960. /**
  137961. * Dispose and release the lens flare with its associated resources.
  137962. */
  137963. dispose(): void;
  137964. }
  137965. }
  137966. declare module BABYLON {
  137967. interface AbstractScene {
  137968. /**
  137969. * The list of lens flare system added to the scene
  137970. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  137971. */
  137972. lensFlareSystems: Array<LensFlareSystem>;
  137973. /**
  137974. * Removes the given lens flare system from this scene.
  137975. * @param toRemove The lens flare system to remove
  137976. * @returns The index of the removed lens flare system
  137977. */
  137978. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  137979. /**
  137980. * Adds the given lens flare system to this scene
  137981. * @param newLensFlareSystem The lens flare system to add
  137982. */
  137983. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  137984. /**
  137985. * Gets a lens flare system using its name
  137986. * @param name defines the name to look for
  137987. * @returns the lens flare system or null if not found
  137988. */
  137989. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  137990. /**
  137991. * Gets a lens flare system using its id
  137992. * @param id defines the id to look for
  137993. * @returns the lens flare system or null if not found
  137994. */
  137995. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  137996. }
  137997. /**
  137998. * Defines the lens flare scene component responsible to manage any lens flares
  137999. * in a given scene.
  138000. */
  138001. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  138002. /**
  138003. * The component name helpfull to identify the component in the list of scene components.
  138004. */
  138005. readonly name: string;
  138006. /**
  138007. * The scene the component belongs to.
  138008. */
  138009. scene: Scene;
  138010. /**
  138011. * Creates a new instance of the component for the given scene
  138012. * @param scene Defines the scene to register the component in
  138013. */
  138014. constructor(scene: Scene);
  138015. /**
  138016. * Registers the component in a given scene
  138017. */
  138018. register(): void;
  138019. /**
  138020. * Rebuilds the elements related to this component in case of
  138021. * context lost for instance.
  138022. */
  138023. rebuild(): void;
  138024. /**
  138025. * Adds all the elements from the container to the scene
  138026. * @param container the container holding the elements
  138027. */
  138028. addFromContainer(container: AbstractScene): void;
  138029. /**
  138030. * Removes all the elements in the container from the scene
  138031. * @param container contains the elements to remove
  138032. * @param dispose if the removed element should be disposed (default: false)
  138033. */
  138034. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138035. /**
  138036. * Serializes the component data to the specified json object
  138037. * @param serializationObject The object to serialize to
  138038. */
  138039. serialize(serializationObject: any): void;
  138040. /**
  138041. * Disposes the component and the associated ressources.
  138042. */
  138043. dispose(): void;
  138044. private _draw;
  138045. }
  138046. }
  138047. declare module BABYLON {
  138048. /** @hidden */
  138049. export var depthPixelShader: {
  138050. name: string;
  138051. shader: string;
  138052. };
  138053. }
  138054. declare module BABYLON {
  138055. /** @hidden */
  138056. export var depthVertexShader: {
  138057. name: string;
  138058. shader: string;
  138059. };
  138060. }
  138061. declare module BABYLON {
  138062. /**
  138063. * This represents a depth renderer in Babylon.
  138064. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  138065. */
  138066. export class DepthRenderer {
  138067. private _scene;
  138068. private _depthMap;
  138069. private _effect;
  138070. private readonly _storeNonLinearDepth;
  138071. private readonly _clearColor;
  138072. /** Get if the depth renderer is using packed depth or not */
  138073. readonly isPacked: boolean;
  138074. private _cachedDefines;
  138075. private _camera;
  138076. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  138077. enabled: boolean;
  138078. /**
  138079. * Specifiess that the depth renderer will only be used within
  138080. * the camera it is created for.
  138081. * This can help forcing its rendering during the camera processing.
  138082. */
  138083. useOnlyInActiveCamera: boolean;
  138084. /** @hidden */
  138085. static _SceneComponentInitialization: (scene: Scene) => void;
  138086. /**
  138087. * Instantiates a depth renderer
  138088. * @param scene The scene the renderer belongs to
  138089. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  138090. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  138091. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  138092. */
  138093. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  138094. /**
  138095. * Creates the depth rendering effect and checks if the effect is ready.
  138096. * @param subMesh The submesh to be used to render the depth map of
  138097. * @param useInstances If multiple world instances should be used
  138098. * @returns if the depth renderer is ready to render the depth map
  138099. */
  138100. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138101. /**
  138102. * Gets the texture which the depth map will be written to.
  138103. * @returns The depth map texture
  138104. */
  138105. getDepthMap(): RenderTargetTexture;
  138106. /**
  138107. * Disposes of the depth renderer.
  138108. */
  138109. dispose(): void;
  138110. }
  138111. }
  138112. declare module BABYLON {
  138113. /** @hidden */
  138114. export var minmaxReduxPixelShader: {
  138115. name: string;
  138116. shader: string;
  138117. };
  138118. }
  138119. declare module BABYLON {
  138120. /**
  138121. * This class computes a min/max reduction from a texture: it means it computes the minimum
  138122. * and maximum values from all values of the texture.
  138123. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  138124. * The source values are read from the red channel of the texture.
  138125. */
  138126. export class MinMaxReducer {
  138127. /**
  138128. * Observable triggered when the computation has been performed
  138129. */
  138130. onAfterReductionPerformed: Observable<{
  138131. min: number;
  138132. max: number;
  138133. }>;
  138134. protected _camera: Camera;
  138135. protected _sourceTexture: Nullable<RenderTargetTexture>;
  138136. protected _reductionSteps: Nullable<Array<PostProcess>>;
  138137. protected _postProcessManager: PostProcessManager;
  138138. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  138139. protected _forceFullscreenViewport: boolean;
  138140. /**
  138141. * Creates a min/max reducer
  138142. * @param camera The camera to use for the post processes
  138143. */
  138144. constructor(camera: Camera);
  138145. /**
  138146. * Gets the texture used to read the values from.
  138147. */
  138148. get sourceTexture(): Nullable<RenderTargetTexture>;
  138149. /**
  138150. * Sets the source texture to read the values from.
  138151. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  138152. * because in such textures '1' value must not be taken into account to compute the maximum
  138153. * as this value is used to clear the texture.
  138154. * Note that the computation is not activated by calling this function, you must call activate() for that!
  138155. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  138156. * @param depthRedux Indicates if the texture is a depth texture or not
  138157. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  138158. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138159. */
  138160. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138161. /**
  138162. * Defines the refresh rate of the computation.
  138163. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138164. */
  138165. get refreshRate(): number;
  138166. set refreshRate(value: number);
  138167. protected _activated: boolean;
  138168. /**
  138169. * Gets the activation status of the reducer
  138170. */
  138171. get activated(): boolean;
  138172. /**
  138173. * Activates the reduction computation.
  138174. * When activated, the observers registered in onAfterReductionPerformed are
  138175. * called after the compuation is performed
  138176. */
  138177. activate(): void;
  138178. /**
  138179. * Deactivates the reduction computation.
  138180. */
  138181. deactivate(): void;
  138182. /**
  138183. * Disposes the min/max reducer
  138184. * @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.
  138185. */
  138186. dispose(disposeAll?: boolean): void;
  138187. }
  138188. }
  138189. declare module BABYLON {
  138190. /**
  138191. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  138192. */
  138193. export class DepthReducer extends MinMaxReducer {
  138194. private _depthRenderer;
  138195. private _depthRendererId;
  138196. /**
  138197. * Gets the depth renderer used for the computation.
  138198. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  138199. */
  138200. get depthRenderer(): Nullable<DepthRenderer>;
  138201. /**
  138202. * Creates a depth reducer
  138203. * @param camera The camera used to render the depth texture
  138204. */
  138205. constructor(camera: Camera);
  138206. /**
  138207. * Sets the depth renderer to use to generate the depth map
  138208. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  138209. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  138210. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  138211. */
  138212. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  138213. /** @hidden */
  138214. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  138215. /**
  138216. * Activates the reduction computation.
  138217. * When activated, the observers registered in onAfterReductionPerformed are
  138218. * called after the compuation is performed
  138219. */
  138220. activate(): void;
  138221. /**
  138222. * Deactivates the reduction computation.
  138223. */
  138224. deactivate(): void;
  138225. /**
  138226. * Disposes the depth reducer
  138227. * @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.
  138228. */
  138229. dispose(disposeAll?: boolean): void;
  138230. }
  138231. }
  138232. declare module BABYLON {
  138233. /**
  138234. * A CSM implementation allowing casting shadows on large scenes.
  138235. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138236. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  138237. */
  138238. export class CascadedShadowGenerator extends ShadowGenerator {
  138239. private static readonly frustumCornersNDCSpace;
  138240. /**
  138241. * Name of the CSM class
  138242. */
  138243. static CLASSNAME: string;
  138244. /**
  138245. * Defines the default number of cascades used by the CSM.
  138246. */
  138247. static readonly DEFAULT_CASCADES_COUNT: number;
  138248. /**
  138249. * Defines the minimum number of cascades used by the CSM.
  138250. */
  138251. static readonly MIN_CASCADES_COUNT: number;
  138252. /**
  138253. * Defines the maximum number of cascades used by the CSM.
  138254. */
  138255. static readonly MAX_CASCADES_COUNT: number;
  138256. protected _validateFilter(filter: number): number;
  138257. /**
  138258. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  138259. */
  138260. penumbraDarkness: number;
  138261. private _numCascades;
  138262. /**
  138263. * Gets or set the number of cascades used by the CSM.
  138264. */
  138265. get numCascades(): number;
  138266. set numCascades(value: number);
  138267. /**
  138268. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  138269. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  138270. */
  138271. stabilizeCascades: boolean;
  138272. private _freezeShadowCastersBoundingInfo;
  138273. private _freezeShadowCastersBoundingInfoObservable;
  138274. /**
  138275. * Enables or disables the shadow casters bounding info computation.
  138276. * If your shadow casters don't move, you can disable this feature.
  138277. * If it is enabled, the bounding box computation is done every frame.
  138278. */
  138279. get freezeShadowCastersBoundingInfo(): boolean;
  138280. set freezeShadowCastersBoundingInfo(freeze: boolean);
  138281. private _scbiMin;
  138282. private _scbiMax;
  138283. protected _computeShadowCastersBoundingInfo(): void;
  138284. protected _shadowCastersBoundingInfo: BoundingInfo;
  138285. /**
  138286. * Gets or sets the shadow casters bounding info.
  138287. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  138288. * so that the system won't overwrite the bounds you provide
  138289. */
  138290. get shadowCastersBoundingInfo(): BoundingInfo;
  138291. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  138292. protected _breaksAreDirty: boolean;
  138293. protected _minDistance: number;
  138294. protected _maxDistance: number;
  138295. /**
  138296. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  138297. *
  138298. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  138299. * If you don't know these values, simply leave them to their defaults and don't call this function.
  138300. * @param min minimal distance for the breaks (default to 0.)
  138301. * @param max maximal distance for the breaks (default to 1.)
  138302. */
  138303. setMinMaxDistance(min: number, max: number): void;
  138304. /** Gets the minimal distance used in the cascade break computation */
  138305. get minDistance(): number;
  138306. /** Gets the maximal distance used in the cascade break computation */
  138307. get maxDistance(): number;
  138308. /**
  138309. * Gets the class name of that object
  138310. * @returns "CascadedShadowGenerator"
  138311. */
  138312. getClassName(): string;
  138313. private _cascadeMinExtents;
  138314. private _cascadeMaxExtents;
  138315. /**
  138316. * Gets a cascade minimum extents
  138317. * @param cascadeIndex index of the cascade
  138318. * @returns the minimum cascade extents
  138319. */
  138320. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  138321. /**
  138322. * Gets a cascade maximum extents
  138323. * @param cascadeIndex index of the cascade
  138324. * @returns the maximum cascade extents
  138325. */
  138326. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  138327. private _cascades;
  138328. private _currentLayer;
  138329. private _viewSpaceFrustumsZ;
  138330. private _viewMatrices;
  138331. private _projectionMatrices;
  138332. private _transformMatrices;
  138333. private _transformMatricesAsArray;
  138334. private _frustumLengths;
  138335. private _lightSizeUVCorrection;
  138336. private _depthCorrection;
  138337. private _frustumCornersWorldSpace;
  138338. private _frustumCenter;
  138339. private _shadowCameraPos;
  138340. private _shadowMaxZ;
  138341. /**
  138342. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  138343. * It defaults to camera.maxZ
  138344. */
  138345. get shadowMaxZ(): number;
  138346. /**
  138347. * Sets the shadow max z distance.
  138348. */
  138349. set shadowMaxZ(value: number);
  138350. protected _debug: boolean;
  138351. /**
  138352. * Gets or sets the debug flag.
  138353. * When enabled, the cascades are materialized by different colors on the screen.
  138354. */
  138355. get debug(): boolean;
  138356. set debug(dbg: boolean);
  138357. private _depthClamp;
  138358. /**
  138359. * Gets or sets the depth clamping value.
  138360. *
  138361. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  138362. * to account for the shadow casters far away.
  138363. *
  138364. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  138365. */
  138366. get depthClamp(): boolean;
  138367. set depthClamp(value: boolean);
  138368. private _cascadeBlendPercentage;
  138369. /**
  138370. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  138371. * It defaults to 0.1 (10% blending).
  138372. */
  138373. get cascadeBlendPercentage(): number;
  138374. set cascadeBlendPercentage(value: number);
  138375. private _lambda;
  138376. /**
  138377. * Gets or set the lambda parameter.
  138378. * This parameter is used to split the camera frustum and create the cascades.
  138379. * 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.
  138380. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  138381. */
  138382. get lambda(): number;
  138383. set lambda(value: number);
  138384. /**
  138385. * Gets the view matrix corresponding to a given cascade
  138386. * @param cascadeNum cascade to retrieve the view matrix from
  138387. * @returns the cascade view matrix
  138388. */
  138389. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  138390. /**
  138391. * Gets the projection matrix corresponding to a given cascade
  138392. * @param cascadeNum cascade to retrieve the projection matrix from
  138393. * @returns the cascade projection matrix
  138394. */
  138395. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  138396. /**
  138397. * Gets the transformation matrix corresponding to a given cascade
  138398. * @param cascadeNum cascade to retrieve the transformation matrix from
  138399. * @returns the cascade transformation matrix
  138400. */
  138401. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  138402. private _depthRenderer;
  138403. /**
  138404. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  138405. *
  138406. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  138407. *
  138408. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  138409. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  138410. * @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
  138411. */
  138412. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  138413. private _depthReducer;
  138414. private _autoCalcDepthBounds;
  138415. /**
  138416. * Gets or sets the autoCalcDepthBounds property.
  138417. *
  138418. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  138419. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  138420. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  138421. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  138422. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  138423. */
  138424. get autoCalcDepthBounds(): boolean;
  138425. set autoCalcDepthBounds(value: boolean);
  138426. /**
  138427. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  138428. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  138429. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  138430. * for setting the refresh rate on the renderer yourself!
  138431. */
  138432. get autoCalcDepthBoundsRefreshRate(): number;
  138433. set autoCalcDepthBoundsRefreshRate(value: number);
  138434. /**
  138435. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  138436. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  138437. * you change the camera near/far planes!
  138438. */
  138439. splitFrustum(): void;
  138440. private _splitFrustum;
  138441. private _computeMatrices;
  138442. private _computeFrustumInWorldSpace;
  138443. private _computeCascadeFrustum;
  138444. /**
  138445. * Support test.
  138446. */
  138447. static get IsSupported(): boolean;
  138448. /** @hidden */
  138449. static _SceneComponentInitialization: (scene: Scene) => void;
  138450. /**
  138451. * Creates a Cascaded Shadow Generator object.
  138452. * A ShadowGenerator is the required tool to use the shadows.
  138453. * Each directional light casting shadows needs to use its own ShadowGenerator.
  138454. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  138455. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  138456. * @param light The directional light object generating the shadows.
  138457. * @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.
  138458. */
  138459. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  138460. protected _initializeGenerator(): void;
  138461. protected _createTargetRenderTexture(): void;
  138462. protected _initializeShadowMap(): void;
  138463. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  138464. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  138465. /**
  138466. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  138467. * @param defines Defines of the material we want to update
  138468. * @param lightIndex Index of the light in the enabled light list of the material
  138469. */
  138470. prepareDefines(defines: any, lightIndex: number): void;
  138471. /**
  138472. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  138473. * defined in the generator but impacting the effect).
  138474. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  138475. * @param effect The effect we are binfing the information for
  138476. */
  138477. bindShadowLight(lightIndex: string, effect: Effect): void;
  138478. /**
  138479. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  138480. * (eq to view projection * shadow projection matrices)
  138481. * @returns The transform matrix used to create the shadow map
  138482. */
  138483. getTransformMatrix(): Matrix;
  138484. /**
  138485. * Disposes the ShadowGenerator.
  138486. * Returns nothing.
  138487. */
  138488. dispose(): void;
  138489. /**
  138490. * Serializes the shadow generator setup to a json object.
  138491. * @returns The serialized JSON object
  138492. */
  138493. serialize(): any;
  138494. /**
  138495. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  138496. * @param parsedShadowGenerator The JSON object to parse
  138497. * @param scene The scene to create the shadow map for
  138498. * @returns The parsed shadow generator
  138499. */
  138500. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  138501. }
  138502. }
  138503. declare module BABYLON {
  138504. /**
  138505. * Defines the shadow generator component responsible to manage any shadow generators
  138506. * in a given scene.
  138507. */
  138508. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  138509. /**
  138510. * The component name helpfull to identify the component in the list of scene components.
  138511. */
  138512. readonly name: string;
  138513. /**
  138514. * The scene the component belongs to.
  138515. */
  138516. scene: Scene;
  138517. /**
  138518. * Creates a new instance of the component for the given scene
  138519. * @param scene Defines the scene to register the component in
  138520. */
  138521. constructor(scene: Scene);
  138522. /**
  138523. * Registers the component in a given scene
  138524. */
  138525. register(): void;
  138526. /**
  138527. * Rebuilds the elements related to this component in case of
  138528. * context lost for instance.
  138529. */
  138530. rebuild(): void;
  138531. /**
  138532. * Serializes the component data to the specified json object
  138533. * @param serializationObject The object to serialize to
  138534. */
  138535. serialize(serializationObject: any): void;
  138536. /**
  138537. * Adds all the elements from the container to the scene
  138538. * @param container the container holding the elements
  138539. */
  138540. addFromContainer(container: AbstractScene): void;
  138541. /**
  138542. * Removes all the elements in the container from the scene
  138543. * @param container contains the elements to remove
  138544. * @param dispose if the removed element should be disposed (default: false)
  138545. */
  138546. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138547. /**
  138548. * Rebuilds the elements related to this component in case of
  138549. * context lost for instance.
  138550. */
  138551. dispose(): void;
  138552. private _gatherRenderTargets;
  138553. }
  138554. }
  138555. declare module BABYLON {
  138556. /**
  138557. * A point light is a light defined by an unique point in world space.
  138558. * The light is emitted in every direction from this point.
  138559. * A good example of a point light is a standard light bulb.
  138560. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138561. */
  138562. export class PointLight extends ShadowLight {
  138563. private _shadowAngle;
  138564. /**
  138565. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138566. * This specifies what angle the shadow will use to be created.
  138567. *
  138568. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138569. */
  138570. get shadowAngle(): number;
  138571. /**
  138572. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138573. * This specifies what angle the shadow will use to be created.
  138574. *
  138575. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  138576. */
  138577. set shadowAngle(value: number);
  138578. /**
  138579. * Gets the direction if it has been set.
  138580. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138581. */
  138582. get direction(): Vector3;
  138583. /**
  138584. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  138585. */
  138586. set direction(value: Vector3);
  138587. /**
  138588. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  138589. * A PointLight emits the light in every direction.
  138590. * It can cast shadows.
  138591. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  138592. * ```javascript
  138593. * var pointLight = new PointLight("pl", camera.position, scene);
  138594. * ```
  138595. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138596. * @param name The light friendly name
  138597. * @param position The position of the point light in the scene
  138598. * @param scene The scene the lights belongs to
  138599. */
  138600. constructor(name: string, position: Vector3, scene: Scene);
  138601. /**
  138602. * Returns the string "PointLight"
  138603. * @returns the class name
  138604. */
  138605. getClassName(): string;
  138606. /**
  138607. * Returns the integer 0.
  138608. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138609. */
  138610. getTypeID(): number;
  138611. /**
  138612. * Specifies wether or not the shadowmap should be a cube texture.
  138613. * @returns true if the shadowmap needs to be a cube texture.
  138614. */
  138615. needCube(): boolean;
  138616. /**
  138617. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  138618. * @param faceIndex The index of the face we are computed the direction to generate shadow
  138619. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  138620. */
  138621. getShadowDirection(faceIndex?: number): Vector3;
  138622. /**
  138623. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  138624. * - fov = PI / 2
  138625. * - aspect ratio : 1.0
  138626. * - z-near and far equal to the active camera minZ and maxZ.
  138627. * Returns the PointLight.
  138628. */
  138629. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138630. protected _buildUniformLayout(): void;
  138631. /**
  138632. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  138633. * @param effect The effect to update
  138634. * @param lightIndex The index of the light in the effect to update
  138635. * @returns The point light
  138636. */
  138637. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  138638. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138639. /**
  138640. * Prepares the list of defines specific to the light type.
  138641. * @param defines the list of defines
  138642. * @param lightIndex defines the index of the light for the effect
  138643. */
  138644. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138645. }
  138646. }
  138647. declare module BABYLON {
  138648. /**
  138649. * Header information of HDR texture files.
  138650. */
  138651. export interface HDRInfo {
  138652. /**
  138653. * The height of the texture in pixels.
  138654. */
  138655. height: number;
  138656. /**
  138657. * The width of the texture in pixels.
  138658. */
  138659. width: number;
  138660. /**
  138661. * The index of the beginning of the data in the binary file.
  138662. */
  138663. dataPosition: number;
  138664. }
  138665. /**
  138666. * This groups tools to convert HDR texture to native colors array.
  138667. */
  138668. export class HDRTools {
  138669. private static Ldexp;
  138670. private static Rgbe2float;
  138671. private static readStringLine;
  138672. /**
  138673. * Reads header information from an RGBE texture stored in a native array.
  138674. * More information on this format are available here:
  138675. * https://en.wikipedia.org/wiki/RGBE_image_format
  138676. *
  138677. * @param uint8array The binary file stored in native array.
  138678. * @return The header information.
  138679. */
  138680. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  138681. /**
  138682. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  138683. * This RGBE texture needs to store the information as a panorama.
  138684. *
  138685. * More information on this format are available here:
  138686. * https://en.wikipedia.org/wiki/RGBE_image_format
  138687. *
  138688. * @param buffer The binary file stored in an array buffer.
  138689. * @param size The expected size of the extracted cubemap.
  138690. * @return The Cube Map information.
  138691. */
  138692. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  138693. /**
  138694. * Returns the pixels data extracted from an RGBE texture.
  138695. * This pixels will be stored left to right up to down in the R G B order in one array.
  138696. *
  138697. * More information on this format are available here:
  138698. * https://en.wikipedia.org/wiki/RGBE_image_format
  138699. *
  138700. * @param uint8array The binary file stored in an array buffer.
  138701. * @param hdrInfo The header information of the file.
  138702. * @return The pixels data in RGB right to left up to down order.
  138703. */
  138704. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  138705. private static RGBE_ReadPixels_RLE;
  138706. private static RGBE_ReadPixels_NOT_RLE;
  138707. }
  138708. }
  138709. declare module BABYLON {
  138710. /**
  138711. * Effect Render Options
  138712. */
  138713. export interface IEffectRendererOptions {
  138714. /**
  138715. * Defines the vertices positions.
  138716. */
  138717. positions?: number[];
  138718. /**
  138719. * Defines the indices.
  138720. */
  138721. indices?: number[];
  138722. }
  138723. /**
  138724. * Helper class to render one or more effects.
  138725. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  138726. */
  138727. export class EffectRenderer {
  138728. private engine;
  138729. private static _DefaultOptions;
  138730. private _vertexBuffers;
  138731. private _indexBuffer;
  138732. private _fullscreenViewport;
  138733. /**
  138734. * Creates an effect renderer
  138735. * @param engine the engine to use for rendering
  138736. * @param options defines the options of the effect renderer
  138737. */
  138738. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  138739. /**
  138740. * Sets the current viewport in normalized coordinates 0-1
  138741. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  138742. */
  138743. setViewport(viewport?: Viewport): void;
  138744. /**
  138745. * Binds the embedded attributes buffer to the effect.
  138746. * @param effect Defines the effect to bind the attributes for
  138747. */
  138748. bindBuffers(effect: Effect): void;
  138749. /**
  138750. * Sets the current effect wrapper to use during draw.
  138751. * The effect needs to be ready before calling this api.
  138752. * This also sets the default full screen position attribute.
  138753. * @param effectWrapper Defines the effect to draw with
  138754. */
  138755. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  138756. /**
  138757. * Restores engine states
  138758. */
  138759. restoreStates(): void;
  138760. /**
  138761. * Draws a full screen quad.
  138762. */
  138763. draw(): void;
  138764. private isRenderTargetTexture;
  138765. /**
  138766. * renders one or more effects to a specified texture
  138767. * @param effectWrapper the effect to renderer
  138768. * @param outputTexture texture to draw to, if null it will render to the screen.
  138769. */
  138770. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  138771. /**
  138772. * Disposes of the effect renderer
  138773. */
  138774. dispose(): void;
  138775. }
  138776. /**
  138777. * Options to create an EffectWrapper
  138778. */
  138779. interface EffectWrapperCreationOptions {
  138780. /**
  138781. * Engine to use to create the effect
  138782. */
  138783. engine: ThinEngine;
  138784. /**
  138785. * Fragment shader for the effect
  138786. */
  138787. fragmentShader: string;
  138788. /**
  138789. * Use the shader store instead of direct source code
  138790. */
  138791. useShaderStore?: boolean;
  138792. /**
  138793. * Vertex shader for the effect
  138794. */
  138795. vertexShader?: string;
  138796. /**
  138797. * Attributes to use in the shader
  138798. */
  138799. attributeNames?: Array<string>;
  138800. /**
  138801. * Uniforms to use in the shader
  138802. */
  138803. uniformNames?: Array<string>;
  138804. /**
  138805. * Texture sampler names to use in the shader
  138806. */
  138807. samplerNames?: Array<string>;
  138808. /**
  138809. * Defines to use in the shader
  138810. */
  138811. defines?: Array<string>;
  138812. /**
  138813. * Callback when effect is compiled
  138814. */
  138815. onCompiled?: Nullable<(effect: Effect) => void>;
  138816. /**
  138817. * The friendly name of the effect displayed in Spector.
  138818. */
  138819. name?: string;
  138820. }
  138821. /**
  138822. * Wraps an effect to be used for rendering
  138823. */
  138824. export class EffectWrapper {
  138825. /**
  138826. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  138827. */
  138828. onApplyObservable: Observable<{}>;
  138829. /**
  138830. * The underlying effect
  138831. */
  138832. effect: Effect;
  138833. /**
  138834. * Creates an effect to be renderer
  138835. * @param creationOptions options to create the effect
  138836. */
  138837. constructor(creationOptions: EffectWrapperCreationOptions);
  138838. /**
  138839. * Disposes of the effect wrapper
  138840. */
  138841. dispose(): void;
  138842. }
  138843. }
  138844. declare module BABYLON {
  138845. /** @hidden */
  138846. export var hdrFilteringVertexShader: {
  138847. name: string;
  138848. shader: string;
  138849. };
  138850. }
  138851. declare module BABYLON {
  138852. /** @hidden */
  138853. export var hdrFilteringPixelShader: {
  138854. name: string;
  138855. shader: string;
  138856. };
  138857. }
  138858. declare module BABYLON {
  138859. /**
  138860. * Options for texture filtering
  138861. */
  138862. interface IHDRFilteringOptions {
  138863. /**
  138864. * Scales pixel intensity for the input HDR map.
  138865. */
  138866. hdrScale?: number;
  138867. /**
  138868. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  138869. */
  138870. quality?: number;
  138871. }
  138872. /**
  138873. * Filters HDR maps to get correct renderings of PBR reflections
  138874. */
  138875. export class HDRFiltering {
  138876. private _engine;
  138877. private _effectRenderer;
  138878. private _effectWrapper;
  138879. private _lodGenerationOffset;
  138880. private _lodGenerationScale;
  138881. /**
  138882. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  138883. * you care about baking speed.
  138884. */
  138885. quality: number;
  138886. /**
  138887. * Scales pixel intensity for the input HDR map.
  138888. */
  138889. hdrScale: number;
  138890. /**
  138891. * Instantiates HDR filter for reflection maps
  138892. *
  138893. * @param engine Thin engine
  138894. * @param options Options
  138895. */
  138896. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  138897. private _createRenderTarget;
  138898. private _prefilterInternal;
  138899. private _createEffect;
  138900. /**
  138901. * Get a value indicating if the filter is ready to be used
  138902. * @param texture Texture to filter
  138903. * @returns true if the filter is ready
  138904. */
  138905. isReady(texture: BaseTexture): boolean;
  138906. /**
  138907. * Prefilters a cube texture to have mipmap levels representing roughness values.
  138908. * Prefiltering will be invoked at the end of next rendering pass.
  138909. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  138910. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  138911. * @param texture Texture to filter
  138912. * @param onFinished Callback when filtering is done
  138913. * @return Promise called when prefiltering is done
  138914. */
  138915. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  138916. }
  138917. }
  138918. declare module BABYLON {
  138919. /**
  138920. * This represents a texture coming from an HDR input.
  138921. *
  138922. * The only supported format is currently panorama picture stored in RGBE format.
  138923. * Example of such files can be found on HDRLib: http://hdrlib.com/
  138924. */
  138925. export class HDRCubeTexture extends BaseTexture {
  138926. private static _facesMapping;
  138927. private _generateHarmonics;
  138928. private _noMipmap;
  138929. private _prefilterOnLoad;
  138930. private _textureMatrix;
  138931. private _size;
  138932. private _onLoad;
  138933. private _onError;
  138934. /**
  138935. * The texture URL.
  138936. */
  138937. url: string;
  138938. /**
  138939. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  138940. */
  138941. coordinatesMode: number;
  138942. protected _isBlocking: boolean;
  138943. /**
  138944. * Sets wether or not the texture is blocking during loading.
  138945. */
  138946. set isBlocking(value: boolean);
  138947. /**
  138948. * Gets wether or not the texture is blocking during loading.
  138949. */
  138950. get isBlocking(): boolean;
  138951. protected _rotationY: number;
  138952. /**
  138953. * Sets texture matrix rotation angle around Y axis in radians.
  138954. */
  138955. set rotationY(value: number);
  138956. /**
  138957. * Gets texture matrix rotation angle around Y axis radians.
  138958. */
  138959. get rotationY(): number;
  138960. /**
  138961. * Gets or sets the center of the bounding box associated with the cube texture
  138962. * It must define where the camera used to render the texture was set
  138963. */
  138964. boundingBoxPosition: Vector3;
  138965. private _boundingBoxSize;
  138966. /**
  138967. * Gets or sets the size of the bounding box associated with the cube texture
  138968. * When defined, the cubemap will switch to local mode
  138969. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  138970. * @example https://www.babylonjs-playground.com/#RNASML
  138971. */
  138972. set boundingBoxSize(value: Vector3);
  138973. get boundingBoxSize(): Vector3;
  138974. /**
  138975. * Instantiates an HDRTexture from the following parameters.
  138976. *
  138977. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  138978. * @param sceneOrEngine The scene or engine the texture will be used in
  138979. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138980. * @param noMipmap Forces to not generate the mipmap if true
  138981. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  138982. * @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)
  138983. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  138984. */
  138985. 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>);
  138986. /**
  138987. * Get the current class name of the texture useful for serialization or dynamic coding.
  138988. * @returns "HDRCubeTexture"
  138989. */
  138990. getClassName(): string;
  138991. /**
  138992. * Occurs when the file is raw .hdr file.
  138993. */
  138994. private loadTexture;
  138995. clone(): HDRCubeTexture;
  138996. delayLoad(): void;
  138997. /**
  138998. * Get the texture reflection matrix used to rotate/transform the reflection.
  138999. * @returns the reflection matrix
  139000. */
  139001. getReflectionTextureMatrix(): Matrix;
  139002. /**
  139003. * Set the texture reflection matrix used to rotate/transform the reflection.
  139004. * @param value Define the reflection matrix to set
  139005. */
  139006. setReflectionTextureMatrix(value: Matrix): void;
  139007. /**
  139008. * Parses a JSON representation of an HDR Texture in order to create the texture
  139009. * @param parsedTexture Define the JSON representation
  139010. * @param scene Define the scene the texture should be created in
  139011. * @param rootUrl Define the root url in case we need to load relative dependencies
  139012. * @returns the newly created texture after parsing
  139013. */
  139014. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  139015. serialize(): any;
  139016. }
  139017. }
  139018. declare module BABYLON {
  139019. /**
  139020. * Class used to control physics engine
  139021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139022. */
  139023. export class PhysicsEngine implements IPhysicsEngine {
  139024. private _physicsPlugin;
  139025. /**
  139026. * Global value used to control the smallest number supported by the simulation
  139027. */
  139028. static Epsilon: number;
  139029. private _impostors;
  139030. private _joints;
  139031. private _subTimeStep;
  139032. /**
  139033. * Gets the gravity vector used by the simulation
  139034. */
  139035. gravity: Vector3;
  139036. /**
  139037. * Factory used to create the default physics plugin.
  139038. * @returns The default physics plugin
  139039. */
  139040. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  139041. /**
  139042. * Creates a new Physics Engine
  139043. * @param gravity defines the gravity vector used by the simulation
  139044. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  139045. */
  139046. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  139047. /**
  139048. * Sets the gravity vector used by the simulation
  139049. * @param gravity defines the gravity vector to use
  139050. */
  139051. setGravity(gravity: Vector3): void;
  139052. /**
  139053. * Set the time step of the physics engine.
  139054. * Default is 1/60.
  139055. * To slow it down, enter 1/600 for example.
  139056. * To speed it up, 1/30
  139057. * @param newTimeStep defines the new timestep to apply to this world.
  139058. */
  139059. setTimeStep(newTimeStep?: number): void;
  139060. /**
  139061. * Get the time step of the physics engine.
  139062. * @returns the current time step
  139063. */
  139064. getTimeStep(): number;
  139065. /**
  139066. * Set the sub time step of the physics engine.
  139067. * Default is 0 meaning there is no sub steps
  139068. * To increase physics resolution precision, set a small value (like 1 ms)
  139069. * @param subTimeStep defines the new sub timestep used for physics resolution.
  139070. */
  139071. setSubTimeStep(subTimeStep?: number): void;
  139072. /**
  139073. * Get the sub time step of the physics engine.
  139074. * @returns the current sub time step
  139075. */
  139076. getSubTimeStep(): number;
  139077. /**
  139078. * Release all resources
  139079. */
  139080. dispose(): void;
  139081. /**
  139082. * Gets the name of the current physics plugin
  139083. * @returns the name of the plugin
  139084. */
  139085. getPhysicsPluginName(): string;
  139086. /**
  139087. * Adding a new impostor for the impostor tracking.
  139088. * This will be done by the impostor itself.
  139089. * @param impostor the impostor to add
  139090. */
  139091. addImpostor(impostor: PhysicsImpostor): void;
  139092. /**
  139093. * Remove an impostor from the engine.
  139094. * This impostor and its mesh will not longer be updated by the physics engine.
  139095. * @param impostor the impostor to remove
  139096. */
  139097. removeImpostor(impostor: PhysicsImpostor): void;
  139098. /**
  139099. * Add a joint to the physics engine
  139100. * @param mainImpostor defines the main impostor to which the joint is added.
  139101. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  139102. * @param joint defines the joint that will connect both impostors.
  139103. */
  139104. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139105. /**
  139106. * Removes a joint from the simulation
  139107. * @param mainImpostor defines the impostor used with the joint
  139108. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  139109. * @param joint defines the joint to remove
  139110. */
  139111. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  139112. /**
  139113. * Called by the scene. No need to call it.
  139114. * @param delta defines the timespam between frames
  139115. */
  139116. _step(delta: number): void;
  139117. /**
  139118. * Gets the current plugin used to run the simulation
  139119. * @returns current plugin
  139120. */
  139121. getPhysicsPlugin(): IPhysicsEnginePlugin;
  139122. /**
  139123. * Gets the list of physic impostors
  139124. * @returns an array of PhysicsImpostor
  139125. */
  139126. getImpostors(): Array<PhysicsImpostor>;
  139127. /**
  139128. * Gets the impostor for a physics enabled object
  139129. * @param object defines the object impersonated by the impostor
  139130. * @returns the PhysicsImpostor or null if not found
  139131. */
  139132. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  139133. /**
  139134. * Gets the impostor for a physics body object
  139135. * @param body defines physics body used by the impostor
  139136. * @returns the PhysicsImpostor or null if not found
  139137. */
  139138. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  139139. /**
  139140. * Does a raycast in the physics world
  139141. * @param from when should the ray start?
  139142. * @param to when should the ray end?
  139143. * @returns PhysicsRaycastResult
  139144. */
  139145. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139146. }
  139147. }
  139148. declare module BABYLON {
  139149. /** @hidden */
  139150. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  139151. private _useDeltaForWorldStep;
  139152. world: any;
  139153. name: string;
  139154. private _physicsMaterials;
  139155. private _fixedTimeStep;
  139156. private _cannonRaycastResult;
  139157. private _raycastResult;
  139158. private _physicsBodysToRemoveAfterStep;
  139159. private _firstFrame;
  139160. BJSCANNON: any;
  139161. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  139162. setGravity(gravity: Vector3): void;
  139163. setTimeStep(timeStep: number): void;
  139164. getTimeStep(): number;
  139165. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139166. private _removeMarkedPhysicsBodiesFromWorld;
  139167. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139168. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139169. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139170. private _processChildMeshes;
  139171. removePhysicsBody(impostor: PhysicsImpostor): void;
  139172. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139173. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139174. private _addMaterial;
  139175. private _checkWithEpsilon;
  139176. private _createShape;
  139177. private _createHeightmap;
  139178. private _minus90X;
  139179. private _plus90X;
  139180. private _tmpPosition;
  139181. private _tmpDeltaPosition;
  139182. private _tmpUnityRotation;
  139183. private _updatePhysicsBodyTransformation;
  139184. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139185. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139186. isSupported(): boolean;
  139187. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139188. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139189. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139190. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139191. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139192. getBodyMass(impostor: PhysicsImpostor): number;
  139193. getBodyFriction(impostor: PhysicsImpostor): number;
  139194. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139195. getBodyRestitution(impostor: PhysicsImpostor): number;
  139196. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139197. sleepBody(impostor: PhysicsImpostor): void;
  139198. wakeUpBody(impostor: PhysicsImpostor): void;
  139199. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  139200. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139201. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139202. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139203. getRadius(impostor: PhysicsImpostor): number;
  139204. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139205. dispose(): void;
  139206. private _extendNamespace;
  139207. /**
  139208. * Does a raycast in the physics world
  139209. * @param from when should the ray start?
  139210. * @param to when should the ray end?
  139211. * @returns PhysicsRaycastResult
  139212. */
  139213. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139214. }
  139215. }
  139216. declare module BABYLON {
  139217. /** @hidden */
  139218. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  139219. private _useDeltaForWorldStep;
  139220. world: any;
  139221. name: string;
  139222. BJSOIMO: any;
  139223. private _raycastResult;
  139224. private _fixedTimeStep;
  139225. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  139226. setGravity(gravity: Vector3): void;
  139227. setTimeStep(timeStep: number): void;
  139228. getTimeStep(): number;
  139229. private _tmpImpostorsArray;
  139230. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139231. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139232. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139233. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139234. private _tmpPositionVector;
  139235. removePhysicsBody(impostor: PhysicsImpostor): void;
  139236. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139237. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139238. isSupported(): boolean;
  139239. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139240. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139241. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139242. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139243. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139244. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139245. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139246. getBodyMass(impostor: PhysicsImpostor): number;
  139247. getBodyFriction(impostor: PhysicsImpostor): number;
  139248. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139249. getBodyRestitution(impostor: PhysicsImpostor): number;
  139250. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139251. sleepBody(impostor: PhysicsImpostor): void;
  139252. wakeUpBody(impostor: PhysicsImpostor): void;
  139253. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139254. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  139255. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  139256. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139257. getRadius(impostor: PhysicsImpostor): number;
  139258. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139259. dispose(): void;
  139260. /**
  139261. * Does a raycast in the physics world
  139262. * @param from when should the ray start?
  139263. * @param to when should the ray end?
  139264. * @returns PhysicsRaycastResult
  139265. */
  139266. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139267. }
  139268. }
  139269. declare module BABYLON {
  139270. /**
  139271. * AmmoJS Physics plugin
  139272. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  139273. * @see https://github.com/kripken/ammo.js/
  139274. */
  139275. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  139276. private _useDeltaForWorldStep;
  139277. /**
  139278. * Reference to the Ammo library
  139279. */
  139280. bjsAMMO: any;
  139281. /**
  139282. * Created ammoJS world which physics bodies are added to
  139283. */
  139284. world: any;
  139285. /**
  139286. * Name of the plugin
  139287. */
  139288. name: string;
  139289. private _timeStep;
  139290. private _fixedTimeStep;
  139291. private _maxSteps;
  139292. private _tmpQuaternion;
  139293. private _tmpAmmoTransform;
  139294. private _tmpAmmoQuaternion;
  139295. private _tmpAmmoConcreteContactResultCallback;
  139296. private _collisionConfiguration;
  139297. private _dispatcher;
  139298. private _overlappingPairCache;
  139299. private _solver;
  139300. private _softBodySolver;
  139301. private _tmpAmmoVectorA;
  139302. private _tmpAmmoVectorB;
  139303. private _tmpAmmoVectorC;
  139304. private _tmpAmmoVectorD;
  139305. private _tmpContactCallbackResult;
  139306. private _tmpAmmoVectorRCA;
  139307. private _tmpAmmoVectorRCB;
  139308. private _raycastResult;
  139309. private static readonly DISABLE_COLLISION_FLAG;
  139310. private static readonly KINEMATIC_FLAG;
  139311. private static readonly DISABLE_DEACTIVATION_FLAG;
  139312. /**
  139313. * Initializes the ammoJS plugin
  139314. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  139315. * @param ammoInjection can be used to inject your own ammo reference
  139316. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  139317. */
  139318. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  139319. /**
  139320. * Sets the gravity of the physics world (m/(s^2))
  139321. * @param gravity Gravity to set
  139322. */
  139323. setGravity(gravity: Vector3): void;
  139324. /**
  139325. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  139326. * @param timeStep timestep to use in seconds
  139327. */
  139328. setTimeStep(timeStep: number): void;
  139329. /**
  139330. * 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)
  139331. * @param fixedTimeStep fixedTimeStep to use in seconds
  139332. */
  139333. setFixedTimeStep(fixedTimeStep: number): void;
  139334. /**
  139335. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  139336. * @param maxSteps the maximum number of steps by the physics engine per frame
  139337. */
  139338. setMaxSteps(maxSteps: number): void;
  139339. /**
  139340. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  139341. * @returns the current timestep in seconds
  139342. */
  139343. getTimeStep(): number;
  139344. /**
  139345. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  139346. */
  139347. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  139348. private _isImpostorInContact;
  139349. private _isImpostorPairInContact;
  139350. private _stepSimulation;
  139351. /**
  139352. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  139353. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  139354. * After the step the babylon meshes are set to the position of the physics imposters
  139355. * @param delta amount of time to step forward
  139356. * @param impostors array of imposters to update before/after the step
  139357. */
  139358. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  139359. /**
  139360. * Update babylon mesh to match physics world object
  139361. * @param impostor imposter to match
  139362. */
  139363. private _afterSoftStep;
  139364. /**
  139365. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139366. * @param impostor imposter to match
  139367. */
  139368. private _ropeStep;
  139369. /**
  139370. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  139371. * @param impostor imposter to match
  139372. */
  139373. private _softbodyOrClothStep;
  139374. private _tmpMatrix;
  139375. /**
  139376. * Applies an impulse on the imposter
  139377. * @param impostor imposter to apply impulse to
  139378. * @param force amount of force to be applied to the imposter
  139379. * @param contactPoint the location to apply the impulse on the imposter
  139380. */
  139381. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139382. /**
  139383. * Applies a force on the imposter
  139384. * @param impostor imposter to apply force
  139385. * @param force amount of force to be applied to the imposter
  139386. * @param contactPoint the location to apply the force on the imposter
  139387. */
  139388. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  139389. /**
  139390. * Creates a physics body using the plugin
  139391. * @param impostor the imposter to create the physics body on
  139392. */
  139393. generatePhysicsBody(impostor: PhysicsImpostor): void;
  139394. /**
  139395. * Removes the physics body from the imposter and disposes of the body's memory
  139396. * @param impostor imposter to remove the physics body from
  139397. */
  139398. removePhysicsBody(impostor: PhysicsImpostor): void;
  139399. /**
  139400. * Generates a joint
  139401. * @param impostorJoint the imposter joint to create the joint with
  139402. */
  139403. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  139404. /**
  139405. * Removes a joint
  139406. * @param impostorJoint the imposter joint to remove the joint from
  139407. */
  139408. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  139409. private _addMeshVerts;
  139410. /**
  139411. * Initialise the soft body vertices to match its object's (mesh) vertices
  139412. * Softbody vertices (nodes) are in world space and to match this
  139413. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  139414. * @param impostor to create the softbody for
  139415. */
  139416. private _softVertexData;
  139417. /**
  139418. * Create an impostor's soft body
  139419. * @param impostor to create the softbody for
  139420. */
  139421. private _createSoftbody;
  139422. /**
  139423. * Create cloth for an impostor
  139424. * @param impostor to create the softbody for
  139425. */
  139426. private _createCloth;
  139427. /**
  139428. * Create rope for an impostor
  139429. * @param impostor to create the softbody for
  139430. */
  139431. private _createRope;
  139432. /**
  139433. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  139434. * @param impostor to create the custom physics shape for
  139435. */
  139436. private _createCustom;
  139437. private _addHullVerts;
  139438. private _createShape;
  139439. /**
  139440. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  139441. * @param impostor imposter containing the physics body and babylon object
  139442. */
  139443. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  139444. /**
  139445. * Sets the babylon object's position/rotation from the physics body's position/rotation
  139446. * @param impostor imposter containing the physics body and babylon object
  139447. * @param newPosition new position
  139448. * @param newRotation new rotation
  139449. */
  139450. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  139451. /**
  139452. * If this plugin is supported
  139453. * @returns true if its supported
  139454. */
  139455. isSupported(): boolean;
  139456. /**
  139457. * Sets the linear velocity of the physics body
  139458. * @param impostor imposter to set the velocity on
  139459. * @param velocity velocity to set
  139460. */
  139461. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139462. /**
  139463. * Sets the angular velocity of the physics body
  139464. * @param impostor imposter to set the velocity on
  139465. * @param velocity velocity to set
  139466. */
  139467. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  139468. /**
  139469. * gets the linear velocity
  139470. * @param impostor imposter to get linear velocity from
  139471. * @returns linear velocity
  139472. */
  139473. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139474. /**
  139475. * gets the angular velocity
  139476. * @param impostor imposter to get angular velocity from
  139477. * @returns angular velocity
  139478. */
  139479. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  139480. /**
  139481. * Sets the mass of physics body
  139482. * @param impostor imposter to set the mass on
  139483. * @param mass mass to set
  139484. */
  139485. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  139486. /**
  139487. * Gets the mass of the physics body
  139488. * @param impostor imposter to get the mass from
  139489. * @returns mass
  139490. */
  139491. getBodyMass(impostor: PhysicsImpostor): number;
  139492. /**
  139493. * Gets friction of the impostor
  139494. * @param impostor impostor to get friction from
  139495. * @returns friction value
  139496. */
  139497. getBodyFriction(impostor: PhysicsImpostor): number;
  139498. /**
  139499. * Sets friction of the impostor
  139500. * @param impostor impostor to set friction on
  139501. * @param friction friction value
  139502. */
  139503. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  139504. /**
  139505. * Gets restitution of the impostor
  139506. * @param impostor impostor to get restitution from
  139507. * @returns restitution value
  139508. */
  139509. getBodyRestitution(impostor: PhysicsImpostor): number;
  139510. /**
  139511. * Sets resitution of the impostor
  139512. * @param impostor impostor to set resitution on
  139513. * @param restitution resitution value
  139514. */
  139515. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  139516. /**
  139517. * Gets pressure inside the impostor
  139518. * @param impostor impostor to get pressure from
  139519. * @returns pressure value
  139520. */
  139521. getBodyPressure(impostor: PhysicsImpostor): number;
  139522. /**
  139523. * Sets pressure inside a soft body impostor
  139524. * Cloth and rope must remain 0 pressure
  139525. * @param impostor impostor to set pressure on
  139526. * @param pressure pressure value
  139527. */
  139528. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  139529. /**
  139530. * Gets stiffness of the impostor
  139531. * @param impostor impostor to get stiffness from
  139532. * @returns pressure value
  139533. */
  139534. getBodyStiffness(impostor: PhysicsImpostor): number;
  139535. /**
  139536. * Sets stiffness of the impostor
  139537. * @param impostor impostor to set stiffness on
  139538. * @param stiffness stiffness value from 0 to 1
  139539. */
  139540. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  139541. /**
  139542. * Gets velocityIterations of the impostor
  139543. * @param impostor impostor to get velocity iterations from
  139544. * @returns velocityIterations value
  139545. */
  139546. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  139547. /**
  139548. * Sets velocityIterations of the impostor
  139549. * @param impostor impostor to set velocity iterations on
  139550. * @param velocityIterations velocityIterations value
  139551. */
  139552. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  139553. /**
  139554. * Gets positionIterations of the impostor
  139555. * @param impostor impostor to get position iterations from
  139556. * @returns positionIterations value
  139557. */
  139558. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  139559. /**
  139560. * Sets positionIterations of the impostor
  139561. * @param impostor impostor to set position on
  139562. * @param positionIterations positionIterations value
  139563. */
  139564. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  139565. /**
  139566. * Append an anchor to a cloth object
  139567. * @param impostor is the cloth impostor to add anchor to
  139568. * @param otherImpostor is the rigid impostor to anchor to
  139569. * @param width ratio across width from 0 to 1
  139570. * @param height ratio up height from 0 to 1
  139571. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  139572. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139573. */
  139574. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139575. /**
  139576. * Append an hook to a rope object
  139577. * @param impostor is the rope impostor to add hook to
  139578. * @param otherImpostor is the rigid impostor to hook to
  139579. * @param length ratio along the rope from 0 to 1
  139580. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  139581. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  139582. */
  139583. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  139584. /**
  139585. * Sleeps the physics body and stops it from being active
  139586. * @param impostor impostor to sleep
  139587. */
  139588. sleepBody(impostor: PhysicsImpostor): void;
  139589. /**
  139590. * Activates the physics body
  139591. * @param impostor impostor to activate
  139592. */
  139593. wakeUpBody(impostor: PhysicsImpostor): void;
  139594. /**
  139595. * Updates the distance parameters of the joint
  139596. * @param joint joint to update
  139597. * @param maxDistance maximum distance of the joint
  139598. * @param minDistance minimum distance of the joint
  139599. */
  139600. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  139601. /**
  139602. * Sets a motor on the joint
  139603. * @param joint joint to set motor on
  139604. * @param speed speed of the motor
  139605. * @param maxForce maximum force of the motor
  139606. * @param motorIndex index of the motor
  139607. */
  139608. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  139609. /**
  139610. * Sets the motors limit
  139611. * @param joint joint to set limit on
  139612. * @param upperLimit upper limit
  139613. * @param lowerLimit lower limit
  139614. */
  139615. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  139616. /**
  139617. * Syncs the position and rotation of a mesh with the impostor
  139618. * @param mesh mesh to sync
  139619. * @param impostor impostor to update the mesh with
  139620. */
  139621. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  139622. /**
  139623. * Gets the radius of the impostor
  139624. * @param impostor impostor to get radius from
  139625. * @returns the radius
  139626. */
  139627. getRadius(impostor: PhysicsImpostor): number;
  139628. /**
  139629. * Gets the box size of the impostor
  139630. * @param impostor impostor to get box size from
  139631. * @param result the resulting box size
  139632. */
  139633. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  139634. /**
  139635. * Disposes of the impostor
  139636. */
  139637. dispose(): void;
  139638. /**
  139639. * Does a raycast in the physics world
  139640. * @param from when should the ray start?
  139641. * @param to when should the ray end?
  139642. * @returns PhysicsRaycastResult
  139643. */
  139644. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  139645. }
  139646. }
  139647. declare module BABYLON {
  139648. interface AbstractScene {
  139649. /**
  139650. * The list of reflection probes added to the scene
  139651. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139652. */
  139653. reflectionProbes: Array<ReflectionProbe>;
  139654. /**
  139655. * Removes the given reflection probe from this scene.
  139656. * @param toRemove The reflection probe to remove
  139657. * @returns The index of the removed reflection probe
  139658. */
  139659. removeReflectionProbe(toRemove: ReflectionProbe): number;
  139660. /**
  139661. * Adds the given reflection probe to this scene.
  139662. * @param newReflectionProbe The reflection probe to add
  139663. */
  139664. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  139665. }
  139666. /**
  139667. * Class used to generate realtime reflection / refraction cube textures
  139668. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  139669. */
  139670. export class ReflectionProbe {
  139671. /** defines the name of the probe */
  139672. name: string;
  139673. private _scene;
  139674. private _renderTargetTexture;
  139675. private _projectionMatrix;
  139676. private _viewMatrix;
  139677. private _target;
  139678. private _add;
  139679. private _attachedMesh;
  139680. private _invertYAxis;
  139681. /** Gets or sets probe position (center of the cube map) */
  139682. position: Vector3;
  139683. /**
  139684. * Creates a new reflection probe
  139685. * @param name defines the name of the probe
  139686. * @param size defines the texture resolution (for each face)
  139687. * @param scene defines the hosting scene
  139688. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  139689. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  139690. */
  139691. constructor(
  139692. /** defines the name of the probe */
  139693. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  139694. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  139695. get samples(): number;
  139696. set samples(value: number);
  139697. /** Gets or sets the refresh rate to use (on every frame by default) */
  139698. get refreshRate(): number;
  139699. set refreshRate(value: number);
  139700. /**
  139701. * Gets the hosting scene
  139702. * @returns a Scene
  139703. */
  139704. getScene(): Scene;
  139705. /** Gets the internal CubeTexture used to render to */
  139706. get cubeTexture(): RenderTargetTexture;
  139707. /** Gets the list of meshes to render */
  139708. get renderList(): Nullable<AbstractMesh[]>;
  139709. /**
  139710. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  139711. * @param mesh defines the mesh to attach to
  139712. */
  139713. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  139714. /**
  139715. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  139716. * @param renderingGroupId The rendering group id corresponding to its index
  139717. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  139718. */
  139719. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  139720. /**
  139721. * Clean all associated resources
  139722. */
  139723. dispose(): void;
  139724. /**
  139725. * Converts the reflection probe information to a readable string for debug purpose.
  139726. * @param fullDetails Supports for multiple levels of logging within scene loading
  139727. * @returns the human readable reflection probe info
  139728. */
  139729. toString(fullDetails?: boolean): string;
  139730. /**
  139731. * Get the class name of the relfection probe.
  139732. * @returns "ReflectionProbe"
  139733. */
  139734. getClassName(): string;
  139735. /**
  139736. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  139737. * @returns The JSON representation of the texture
  139738. */
  139739. serialize(): any;
  139740. /**
  139741. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  139742. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  139743. * @param scene Define the scene the parsed reflection probe should be instantiated in
  139744. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  139745. * @returns The parsed reflection probe if successful
  139746. */
  139747. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  139748. }
  139749. }
  139750. declare module BABYLON {
  139751. /** @hidden */
  139752. export var _BabylonLoaderRegistered: boolean;
  139753. /**
  139754. * Helps setting up some configuration for the babylon file loader.
  139755. */
  139756. export class BabylonFileLoaderConfiguration {
  139757. /**
  139758. * The loader does not allow injecting custom physix engine into the plugins.
  139759. * Unfortunately in ES6, we need to manually inject them into the plugin.
  139760. * So you could set this variable to your engine import to make it work.
  139761. */
  139762. static LoaderInjectedPhysicsEngine: any;
  139763. }
  139764. }
  139765. declare module BABYLON {
  139766. /**
  139767. * The Physically based simple base material of BJS.
  139768. *
  139769. * This enables better naming and convention enforcements on top of the pbrMaterial.
  139770. * It is used as the base class for both the specGloss and metalRough conventions.
  139771. */
  139772. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  139773. /**
  139774. * Number of Simultaneous lights allowed on the material.
  139775. */
  139776. maxSimultaneousLights: number;
  139777. /**
  139778. * If sets to true, disables all the lights affecting the material.
  139779. */
  139780. disableLighting: boolean;
  139781. /**
  139782. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  139783. */
  139784. environmentTexture: BaseTexture;
  139785. /**
  139786. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  139787. */
  139788. invertNormalMapX: boolean;
  139789. /**
  139790. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  139791. */
  139792. invertNormalMapY: boolean;
  139793. /**
  139794. * Normal map used in the model.
  139795. */
  139796. normalTexture: BaseTexture;
  139797. /**
  139798. * Emissivie color used to self-illuminate the model.
  139799. */
  139800. emissiveColor: Color3;
  139801. /**
  139802. * Emissivie texture used to self-illuminate the model.
  139803. */
  139804. emissiveTexture: BaseTexture;
  139805. /**
  139806. * Occlusion Channel Strenght.
  139807. */
  139808. occlusionStrength: number;
  139809. /**
  139810. * Occlusion Texture of the material (adding extra occlusion effects).
  139811. */
  139812. occlusionTexture: BaseTexture;
  139813. /**
  139814. * Defines the alpha limits in alpha test mode.
  139815. */
  139816. alphaCutOff: number;
  139817. /**
  139818. * Gets the current double sided mode.
  139819. */
  139820. get doubleSided(): boolean;
  139821. /**
  139822. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  139823. */
  139824. set doubleSided(value: boolean);
  139825. /**
  139826. * Stores the pre-calculated light information of a mesh in a texture.
  139827. */
  139828. lightmapTexture: BaseTexture;
  139829. /**
  139830. * If true, the light map contains occlusion information instead of lighting info.
  139831. */
  139832. useLightmapAsShadowmap: boolean;
  139833. /**
  139834. * Instantiates a new PBRMaterial instance.
  139835. *
  139836. * @param name The material name
  139837. * @param scene The scene the material will be use in.
  139838. */
  139839. constructor(name: string, scene: Scene);
  139840. getClassName(): string;
  139841. }
  139842. }
  139843. declare module BABYLON {
  139844. /**
  139845. * The PBR material of BJS following the metal roughness convention.
  139846. *
  139847. * This fits to the PBR convention in the GLTF definition:
  139848. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  139849. */
  139850. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  139851. /**
  139852. * The base color has two different interpretations depending on the value of metalness.
  139853. * When the material is a metal, the base color is the specific measured reflectance value
  139854. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  139855. * of the material.
  139856. */
  139857. baseColor: Color3;
  139858. /**
  139859. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  139860. * well as opacity information in the alpha channel.
  139861. */
  139862. baseTexture: BaseTexture;
  139863. /**
  139864. * Specifies the metallic scalar value of the material.
  139865. * Can also be used to scale the metalness values of the metallic texture.
  139866. */
  139867. metallic: number;
  139868. /**
  139869. * Specifies the roughness scalar value of the material.
  139870. * Can also be used to scale the roughness values of the metallic texture.
  139871. */
  139872. roughness: number;
  139873. /**
  139874. * Texture containing both the metallic value in the B channel and the
  139875. * roughness value in the G channel to keep better precision.
  139876. */
  139877. metallicRoughnessTexture: BaseTexture;
  139878. /**
  139879. * Instantiates a new PBRMetalRoughnessMaterial instance.
  139880. *
  139881. * @param name The material name
  139882. * @param scene The scene the material will be use in.
  139883. */
  139884. constructor(name: string, scene: Scene);
  139885. /**
  139886. * Return the currrent class name of the material.
  139887. */
  139888. getClassName(): string;
  139889. /**
  139890. * Makes a duplicate of the current material.
  139891. * @param name - name to use for the new material.
  139892. */
  139893. clone(name: string): PBRMetallicRoughnessMaterial;
  139894. /**
  139895. * Serialize the material to a parsable JSON object.
  139896. */
  139897. serialize(): any;
  139898. /**
  139899. * Parses a JSON object correponding to the serialize function.
  139900. */
  139901. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  139902. }
  139903. }
  139904. declare module BABYLON {
  139905. /**
  139906. * The PBR material of BJS following the specular glossiness convention.
  139907. *
  139908. * This fits to the PBR convention in the GLTF definition:
  139909. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  139910. */
  139911. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  139912. /**
  139913. * Specifies the diffuse color of the material.
  139914. */
  139915. diffuseColor: Color3;
  139916. /**
  139917. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  139918. * channel.
  139919. */
  139920. diffuseTexture: BaseTexture;
  139921. /**
  139922. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  139923. */
  139924. specularColor: Color3;
  139925. /**
  139926. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  139927. */
  139928. glossiness: number;
  139929. /**
  139930. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  139931. */
  139932. specularGlossinessTexture: BaseTexture;
  139933. /**
  139934. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  139935. *
  139936. * @param name The material name
  139937. * @param scene The scene the material will be use in.
  139938. */
  139939. constructor(name: string, scene: Scene);
  139940. /**
  139941. * Return the currrent class name of the material.
  139942. */
  139943. getClassName(): string;
  139944. /**
  139945. * Makes a duplicate of the current material.
  139946. * @param name - name to use for the new material.
  139947. */
  139948. clone(name: string): PBRSpecularGlossinessMaterial;
  139949. /**
  139950. * Serialize the material to a parsable JSON object.
  139951. */
  139952. serialize(): any;
  139953. /**
  139954. * Parses a JSON object correponding to the serialize function.
  139955. */
  139956. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  139957. }
  139958. }
  139959. declare module BABYLON {
  139960. /**
  139961. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  139962. * It can help converting any input color in a desired output one. This can then be used to create effects
  139963. * from sepia, black and white to sixties or futuristic rendering...
  139964. *
  139965. * The only supported format is currently 3dl.
  139966. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  139967. */
  139968. export class ColorGradingTexture extends BaseTexture {
  139969. /**
  139970. * The texture URL.
  139971. */
  139972. url: string;
  139973. /**
  139974. * Empty line regex stored for GC.
  139975. */
  139976. private static _noneEmptyLineRegex;
  139977. private _textureMatrix;
  139978. private _onLoad;
  139979. /**
  139980. * Instantiates a ColorGradingTexture from the following parameters.
  139981. *
  139982. * @param url The location of the color gradind data (currently only supporting 3dl)
  139983. * @param sceneOrEngine The scene or engine the texture will be used in
  139984. * @param onLoad defines a callback triggered when the texture has been loaded
  139985. */
  139986. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  139987. /**
  139988. * Fires the onload event from the constructor if requested.
  139989. */
  139990. private _triggerOnLoad;
  139991. /**
  139992. * Returns the texture matrix used in most of the material.
  139993. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  139994. */
  139995. getTextureMatrix(): Matrix;
  139996. /**
  139997. * Occurs when the file being loaded is a .3dl LUT file.
  139998. */
  139999. private load3dlTexture;
  140000. /**
  140001. * Starts the loading process of the texture.
  140002. */
  140003. private loadTexture;
  140004. /**
  140005. * Clones the color gradind texture.
  140006. */
  140007. clone(): ColorGradingTexture;
  140008. /**
  140009. * Called during delayed load for textures.
  140010. */
  140011. delayLoad(): void;
  140012. /**
  140013. * Parses a color grading texture serialized by Babylon.
  140014. * @param parsedTexture The texture information being parsedTexture
  140015. * @param scene The scene to load the texture in
  140016. * @param rootUrl The root url of the data assets to load
  140017. * @return A color gradind texture
  140018. */
  140019. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  140020. /**
  140021. * Serializes the LUT texture to json format.
  140022. */
  140023. serialize(): any;
  140024. }
  140025. }
  140026. declare module BABYLON {
  140027. /**
  140028. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  140029. */
  140030. export class EquiRectangularCubeTexture extends BaseTexture {
  140031. /** The six faces of the cube. */
  140032. private static _FacesMapping;
  140033. private _noMipmap;
  140034. private _onLoad;
  140035. private _onError;
  140036. /** The size of the cubemap. */
  140037. private _size;
  140038. /** The buffer of the image. */
  140039. private _buffer;
  140040. /** The width of the input image. */
  140041. private _width;
  140042. /** The height of the input image. */
  140043. private _height;
  140044. /** The URL to the image. */
  140045. url: string;
  140046. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  140047. coordinatesMode: number;
  140048. /**
  140049. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  140050. * @param url The location of the image
  140051. * @param scene The scene the texture will be used in
  140052. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140053. * @param noMipmap Forces to not generate the mipmap if true
  140054. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140055. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140056. * @param onLoad — defines a callback called when texture is loaded
  140057. * @param onError — defines a callback called if there is an error
  140058. */
  140059. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  140060. /**
  140061. * Load the image data, by putting the image on a canvas and extracting its buffer.
  140062. */
  140063. private loadImage;
  140064. /**
  140065. * Convert the image buffer into a cubemap and create a CubeTexture.
  140066. */
  140067. private loadTexture;
  140068. /**
  140069. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  140070. * @param buffer The ArrayBuffer that should be converted.
  140071. * @returns The buffer as Float32Array.
  140072. */
  140073. private getFloat32ArrayFromArrayBuffer;
  140074. /**
  140075. * Get the current class name of the texture useful for serialization or dynamic coding.
  140076. * @returns "EquiRectangularCubeTexture"
  140077. */
  140078. getClassName(): string;
  140079. /**
  140080. * Create a clone of the current EquiRectangularCubeTexture and return it.
  140081. * @returns A clone of the current EquiRectangularCubeTexture.
  140082. */
  140083. clone(): EquiRectangularCubeTexture;
  140084. }
  140085. }
  140086. declare module BABYLON {
  140087. /**
  140088. * Defines the options related to the creation of an HtmlElementTexture
  140089. */
  140090. export interface IHtmlElementTextureOptions {
  140091. /**
  140092. * Defines wether mip maps should be created or not.
  140093. */
  140094. generateMipMaps?: boolean;
  140095. /**
  140096. * Defines the sampling mode of the texture.
  140097. */
  140098. samplingMode?: number;
  140099. /**
  140100. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  140101. */
  140102. engine: Nullable<ThinEngine>;
  140103. /**
  140104. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  140105. */
  140106. scene: Nullable<Scene>;
  140107. }
  140108. /**
  140109. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  140110. * To be as efficient as possible depending on your constraints nothing aside the first upload
  140111. * is automatically managed.
  140112. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  140113. * in your application.
  140114. *
  140115. * As the update is not automatic, you need to call them manually.
  140116. */
  140117. export class HtmlElementTexture extends BaseTexture {
  140118. /**
  140119. * The texture URL.
  140120. */
  140121. element: HTMLVideoElement | HTMLCanvasElement;
  140122. private static readonly DefaultOptions;
  140123. private _textureMatrix;
  140124. private _isVideo;
  140125. private _generateMipMaps;
  140126. private _samplingMode;
  140127. /**
  140128. * Instantiates a HtmlElementTexture from the following parameters.
  140129. *
  140130. * @param name Defines the name of the texture
  140131. * @param element Defines the video or canvas the texture is filled with
  140132. * @param options Defines the other none mandatory texture creation options
  140133. */
  140134. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  140135. private _createInternalTexture;
  140136. /**
  140137. * Returns the texture matrix used in most of the material.
  140138. */
  140139. getTextureMatrix(): Matrix;
  140140. /**
  140141. * Updates the content of the texture.
  140142. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  140143. */
  140144. update(invertY?: Nullable<boolean>): void;
  140145. }
  140146. }
  140147. declare module BABYLON {
  140148. /**
  140149. * Based on jsTGALoader - Javascript loader for TGA file
  140150. * By Vincent Thibault
  140151. * @see http://blog.robrowser.com/javascript-tga-loader.html
  140152. */
  140153. export class TGATools {
  140154. private static _TYPE_INDEXED;
  140155. private static _TYPE_RGB;
  140156. private static _TYPE_GREY;
  140157. private static _TYPE_RLE_INDEXED;
  140158. private static _TYPE_RLE_RGB;
  140159. private static _TYPE_RLE_GREY;
  140160. private static _ORIGIN_MASK;
  140161. private static _ORIGIN_SHIFT;
  140162. private static _ORIGIN_BL;
  140163. private static _ORIGIN_BR;
  140164. private static _ORIGIN_UL;
  140165. private static _ORIGIN_UR;
  140166. /**
  140167. * Gets the header of a TGA file
  140168. * @param data defines the TGA data
  140169. * @returns the header
  140170. */
  140171. static GetTGAHeader(data: Uint8Array): any;
  140172. /**
  140173. * Uploads TGA content to a Babylon Texture
  140174. * @hidden
  140175. */
  140176. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  140177. /** @hidden */
  140178. 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;
  140179. /** @hidden */
  140180. 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;
  140181. /** @hidden */
  140182. 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;
  140183. /** @hidden */
  140184. 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;
  140185. /** @hidden */
  140186. 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;
  140187. /** @hidden */
  140188. 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;
  140189. }
  140190. }
  140191. declare module BABYLON {
  140192. /**
  140193. * Implementation of the TGA Texture Loader.
  140194. * @hidden
  140195. */
  140196. export class _TGATextureLoader implements IInternalTextureLoader {
  140197. /**
  140198. * Defines wether the loader supports cascade loading the different faces.
  140199. */
  140200. readonly supportCascades: boolean;
  140201. /**
  140202. * This returns if the loader support the current file information.
  140203. * @param extension defines the file extension of the file being loaded
  140204. * @returns true if the loader can load the specified file
  140205. */
  140206. canLoad(extension: string): boolean;
  140207. /**
  140208. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140209. * @param data contains the texture data
  140210. * @param texture defines the BabylonJS internal texture
  140211. * @param createPolynomials will be true if polynomials have been requested
  140212. * @param onLoad defines the callback to trigger once the texture is ready
  140213. * @param onError defines the callback to trigger in case of error
  140214. */
  140215. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140216. /**
  140217. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140218. * @param data contains the texture data
  140219. * @param texture defines the BabylonJS internal texture
  140220. * @param callback defines the method to call once ready to upload
  140221. */
  140222. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140223. }
  140224. }
  140225. declare module BABYLON {
  140226. /**
  140227. * Info about the .basis files
  140228. */
  140229. class BasisFileInfo {
  140230. /**
  140231. * If the file has alpha
  140232. */
  140233. hasAlpha: boolean;
  140234. /**
  140235. * Info about each image of the basis file
  140236. */
  140237. images: Array<{
  140238. levels: Array<{
  140239. width: number;
  140240. height: number;
  140241. transcodedPixels: ArrayBufferView;
  140242. }>;
  140243. }>;
  140244. }
  140245. /**
  140246. * Result of transcoding a basis file
  140247. */
  140248. class TranscodeResult {
  140249. /**
  140250. * Info about the .basis file
  140251. */
  140252. fileInfo: BasisFileInfo;
  140253. /**
  140254. * Format to use when loading the file
  140255. */
  140256. format: number;
  140257. }
  140258. /**
  140259. * Configuration options for the Basis transcoder
  140260. */
  140261. export class BasisTranscodeConfiguration {
  140262. /**
  140263. * Supported compression formats used to determine the supported output format of the transcoder
  140264. */
  140265. supportedCompressionFormats?: {
  140266. /**
  140267. * etc1 compression format
  140268. */
  140269. etc1?: boolean;
  140270. /**
  140271. * s3tc compression format
  140272. */
  140273. s3tc?: boolean;
  140274. /**
  140275. * pvrtc compression format
  140276. */
  140277. pvrtc?: boolean;
  140278. /**
  140279. * etc2 compression format
  140280. */
  140281. etc2?: boolean;
  140282. };
  140283. /**
  140284. * If mipmap levels should be loaded for transcoded images (Default: true)
  140285. */
  140286. loadMipmapLevels?: boolean;
  140287. /**
  140288. * Index of a single image to load (Default: all images)
  140289. */
  140290. loadSingleImage?: number;
  140291. }
  140292. /**
  140293. * Used to load .Basis files
  140294. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  140295. */
  140296. export class BasisTools {
  140297. private static _IgnoreSupportedFormats;
  140298. /**
  140299. * URL to use when loading the basis transcoder
  140300. */
  140301. static JSModuleURL: string;
  140302. /**
  140303. * URL to use when loading the wasm module for the transcoder
  140304. */
  140305. static WasmModuleURL: string;
  140306. /**
  140307. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  140308. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  140309. * @returns internal format corresponding to the Basis format
  140310. */
  140311. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  140312. private static _WorkerPromise;
  140313. private static _Worker;
  140314. private static _actionId;
  140315. private static _CreateWorkerAsync;
  140316. /**
  140317. * Transcodes a loaded image file to compressed pixel data
  140318. * @param data image data to transcode
  140319. * @param config configuration options for the transcoding
  140320. * @returns a promise resulting in the transcoded image
  140321. */
  140322. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  140323. /**
  140324. * Loads a texture from the transcode result
  140325. * @param texture texture load to
  140326. * @param transcodeResult the result of transcoding the basis file to load from
  140327. */
  140328. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  140329. }
  140330. }
  140331. declare module BABYLON {
  140332. /**
  140333. * Loader for .basis file format
  140334. */
  140335. export class _BasisTextureLoader implements IInternalTextureLoader {
  140336. /**
  140337. * Defines whether the loader supports cascade loading the different faces.
  140338. */
  140339. readonly supportCascades: boolean;
  140340. /**
  140341. * This returns if the loader support the current file information.
  140342. * @param extension defines the file extension of the file being loaded
  140343. * @returns true if the loader can load the specified file
  140344. */
  140345. canLoad(extension: string): boolean;
  140346. /**
  140347. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140348. * @param data contains the texture data
  140349. * @param texture defines the BabylonJS internal texture
  140350. * @param createPolynomials will be true if polynomials have been requested
  140351. * @param onLoad defines the callback to trigger once the texture is ready
  140352. * @param onError defines the callback to trigger in case of error
  140353. */
  140354. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140355. /**
  140356. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140357. * @param data contains the texture data
  140358. * @param texture defines the BabylonJS internal texture
  140359. * @param callback defines the method to call once ready to upload
  140360. */
  140361. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140362. }
  140363. }
  140364. declare module BABYLON {
  140365. /**
  140366. * Defines the basic options interface of a TexturePacker Frame
  140367. */
  140368. export interface ITexturePackerFrame {
  140369. /**
  140370. * The frame ID
  140371. */
  140372. id: number;
  140373. /**
  140374. * The frames Scale
  140375. */
  140376. scale: Vector2;
  140377. /**
  140378. * The Frames offset
  140379. */
  140380. offset: Vector2;
  140381. }
  140382. /**
  140383. * This is a support class for frame Data on texture packer sets.
  140384. */
  140385. export class TexturePackerFrame implements ITexturePackerFrame {
  140386. /**
  140387. * The frame ID
  140388. */
  140389. id: number;
  140390. /**
  140391. * The frames Scale
  140392. */
  140393. scale: Vector2;
  140394. /**
  140395. * The Frames offset
  140396. */
  140397. offset: Vector2;
  140398. /**
  140399. * Initializes a texture package frame.
  140400. * @param id The numerical frame identifier
  140401. * @param scale Scalar Vector2 for UV frame
  140402. * @param offset Vector2 for the frame position in UV units.
  140403. * @returns TexturePackerFrame
  140404. */
  140405. constructor(id: number, scale: Vector2, offset: Vector2);
  140406. }
  140407. }
  140408. declare module BABYLON {
  140409. /**
  140410. * Defines the basic options interface of a TexturePacker
  140411. */
  140412. export interface ITexturePackerOptions {
  140413. /**
  140414. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  140415. */
  140416. map?: string[];
  140417. /**
  140418. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140419. */
  140420. uvsIn?: string;
  140421. /**
  140422. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  140423. */
  140424. uvsOut?: string;
  140425. /**
  140426. * number representing the layout style. Defaults to LAYOUT_STRIP
  140427. */
  140428. layout?: number;
  140429. /**
  140430. * number of columns if using custom column count layout(2). This defaults to 4.
  140431. */
  140432. colnum?: number;
  140433. /**
  140434. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  140435. */
  140436. updateInputMeshes?: boolean;
  140437. /**
  140438. * boolean flag to dispose all the source textures. Defaults to true.
  140439. */
  140440. disposeSources?: boolean;
  140441. /**
  140442. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  140443. */
  140444. fillBlanks?: boolean;
  140445. /**
  140446. * string value representing the context fill style color. Defaults to 'black'.
  140447. */
  140448. customFillColor?: string;
  140449. /**
  140450. * Width and Height Value of each Frame in the TexturePacker Sets
  140451. */
  140452. frameSize?: number;
  140453. /**
  140454. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  140455. */
  140456. paddingRatio?: number;
  140457. /**
  140458. * Number that declares the fill method for the padding gutter.
  140459. */
  140460. paddingMode?: number;
  140461. /**
  140462. * If in SUBUV_COLOR padding mode what color to use.
  140463. */
  140464. paddingColor?: Color3 | Color4;
  140465. }
  140466. /**
  140467. * Defines the basic interface of a TexturePacker JSON File
  140468. */
  140469. export interface ITexturePackerJSON {
  140470. /**
  140471. * The frame ID
  140472. */
  140473. name: string;
  140474. /**
  140475. * The base64 channel data
  140476. */
  140477. sets: any;
  140478. /**
  140479. * The options of the Packer
  140480. */
  140481. options: ITexturePackerOptions;
  140482. /**
  140483. * The frame data of the Packer
  140484. */
  140485. frames: Array<number>;
  140486. }
  140487. /**
  140488. * This is a support class that generates a series of packed texture sets.
  140489. * @see https://doc.babylonjs.com/babylon101/materials
  140490. */
  140491. export class TexturePacker {
  140492. /** Packer Layout Constant 0 */
  140493. static readonly LAYOUT_STRIP: number;
  140494. /** Packer Layout Constant 1 */
  140495. static readonly LAYOUT_POWER2: number;
  140496. /** Packer Layout Constant 2 */
  140497. static readonly LAYOUT_COLNUM: number;
  140498. /** Packer Layout Constant 0 */
  140499. static readonly SUBUV_WRAP: number;
  140500. /** Packer Layout Constant 1 */
  140501. static readonly SUBUV_EXTEND: number;
  140502. /** Packer Layout Constant 2 */
  140503. static readonly SUBUV_COLOR: number;
  140504. /** The Name of the Texture Package */
  140505. name: string;
  140506. /** The scene scope of the TexturePacker */
  140507. scene: Scene;
  140508. /** The Meshes to target */
  140509. meshes: AbstractMesh[];
  140510. /** Arguments passed with the Constructor */
  140511. options: ITexturePackerOptions;
  140512. /** The promise that is started upon initialization */
  140513. promise: Nullable<Promise<TexturePacker | string>>;
  140514. /** The Container object for the channel sets that are generated */
  140515. sets: object;
  140516. /** The Container array for the frames that are generated */
  140517. frames: TexturePackerFrame[];
  140518. /** The expected number of textures the system is parsing. */
  140519. private _expecting;
  140520. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  140521. private _paddingValue;
  140522. /**
  140523. * Initializes a texture package series from an array of meshes or a single mesh.
  140524. * @param name The name of the package
  140525. * @param meshes The target meshes to compose the package from
  140526. * @param options The arguments that texture packer should follow while building.
  140527. * @param scene The scene which the textures are scoped to.
  140528. * @returns TexturePacker
  140529. */
  140530. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  140531. /**
  140532. * Starts the package process
  140533. * @param resolve The promises resolution function
  140534. * @returns TexturePacker
  140535. */
  140536. private _createFrames;
  140537. /**
  140538. * Calculates the Size of the Channel Sets
  140539. * @returns Vector2
  140540. */
  140541. private _calculateSize;
  140542. /**
  140543. * Calculates the UV data for the frames.
  140544. * @param baseSize the base frameSize
  140545. * @param padding the base frame padding
  140546. * @param dtSize size of the Dynamic Texture for that channel
  140547. * @param dtUnits is 1/dtSize
  140548. * @param update flag to update the input meshes
  140549. */
  140550. private _calculateMeshUVFrames;
  140551. /**
  140552. * Calculates the frames Offset.
  140553. * @param index of the frame
  140554. * @returns Vector2
  140555. */
  140556. private _getFrameOffset;
  140557. /**
  140558. * Updates a Mesh to the frame data
  140559. * @param mesh that is the target
  140560. * @param frameID or the frame index
  140561. */
  140562. private _updateMeshUV;
  140563. /**
  140564. * Updates a Meshes materials to use the texture packer channels
  140565. * @param m is the mesh to target
  140566. * @param force all channels on the packer to be set.
  140567. */
  140568. private _updateTextureReferences;
  140569. /**
  140570. * Public method to set a Mesh to a frame
  140571. * @param m that is the target
  140572. * @param frameID or the frame index
  140573. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  140574. */
  140575. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  140576. /**
  140577. * Starts the async promise to compile the texture packer.
  140578. * @returns Promise<void>
  140579. */
  140580. processAsync(): Promise<void>;
  140581. /**
  140582. * Disposes all textures associated with this packer
  140583. */
  140584. dispose(): void;
  140585. /**
  140586. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  140587. * @param imageType is the image type to use.
  140588. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  140589. */
  140590. download(imageType?: string, quality?: number): void;
  140591. /**
  140592. * Public method to load a texturePacker JSON file.
  140593. * @param data of the JSON file in string format.
  140594. */
  140595. updateFromJSON(data: string): void;
  140596. }
  140597. }
  140598. declare module BABYLON {
  140599. /**
  140600. * 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.
  140601. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140602. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140603. */
  140604. export class CustomProceduralTexture extends ProceduralTexture {
  140605. private _animate;
  140606. private _time;
  140607. private _config;
  140608. private _texturePath;
  140609. /**
  140610. * Instantiates a new Custom Procedural Texture.
  140611. * 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.
  140612. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  140613. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  140614. * @param name Define the name of the texture
  140615. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  140616. * @param size Define the size of the texture to create
  140617. * @param scene Define the scene the texture belongs to
  140618. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  140619. * @param generateMipMaps Define if the texture should creates mip maps or not
  140620. */
  140621. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140622. private _loadJson;
  140623. /**
  140624. * Is the texture ready to be used ? (rendered at least once)
  140625. * @returns true if ready, otherwise, false.
  140626. */
  140627. isReady(): boolean;
  140628. /**
  140629. * Render the texture to its associated render target.
  140630. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  140631. */
  140632. render(useCameraPostProcess?: boolean): void;
  140633. /**
  140634. * Update the list of dependant textures samplers in the shader.
  140635. */
  140636. updateTextures(): void;
  140637. /**
  140638. * Update the uniform values of the procedural texture in the shader.
  140639. */
  140640. updateShaderUniforms(): void;
  140641. /**
  140642. * Define if the texture animates or not.
  140643. */
  140644. get animate(): boolean;
  140645. set animate(value: boolean);
  140646. }
  140647. }
  140648. declare module BABYLON {
  140649. /** @hidden */
  140650. export var noisePixelShader: {
  140651. name: string;
  140652. shader: string;
  140653. };
  140654. }
  140655. declare module BABYLON {
  140656. /**
  140657. * Class used to generate noise procedural textures
  140658. */
  140659. export class NoiseProceduralTexture extends ProceduralTexture {
  140660. private _time;
  140661. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  140662. brightness: number;
  140663. /** Defines the number of octaves to process */
  140664. octaves: number;
  140665. /** Defines the level of persistence (0.8 by default) */
  140666. persistence: number;
  140667. /** Gets or sets animation speed factor (default is 1) */
  140668. animationSpeedFactor: number;
  140669. /**
  140670. * Creates a new NoiseProceduralTexture
  140671. * @param name defines the name fo the texture
  140672. * @param size defines the size of the texture (default is 256)
  140673. * @param scene defines the hosting scene
  140674. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  140675. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  140676. */
  140677. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  140678. private _updateShaderUniforms;
  140679. protected _getDefines(): string;
  140680. /** Generate the current state of the procedural texture */
  140681. render(useCameraPostProcess?: boolean): void;
  140682. /**
  140683. * Serializes this noise procedural texture
  140684. * @returns a serialized noise procedural texture object
  140685. */
  140686. serialize(): any;
  140687. /**
  140688. * Clone the texture.
  140689. * @returns the cloned texture
  140690. */
  140691. clone(): NoiseProceduralTexture;
  140692. /**
  140693. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  140694. * @param parsedTexture defines parsed texture data
  140695. * @param scene defines the current scene
  140696. * @param rootUrl defines the root URL containing noise procedural texture information
  140697. * @returns a parsed NoiseProceduralTexture
  140698. */
  140699. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  140700. }
  140701. }
  140702. declare module BABYLON {
  140703. /**
  140704. * Raw cube texture where the raw buffers are passed in
  140705. */
  140706. export class RawCubeTexture extends CubeTexture {
  140707. /**
  140708. * Creates a cube texture where the raw buffers are passed in.
  140709. * @param scene defines the scene the texture is attached to
  140710. * @param data defines the array of data to use to create each face
  140711. * @param size defines the size of the textures
  140712. * @param format defines the format of the data
  140713. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  140714. * @param generateMipMaps defines if the engine should generate the mip levels
  140715. * @param invertY defines if data must be stored with Y axis inverted
  140716. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  140717. * @param compression defines the compression used (null by default)
  140718. */
  140719. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  140720. /**
  140721. * Updates the raw cube texture.
  140722. * @param data defines the data to store
  140723. * @param format defines the data format
  140724. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140725. * @param invertY defines if data must be stored with Y axis inverted
  140726. * @param compression defines the compression used (null by default)
  140727. * @param level defines which level of the texture to update
  140728. */
  140729. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  140730. /**
  140731. * Updates a raw cube texture with RGBD encoded data.
  140732. * @param data defines the array of data [mipmap][face] to use to create each face
  140733. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  140734. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  140735. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  140736. * @returns a promsie that resolves when the operation is complete
  140737. */
  140738. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  140739. /**
  140740. * Clones the raw cube texture.
  140741. * @return a new cube texture
  140742. */
  140743. clone(): CubeTexture;
  140744. /** @hidden */
  140745. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  140746. }
  140747. }
  140748. declare module BABYLON {
  140749. /**
  140750. * Class used to store 2D array textures containing user data
  140751. */
  140752. export class RawTexture2DArray extends Texture {
  140753. /** Gets or sets the texture format to use */
  140754. format: number;
  140755. /**
  140756. * Create a new RawTexture2DArray
  140757. * @param data defines the data of the texture
  140758. * @param width defines the width of the texture
  140759. * @param height defines the height of the texture
  140760. * @param depth defines the number of layers of the texture
  140761. * @param format defines the texture format to use
  140762. * @param scene defines the hosting scene
  140763. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140764. * @param invertY defines if texture must be stored with Y axis inverted
  140765. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140766. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140767. */
  140768. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140769. /** Gets or sets the texture format to use */
  140770. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140771. /**
  140772. * Update the texture with new data
  140773. * @param data defines the data to store in the texture
  140774. */
  140775. update(data: ArrayBufferView): void;
  140776. }
  140777. }
  140778. declare module BABYLON {
  140779. /**
  140780. * Class used to store 3D textures containing user data
  140781. */
  140782. export class RawTexture3D extends Texture {
  140783. /** Gets or sets the texture format to use */
  140784. format: number;
  140785. /**
  140786. * Create a new RawTexture3D
  140787. * @param data defines the data of the texture
  140788. * @param width defines the width of the texture
  140789. * @param height defines the height of the texture
  140790. * @param depth defines the depth of the texture
  140791. * @param format defines the texture format to use
  140792. * @param scene defines the hosting scene
  140793. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  140794. * @param invertY defines if texture must be stored with Y axis inverted
  140795. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140796. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  140797. */
  140798. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  140799. /** Gets or sets the texture format to use */
  140800. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  140801. /**
  140802. * Update the texture with new data
  140803. * @param data defines the data to store in the texture
  140804. */
  140805. update(data: ArrayBufferView): void;
  140806. }
  140807. }
  140808. declare module BABYLON {
  140809. /**
  140810. * Creates a refraction texture used by refraction channel of the standard material.
  140811. * It is like a mirror but to see through a material.
  140812. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140813. */
  140814. export class RefractionTexture extends RenderTargetTexture {
  140815. /**
  140816. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  140817. * 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.
  140818. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140819. */
  140820. refractionPlane: Plane;
  140821. /**
  140822. * Define how deep under the surface we should see.
  140823. */
  140824. depth: number;
  140825. /**
  140826. * Creates a refraction texture used by refraction channel of the standard material.
  140827. * It is like a mirror but to see through a material.
  140828. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  140829. * @param name Define the texture name
  140830. * @param size Define the size of the underlying texture
  140831. * @param scene Define the scene the refraction belongs to
  140832. * @param generateMipMaps Define if we need to generate mips level for the refraction
  140833. */
  140834. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  140835. /**
  140836. * Clone the refraction texture.
  140837. * @returns the cloned texture
  140838. */
  140839. clone(): RefractionTexture;
  140840. /**
  140841. * Serialize the texture to a JSON representation you could use in Parse later on
  140842. * @returns the serialized JSON representation
  140843. */
  140844. serialize(): any;
  140845. }
  140846. }
  140847. declare module BABYLON {
  140848. /**
  140849. * Block used to add support for vertex skinning (bones)
  140850. */
  140851. export class BonesBlock extends NodeMaterialBlock {
  140852. /**
  140853. * Creates a new BonesBlock
  140854. * @param name defines the block name
  140855. */
  140856. constructor(name: string);
  140857. /**
  140858. * Initialize the block and prepare the context for build
  140859. * @param state defines the state that will be used for the build
  140860. */
  140861. initialize(state: NodeMaterialBuildState): void;
  140862. /**
  140863. * Gets the current class name
  140864. * @returns the class name
  140865. */
  140866. getClassName(): string;
  140867. /**
  140868. * Gets the matrix indices input component
  140869. */
  140870. get matricesIndices(): NodeMaterialConnectionPoint;
  140871. /**
  140872. * Gets the matrix weights input component
  140873. */
  140874. get matricesWeights(): NodeMaterialConnectionPoint;
  140875. /**
  140876. * Gets the extra matrix indices input component
  140877. */
  140878. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  140879. /**
  140880. * Gets the extra matrix weights input component
  140881. */
  140882. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  140883. /**
  140884. * Gets the world input component
  140885. */
  140886. get world(): NodeMaterialConnectionPoint;
  140887. /**
  140888. * Gets the output component
  140889. */
  140890. get output(): NodeMaterialConnectionPoint;
  140891. autoConfigure(material: NodeMaterial): void;
  140892. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  140893. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140894. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140895. protected _buildBlock(state: NodeMaterialBuildState): this;
  140896. }
  140897. }
  140898. declare module BABYLON {
  140899. /**
  140900. * Block used to add support for instances
  140901. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  140902. */
  140903. export class InstancesBlock extends NodeMaterialBlock {
  140904. /**
  140905. * Creates a new InstancesBlock
  140906. * @param name defines the block name
  140907. */
  140908. constructor(name: string);
  140909. /**
  140910. * Gets the current class name
  140911. * @returns the class name
  140912. */
  140913. getClassName(): string;
  140914. /**
  140915. * Gets the first world row input component
  140916. */
  140917. get world0(): NodeMaterialConnectionPoint;
  140918. /**
  140919. * Gets the second world row input component
  140920. */
  140921. get world1(): NodeMaterialConnectionPoint;
  140922. /**
  140923. * Gets the third world row input component
  140924. */
  140925. get world2(): NodeMaterialConnectionPoint;
  140926. /**
  140927. * Gets the forth world row input component
  140928. */
  140929. get world3(): NodeMaterialConnectionPoint;
  140930. /**
  140931. * Gets the world input component
  140932. */
  140933. get world(): NodeMaterialConnectionPoint;
  140934. /**
  140935. * Gets the output component
  140936. */
  140937. get output(): NodeMaterialConnectionPoint;
  140938. /**
  140939. * Gets the isntanceID component
  140940. */
  140941. get instanceID(): NodeMaterialConnectionPoint;
  140942. autoConfigure(material: NodeMaterial): void;
  140943. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  140944. protected _buildBlock(state: NodeMaterialBuildState): this;
  140945. }
  140946. }
  140947. declare module BABYLON {
  140948. /**
  140949. * Block used to add morph targets support to vertex shader
  140950. */
  140951. export class MorphTargetsBlock extends NodeMaterialBlock {
  140952. private _repeatableContentAnchor;
  140953. /**
  140954. * Create a new MorphTargetsBlock
  140955. * @param name defines the block name
  140956. */
  140957. constructor(name: string);
  140958. /**
  140959. * Gets the current class name
  140960. * @returns the class name
  140961. */
  140962. getClassName(): string;
  140963. /**
  140964. * Gets the position input component
  140965. */
  140966. get position(): NodeMaterialConnectionPoint;
  140967. /**
  140968. * Gets the normal input component
  140969. */
  140970. get normal(): NodeMaterialConnectionPoint;
  140971. /**
  140972. * Gets the tangent input component
  140973. */
  140974. get tangent(): NodeMaterialConnectionPoint;
  140975. /**
  140976. * Gets the tangent input component
  140977. */
  140978. get uv(): NodeMaterialConnectionPoint;
  140979. /**
  140980. * Gets the position output component
  140981. */
  140982. get positionOutput(): NodeMaterialConnectionPoint;
  140983. /**
  140984. * Gets the normal output component
  140985. */
  140986. get normalOutput(): NodeMaterialConnectionPoint;
  140987. /**
  140988. * Gets the tangent output component
  140989. */
  140990. get tangentOutput(): NodeMaterialConnectionPoint;
  140991. /**
  140992. * Gets the tangent output component
  140993. */
  140994. get uvOutput(): NodeMaterialConnectionPoint;
  140995. initialize(state: NodeMaterialBuildState): void;
  140996. autoConfigure(material: NodeMaterial): void;
  140997. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140998. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140999. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  141000. protected _buildBlock(state: NodeMaterialBuildState): this;
  141001. }
  141002. }
  141003. declare module BABYLON {
  141004. /**
  141005. * Block used to get data information from a light
  141006. */
  141007. export class LightInformationBlock extends NodeMaterialBlock {
  141008. private _lightDataUniformName;
  141009. private _lightColorUniformName;
  141010. private _lightTypeDefineName;
  141011. /**
  141012. * Gets or sets the light associated with this block
  141013. */
  141014. light: Nullable<Light>;
  141015. /**
  141016. * Creates a new LightInformationBlock
  141017. * @param name defines the block name
  141018. */
  141019. constructor(name: string);
  141020. /**
  141021. * Gets the current class name
  141022. * @returns the class name
  141023. */
  141024. getClassName(): string;
  141025. /**
  141026. * Gets the world position input component
  141027. */
  141028. get worldPosition(): NodeMaterialConnectionPoint;
  141029. /**
  141030. * Gets the direction output component
  141031. */
  141032. get direction(): NodeMaterialConnectionPoint;
  141033. /**
  141034. * Gets the direction output component
  141035. */
  141036. get color(): NodeMaterialConnectionPoint;
  141037. /**
  141038. * Gets the direction output component
  141039. */
  141040. get intensity(): NodeMaterialConnectionPoint;
  141041. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141043. protected _buildBlock(state: NodeMaterialBuildState): this;
  141044. serialize(): any;
  141045. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141046. }
  141047. }
  141048. declare module BABYLON {
  141049. /**
  141050. * Block used to add image processing support to fragment shader
  141051. */
  141052. export class ImageProcessingBlock extends NodeMaterialBlock {
  141053. /**
  141054. * Create a new ImageProcessingBlock
  141055. * @param name defines the block name
  141056. */
  141057. constructor(name: string);
  141058. /**
  141059. * Gets the current class name
  141060. * @returns the class name
  141061. */
  141062. getClassName(): string;
  141063. /**
  141064. * Gets the color input component
  141065. */
  141066. get color(): NodeMaterialConnectionPoint;
  141067. /**
  141068. * Gets the output component
  141069. */
  141070. get output(): NodeMaterialConnectionPoint;
  141071. /**
  141072. * Initialize the block and prepare the context for build
  141073. * @param state defines the state that will be used for the build
  141074. */
  141075. initialize(state: NodeMaterialBuildState): void;
  141076. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  141077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141078. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141079. protected _buildBlock(state: NodeMaterialBuildState): this;
  141080. }
  141081. }
  141082. declare module BABYLON {
  141083. /**
  141084. * Block used to pertub normals based on a normal map
  141085. */
  141086. export class PerturbNormalBlock extends NodeMaterialBlock {
  141087. private _tangentSpaceParameterName;
  141088. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141089. invertX: boolean;
  141090. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  141091. invertY: boolean;
  141092. /**
  141093. * Create a new PerturbNormalBlock
  141094. * @param name defines the block name
  141095. */
  141096. constructor(name: string);
  141097. /**
  141098. * Gets the current class name
  141099. * @returns the class name
  141100. */
  141101. getClassName(): string;
  141102. /**
  141103. * Gets the world position input component
  141104. */
  141105. get worldPosition(): NodeMaterialConnectionPoint;
  141106. /**
  141107. * Gets the world normal input component
  141108. */
  141109. get worldNormal(): NodeMaterialConnectionPoint;
  141110. /**
  141111. * Gets the world tangent input component
  141112. */
  141113. get worldTangent(): NodeMaterialConnectionPoint;
  141114. /**
  141115. * Gets the uv input component
  141116. */
  141117. get uv(): NodeMaterialConnectionPoint;
  141118. /**
  141119. * Gets the normal map color input component
  141120. */
  141121. get normalMapColor(): NodeMaterialConnectionPoint;
  141122. /**
  141123. * Gets the strength input component
  141124. */
  141125. get strength(): NodeMaterialConnectionPoint;
  141126. /**
  141127. * Gets the output component
  141128. */
  141129. get output(): NodeMaterialConnectionPoint;
  141130. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141132. autoConfigure(material: NodeMaterial): void;
  141133. protected _buildBlock(state: NodeMaterialBuildState): this;
  141134. protected _dumpPropertiesCode(): string;
  141135. serialize(): any;
  141136. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141137. }
  141138. }
  141139. declare module BABYLON {
  141140. /**
  141141. * Block used to discard a pixel if a value is smaller than a cutoff
  141142. */
  141143. export class DiscardBlock extends NodeMaterialBlock {
  141144. /**
  141145. * Create a new DiscardBlock
  141146. * @param name defines the block name
  141147. */
  141148. constructor(name: string);
  141149. /**
  141150. * Gets the current class name
  141151. * @returns the class name
  141152. */
  141153. getClassName(): string;
  141154. /**
  141155. * Gets the color input component
  141156. */
  141157. get value(): NodeMaterialConnectionPoint;
  141158. /**
  141159. * Gets the cutoff input component
  141160. */
  141161. get cutoff(): NodeMaterialConnectionPoint;
  141162. protected _buildBlock(state: NodeMaterialBuildState): this;
  141163. }
  141164. }
  141165. declare module BABYLON {
  141166. /**
  141167. * Block used to test if the fragment shader is front facing
  141168. */
  141169. export class FrontFacingBlock extends NodeMaterialBlock {
  141170. /**
  141171. * Creates a new FrontFacingBlock
  141172. * @param name defines the block name
  141173. */
  141174. constructor(name: string);
  141175. /**
  141176. * Gets the current class name
  141177. * @returns the class name
  141178. */
  141179. getClassName(): string;
  141180. /**
  141181. * Gets the output component
  141182. */
  141183. get output(): NodeMaterialConnectionPoint;
  141184. protected _buildBlock(state: NodeMaterialBuildState): this;
  141185. }
  141186. }
  141187. declare module BABYLON {
  141188. /**
  141189. * Block used to get the derivative value on x and y of a given input
  141190. */
  141191. export class DerivativeBlock extends NodeMaterialBlock {
  141192. /**
  141193. * Create a new DerivativeBlock
  141194. * @param name defines the block name
  141195. */
  141196. constructor(name: string);
  141197. /**
  141198. * Gets the current class name
  141199. * @returns the class name
  141200. */
  141201. getClassName(): string;
  141202. /**
  141203. * Gets the input component
  141204. */
  141205. get input(): NodeMaterialConnectionPoint;
  141206. /**
  141207. * Gets the derivative output on x
  141208. */
  141209. get dx(): NodeMaterialConnectionPoint;
  141210. /**
  141211. * Gets the derivative output on y
  141212. */
  141213. get dy(): NodeMaterialConnectionPoint;
  141214. protected _buildBlock(state: NodeMaterialBuildState): this;
  141215. }
  141216. }
  141217. declare module BABYLON {
  141218. /**
  141219. * Block used to make gl_FragCoord available
  141220. */
  141221. export class FragCoordBlock extends NodeMaterialBlock {
  141222. /**
  141223. * Creates a new FragCoordBlock
  141224. * @param name defines the block name
  141225. */
  141226. constructor(name: string);
  141227. /**
  141228. * Gets the current class name
  141229. * @returns the class name
  141230. */
  141231. getClassName(): string;
  141232. /**
  141233. * Gets the xy component
  141234. */
  141235. get xy(): NodeMaterialConnectionPoint;
  141236. /**
  141237. * Gets the xyz component
  141238. */
  141239. get xyz(): NodeMaterialConnectionPoint;
  141240. /**
  141241. * Gets the xyzw component
  141242. */
  141243. get xyzw(): NodeMaterialConnectionPoint;
  141244. /**
  141245. * Gets the x component
  141246. */
  141247. get x(): NodeMaterialConnectionPoint;
  141248. /**
  141249. * Gets the y component
  141250. */
  141251. get y(): NodeMaterialConnectionPoint;
  141252. /**
  141253. * Gets the z component
  141254. */
  141255. get z(): NodeMaterialConnectionPoint;
  141256. /**
  141257. * Gets the w component
  141258. */
  141259. get output(): NodeMaterialConnectionPoint;
  141260. protected writeOutputs(state: NodeMaterialBuildState): string;
  141261. protected _buildBlock(state: NodeMaterialBuildState): this;
  141262. }
  141263. }
  141264. declare module BABYLON {
  141265. /**
  141266. * Block used to get the screen sizes
  141267. */
  141268. export class ScreenSizeBlock extends NodeMaterialBlock {
  141269. private _varName;
  141270. private _scene;
  141271. /**
  141272. * Creates a new ScreenSizeBlock
  141273. * @param name defines the block name
  141274. */
  141275. constructor(name: string);
  141276. /**
  141277. * Gets the current class name
  141278. * @returns the class name
  141279. */
  141280. getClassName(): string;
  141281. /**
  141282. * Gets the xy component
  141283. */
  141284. get xy(): NodeMaterialConnectionPoint;
  141285. /**
  141286. * Gets the x component
  141287. */
  141288. get x(): NodeMaterialConnectionPoint;
  141289. /**
  141290. * Gets the y component
  141291. */
  141292. get y(): NodeMaterialConnectionPoint;
  141293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141294. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  141295. protected _buildBlock(state: NodeMaterialBuildState): this;
  141296. }
  141297. }
  141298. declare module BABYLON {
  141299. /**
  141300. * Block used to add support for scene fog
  141301. */
  141302. export class FogBlock extends NodeMaterialBlock {
  141303. private _fogDistanceName;
  141304. private _fogParameters;
  141305. /**
  141306. * Create a new FogBlock
  141307. * @param name defines the block name
  141308. */
  141309. constructor(name: string);
  141310. /**
  141311. * Gets the current class name
  141312. * @returns the class name
  141313. */
  141314. getClassName(): string;
  141315. /**
  141316. * Gets the world position input component
  141317. */
  141318. get worldPosition(): NodeMaterialConnectionPoint;
  141319. /**
  141320. * Gets the view input component
  141321. */
  141322. get view(): NodeMaterialConnectionPoint;
  141323. /**
  141324. * Gets the color input component
  141325. */
  141326. get input(): NodeMaterialConnectionPoint;
  141327. /**
  141328. * Gets the fog color input component
  141329. */
  141330. get fogColor(): NodeMaterialConnectionPoint;
  141331. /**
  141332. * Gets the output component
  141333. */
  141334. get output(): NodeMaterialConnectionPoint;
  141335. autoConfigure(material: NodeMaterial): void;
  141336. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141338. protected _buildBlock(state: NodeMaterialBuildState): this;
  141339. }
  141340. }
  141341. declare module BABYLON {
  141342. /**
  141343. * Block used to add light in the fragment shader
  141344. */
  141345. export class LightBlock extends NodeMaterialBlock {
  141346. private _lightId;
  141347. /**
  141348. * Gets or sets the light associated with this block
  141349. */
  141350. light: Nullable<Light>;
  141351. /**
  141352. * Create a new LightBlock
  141353. * @param name defines the block name
  141354. */
  141355. constructor(name: string);
  141356. /**
  141357. * Gets the current class name
  141358. * @returns the class name
  141359. */
  141360. getClassName(): string;
  141361. /**
  141362. * Gets the world position input component
  141363. */
  141364. get worldPosition(): NodeMaterialConnectionPoint;
  141365. /**
  141366. * Gets the world normal input component
  141367. */
  141368. get worldNormal(): NodeMaterialConnectionPoint;
  141369. /**
  141370. * Gets the camera (or eye) position component
  141371. */
  141372. get cameraPosition(): NodeMaterialConnectionPoint;
  141373. /**
  141374. * Gets the glossiness component
  141375. */
  141376. get glossiness(): NodeMaterialConnectionPoint;
  141377. /**
  141378. * Gets the glossinness power component
  141379. */
  141380. get glossPower(): NodeMaterialConnectionPoint;
  141381. /**
  141382. * Gets the diffuse color component
  141383. */
  141384. get diffuseColor(): NodeMaterialConnectionPoint;
  141385. /**
  141386. * Gets the specular color component
  141387. */
  141388. get specularColor(): NodeMaterialConnectionPoint;
  141389. /**
  141390. * Gets the diffuse output component
  141391. */
  141392. get diffuseOutput(): NodeMaterialConnectionPoint;
  141393. /**
  141394. * Gets the specular output component
  141395. */
  141396. get specularOutput(): NodeMaterialConnectionPoint;
  141397. /**
  141398. * Gets the shadow output component
  141399. */
  141400. get shadow(): NodeMaterialConnectionPoint;
  141401. autoConfigure(material: NodeMaterial): void;
  141402. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141403. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141405. private _injectVertexCode;
  141406. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141407. serialize(): any;
  141408. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141409. }
  141410. }
  141411. declare module BABYLON {
  141412. /**
  141413. * Block used to read a reflection texture from a sampler
  141414. */
  141415. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  141416. /**
  141417. * Create a new ReflectionTextureBlock
  141418. * @param name defines the block name
  141419. */
  141420. constructor(name: string);
  141421. /**
  141422. * Gets the current class name
  141423. * @returns the class name
  141424. */
  141425. getClassName(): string;
  141426. /**
  141427. * Gets the world position input component
  141428. */
  141429. get position(): NodeMaterialConnectionPoint;
  141430. /**
  141431. * Gets the world position input component
  141432. */
  141433. get worldPosition(): NodeMaterialConnectionPoint;
  141434. /**
  141435. * Gets the world normal input component
  141436. */
  141437. get worldNormal(): NodeMaterialConnectionPoint;
  141438. /**
  141439. * Gets the world input component
  141440. */
  141441. get world(): NodeMaterialConnectionPoint;
  141442. /**
  141443. * Gets the camera (or eye) position component
  141444. */
  141445. get cameraPosition(): NodeMaterialConnectionPoint;
  141446. /**
  141447. * Gets the view input component
  141448. */
  141449. get view(): NodeMaterialConnectionPoint;
  141450. /**
  141451. * Gets the rgb output component
  141452. */
  141453. get rgb(): NodeMaterialConnectionPoint;
  141454. /**
  141455. * Gets the rgba output component
  141456. */
  141457. get rgba(): NodeMaterialConnectionPoint;
  141458. /**
  141459. * Gets the r output component
  141460. */
  141461. get r(): NodeMaterialConnectionPoint;
  141462. /**
  141463. * Gets the g output component
  141464. */
  141465. get g(): NodeMaterialConnectionPoint;
  141466. /**
  141467. * Gets the b output component
  141468. */
  141469. get b(): NodeMaterialConnectionPoint;
  141470. /**
  141471. * Gets the a output component
  141472. */
  141473. get a(): NodeMaterialConnectionPoint;
  141474. autoConfigure(material: NodeMaterial): void;
  141475. protected _buildBlock(state: NodeMaterialBuildState): this;
  141476. }
  141477. }
  141478. declare module BABYLON {
  141479. /**
  141480. * Block used to add 2 vectors
  141481. */
  141482. export class AddBlock extends NodeMaterialBlock {
  141483. /**
  141484. * Creates a new AddBlock
  141485. * @param name defines the block name
  141486. */
  141487. constructor(name: string);
  141488. /**
  141489. * Gets the current class name
  141490. * @returns the class name
  141491. */
  141492. getClassName(): string;
  141493. /**
  141494. * Gets the left operand input component
  141495. */
  141496. get left(): NodeMaterialConnectionPoint;
  141497. /**
  141498. * Gets the right operand input component
  141499. */
  141500. get right(): NodeMaterialConnectionPoint;
  141501. /**
  141502. * Gets the output component
  141503. */
  141504. get output(): NodeMaterialConnectionPoint;
  141505. protected _buildBlock(state: NodeMaterialBuildState): this;
  141506. }
  141507. }
  141508. declare module BABYLON {
  141509. /**
  141510. * Block used to scale a vector by a float
  141511. */
  141512. export class ScaleBlock extends NodeMaterialBlock {
  141513. /**
  141514. * Creates a new ScaleBlock
  141515. * @param name defines the block name
  141516. */
  141517. constructor(name: string);
  141518. /**
  141519. * Gets the current class name
  141520. * @returns the class name
  141521. */
  141522. getClassName(): string;
  141523. /**
  141524. * Gets the input component
  141525. */
  141526. get input(): NodeMaterialConnectionPoint;
  141527. /**
  141528. * Gets the factor input component
  141529. */
  141530. get factor(): NodeMaterialConnectionPoint;
  141531. /**
  141532. * Gets the output component
  141533. */
  141534. get output(): NodeMaterialConnectionPoint;
  141535. protected _buildBlock(state: NodeMaterialBuildState): this;
  141536. }
  141537. }
  141538. declare module BABYLON {
  141539. /**
  141540. * Block used to clamp a float
  141541. */
  141542. export class ClampBlock extends NodeMaterialBlock {
  141543. /** Gets or sets the minimum range */
  141544. minimum: number;
  141545. /** Gets or sets the maximum range */
  141546. maximum: number;
  141547. /**
  141548. * Creates a new ClampBlock
  141549. * @param name defines the block name
  141550. */
  141551. constructor(name: string);
  141552. /**
  141553. * Gets the current class name
  141554. * @returns the class name
  141555. */
  141556. getClassName(): string;
  141557. /**
  141558. * Gets the value input component
  141559. */
  141560. get value(): NodeMaterialConnectionPoint;
  141561. /**
  141562. * Gets the output component
  141563. */
  141564. get output(): NodeMaterialConnectionPoint;
  141565. protected _buildBlock(state: NodeMaterialBuildState): this;
  141566. protected _dumpPropertiesCode(): string;
  141567. serialize(): any;
  141568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141569. }
  141570. }
  141571. declare module BABYLON {
  141572. /**
  141573. * Block used to apply a cross product between 2 vectors
  141574. */
  141575. export class CrossBlock extends NodeMaterialBlock {
  141576. /**
  141577. * Creates a new CrossBlock
  141578. * @param name defines the block name
  141579. */
  141580. constructor(name: string);
  141581. /**
  141582. * Gets the current class name
  141583. * @returns the class name
  141584. */
  141585. getClassName(): string;
  141586. /**
  141587. * Gets the left operand input component
  141588. */
  141589. get left(): NodeMaterialConnectionPoint;
  141590. /**
  141591. * Gets the right operand input component
  141592. */
  141593. get right(): NodeMaterialConnectionPoint;
  141594. /**
  141595. * Gets the output component
  141596. */
  141597. get output(): NodeMaterialConnectionPoint;
  141598. protected _buildBlock(state: NodeMaterialBuildState): this;
  141599. }
  141600. }
  141601. declare module BABYLON {
  141602. /**
  141603. * Block used to apply a dot product between 2 vectors
  141604. */
  141605. export class DotBlock extends NodeMaterialBlock {
  141606. /**
  141607. * Creates a new DotBlock
  141608. * @param name defines the block name
  141609. */
  141610. constructor(name: string);
  141611. /**
  141612. * Gets the current class name
  141613. * @returns the class name
  141614. */
  141615. getClassName(): string;
  141616. /**
  141617. * Gets the left operand input component
  141618. */
  141619. get left(): NodeMaterialConnectionPoint;
  141620. /**
  141621. * Gets the right operand input component
  141622. */
  141623. get right(): NodeMaterialConnectionPoint;
  141624. /**
  141625. * Gets the output component
  141626. */
  141627. get output(): NodeMaterialConnectionPoint;
  141628. protected _buildBlock(state: NodeMaterialBuildState): this;
  141629. }
  141630. }
  141631. declare module BABYLON {
  141632. /**
  141633. * Block used to normalize a vector
  141634. */
  141635. export class NormalizeBlock extends NodeMaterialBlock {
  141636. /**
  141637. * Creates a new NormalizeBlock
  141638. * @param name defines the block name
  141639. */
  141640. constructor(name: string);
  141641. /**
  141642. * Gets the current class name
  141643. * @returns the class name
  141644. */
  141645. getClassName(): string;
  141646. /**
  141647. * Gets the input component
  141648. */
  141649. get input(): NodeMaterialConnectionPoint;
  141650. /**
  141651. * Gets the output component
  141652. */
  141653. get output(): NodeMaterialConnectionPoint;
  141654. protected _buildBlock(state: NodeMaterialBuildState): this;
  141655. }
  141656. }
  141657. declare module BABYLON {
  141658. /**
  141659. * Operations supported by the Trigonometry block
  141660. */
  141661. export enum TrigonometryBlockOperations {
  141662. /** Cos */
  141663. Cos = 0,
  141664. /** Sin */
  141665. Sin = 1,
  141666. /** Abs */
  141667. Abs = 2,
  141668. /** Exp */
  141669. Exp = 3,
  141670. /** Exp2 */
  141671. Exp2 = 4,
  141672. /** Round */
  141673. Round = 5,
  141674. /** Floor */
  141675. Floor = 6,
  141676. /** Ceiling */
  141677. Ceiling = 7,
  141678. /** Square root */
  141679. Sqrt = 8,
  141680. /** Log */
  141681. Log = 9,
  141682. /** Tangent */
  141683. Tan = 10,
  141684. /** Arc tangent */
  141685. ArcTan = 11,
  141686. /** Arc cosinus */
  141687. ArcCos = 12,
  141688. /** Arc sinus */
  141689. ArcSin = 13,
  141690. /** Fraction */
  141691. Fract = 14,
  141692. /** Sign */
  141693. Sign = 15,
  141694. /** To radians (from degrees) */
  141695. Radians = 16,
  141696. /** To degrees (from radians) */
  141697. Degrees = 17
  141698. }
  141699. /**
  141700. * Block used to apply trigonometry operation to floats
  141701. */
  141702. export class TrigonometryBlock extends NodeMaterialBlock {
  141703. /**
  141704. * Gets or sets the operation applied by the block
  141705. */
  141706. operation: TrigonometryBlockOperations;
  141707. /**
  141708. * Creates a new TrigonometryBlock
  141709. * @param name defines the block name
  141710. */
  141711. constructor(name: string);
  141712. /**
  141713. * Gets the current class name
  141714. * @returns the class name
  141715. */
  141716. getClassName(): string;
  141717. /**
  141718. * Gets the input component
  141719. */
  141720. get input(): NodeMaterialConnectionPoint;
  141721. /**
  141722. * Gets the output component
  141723. */
  141724. get output(): NodeMaterialConnectionPoint;
  141725. protected _buildBlock(state: NodeMaterialBuildState): this;
  141726. serialize(): any;
  141727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141728. protected _dumpPropertiesCode(): string;
  141729. }
  141730. }
  141731. declare module BABYLON {
  141732. /**
  141733. * Block used to create a Color3/4 out of individual inputs (one for each component)
  141734. */
  141735. export class ColorMergerBlock extends NodeMaterialBlock {
  141736. /**
  141737. * Create a new ColorMergerBlock
  141738. * @param name defines the block name
  141739. */
  141740. constructor(name: string);
  141741. /**
  141742. * Gets the current class name
  141743. * @returns the class name
  141744. */
  141745. getClassName(): string;
  141746. /**
  141747. * Gets the rgb component (input)
  141748. */
  141749. get rgbIn(): NodeMaterialConnectionPoint;
  141750. /**
  141751. * Gets the r component (input)
  141752. */
  141753. get r(): NodeMaterialConnectionPoint;
  141754. /**
  141755. * Gets the g component (input)
  141756. */
  141757. get g(): NodeMaterialConnectionPoint;
  141758. /**
  141759. * Gets the b component (input)
  141760. */
  141761. get b(): NodeMaterialConnectionPoint;
  141762. /**
  141763. * Gets the a component (input)
  141764. */
  141765. get a(): NodeMaterialConnectionPoint;
  141766. /**
  141767. * Gets the rgba component (output)
  141768. */
  141769. get rgba(): NodeMaterialConnectionPoint;
  141770. /**
  141771. * Gets the rgb component (output)
  141772. */
  141773. get rgbOut(): NodeMaterialConnectionPoint;
  141774. /**
  141775. * Gets the rgb component (output)
  141776. * @deprecated Please use rgbOut instead.
  141777. */
  141778. get rgb(): NodeMaterialConnectionPoint;
  141779. protected _buildBlock(state: NodeMaterialBuildState): this;
  141780. }
  141781. }
  141782. declare module BABYLON {
  141783. /**
  141784. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  141785. */
  141786. export class VectorSplitterBlock extends NodeMaterialBlock {
  141787. /**
  141788. * Create a new VectorSplitterBlock
  141789. * @param name defines the block name
  141790. */
  141791. constructor(name: string);
  141792. /**
  141793. * Gets the current class name
  141794. * @returns the class name
  141795. */
  141796. getClassName(): string;
  141797. /**
  141798. * Gets the xyzw component (input)
  141799. */
  141800. get xyzw(): NodeMaterialConnectionPoint;
  141801. /**
  141802. * Gets the xyz component (input)
  141803. */
  141804. get xyzIn(): NodeMaterialConnectionPoint;
  141805. /**
  141806. * Gets the xy component (input)
  141807. */
  141808. get xyIn(): NodeMaterialConnectionPoint;
  141809. /**
  141810. * Gets the xyz component (output)
  141811. */
  141812. get xyzOut(): NodeMaterialConnectionPoint;
  141813. /**
  141814. * Gets the xy component (output)
  141815. */
  141816. get xyOut(): NodeMaterialConnectionPoint;
  141817. /**
  141818. * Gets the x component (output)
  141819. */
  141820. get x(): NodeMaterialConnectionPoint;
  141821. /**
  141822. * Gets the y component (output)
  141823. */
  141824. get y(): NodeMaterialConnectionPoint;
  141825. /**
  141826. * Gets the z component (output)
  141827. */
  141828. get z(): NodeMaterialConnectionPoint;
  141829. /**
  141830. * Gets the w component (output)
  141831. */
  141832. get w(): NodeMaterialConnectionPoint;
  141833. protected _inputRename(name: string): string;
  141834. protected _outputRename(name: string): string;
  141835. protected _buildBlock(state: NodeMaterialBuildState): this;
  141836. }
  141837. }
  141838. declare module BABYLON {
  141839. /**
  141840. * Block used to lerp between 2 values
  141841. */
  141842. export class LerpBlock extends NodeMaterialBlock {
  141843. /**
  141844. * Creates a new LerpBlock
  141845. * @param name defines the block name
  141846. */
  141847. constructor(name: string);
  141848. /**
  141849. * Gets the current class name
  141850. * @returns the class name
  141851. */
  141852. getClassName(): string;
  141853. /**
  141854. * Gets the left operand input component
  141855. */
  141856. get left(): NodeMaterialConnectionPoint;
  141857. /**
  141858. * Gets the right operand input component
  141859. */
  141860. get right(): NodeMaterialConnectionPoint;
  141861. /**
  141862. * Gets the gradient operand input component
  141863. */
  141864. get gradient(): NodeMaterialConnectionPoint;
  141865. /**
  141866. * Gets the output component
  141867. */
  141868. get output(): NodeMaterialConnectionPoint;
  141869. protected _buildBlock(state: NodeMaterialBuildState): this;
  141870. }
  141871. }
  141872. declare module BABYLON {
  141873. /**
  141874. * Block used to divide 2 vectors
  141875. */
  141876. export class DivideBlock extends NodeMaterialBlock {
  141877. /**
  141878. * Creates a new DivideBlock
  141879. * @param name defines the block name
  141880. */
  141881. constructor(name: string);
  141882. /**
  141883. * Gets the current class name
  141884. * @returns the class name
  141885. */
  141886. getClassName(): string;
  141887. /**
  141888. * Gets the left operand input component
  141889. */
  141890. get left(): NodeMaterialConnectionPoint;
  141891. /**
  141892. * Gets the right operand input component
  141893. */
  141894. get right(): NodeMaterialConnectionPoint;
  141895. /**
  141896. * Gets the output component
  141897. */
  141898. get output(): NodeMaterialConnectionPoint;
  141899. protected _buildBlock(state: NodeMaterialBuildState): this;
  141900. }
  141901. }
  141902. declare module BABYLON {
  141903. /**
  141904. * Block used to subtract 2 vectors
  141905. */
  141906. export class SubtractBlock extends NodeMaterialBlock {
  141907. /**
  141908. * Creates a new SubtractBlock
  141909. * @param name defines the block name
  141910. */
  141911. constructor(name: string);
  141912. /**
  141913. * Gets the current class name
  141914. * @returns the class name
  141915. */
  141916. getClassName(): string;
  141917. /**
  141918. * Gets the left operand input component
  141919. */
  141920. get left(): NodeMaterialConnectionPoint;
  141921. /**
  141922. * Gets the right operand input component
  141923. */
  141924. get right(): NodeMaterialConnectionPoint;
  141925. /**
  141926. * Gets the output component
  141927. */
  141928. get output(): NodeMaterialConnectionPoint;
  141929. protected _buildBlock(state: NodeMaterialBuildState): this;
  141930. }
  141931. }
  141932. declare module BABYLON {
  141933. /**
  141934. * Block used to step a value
  141935. */
  141936. export class StepBlock extends NodeMaterialBlock {
  141937. /**
  141938. * Creates a new StepBlock
  141939. * @param name defines the block name
  141940. */
  141941. constructor(name: string);
  141942. /**
  141943. * Gets the current class name
  141944. * @returns the class name
  141945. */
  141946. getClassName(): string;
  141947. /**
  141948. * Gets the value operand input component
  141949. */
  141950. get value(): NodeMaterialConnectionPoint;
  141951. /**
  141952. * Gets the edge operand input component
  141953. */
  141954. get edge(): NodeMaterialConnectionPoint;
  141955. /**
  141956. * Gets the output component
  141957. */
  141958. get output(): NodeMaterialConnectionPoint;
  141959. protected _buildBlock(state: NodeMaterialBuildState): this;
  141960. }
  141961. }
  141962. declare module BABYLON {
  141963. /**
  141964. * Block used to get the opposite (1 - x) of a value
  141965. */
  141966. export class OneMinusBlock extends NodeMaterialBlock {
  141967. /**
  141968. * Creates a new OneMinusBlock
  141969. * @param name defines the block name
  141970. */
  141971. constructor(name: string);
  141972. /**
  141973. * Gets the current class name
  141974. * @returns the class name
  141975. */
  141976. getClassName(): string;
  141977. /**
  141978. * Gets the input component
  141979. */
  141980. get input(): NodeMaterialConnectionPoint;
  141981. /**
  141982. * Gets the output component
  141983. */
  141984. get output(): NodeMaterialConnectionPoint;
  141985. protected _buildBlock(state: NodeMaterialBuildState): this;
  141986. }
  141987. }
  141988. declare module BABYLON {
  141989. /**
  141990. * Block used to get the view direction
  141991. */
  141992. export class ViewDirectionBlock extends NodeMaterialBlock {
  141993. /**
  141994. * Creates a new ViewDirectionBlock
  141995. * @param name defines the block name
  141996. */
  141997. constructor(name: string);
  141998. /**
  141999. * Gets the current class name
  142000. * @returns the class name
  142001. */
  142002. getClassName(): string;
  142003. /**
  142004. * Gets the world position component
  142005. */
  142006. get worldPosition(): NodeMaterialConnectionPoint;
  142007. /**
  142008. * Gets the camera position component
  142009. */
  142010. get cameraPosition(): NodeMaterialConnectionPoint;
  142011. /**
  142012. * Gets the output component
  142013. */
  142014. get output(): NodeMaterialConnectionPoint;
  142015. autoConfigure(material: NodeMaterial): void;
  142016. protected _buildBlock(state: NodeMaterialBuildState): this;
  142017. }
  142018. }
  142019. declare module BABYLON {
  142020. /**
  142021. * Block used to compute fresnel value
  142022. */
  142023. export class FresnelBlock extends NodeMaterialBlock {
  142024. /**
  142025. * Create a new FresnelBlock
  142026. * @param name defines the block name
  142027. */
  142028. constructor(name: string);
  142029. /**
  142030. * Gets the current class name
  142031. * @returns the class name
  142032. */
  142033. getClassName(): string;
  142034. /**
  142035. * Gets the world normal input component
  142036. */
  142037. get worldNormal(): NodeMaterialConnectionPoint;
  142038. /**
  142039. * Gets the view direction input component
  142040. */
  142041. get viewDirection(): NodeMaterialConnectionPoint;
  142042. /**
  142043. * Gets the bias input component
  142044. */
  142045. get bias(): NodeMaterialConnectionPoint;
  142046. /**
  142047. * Gets the camera (or eye) position component
  142048. */
  142049. get power(): NodeMaterialConnectionPoint;
  142050. /**
  142051. * Gets the fresnel output component
  142052. */
  142053. get fresnel(): NodeMaterialConnectionPoint;
  142054. autoConfigure(material: NodeMaterial): void;
  142055. protected _buildBlock(state: NodeMaterialBuildState): this;
  142056. }
  142057. }
  142058. declare module BABYLON {
  142059. /**
  142060. * Block used to get the max of 2 values
  142061. */
  142062. export class MaxBlock extends NodeMaterialBlock {
  142063. /**
  142064. * Creates a new MaxBlock
  142065. * @param name defines the block name
  142066. */
  142067. constructor(name: string);
  142068. /**
  142069. * Gets the current class name
  142070. * @returns the class name
  142071. */
  142072. getClassName(): string;
  142073. /**
  142074. * Gets the left operand input component
  142075. */
  142076. get left(): NodeMaterialConnectionPoint;
  142077. /**
  142078. * Gets the right operand input component
  142079. */
  142080. get right(): NodeMaterialConnectionPoint;
  142081. /**
  142082. * Gets the output component
  142083. */
  142084. get output(): NodeMaterialConnectionPoint;
  142085. protected _buildBlock(state: NodeMaterialBuildState): this;
  142086. }
  142087. }
  142088. declare module BABYLON {
  142089. /**
  142090. * Block used to get the min of 2 values
  142091. */
  142092. export class MinBlock extends NodeMaterialBlock {
  142093. /**
  142094. * Creates a new MinBlock
  142095. * @param name defines the block name
  142096. */
  142097. constructor(name: string);
  142098. /**
  142099. * Gets the current class name
  142100. * @returns the class name
  142101. */
  142102. getClassName(): string;
  142103. /**
  142104. * Gets the left operand input component
  142105. */
  142106. get left(): NodeMaterialConnectionPoint;
  142107. /**
  142108. * Gets the right operand input component
  142109. */
  142110. get right(): NodeMaterialConnectionPoint;
  142111. /**
  142112. * Gets the output component
  142113. */
  142114. get output(): NodeMaterialConnectionPoint;
  142115. protected _buildBlock(state: NodeMaterialBuildState): this;
  142116. }
  142117. }
  142118. declare module BABYLON {
  142119. /**
  142120. * Block used to get the distance between 2 values
  142121. */
  142122. export class DistanceBlock extends NodeMaterialBlock {
  142123. /**
  142124. * Creates a new DistanceBlock
  142125. * @param name defines the block name
  142126. */
  142127. constructor(name: string);
  142128. /**
  142129. * Gets the current class name
  142130. * @returns the class name
  142131. */
  142132. getClassName(): string;
  142133. /**
  142134. * Gets the left operand input component
  142135. */
  142136. get left(): NodeMaterialConnectionPoint;
  142137. /**
  142138. * Gets the right operand input component
  142139. */
  142140. get right(): NodeMaterialConnectionPoint;
  142141. /**
  142142. * Gets the output component
  142143. */
  142144. get output(): NodeMaterialConnectionPoint;
  142145. protected _buildBlock(state: NodeMaterialBuildState): this;
  142146. }
  142147. }
  142148. declare module BABYLON {
  142149. /**
  142150. * Block used to get the length of a vector
  142151. */
  142152. export class LengthBlock extends NodeMaterialBlock {
  142153. /**
  142154. * Creates a new LengthBlock
  142155. * @param name defines the block name
  142156. */
  142157. constructor(name: string);
  142158. /**
  142159. * Gets the current class name
  142160. * @returns the class name
  142161. */
  142162. getClassName(): string;
  142163. /**
  142164. * Gets the value input component
  142165. */
  142166. get value(): NodeMaterialConnectionPoint;
  142167. /**
  142168. * Gets the output component
  142169. */
  142170. get output(): NodeMaterialConnectionPoint;
  142171. protected _buildBlock(state: NodeMaterialBuildState): this;
  142172. }
  142173. }
  142174. declare module BABYLON {
  142175. /**
  142176. * Block used to get negative version of a value (i.e. x * -1)
  142177. */
  142178. export class NegateBlock extends NodeMaterialBlock {
  142179. /**
  142180. * Creates a new NegateBlock
  142181. * @param name defines the block name
  142182. */
  142183. constructor(name: string);
  142184. /**
  142185. * Gets the current class name
  142186. * @returns the class name
  142187. */
  142188. getClassName(): string;
  142189. /**
  142190. * Gets the value input component
  142191. */
  142192. get value(): NodeMaterialConnectionPoint;
  142193. /**
  142194. * Gets the output component
  142195. */
  142196. get output(): NodeMaterialConnectionPoint;
  142197. protected _buildBlock(state: NodeMaterialBuildState): this;
  142198. }
  142199. }
  142200. declare module BABYLON {
  142201. /**
  142202. * Block used to get the value of the first parameter raised to the power of the second
  142203. */
  142204. export class PowBlock extends NodeMaterialBlock {
  142205. /**
  142206. * Creates a new PowBlock
  142207. * @param name defines the block name
  142208. */
  142209. constructor(name: string);
  142210. /**
  142211. * Gets the current class name
  142212. * @returns the class name
  142213. */
  142214. getClassName(): string;
  142215. /**
  142216. * Gets the value operand input component
  142217. */
  142218. get value(): NodeMaterialConnectionPoint;
  142219. /**
  142220. * Gets the power operand input component
  142221. */
  142222. get power(): NodeMaterialConnectionPoint;
  142223. /**
  142224. * Gets the output component
  142225. */
  142226. get output(): NodeMaterialConnectionPoint;
  142227. protected _buildBlock(state: NodeMaterialBuildState): this;
  142228. }
  142229. }
  142230. declare module BABYLON {
  142231. /**
  142232. * Block used to get a random number
  142233. */
  142234. export class RandomNumberBlock extends NodeMaterialBlock {
  142235. /**
  142236. * Creates a new RandomNumberBlock
  142237. * @param name defines the block name
  142238. */
  142239. constructor(name: string);
  142240. /**
  142241. * Gets the current class name
  142242. * @returns the class name
  142243. */
  142244. getClassName(): string;
  142245. /**
  142246. * Gets the seed input component
  142247. */
  142248. get seed(): NodeMaterialConnectionPoint;
  142249. /**
  142250. * Gets the output component
  142251. */
  142252. get output(): NodeMaterialConnectionPoint;
  142253. protected _buildBlock(state: NodeMaterialBuildState): this;
  142254. }
  142255. }
  142256. declare module BABYLON {
  142257. /**
  142258. * Block used to compute arc tangent of 2 values
  142259. */
  142260. export class ArcTan2Block extends NodeMaterialBlock {
  142261. /**
  142262. * Creates a new ArcTan2Block
  142263. * @param name defines the block name
  142264. */
  142265. constructor(name: string);
  142266. /**
  142267. * Gets the current class name
  142268. * @returns the class name
  142269. */
  142270. getClassName(): string;
  142271. /**
  142272. * Gets the x operand input component
  142273. */
  142274. get x(): NodeMaterialConnectionPoint;
  142275. /**
  142276. * Gets the y operand input component
  142277. */
  142278. get y(): NodeMaterialConnectionPoint;
  142279. /**
  142280. * Gets the output component
  142281. */
  142282. get output(): NodeMaterialConnectionPoint;
  142283. protected _buildBlock(state: NodeMaterialBuildState): this;
  142284. }
  142285. }
  142286. declare module BABYLON {
  142287. /**
  142288. * Block used to smooth step a value
  142289. */
  142290. export class SmoothStepBlock extends NodeMaterialBlock {
  142291. /**
  142292. * Creates a new SmoothStepBlock
  142293. * @param name defines the block name
  142294. */
  142295. constructor(name: string);
  142296. /**
  142297. * Gets the current class name
  142298. * @returns the class name
  142299. */
  142300. getClassName(): string;
  142301. /**
  142302. * Gets the value operand input component
  142303. */
  142304. get value(): NodeMaterialConnectionPoint;
  142305. /**
  142306. * Gets the first edge operand input component
  142307. */
  142308. get edge0(): NodeMaterialConnectionPoint;
  142309. /**
  142310. * Gets the second edge operand input component
  142311. */
  142312. get edge1(): NodeMaterialConnectionPoint;
  142313. /**
  142314. * Gets the output component
  142315. */
  142316. get output(): NodeMaterialConnectionPoint;
  142317. protected _buildBlock(state: NodeMaterialBuildState): this;
  142318. }
  142319. }
  142320. declare module BABYLON {
  142321. /**
  142322. * Block used to get the reciprocal (1 / x) of a value
  142323. */
  142324. export class ReciprocalBlock extends NodeMaterialBlock {
  142325. /**
  142326. * Creates a new ReciprocalBlock
  142327. * @param name defines the block name
  142328. */
  142329. constructor(name: string);
  142330. /**
  142331. * Gets the current class name
  142332. * @returns the class name
  142333. */
  142334. getClassName(): string;
  142335. /**
  142336. * Gets the input component
  142337. */
  142338. get input(): NodeMaterialConnectionPoint;
  142339. /**
  142340. * Gets the output component
  142341. */
  142342. get output(): NodeMaterialConnectionPoint;
  142343. protected _buildBlock(state: NodeMaterialBuildState): this;
  142344. }
  142345. }
  142346. declare module BABYLON {
  142347. /**
  142348. * Block used to replace a color by another one
  142349. */
  142350. export class ReplaceColorBlock extends NodeMaterialBlock {
  142351. /**
  142352. * Creates a new ReplaceColorBlock
  142353. * @param name defines the block name
  142354. */
  142355. constructor(name: string);
  142356. /**
  142357. * Gets the current class name
  142358. * @returns the class name
  142359. */
  142360. getClassName(): string;
  142361. /**
  142362. * Gets the value input component
  142363. */
  142364. get value(): NodeMaterialConnectionPoint;
  142365. /**
  142366. * Gets the reference input component
  142367. */
  142368. get reference(): NodeMaterialConnectionPoint;
  142369. /**
  142370. * Gets the distance input component
  142371. */
  142372. get distance(): NodeMaterialConnectionPoint;
  142373. /**
  142374. * Gets the replacement input component
  142375. */
  142376. get replacement(): NodeMaterialConnectionPoint;
  142377. /**
  142378. * Gets the output component
  142379. */
  142380. get output(): NodeMaterialConnectionPoint;
  142381. protected _buildBlock(state: NodeMaterialBuildState): this;
  142382. }
  142383. }
  142384. declare module BABYLON {
  142385. /**
  142386. * Block used to posterize a value
  142387. * @see https://en.wikipedia.org/wiki/Posterization
  142388. */
  142389. export class PosterizeBlock extends NodeMaterialBlock {
  142390. /**
  142391. * Creates a new PosterizeBlock
  142392. * @param name defines the block name
  142393. */
  142394. constructor(name: string);
  142395. /**
  142396. * Gets the current class name
  142397. * @returns the class name
  142398. */
  142399. getClassName(): string;
  142400. /**
  142401. * Gets the value input component
  142402. */
  142403. get value(): NodeMaterialConnectionPoint;
  142404. /**
  142405. * Gets the steps input component
  142406. */
  142407. get steps(): NodeMaterialConnectionPoint;
  142408. /**
  142409. * Gets the output component
  142410. */
  142411. get output(): NodeMaterialConnectionPoint;
  142412. protected _buildBlock(state: NodeMaterialBuildState): this;
  142413. }
  142414. }
  142415. declare module BABYLON {
  142416. /**
  142417. * Operations supported by the Wave block
  142418. */
  142419. export enum WaveBlockKind {
  142420. /** SawTooth */
  142421. SawTooth = 0,
  142422. /** Square */
  142423. Square = 1,
  142424. /** Triangle */
  142425. Triangle = 2
  142426. }
  142427. /**
  142428. * Block used to apply wave operation to floats
  142429. */
  142430. export class WaveBlock extends NodeMaterialBlock {
  142431. /**
  142432. * Gets or sets the kibnd of wave to be applied by the block
  142433. */
  142434. kind: WaveBlockKind;
  142435. /**
  142436. * Creates a new WaveBlock
  142437. * @param name defines the block name
  142438. */
  142439. constructor(name: string);
  142440. /**
  142441. * Gets the current class name
  142442. * @returns the class name
  142443. */
  142444. getClassName(): string;
  142445. /**
  142446. * Gets the input component
  142447. */
  142448. get input(): NodeMaterialConnectionPoint;
  142449. /**
  142450. * Gets the output component
  142451. */
  142452. get output(): NodeMaterialConnectionPoint;
  142453. protected _buildBlock(state: NodeMaterialBuildState): this;
  142454. serialize(): any;
  142455. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142456. }
  142457. }
  142458. declare module BABYLON {
  142459. /**
  142460. * Class used to store a color step for the GradientBlock
  142461. */
  142462. export class GradientBlockColorStep {
  142463. /**
  142464. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142465. */
  142466. step: number;
  142467. /**
  142468. * Gets or sets the color associated with this step
  142469. */
  142470. color: Color3;
  142471. /**
  142472. * Creates a new GradientBlockColorStep
  142473. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  142474. * @param color defines the color associated with this step
  142475. */
  142476. constructor(
  142477. /**
  142478. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  142479. */
  142480. step: number,
  142481. /**
  142482. * Gets or sets the color associated with this step
  142483. */
  142484. color: Color3);
  142485. }
  142486. /**
  142487. * Block used to return a color from a gradient based on an input value between 0 and 1
  142488. */
  142489. export class GradientBlock extends NodeMaterialBlock {
  142490. /**
  142491. * Gets or sets the list of color steps
  142492. */
  142493. colorSteps: GradientBlockColorStep[];
  142494. /**
  142495. * Creates a new GradientBlock
  142496. * @param name defines the block name
  142497. */
  142498. constructor(name: string);
  142499. /**
  142500. * Gets the current class name
  142501. * @returns the class name
  142502. */
  142503. getClassName(): string;
  142504. /**
  142505. * Gets the gradient input component
  142506. */
  142507. get gradient(): NodeMaterialConnectionPoint;
  142508. /**
  142509. * Gets the output component
  142510. */
  142511. get output(): NodeMaterialConnectionPoint;
  142512. private _writeColorConstant;
  142513. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142514. serialize(): any;
  142515. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142516. protected _dumpPropertiesCode(): string;
  142517. }
  142518. }
  142519. declare module BABYLON {
  142520. /**
  142521. * Block used to normalize lerp between 2 values
  142522. */
  142523. export class NLerpBlock extends NodeMaterialBlock {
  142524. /**
  142525. * Creates a new NLerpBlock
  142526. * @param name defines the block name
  142527. */
  142528. constructor(name: string);
  142529. /**
  142530. * Gets the current class name
  142531. * @returns the class name
  142532. */
  142533. getClassName(): string;
  142534. /**
  142535. * Gets the left operand input component
  142536. */
  142537. get left(): NodeMaterialConnectionPoint;
  142538. /**
  142539. * Gets the right operand input component
  142540. */
  142541. get right(): NodeMaterialConnectionPoint;
  142542. /**
  142543. * Gets the gradient operand input component
  142544. */
  142545. get gradient(): NodeMaterialConnectionPoint;
  142546. /**
  142547. * Gets the output component
  142548. */
  142549. get output(): NodeMaterialConnectionPoint;
  142550. protected _buildBlock(state: NodeMaterialBuildState): this;
  142551. }
  142552. }
  142553. declare module BABYLON {
  142554. /**
  142555. * block used to Generate a Worley Noise 3D Noise Pattern
  142556. */
  142557. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  142558. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142559. manhattanDistance: boolean;
  142560. /**
  142561. * Creates a new WorleyNoise3DBlock
  142562. * @param name defines the block name
  142563. */
  142564. constructor(name: string);
  142565. /**
  142566. * Gets the current class name
  142567. * @returns the class name
  142568. */
  142569. getClassName(): string;
  142570. /**
  142571. * Gets the seed input component
  142572. */
  142573. get seed(): NodeMaterialConnectionPoint;
  142574. /**
  142575. * Gets the jitter input component
  142576. */
  142577. get jitter(): NodeMaterialConnectionPoint;
  142578. /**
  142579. * Gets the output component
  142580. */
  142581. get output(): NodeMaterialConnectionPoint;
  142582. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142583. /**
  142584. * Exposes the properties to the UI?
  142585. */
  142586. protected _dumpPropertiesCode(): string;
  142587. /**
  142588. * Exposes the properties to the Seralize?
  142589. */
  142590. serialize(): any;
  142591. /**
  142592. * Exposes the properties to the deseralize?
  142593. */
  142594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142595. }
  142596. }
  142597. declare module BABYLON {
  142598. /**
  142599. * block used to Generate a Simplex Perlin 3d Noise Pattern
  142600. */
  142601. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  142602. /**
  142603. * Creates a new SimplexPerlin3DBlock
  142604. * @param name defines the block name
  142605. */
  142606. constructor(name: string);
  142607. /**
  142608. * Gets the current class name
  142609. * @returns the class name
  142610. */
  142611. getClassName(): string;
  142612. /**
  142613. * Gets the seed operand input component
  142614. */
  142615. get seed(): NodeMaterialConnectionPoint;
  142616. /**
  142617. * Gets the output component
  142618. */
  142619. get output(): NodeMaterialConnectionPoint;
  142620. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142621. }
  142622. }
  142623. declare module BABYLON {
  142624. /**
  142625. * Block used to blend normals
  142626. */
  142627. export class NormalBlendBlock extends NodeMaterialBlock {
  142628. /**
  142629. * Creates a new NormalBlendBlock
  142630. * @param name defines the block name
  142631. */
  142632. constructor(name: string);
  142633. /**
  142634. * Gets the current class name
  142635. * @returns the class name
  142636. */
  142637. getClassName(): string;
  142638. /**
  142639. * Gets the first input component
  142640. */
  142641. get normalMap0(): NodeMaterialConnectionPoint;
  142642. /**
  142643. * Gets the second input component
  142644. */
  142645. get normalMap1(): NodeMaterialConnectionPoint;
  142646. /**
  142647. * Gets the output component
  142648. */
  142649. get output(): NodeMaterialConnectionPoint;
  142650. protected _buildBlock(state: NodeMaterialBuildState): this;
  142651. }
  142652. }
  142653. declare module BABYLON {
  142654. /**
  142655. * Block used to rotate a 2d vector by a given angle
  142656. */
  142657. export class Rotate2dBlock extends NodeMaterialBlock {
  142658. /**
  142659. * Creates a new Rotate2dBlock
  142660. * @param name defines the block name
  142661. */
  142662. constructor(name: string);
  142663. /**
  142664. * Gets the current class name
  142665. * @returns the class name
  142666. */
  142667. getClassName(): string;
  142668. /**
  142669. * Gets the input vector
  142670. */
  142671. get input(): NodeMaterialConnectionPoint;
  142672. /**
  142673. * Gets the input angle
  142674. */
  142675. get angle(): NodeMaterialConnectionPoint;
  142676. /**
  142677. * Gets the output component
  142678. */
  142679. get output(): NodeMaterialConnectionPoint;
  142680. autoConfigure(material: NodeMaterial): void;
  142681. protected _buildBlock(state: NodeMaterialBuildState): this;
  142682. }
  142683. }
  142684. declare module BABYLON {
  142685. /**
  142686. * Block used to get the reflected vector from a direction and a normal
  142687. */
  142688. export class ReflectBlock extends NodeMaterialBlock {
  142689. /**
  142690. * Creates a new ReflectBlock
  142691. * @param name defines the block name
  142692. */
  142693. constructor(name: string);
  142694. /**
  142695. * Gets the current class name
  142696. * @returns the class name
  142697. */
  142698. getClassName(): string;
  142699. /**
  142700. * Gets the incident component
  142701. */
  142702. get incident(): NodeMaterialConnectionPoint;
  142703. /**
  142704. * Gets the normal component
  142705. */
  142706. get normal(): NodeMaterialConnectionPoint;
  142707. /**
  142708. * Gets the output component
  142709. */
  142710. get output(): NodeMaterialConnectionPoint;
  142711. protected _buildBlock(state: NodeMaterialBuildState): this;
  142712. }
  142713. }
  142714. declare module BABYLON {
  142715. /**
  142716. * Block used to get the refracted vector from a direction and a normal
  142717. */
  142718. export class RefractBlock extends NodeMaterialBlock {
  142719. /**
  142720. * Creates a new RefractBlock
  142721. * @param name defines the block name
  142722. */
  142723. constructor(name: string);
  142724. /**
  142725. * Gets the current class name
  142726. * @returns the class name
  142727. */
  142728. getClassName(): string;
  142729. /**
  142730. * Gets the incident component
  142731. */
  142732. get incident(): NodeMaterialConnectionPoint;
  142733. /**
  142734. * Gets the normal component
  142735. */
  142736. get normal(): NodeMaterialConnectionPoint;
  142737. /**
  142738. * Gets the index of refraction component
  142739. */
  142740. get ior(): NodeMaterialConnectionPoint;
  142741. /**
  142742. * Gets the output component
  142743. */
  142744. get output(): NodeMaterialConnectionPoint;
  142745. protected _buildBlock(state: NodeMaterialBuildState): this;
  142746. }
  142747. }
  142748. declare module BABYLON {
  142749. /**
  142750. * Block used to desaturate a color
  142751. */
  142752. export class DesaturateBlock extends NodeMaterialBlock {
  142753. /**
  142754. * Creates a new DesaturateBlock
  142755. * @param name defines the block name
  142756. */
  142757. constructor(name: string);
  142758. /**
  142759. * Gets the current class name
  142760. * @returns the class name
  142761. */
  142762. getClassName(): string;
  142763. /**
  142764. * Gets the color operand input component
  142765. */
  142766. get color(): NodeMaterialConnectionPoint;
  142767. /**
  142768. * Gets the level operand input component
  142769. */
  142770. get level(): NodeMaterialConnectionPoint;
  142771. /**
  142772. * Gets the output component
  142773. */
  142774. get output(): NodeMaterialConnectionPoint;
  142775. protected _buildBlock(state: NodeMaterialBuildState): this;
  142776. }
  142777. }
  142778. declare module BABYLON {
  142779. /**
  142780. * Block used to implement the ambient occlusion module of the PBR material
  142781. */
  142782. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  142783. /**
  142784. * Create a new AmbientOcclusionBlock
  142785. * @param name defines the block name
  142786. */
  142787. constructor(name: string);
  142788. /**
  142789. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  142790. */
  142791. useAmbientInGrayScale: boolean;
  142792. /**
  142793. * Initialize the block and prepare the context for build
  142794. * @param state defines the state that will be used for the build
  142795. */
  142796. initialize(state: NodeMaterialBuildState): void;
  142797. /**
  142798. * Gets the current class name
  142799. * @returns the class name
  142800. */
  142801. getClassName(): string;
  142802. /**
  142803. * Gets the texture input component
  142804. */
  142805. get texture(): NodeMaterialConnectionPoint;
  142806. /**
  142807. * Gets the texture intensity component
  142808. */
  142809. get intensity(): NodeMaterialConnectionPoint;
  142810. /**
  142811. * Gets the direct light intensity input component
  142812. */
  142813. get directLightIntensity(): NodeMaterialConnectionPoint;
  142814. /**
  142815. * Gets the ambient occlusion object output component
  142816. */
  142817. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142818. /**
  142819. * Gets the main code of the block (fragment side)
  142820. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  142821. * @returns the shader code
  142822. */
  142823. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  142824. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142825. protected _buildBlock(state: NodeMaterialBuildState): this;
  142826. protected _dumpPropertiesCode(): string;
  142827. serialize(): any;
  142828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142829. }
  142830. }
  142831. declare module BABYLON {
  142832. /**
  142833. * Block used to implement the reflection module of the PBR material
  142834. */
  142835. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  142836. /** @hidden */
  142837. _defineLODReflectionAlpha: string;
  142838. /** @hidden */
  142839. _defineLinearSpecularReflection: string;
  142840. private _vEnvironmentIrradianceName;
  142841. /** @hidden */
  142842. _vReflectionMicrosurfaceInfosName: string;
  142843. /** @hidden */
  142844. _vReflectionInfosName: string;
  142845. /** @hidden */
  142846. _vReflectionFilteringInfoName: string;
  142847. private _scene;
  142848. /**
  142849. * The three properties below are set by the main PBR block prior to calling methods of this class.
  142850. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  142851. * It's less burden on the user side in the editor part.
  142852. */
  142853. /** @hidden */
  142854. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  142855. /** @hidden */
  142856. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  142857. /** @hidden */
  142858. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  142859. /**
  142860. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  142861. * diffuse part of the IBL.
  142862. */
  142863. useSphericalHarmonics: boolean;
  142864. /**
  142865. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  142866. */
  142867. forceIrradianceInFragment: boolean;
  142868. /**
  142869. * Create a new ReflectionBlock
  142870. * @param name defines the block name
  142871. */
  142872. constructor(name: string);
  142873. /**
  142874. * Gets the current class name
  142875. * @returns the class name
  142876. */
  142877. getClassName(): string;
  142878. /**
  142879. * Gets the position input component
  142880. */
  142881. get position(): NodeMaterialConnectionPoint;
  142882. /**
  142883. * Gets the world position input component
  142884. */
  142885. get worldPosition(): NodeMaterialConnectionPoint;
  142886. /**
  142887. * Gets the world normal input component
  142888. */
  142889. get worldNormal(): NodeMaterialConnectionPoint;
  142890. /**
  142891. * Gets the world input component
  142892. */
  142893. get world(): NodeMaterialConnectionPoint;
  142894. /**
  142895. * Gets the camera (or eye) position component
  142896. */
  142897. get cameraPosition(): NodeMaterialConnectionPoint;
  142898. /**
  142899. * Gets the view input component
  142900. */
  142901. get view(): NodeMaterialConnectionPoint;
  142902. /**
  142903. * Gets the color input component
  142904. */
  142905. get color(): NodeMaterialConnectionPoint;
  142906. /**
  142907. * Gets the reflection object output component
  142908. */
  142909. get reflection(): NodeMaterialConnectionPoint;
  142910. /**
  142911. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  142912. */
  142913. get hasTexture(): boolean;
  142914. /**
  142915. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  142916. */
  142917. get reflectionColor(): string;
  142918. protected _getTexture(): Nullable<BaseTexture>;
  142919. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142920. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142921. /**
  142922. * Gets the code to inject in the vertex shader
  142923. * @param state current state of the node material building
  142924. * @returns the shader code
  142925. */
  142926. handleVertexSide(state: NodeMaterialBuildState): string;
  142927. /**
  142928. * Gets the main code of the block (fragment side)
  142929. * @param state current state of the node material building
  142930. * @param normalVarName name of the existing variable corresponding to the normal
  142931. * @returns the shader code
  142932. */
  142933. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  142934. protected _buildBlock(state: NodeMaterialBuildState): this;
  142935. protected _dumpPropertiesCode(): string;
  142936. serialize(): any;
  142937. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142938. }
  142939. }
  142940. declare module BABYLON {
  142941. /**
  142942. * Block used to implement the sheen module of the PBR material
  142943. */
  142944. export class SheenBlock extends NodeMaterialBlock {
  142945. /**
  142946. * Create a new SheenBlock
  142947. * @param name defines the block name
  142948. */
  142949. constructor(name: string);
  142950. /**
  142951. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  142952. * It allows the strength of the sheen effect to not depend on the base color of the material,
  142953. * making it easier to setup and tweak the effect
  142954. */
  142955. albedoScaling: boolean;
  142956. /**
  142957. * Defines if the sheen is linked to the sheen color.
  142958. */
  142959. linkSheenWithAlbedo: boolean;
  142960. /**
  142961. * Initialize the block and prepare the context for build
  142962. * @param state defines the state that will be used for the build
  142963. */
  142964. initialize(state: NodeMaterialBuildState): void;
  142965. /**
  142966. * Gets the current class name
  142967. * @returns the class name
  142968. */
  142969. getClassName(): string;
  142970. /**
  142971. * Gets the intensity input component
  142972. */
  142973. get intensity(): NodeMaterialConnectionPoint;
  142974. /**
  142975. * Gets the color input component
  142976. */
  142977. get color(): NodeMaterialConnectionPoint;
  142978. /**
  142979. * Gets the roughness input component
  142980. */
  142981. get roughness(): NodeMaterialConnectionPoint;
  142982. /**
  142983. * Gets the sheen object output component
  142984. */
  142985. get sheen(): NodeMaterialConnectionPoint;
  142986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142987. /**
  142988. * Gets the main code of the block (fragment side)
  142989. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142990. * @returns the shader code
  142991. */
  142992. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  142993. protected _buildBlock(state: NodeMaterialBuildState): this;
  142994. protected _dumpPropertiesCode(): string;
  142995. serialize(): any;
  142996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142997. }
  142998. }
  142999. declare module BABYLON {
  143000. /**
  143001. * Block used to implement the reflectivity module of the PBR material
  143002. */
  143003. export class ReflectivityBlock extends NodeMaterialBlock {
  143004. private _metallicReflectanceColor;
  143005. private _metallicF0Factor;
  143006. /** @hidden */
  143007. _vMetallicReflectanceFactorsName: string;
  143008. /**
  143009. * The property below is set by the main PBR block prior to calling methods of this class.
  143010. */
  143011. /** @hidden */
  143012. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  143013. /**
  143014. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  143015. */
  143016. useAmbientOcclusionFromMetallicTextureRed: boolean;
  143017. /**
  143018. * Specifies if the metallic texture contains the metallness information in its blue channel.
  143019. */
  143020. useMetallnessFromMetallicTextureBlue: boolean;
  143021. /**
  143022. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  143023. */
  143024. useRoughnessFromMetallicTextureAlpha: boolean;
  143025. /**
  143026. * Specifies if the metallic texture contains the roughness information in its green channel.
  143027. */
  143028. useRoughnessFromMetallicTextureGreen: boolean;
  143029. /**
  143030. * Create a new ReflectivityBlock
  143031. * @param name defines the block name
  143032. */
  143033. constructor(name: string);
  143034. /**
  143035. * Initialize the block and prepare the context for build
  143036. * @param state defines the state that will be used for the build
  143037. */
  143038. initialize(state: NodeMaterialBuildState): void;
  143039. /**
  143040. * Gets the current class name
  143041. * @returns the class name
  143042. */
  143043. getClassName(): string;
  143044. /**
  143045. * Gets the metallic input component
  143046. */
  143047. get metallic(): NodeMaterialConnectionPoint;
  143048. /**
  143049. * Gets the roughness input component
  143050. */
  143051. get roughness(): NodeMaterialConnectionPoint;
  143052. /**
  143053. * Gets the texture input component
  143054. */
  143055. get texture(): NodeMaterialConnectionPoint;
  143056. /**
  143057. * Gets the reflectivity object output component
  143058. */
  143059. get reflectivity(): NodeMaterialConnectionPoint;
  143060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143061. /**
  143062. * Gets the main code of the block (fragment side)
  143063. * @param state current state of the node material building
  143064. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  143065. * @returns the shader code
  143066. */
  143067. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  143068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143069. protected _buildBlock(state: NodeMaterialBuildState): this;
  143070. protected _dumpPropertiesCode(): string;
  143071. serialize(): any;
  143072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143073. }
  143074. }
  143075. declare module BABYLON {
  143076. /**
  143077. * Block used to implement the anisotropy module of the PBR material
  143078. */
  143079. export class AnisotropyBlock extends NodeMaterialBlock {
  143080. /**
  143081. * The two properties below are set by the main PBR block prior to calling methods of this class.
  143082. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  143083. * It's less burden on the user side in the editor part.
  143084. */
  143085. /** @hidden */
  143086. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  143087. /** @hidden */
  143088. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  143089. /**
  143090. * Create a new AnisotropyBlock
  143091. * @param name defines the block name
  143092. */
  143093. constructor(name: string);
  143094. /**
  143095. * Initialize the block and prepare the context for build
  143096. * @param state defines the state that will be used for the build
  143097. */
  143098. initialize(state: NodeMaterialBuildState): void;
  143099. /**
  143100. * Gets the current class name
  143101. * @returns the class name
  143102. */
  143103. getClassName(): string;
  143104. /**
  143105. * Gets the intensity input component
  143106. */
  143107. get intensity(): NodeMaterialConnectionPoint;
  143108. /**
  143109. * Gets the direction input component
  143110. */
  143111. get direction(): NodeMaterialConnectionPoint;
  143112. /**
  143113. * Gets the texture input component
  143114. */
  143115. get texture(): NodeMaterialConnectionPoint;
  143116. /**
  143117. * Gets the uv input component
  143118. */
  143119. get uv(): NodeMaterialConnectionPoint;
  143120. /**
  143121. * Gets the worldTangent input component
  143122. */
  143123. get worldTangent(): NodeMaterialConnectionPoint;
  143124. /**
  143125. * Gets the anisotropy object output component
  143126. */
  143127. get anisotropy(): NodeMaterialConnectionPoint;
  143128. private _generateTBNSpace;
  143129. /**
  143130. * Gets the main code of the block (fragment side)
  143131. * @param state current state of the node material building
  143132. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143133. * @returns the shader code
  143134. */
  143135. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  143136. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143137. protected _buildBlock(state: NodeMaterialBuildState): this;
  143138. }
  143139. }
  143140. declare module BABYLON {
  143141. /**
  143142. * Block used to implement the clear coat module of the PBR material
  143143. */
  143144. export class ClearCoatBlock extends NodeMaterialBlock {
  143145. private _scene;
  143146. /**
  143147. * Create a new ClearCoatBlock
  143148. * @param name defines the block name
  143149. */
  143150. constructor(name: string);
  143151. /**
  143152. * Initialize the block and prepare the context for build
  143153. * @param state defines the state that will be used for the build
  143154. */
  143155. initialize(state: NodeMaterialBuildState): void;
  143156. /**
  143157. * Gets the current class name
  143158. * @returns the class name
  143159. */
  143160. getClassName(): string;
  143161. /**
  143162. * Gets the intensity input component
  143163. */
  143164. get intensity(): NodeMaterialConnectionPoint;
  143165. /**
  143166. * Gets the roughness input component
  143167. */
  143168. get roughness(): NodeMaterialConnectionPoint;
  143169. /**
  143170. * Gets the ior input component
  143171. */
  143172. get ior(): NodeMaterialConnectionPoint;
  143173. /**
  143174. * Gets the texture input component
  143175. */
  143176. get texture(): NodeMaterialConnectionPoint;
  143177. /**
  143178. * Gets the bump texture input component
  143179. */
  143180. get bumpTexture(): NodeMaterialConnectionPoint;
  143181. /**
  143182. * Gets the uv input component
  143183. */
  143184. get uv(): NodeMaterialConnectionPoint;
  143185. /**
  143186. * Gets the tint color input component
  143187. */
  143188. get tintColor(): NodeMaterialConnectionPoint;
  143189. /**
  143190. * Gets the tint "at distance" input component
  143191. */
  143192. get tintAtDistance(): NodeMaterialConnectionPoint;
  143193. /**
  143194. * Gets the tint thickness input component
  143195. */
  143196. get tintThickness(): NodeMaterialConnectionPoint;
  143197. /**
  143198. * Gets the world tangent input component
  143199. */
  143200. get worldTangent(): NodeMaterialConnectionPoint;
  143201. /**
  143202. * Gets the clear coat object output component
  143203. */
  143204. get clearcoat(): NodeMaterialConnectionPoint;
  143205. autoConfigure(material: NodeMaterial): void;
  143206. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143207. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  143208. private _generateTBNSpace;
  143209. /**
  143210. * Gets the main code of the block (fragment side)
  143211. * @param state current state of the node material building
  143212. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  143213. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143214. * @param worldPosVarName name of the variable holding the world position
  143215. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  143216. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  143217. * @param worldNormalVarName name of the variable holding the world normal
  143218. * @returns the shader code
  143219. */
  143220. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  143221. protected _buildBlock(state: NodeMaterialBuildState): this;
  143222. }
  143223. }
  143224. declare module BABYLON {
  143225. /**
  143226. * Block used to implement the sub surface module of the PBR material
  143227. */
  143228. export class SubSurfaceBlock extends NodeMaterialBlock {
  143229. /**
  143230. * Create a new SubSurfaceBlock
  143231. * @param name defines the block name
  143232. */
  143233. constructor(name: string);
  143234. /**
  143235. * Stores the intensity of the different subsurface effects in the thickness texture.
  143236. * * the green channel is the translucency intensity.
  143237. * * the blue channel is the scattering intensity.
  143238. * * the alpha channel is the refraction intensity.
  143239. */
  143240. useMaskFromThicknessTexture: boolean;
  143241. /**
  143242. * Initialize the block and prepare the context for build
  143243. * @param state defines the state that will be used for the build
  143244. */
  143245. initialize(state: NodeMaterialBuildState): void;
  143246. /**
  143247. * Gets the current class name
  143248. * @returns the class name
  143249. */
  143250. getClassName(): string;
  143251. /**
  143252. * Gets the min thickness input component
  143253. */
  143254. get minThickness(): NodeMaterialConnectionPoint;
  143255. /**
  143256. * Gets the max thickness input component
  143257. */
  143258. get maxThickness(): NodeMaterialConnectionPoint;
  143259. /**
  143260. * Gets the thickness texture component
  143261. */
  143262. get thicknessTexture(): NodeMaterialConnectionPoint;
  143263. /**
  143264. * Gets the tint color input component
  143265. */
  143266. get tintColor(): NodeMaterialConnectionPoint;
  143267. /**
  143268. * Gets the translucency intensity input component
  143269. */
  143270. get translucencyIntensity(): NodeMaterialConnectionPoint;
  143271. /**
  143272. * Gets the translucency diffusion distance input component
  143273. */
  143274. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  143275. /**
  143276. * Gets the refraction object parameters
  143277. */
  143278. get refraction(): NodeMaterialConnectionPoint;
  143279. /**
  143280. * Gets the sub surface object output component
  143281. */
  143282. get subsurface(): NodeMaterialConnectionPoint;
  143283. autoConfigure(material: NodeMaterial): void;
  143284. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143285. /**
  143286. * Gets the main code of the block (fragment side)
  143287. * @param state current state of the node material building
  143288. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  143289. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  143290. * @param worldPosVarName name of the variable holding the world position
  143291. * @returns the shader code
  143292. */
  143293. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  143294. protected _buildBlock(state: NodeMaterialBuildState): this;
  143295. }
  143296. }
  143297. declare module BABYLON {
  143298. /**
  143299. * Block used to implement the PBR metallic/roughness model
  143300. */
  143301. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  143302. /**
  143303. * Gets or sets the light associated with this block
  143304. */
  143305. light: Nullable<Light>;
  143306. private _lightId;
  143307. private _scene;
  143308. private _environmentBRDFTexture;
  143309. private _environmentBrdfSamplerName;
  143310. private _vNormalWName;
  143311. private _invertNormalName;
  143312. /**
  143313. * Create a new ReflectionBlock
  143314. * @param name defines the block name
  143315. */
  143316. constructor(name: string);
  143317. /**
  143318. * Intensity of the direct lights e.g. the four lights available in your scene.
  143319. * This impacts both the direct diffuse and specular highlights.
  143320. */
  143321. directIntensity: number;
  143322. /**
  143323. * Intensity of the environment e.g. how much the environment will light the object
  143324. * either through harmonics for rough material or through the refelction for shiny ones.
  143325. */
  143326. environmentIntensity: number;
  143327. /**
  143328. * This is a special control allowing the reduction of the specular highlights coming from the
  143329. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  143330. */
  143331. specularIntensity: number;
  143332. /**
  143333. * Defines the falloff type used in this material.
  143334. * It by default is Physical.
  143335. */
  143336. lightFalloff: number;
  143337. /**
  143338. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  143339. */
  143340. useAlphaFromAlbedoTexture: boolean;
  143341. /**
  143342. * Specifies that alpha test should be used
  143343. */
  143344. useAlphaTest: boolean;
  143345. /**
  143346. * Defines the alpha limits in alpha test mode.
  143347. */
  143348. alphaTestCutoff: number;
  143349. /**
  143350. * Specifies that alpha blending should be used
  143351. */
  143352. useAlphaBlending: boolean;
  143353. /**
  143354. * Defines if the alpha value should be determined via the rgb values.
  143355. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  143356. */
  143357. opacityRGB: boolean;
  143358. /**
  143359. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  143360. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  143361. */
  143362. useRadianceOverAlpha: boolean;
  143363. /**
  143364. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  143365. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  143366. */
  143367. useSpecularOverAlpha: boolean;
  143368. /**
  143369. * Enables specular anti aliasing in the PBR shader.
  143370. * It will both interacts on the Geometry for analytical and IBL lighting.
  143371. * It also prefilter the roughness map based on the bump values.
  143372. */
  143373. enableSpecularAntiAliasing: boolean;
  143374. /**
  143375. * Enables realtime filtering on the texture.
  143376. */
  143377. realTimeFiltering: boolean;
  143378. /**
  143379. * Quality switch for realtime filtering
  143380. */
  143381. realTimeFilteringQuality: number;
  143382. /**
  143383. * Defines if the material uses energy conservation.
  143384. */
  143385. useEnergyConservation: boolean;
  143386. /**
  143387. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  143388. * too much the area relying on ambient texture to define their ambient occlusion.
  143389. */
  143390. useRadianceOcclusion: boolean;
  143391. /**
  143392. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  143393. * makes the reflect vector face the model (under horizon).
  143394. */
  143395. useHorizonOcclusion: boolean;
  143396. /**
  143397. * If set to true, no lighting calculations will be applied.
  143398. */
  143399. unlit: boolean;
  143400. /**
  143401. * Force normal to face away from face.
  143402. */
  143403. forceNormalForward: boolean;
  143404. /**
  143405. * Defines the material debug mode.
  143406. * It helps seeing only some components of the material while troubleshooting.
  143407. */
  143408. debugMode: number;
  143409. /**
  143410. * Specify from where on screen the debug mode should start.
  143411. * The value goes from -1 (full screen) to 1 (not visible)
  143412. * It helps with side by side comparison against the final render
  143413. * This defaults to 0
  143414. */
  143415. debugLimit: number;
  143416. /**
  143417. * As the default viewing range might not be enough (if the ambient is really small for instance)
  143418. * You can use the factor to better multiply the final value.
  143419. */
  143420. debugFactor: number;
  143421. /**
  143422. * Initialize the block and prepare the context for build
  143423. * @param state defines the state that will be used for the build
  143424. */
  143425. initialize(state: NodeMaterialBuildState): void;
  143426. /**
  143427. * Gets the current class name
  143428. * @returns the class name
  143429. */
  143430. getClassName(): string;
  143431. /**
  143432. * Gets the world position input component
  143433. */
  143434. get worldPosition(): NodeMaterialConnectionPoint;
  143435. /**
  143436. * Gets the world normal input component
  143437. */
  143438. get worldNormal(): NodeMaterialConnectionPoint;
  143439. /**
  143440. * Gets the perturbed normal input component
  143441. */
  143442. get perturbedNormal(): NodeMaterialConnectionPoint;
  143443. /**
  143444. * Gets the camera position input component
  143445. */
  143446. get cameraPosition(): NodeMaterialConnectionPoint;
  143447. /**
  143448. * Gets the base color input component
  143449. */
  143450. get baseColor(): NodeMaterialConnectionPoint;
  143451. /**
  143452. * Gets the opacity texture input component
  143453. */
  143454. get opacityTexture(): NodeMaterialConnectionPoint;
  143455. /**
  143456. * Gets the ambient color input component
  143457. */
  143458. get ambientColor(): NodeMaterialConnectionPoint;
  143459. /**
  143460. * Gets the reflectivity object parameters
  143461. */
  143462. get reflectivity(): NodeMaterialConnectionPoint;
  143463. /**
  143464. * Gets the ambient occlusion object parameters
  143465. */
  143466. get ambientOcclusion(): NodeMaterialConnectionPoint;
  143467. /**
  143468. * Gets the reflection object parameters
  143469. */
  143470. get reflection(): NodeMaterialConnectionPoint;
  143471. /**
  143472. * Gets the sheen object parameters
  143473. */
  143474. get sheen(): NodeMaterialConnectionPoint;
  143475. /**
  143476. * Gets the clear coat object parameters
  143477. */
  143478. get clearcoat(): NodeMaterialConnectionPoint;
  143479. /**
  143480. * Gets the sub surface object parameters
  143481. */
  143482. get subsurface(): NodeMaterialConnectionPoint;
  143483. /**
  143484. * Gets the anisotropy object parameters
  143485. */
  143486. get anisotropy(): NodeMaterialConnectionPoint;
  143487. /**
  143488. * Gets the ambient output component
  143489. */
  143490. get ambient(): NodeMaterialConnectionPoint;
  143491. /**
  143492. * Gets the diffuse output component
  143493. */
  143494. get diffuse(): NodeMaterialConnectionPoint;
  143495. /**
  143496. * Gets the specular output component
  143497. */
  143498. get specular(): NodeMaterialConnectionPoint;
  143499. /**
  143500. * Gets the sheen output component
  143501. */
  143502. get sheenDir(): NodeMaterialConnectionPoint;
  143503. /**
  143504. * Gets the clear coat output component
  143505. */
  143506. get clearcoatDir(): NodeMaterialConnectionPoint;
  143507. /**
  143508. * Gets the indirect diffuse output component
  143509. */
  143510. get diffuseIndirect(): NodeMaterialConnectionPoint;
  143511. /**
  143512. * Gets the indirect specular output component
  143513. */
  143514. get specularIndirect(): NodeMaterialConnectionPoint;
  143515. /**
  143516. * Gets the indirect sheen output component
  143517. */
  143518. get sheenIndirect(): NodeMaterialConnectionPoint;
  143519. /**
  143520. * Gets the indirect clear coat output component
  143521. */
  143522. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  143523. /**
  143524. * Gets the refraction output component
  143525. */
  143526. get refraction(): NodeMaterialConnectionPoint;
  143527. /**
  143528. * Gets the global lighting output component
  143529. */
  143530. get lighting(): NodeMaterialConnectionPoint;
  143531. /**
  143532. * Gets the shadow output component
  143533. */
  143534. get shadow(): NodeMaterialConnectionPoint;
  143535. /**
  143536. * Gets the alpha output component
  143537. */
  143538. get alpha(): NodeMaterialConnectionPoint;
  143539. autoConfigure(material: NodeMaterial): void;
  143540. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143541. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143542. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143543. private _injectVertexCode;
  143544. /**
  143545. * Gets the code corresponding to the albedo/opacity module
  143546. * @returns the shader code
  143547. */
  143548. getAlbedoOpacityCode(): string;
  143549. protected _buildBlock(state: NodeMaterialBuildState): this;
  143550. protected _dumpPropertiesCode(): string;
  143551. serialize(): any;
  143552. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143553. }
  143554. }
  143555. declare module BABYLON {
  143556. /**
  143557. * Block used to compute value of one parameter modulo another
  143558. */
  143559. export class ModBlock extends NodeMaterialBlock {
  143560. /**
  143561. * Creates a new ModBlock
  143562. * @param name defines the block name
  143563. */
  143564. constructor(name: string);
  143565. /**
  143566. * Gets the current class name
  143567. * @returns the class name
  143568. */
  143569. getClassName(): string;
  143570. /**
  143571. * Gets the left operand input component
  143572. */
  143573. get left(): NodeMaterialConnectionPoint;
  143574. /**
  143575. * Gets the right operand input component
  143576. */
  143577. get right(): NodeMaterialConnectionPoint;
  143578. /**
  143579. * Gets the output component
  143580. */
  143581. get output(): NodeMaterialConnectionPoint;
  143582. protected _buildBlock(state: NodeMaterialBuildState): this;
  143583. }
  143584. }
  143585. declare module BABYLON {
  143586. /**
  143587. * Helper class to push actions to a pool of workers.
  143588. */
  143589. export class WorkerPool implements IDisposable {
  143590. private _workerInfos;
  143591. private _pendingActions;
  143592. /**
  143593. * Constructor
  143594. * @param workers Array of workers to use for actions
  143595. */
  143596. constructor(workers: Array<Worker>);
  143597. /**
  143598. * Terminates all workers and clears any pending actions.
  143599. */
  143600. dispose(): void;
  143601. /**
  143602. * Pushes an action to the worker pool. If all the workers are active, the action will be
  143603. * pended until a worker has completed its action.
  143604. * @param action The action to perform. Call onComplete when the action is complete.
  143605. */
  143606. push(action: (worker: Worker, onComplete: () => void) => void): void;
  143607. private _execute;
  143608. }
  143609. }
  143610. declare module BABYLON {
  143611. /**
  143612. * Configuration for Draco compression
  143613. */
  143614. export interface IDracoCompressionConfiguration {
  143615. /**
  143616. * Configuration for the decoder.
  143617. */
  143618. decoder: {
  143619. /**
  143620. * The url to the WebAssembly module.
  143621. */
  143622. wasmUrl?: string;
  143623. /**
  143624. * The url to the WebAssembly binary.
  143625. */
  143626. wasmBinaryUrl?: string;
  143627. /**
  143628. * The url to the fallback JavaScript module.
  143629. */
  143630. fallbackUrl?: string;
  143631. };
  143632. }
  143633. /**
  143634. * Draco compression (https://google.github.io/draco/)
  143635. *
  143636. * This class wraps the Draco module.
  143637. *
  143638. * **Encoder**
  143639. *
  143640. * The encoder is not currently implemented.
  143641. *
  143642. * **Decoder**
  143643. *
  143644. * 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.
  143645. *
  143646. * To update the configuration, use the following code:
  143647. * ```javascript
  143648. * DracoCompression.Configuration = {
  143649. * decoder: {
  143650. * wasmUrl: "<url to the WebAssembly library>",
  143651. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  143652. * fallbackUrl: "<url to the fallback JavaScript library>",
  143653. * }
  143654. * };
  143655. * ```
  143656. *
  143657. * 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.
  143658. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  143659. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  143660. *
  143661. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  143662. * ```javascript
  143663. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  143664. * ```
  143665. *
  143666. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  143667. */
  143668. export class DracoCompression implements IDisposable {
  143669. private _workerPoolPromise?;
  143670. private _decoderModulePromise?;
  143671. /**
  143672. * The configuration. Defaults to the following urls:
  143673. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  143674. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  143675. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  143676. */
  143677. static Configuration: IDracoCompressionConfiguration;
  143678. /**
  143679. * Returns true if the decoder configuration is available.
  143680. */
  143681. static get DecoderAvailable(): boolean;
  143682. /**
  143683. * Default number of workers to create when creating the draco compression object.
  143684. */
  143685. static DefaultNumWorkers: number;
  143686. private static GetDefaultNumWorkers;
  143687. private static _Default;
  143688. /**
  143689. * Default instance for the draco compression object.
  143690. */
  143691. static get Default(): DracoCompression;
  143692. /**
  143693. * Constructor
  143694. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  143695. */
  143696. constructor(numWorkers?: number);
  143697. /**
  143698. * Stop all async operations and release resources.
  143699. */
  143700. dispose(): void;
  143701. /**
  143702. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  143703. * @returns a promise that resolves when ready
  143704. */
  143705. whenReadyAsync(): Promise<void>;
  143706. /**
  143707. * Decode Draco compressed mesh data to vertex data.
  143708. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  143709. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  143710. * @returns A promise that resolves with the decoded vertex data
  143711. */
  143712. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  143713. [kind: string]: number;
  143714. }): Promise<VertexData>;
  143715. }
  143716. }
  143717. declare module BABYLON {
  143718. /**
  143719. * Class for building Constructive Solid Geometry
  143720. */
  143721. export class CSG {
  143722. private polygons;
  143723. /**
  143724. * The world matrix
  143725. */
  143726. matrix: Matrix;
  143727. /**
  143728. * Stores the position
  143729. */
  143730. position: Vector3;
  143731. /**
  143732. * Stores the rotation
  143733. */
  143734. rotation: Vector3;
  143735. /**
  143736. * Stores the rotation quaternion
  143737. */
  143738. rotationQuaternion: Nullable<Quaternion>;
  143739. /**
  143740. * Stores the scaling vector
  143741. */
  143742. scaling: Vector3;
  143743. /**
  143744. * Convert the Mesh to CSG
  143745. * @param mesh The Mesh to convert to CSG
  143746. * @returns A new CSG from the Mesh
  143747. */
  143748. static FromMesh(mesh: Mesh): CSG;
  143749. /**
  143750. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  143751. * @param polygons Polygons used to construct a CSG solid
  143752. */
  143753. private static FromPolygons;
  143754. /**
  143755. * Clones, or makes a deep copy, of the CSG
  143756. * @returns A new CSG
  143757. */
  143758. clone(): CSG;
  143759. /**
  143760. * Unions this CSG with another CSG
  143761. * @param csg The CSG to union against this CSG
  143762. * @returns The unioned CSG
  143763. */
  143764. union(csg: CSG): CSG;
  143765. /**
  143766. * Unions this CSG with another CSG in place
  143767. * @param csg The CSG to union against this CSG
  143768. */
  143769. unionInPlace(csg: CSG): void;
  143770. /**
  143771. * Subtracts this CSG with another CSG
  143772. * @param csg The CSG to subtract against this CSG
  143773. * @returns A new CSG
  143774. */
  143775. subtract(csg: CSG): CSG;
  143776. /**
  143777. * Subtracts this CSG with another CSG in place
  143778. * @param csg The CSG to subtact against this CSG
  143779. */
  143780. subtractInPlace(csg: CSG): void;
  143781. /**
  143782. * Intersect this CSG with another CSG
  143783. * @param csg The CSG to intersect against this CSG
  143784. * @returns A new CSG
  143785. */
  143786. intersect(csg: CSG): CSG;
  143787. /**
  143788. * Intersects this CSG with another CSG in place
  143789. * @param csg The CSG to intersect against this CSG
  143790. */
  143791. intersectInPlace(csg: CSG): void;
  143792. /**
  143793. * Return a new CSG solid with solid and empty space switched. This solid is
  143794. * not modified.
  143795. * @returns A new CSG solid with solid and empty space switched
  143796. */
  143797. inverse(): CSG;
  143798. /**
  143799. * Inverses the CSG in place
  143800. */
  143801. inverseInPlace(): void;
  143802. /**
  143803. * This is used to keep meshes transformations so they can be restored
  143804. * when we build back a Babylon Mesh
  143805. * NB : All CSG operations are performed in world coordinates
  143806. * @param csg The CSG to copy the transform attributes from
  143807. * @returns This CSG
  143808. */
  143809. copyTransformAttributes(csg: CSG): CSG;
  143810. /**
  143811. * Build Raw mesh from CSG
  143812. * Coordinates here are in world space
  143813. * @param name The name of the mesh geometry
  143814. * @param scene The Scene
  143815. * @param keepSubMeshes Specifies if the submeshes should be kept
  143816. * @returns A new Mesh
  143817. */
  143818. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143819. /**
  143820. * Build Mesh from CSG taking material and transforms into account
  143821. * @param name The name of the Mesh
  143822. * @param material The material of the Mesh
  143823. * @param scene The Scene
  143824. * @param keepSubMeshes Specifies if submeshes should be kept
  143825. * @returns The new Mesh
  143826. */
  143827. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  143828. }
  143829. }
  143830. declare module BABYLON {
  143831. /**
  143832. * Class used to create a trail following a mesh
  143833. */
  143834. export class TrailMesh extends Mesh {
  143835. private _generator;
  143836. private _autoStart;
  143837. private _running;
  143838. private _diameter;
  143839. private _length;
  143840. private _sectionPolygonPointsCount;
  143841. private _sectionVectors;
  143842. private _sectionNormalVectors;
  143843. private _beforeRenderObserver;
  143844. /**
  143845. * @constructor
  143846. * @param name The value used by scene.getMeshByName() to do a lookup.
  143847. * @param generator The mesh or transform node to generate a trail.
  143848. * @param scene The scene to add this mesh to.
  143849. * @param diameter Diameter of trailing mesh. Default is 1.
  143850. * @param length Length of trailing mesh. Default is 60.
  143851. * @param autoStart Automatically start trailing mesh. Default true.
  143852. */
  143853. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  143854. /**
  143855. * "TrailMesh"
  143856. * @returns "TrailMesh"
  143857. */
  143858. getClassName(): string;
  143859. private _createMesh;
  143860. /**
  143861. * Start trailing mesh.
  143862. */
  143863. start(): void;
  143864. /**
  143865. * Stop trailing mesh.
  143866. */
  143867. stop(): void;
  143868. /**
  143869. * Update trailing mesh geometry.
  143870. */
  143871. update(): void;
  143872. /**
  143873. * Returns a new TrailMesh object.
  143874. * @param name is a string, the name given to the new mesh
  143875. * @param newGenerator use new generator object for cloned trail mesh
  143876. * @returns a new mesh
  143877. */
  143878. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  143879. /**
  143880. * Serializes this trail mesh
  143881. * @param serializationObject object to write serialization to
  143882. */
  143883. serialize(serializationObject: any): void;
  143884. /**
  143885. * Parses a serialized trail mesh
  143886. * @param parsedMesh the serialized mesh
  143887. * @param scene the scene to create the trail mesh in
  143888. * @returns the created trail mesh
  143889. */
  143890. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  143891. }
  143892. }
  143893. declare module BABYLON {
  143894. /**
  143895. * Class containing static functions to help procedurally build meshes
  143896. */
  143897. export class TiledBoxBuilder {
  143898. /**
  143899. * Creates a box mesh
  143900. * 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)
  143901. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143905. * @param name defines the name of the mesh
  143906. * @param options defines the options used to create the mesh
  143907. * @param scene defines the hosting scene
  143908. * @returns the box mesh
  143909. */
  143910. static CreateTiledBox(name: string, options: {
  143911. pattern?: number;
  143912. width?: number;
  143913. height?: number;
  143914. depth?: number;
  143915. tileSize?: number;
  143916. tileWidth?: number;
  143917. tileHeight?: number;
  143918. alignHorizontal?: number;
  143919. alignVertical?: number;
  143920. faceUV?: Vector4[];
  143921. faceColors?: Color4[];
  143922. sideOrientation?: number;
  143923. updatable?: boolean;
  143924. }, scene?: Nullable<Scene>): Mesh;
  143925. }
  143926. }
  143927. declare module BABYLON {
  143928. /**
  143929. * Class containing static functions to help procedurally build meshes
  143930. */
  143931. export class TorusKnotBuilder {
  143932. /**
  143933. * Creates a torus knot mesh
  143934. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143935. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143936. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143937. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143941. * @param name defines the name of the mesh
  143942. * @param options defines the options used to create the mesh
  143943. * @param scene defines the hosting scene
  143944. * @returns the torus knot mesh
  143945. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143946. */
  143947. static CreateTorusKnot(name: string, options: {
  143948. radius?: number;
  143949. tube?: number;
  143950. radialSegments?: number;
  143951. tubularSegments?: number;
  143952. p?: number;
  143953. q?: number;
  143954. updatable?: boolean;
  143955. sideOrientation?: number;
  143956. frontUVs?: Vector4;
  143957. backUVs?: Vector4;
  143958. }, scene: any): Mesh;
  143959. }
  143960. }
  143961. declare module BABYLON {
  143962. /**
  143963. * Polygon
  143964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  143965. */
  143966. export class Polygon {
  143967. /**
  143968. * Creates a rectangle
  143969. * @param xmin bottom X coord
  143970. * @param ymin bottom Y coord
  143971. * @param xmax top X coord
  143972. * @param ymax top Y coord
  143973. * @returns points that make the resulting rectation
  143974. */
  143975. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  143976. /**
  143977. * Creates a circle
  143978. * @param radius radius of circle
  143979. * @param cx scale in x
  143980. * @param cy scale in y
  143981. * @param numberOfSides number of sides that make up the circle
  143982. * @returns points that make the resulting circle
  143983. */
  143984. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  143985. /**
  143986. * Creates a polygon from input string
  143987. * @param input Input polygon data
  143988. * @returns the parsed points
  143989. */
  143990. static Parse(input: string): Vector2[];
  143991. /**
  143992. * Starts building a polygon from x and y coordinates
  143993. * @param x x coordinate
  143994. * @param y y coordinate
  143995. * @returns the started path2
  143996. */
  143997. static StartingAt(x: number, y: number): Path2;
  143998. }
  143999. /**
  144000. * Builds a polygon
  144001. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  144002. */
  144003. export class PolygonMeshBuilder {
  144004. private _points;
  144005. private _outlinepoints;
  144006. private _holes;
  144007. private _name;
  144008. private _scene;
  144009. private _epoints;
  144010. private _eholes;
  144011. private _addToepoint;
  144012. /**
  144013. * Babylon reference to the earcut plugin.
  144014. */
  144015. bjsEarcut: any;
  144016. /**
  144017. * Creates a PolygonMeshBuilder
  144018. * @param name name of the builder
  144019. * @param contours Path of the polygon
  144020. * @param scene scene to add to when creating the mesh
  144021. * @param earcutInjection can be used to inject your own earcut reference
  144022. */
  144023. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  144024. /**
  144025. * Adds a whole within the polygon
  144026. * @param hole Array of points defining the hole
  144027. * @returns this
  144028. */
  144029. addHole(hole: Vector2[]): PolygonMeshBuilder;
  144030. /**
  144031. * Creates the polygon
  144032. * @param updatable If the mesh should be updatable
  144033. * @param depth The depth of the mesh created
  144034. * @returns the created mesh
  144035. */
  144036. build(updatable?: boolean, depth?: number): Mesh;
  144037. /**
  144038. * Creates the polygon
  144039. * @param depth The depth of the mesh created
  144040. * @returns the created VertexData
  144041. */
  144042. buildVertexData(depth?: number): VertexData;
  144043. /**
  144044. * Adds a side to the polygon
  144045. * @param positions points that make the polygon
  144046. * @param normals normals of the polygon
  144047. * @param uvs uvs of the polygon
  144048. * @param indices indices of the polygon
  144049. * @param bounds bounds of the polygon
  144050. * @param points points of the polygon
  144051. * @param depth depth of the polygon
  144052. * @param flip flip of the polygon
  144053. */
  144054. private addSide;
  144055. }
  144056. }
  144057. declare module BABYLON {
  144058. /**
  144059. * Class containing static functions to help procedurally build meshes
  144060. */
  144061. export class PolygonBuilder {
  144062. /**
  144063. * Creates a polygon mesh
  144064. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144065. * * 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
  144066. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144069. * * Remember you can only change the shape positions, not their number when updating a polygon
  144070. * @param name defines the name of the mesh
  144071. * @param options defines the options used to create the mesh
  144072. * @param scene defines the hosting scene
  144073. * @param earcutInjection can be used to inject your own earcut reference
  144074. * @returns the polygon mesh
  144075. */
  144076. static CreatePolygon(name: string, options: {
  144077. shape: Vector3[];
  144078. holes?: Vector3[][];
  144079. depth?: number;
  144080. faceUV?: Vector4[];
  144081. faceColors?: Color4[];
  144082. updatable?: boolean;
  144083. sideOrientation?: number;
  144084. frontUVs?: Vector4;
  144085. backUVs?: Vector4;
  144086. wrap?: boolean;
  144087. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144088. /**
  144089. * Creates an extruded polygon mesh, with depth in the Y direction.
  144090. * * 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)
  144091. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144092. * @param name defines the name of the mesh
  144093. * @param options defines the options used to create the mesh
  144094. * @param scene defines the hosting scene
  144095. * @param earcutInjection can be used to inject your own earcut reference
  144096. * @returns the polygon mesh
  144097. */
  144098. static ExtrudePolygon(name: string, options: {
  144099. shape: Vector3[];
  144100. holes?: Vector3[][];
  144101. depth?: number;
  144102. faceUV?: Vector4[];
  144103. faceColors?: Color4[];
  144104. updatable?: boolean;
  144105. sideOrientation?: number;
  144106. frontUVs?: Vector4;
  144107. backUVs?: Vector4;
  144108. wrap?: boolean;
  144109. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144110. }
  144111. }
  144112. declare module BABYLON {
  144113. /**
  144114. * Class containing static functions to help procedurally build meshes
  144115. */
  144116. export class LatheBuilder {
  144117. /**
  144118. * Creates lathe mesh.
  144119. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144120. * * 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
  144121. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144122. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144123. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144124. * * 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
  144125. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144126. * * 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
  144127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144131. * @param name defines the name of the mesh
  144132. * @param options defines the options used to create the mesh
  144133. * @param scene defines the hosting scene
  144134. * @returns the lathe mesh
  144135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144136. */
  144137. static CreateLathe(name: string, options: {
  144138. shape: Vector3[];
  144139. radius?: number;
  144140. tessellation?: number;
  144141. clip?: number;
  144142. arc?: number;
  144143. closed?: boolean;
  144144. updatable?: boolean;
  144145. sideOrientation?: number;
  144146. frontUVs?: Vector4;
  144147. backUVs?: Vector4;
  144148. cap?: number;
  144149. invertUV?: boolean;
  144150. }, scene?: Nullable<Scene>): Mesh;
  144151. }
  144152. }
  144153. declare module BABYLON {
  144154. /**
  144155. * Class containing static functions to help procedurally build meshes
  144156. */
  144157. export class TiledPlaneBuilder {
  144158. /**
  144159. * Creates a tiled plane mesh
  144160. * * The parameter `pattern` will, depending on value, do nothing or
  144161. * * * flip (reflect about central vertical) alternate tiles across and up
  144162. * * * flip every tile on alternate rows
  144163. * * * rotate (180 degs) alternate tiles across and up
  144164. * * * rotate every tile on alternate rows
  144165. * * * flip and rotate alternate tiles across and up
  144166. * * * flip and rotate every tile on alternate rows
  144167. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  144168. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  144169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144171. * * 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)
  144172. * * 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)
  144173. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144174. * @param name defines the name of the mesh
  144175. * @param options defines the options used to create the mesh
  144176. * @param scene defines the hosting scene
  144177. * @returns the box mesh
  144178. */
  144179. static CreateTiledPlane(name: string, options: {
  144180. pattern?: number;
  144181. tileSize?: number;
  144182. tileWidth?: number;
  144183. tileHeight?: number;
  144184. size?: number;
  144185. width?: number;
  144186. height?: number;
  144187. alignHorizontal?: number;
  144188. alignVertical?: number;
  144189. sideOrientation?: number;
  144190. frontUVs?: Vector4;
  144191. backUVs?: Vector4;
  144192. updatable?: boolean;
  144193. }, scene?: Nullable<Scene>): Mesh;
  144194. }
  144195. }
  144196. declare module BABYLON {
  144197. /**
  144198. * Class containing static functions to help procedurally build meshes
  144199. */
  144200. export class TubeBuilder {
  144201. /**
  144202. * Creates a tube mesh.
  144203. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144204. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144205. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144206. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144207. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144208. * * 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)
  144209. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144210. * * 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
  144211. * * 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
  144212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144213. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144214. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144216. * @param name defines the name of the mesh
  144217. * @param options defines the options used to create the mesh
  144218. * @param scene defines the hosting scene
  144219. * @returns the tube mesh
  144220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144221. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144222. */
  144223. static CreateTube(name: string, options: {
  144224. path: Vector3[];
  144225. radius?: number;
  144226. tessellation?: number;
  144227. radiusFunction?: {
  144228. (i: number, distance: number): number;
  144229. };
  144230. cap?: number;
  144231. arc?: number;
  144232. updatable?: boolean;
  144233. sideOrientation?: number;
  144234. frontUVs?: Vector4;
  144235. backUVs?: Vector4;
  144236. instance?: Mesh;
  144237. invertUV?: boolean;
  144238. }, scene?: Nullable<Scene>): Mesh;
  144239. }
  144240. }
  144241. declare module BABYLON {
  144242. /**
  144243. * Class containing static functions to help procedurally build meshes
  144244. */
  144245. export class IcoSphereBuilder {
  144246. /**
  144247. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144248. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144249. * * 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`)
  144250. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144251. * * 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
  144252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144255. * @param name defines the name of the mesh
  144256. * @param options defines the options used to create the mesh
  144257. * @param scene defines the hosting scene
  144258. * @returns the icosahedron mesh
  144259. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144260. */
  144261. static CreateIcoSphere(name: string, options: {
  144262. radius?: number;
  144263. radiusX?: number;
  144264. radiusY?: number;
  144265. radiusZ?: number;
  144266. flat?: boolean;
  144267. subdivisions?: number;
  144268. sideOrientation?: number;
  144269. frontUVs?: Vector4;
  144270. backUVs?: Vector4;
  144271. updatable?: boolean;
  144272. }, scene?: Nullable<Scene>): Mesh;
  144273. }
  144274. }
  144275. declare module BABYLON {
  144276. /**
  144277. * Class containing static functions to help procedurally build meshes
  144278. */
  144279. export class DecalBuilder {
  144280. /**
  144281. * Creates a decal mesh.
  144282. * 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
  144283. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  144284. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  144285. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  144286. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  144287. * @param name defines the name of the mesh
  144288. * @param sourceMesh defines the mesh where the decal must be applied
  144289. * @param options defines the options used to create the mesh
  144290. * @param scene defines the hosting scene
  144291. * @returns the decal mesh
  144292. * @see https://doc.babylonjs.com/how_to/decals
  144293. */
  144294. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  144295. position?: Vector3;
  144296. normal?: Vector3;
  144297. size?: Vector3;
  144298. angle?: number;
  144299. }): Mesh;
  144300. }
  144301. }
  144302. declare module BABYLON {
  144303. /**
  144304. * Class containing static functions to help procedurally build meshes
  144305. */
  144306. export class MeshBuilder {
  144307. /**
  144308. * Creates a box mesh
  144309. * * The parameter `size` sets the size (float) of each box side (default 1)
  144310. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  144311. * * 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)
  144312. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144316. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  144317. * @param name defines the name of the mesh
  144318. * @param options defines the options used to create the mesh
  144319. * @param scene defines the hosting scene
  144320. * @returns the box mesh
  144321. */
  144322. static CreateBox(name: string, options: {
  144323. size?: number;
  144324. width?: number;
  144325. height?: number;
  144326. depth?: number;
  144327. faceUV?: Vector4[];
  144328. faceColors?: Color4[];
  144329. sideOrientation?: number;
  144330. frontUVs?: Vector4;
  144331. backUVs?: Vector4;
  144332. wrap?: boolean;
  144333. topBaseAt?: number;
  144334. bottomBaseAt?: number;
  144335. updatable?: boolean;
  144336. }, scene?: Nullable<Scene>): Mesh;
  144337. /**
  144338. * Creates a tiled box mesh
  144339. * * faceTiles sets the pattern, tile size and number of tiles for a face
  144340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144341. * @param name defines the name of the mesh
  144342. * @param options defines the options used to create the mesh
  144343. * @param scene defines the hosting scene
  144344. * @returns the tiled box mesh
  144345. */
  144346. static CreateTiledBox(name: string, options: {
  144347. pattern?: number;
  144348. size?: number;
  144349. width?: number;
  144350. height?: number;
  144351. depth: number;
  144352. tileSize?: number;
  144353. tileWidth?: number;
  144354. tileHeight?: number;
  144355. faceUV?: Vector4[];
  144356. faceColors?: Color4[];
  144357. alignHorizontal?: number;
  144358. alignVertical?: number;
  144359. sideOrientation?: number;
  144360. updatable?: boolean;
  144361. }, scene?: Nullable<Scene>): Mesh;
  144362. /**
  144363. * Creates a sphere mesh
  144364. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  144365. * * 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`)
  144366. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  144367. * * 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
  144368. * * 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)
  144369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144372. * @param name defines the name of the mesh
  144373. * @param options defines the options used to create the mesh
  144374. * @param scene defines the hosting scene
  144375. * @returns the sphere mesh
  144376. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  144377. */
  144378. static CreateSphere(name: string, options: {
  144379. segments?: number;
  144380. diameter?: number;
  144381. diameterX?: number;
  144382. diameterY?: number;
  144383. diameterZ?: number;
  144384. arc?: number;
  144385. slice?: number;
  144386. sideOrientation?: number;
  144387. frontUVs?: Vector4;
  144388. backUVs?: Vector4;
  144389. updatable?: boolean;
  144390. }, scene?: Nullable<Scene>): Mesh;
  144391. /**
  144392. * Creates a plane polygonal mesh. By default, this is a disc
  144393. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  144394. * * 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
  144395. * * 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
  144396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144399. * @param name defines the name of the mesh
  144400. * @param options defines the options used to create the mesh
  144401. * @param scene defines the hosting scene
  144402. * @returns the plane polygonal mesh
  144403. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  144404. */
  144405. static CreateDisc(name: string, options: {
  144406. radius?: number;
  144407. tessellation?: number;
  144408. arc?: number;
  144409. updatable?: boolean;
  144410. sideOrientation?: number;
  144411. frontUVs?: Vector4;
  144412. backUVs?: Vector4;
  144413. }, scene?: Nullable<Scene>): Mesh;
  144414. /**
  144415. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  144416. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  144417. * * 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`)
  144418. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  144419. * * 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
  144420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144423. * @param name defines the name of the mesh
  144424. * @param options defines the options used to create the mesh
  144425. * @param scene defines the hosting scene
  144426. * @returns the icosahedron mesh
  144427. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  144428. */
  144429. static CreateIcoSphere(name: string, options: {
  144430. radius?: number;
  144431. radiusX?: number;
  144432. radiusY?: number;
  144433. radiusZ?: number;
  144434. flat?: boolean;
  144435. subdivisions?: number;
  144436. sideOrientation?: number;
  144437. frontUVs?: Vector4;
  144438. backUVs?: Vector4;
  144439. updatable?: boolean;
  144440. }, scene?: Nullable<Scene>): Mesh;
  144441. /**
  144442. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144443. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  144444. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  144445. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  144446. * * 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
  144447. * * 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
  144448. * * 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
  144449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144452. * * 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
  144453. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  144454. * * 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
  144455. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  144456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144457. * @param name defines the name of the mesh
  144458. * @param options defines the options used to create the mesh
  144459. * @param scene defines the hosting scene
  144460. * @returns the ribbon mesh
  144461. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  144462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144463. */
  144464. static CreateRibbon(name: string, options: {
  144465. pathArray: Vector3[][];
  144466. closeArray?: boolean;
  144467. closePath?: boolean;
  144468. offset?: number;
  144469. updatable?: boolean;
  144470. sideOrientation?: number;
  144471. frontUVs?: Vector4;
  144472. backUVs?: Vector4;
  144473. instance?: Mesh;
  144474. invertUV?: boolean;
  144475. uvs?: Vector2[];
  144476. colors?: Color4[];
  144477. }, scene?: Nullable<Scene>): Mesh;
  144478. /**
  144479. * Creates a cylinder or a cone mesh
  144480. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  144481. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  144482. * * 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.
  144483. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  144484. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  144485. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  144486. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  144487. * * 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).
  144488. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  144489. * * 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).
  144490. * * 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
  144491. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  144492. * * 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
  144493. * * 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.
  144494. * * If `enclose` is false, a ring surface is one element.
  144495. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  144496. * * 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
  144497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144500. * @param name defines the name of the mesh
  144501. * @param options defines the options used to create the mesh
  144502. * @param scene defines the hosting scene
  144503. * @returns the cylinder mesh
  144504. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  144505. */
  144506. static CreateCylinder(name: string, options: {
  144507. height?: number;
  144508. diameterTop?: number;
  144509. diameterBottom?: number;
  144510. diameter?: number;
  144511. tessellation?: number;
  144512. subdivisions?: number;
  144513. arc?: number;
  144514. faceColors?: Color4[];
  144515. faceUV?: Vector4[];
  144516. updatable?: boolean;
  144517. hasRings?: boolean;
  144518. enclose?: boolean;
  144519. cap?: number;
  144520. sideOrientation?: number;
  144521. frontUVs?: Vector4;
  144522. backUVs?: Vector4;
  144523. }, scene?: Nullable<Scene>): Mesh;
  144524. /**
  144525. * Creates a torus mesh
  144526. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  144527. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  144528. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  144529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144532. * @param name defines the name of the mesh
  144533. * @param options defines the options used to create the mesh
  144534. * @param scene defines the hosting scene
  144535. * @returns the torus mesh
  144536. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  144537. */
  144538. static CreateTorus(name: string, options: {
  144539. diameter?: number;
  144540. thickness?: number;
  144541. tessellation?: number;
  144542. updatable?: boolean;
  144543. sideOrientation?: number;
  144544. frontUVs?: Vector4;
  144545. backUVs?: Vector4;
  144546. }, scene?: Nullable<Scene>): Mesh;
  144547. /**
  144548. * Creates a torus knot mesh
  144549. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  144550. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  144551. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  144552. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  144553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144556. * @param name defines the name of the mesh
  144557. * @param options defines the options used to create the mesh
  144558. * @param scene defines the hosting scene
  144559. * @returns the torus knot mesh
  144560. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  144561. */
  144562. static CreateTorusKnot(name: string, options: {
  144563. radius?: number;
  144564. tube?: number;
  144565. radialSegments?: number;
  144566. tubularSegments?: number;
  144567. p?: number;
  144568. q?: number;
  144569. updatable?: boolean;
  144570. sideOrientation?: number;
  144571. frontUVs?: Vector4;
  144572. backUVs?: Vector4;
  144573. }, scene?: Nullable<Scene>): Mesh;
  144574. /**
  144575. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  144576. * * 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
  144577. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  144578. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  144579. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  144580. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  144581. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  144582. * * 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
  144583. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  144584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  144586. * @param name defines the name of the new line system
  144587. * @param options defines the options used to create the line system
  144588. * @param scene defines the hosting scene
  144589. * @returns a new line system mesh
  144590. */
  144591. static CreateLineSystem(name: string, options: {
  144592. lines: Vector3[][];
  144593. updatable?: boolean;
  144594. instance?: Nullable<LinesMesh>;
  144595. colors?: Nullable<Color4[][]>;
  144596. useVertexAlpha?: boolean;
  144597. }, scene: Nullable<Scene>): LinesMesh;
  144598. /**
  144599. * Creates a line mesh
  144600. * 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
  144601. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144602. * * The parameter `points` is an array successive Vector3
  144603. * * 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
  144604. * * The optional parameter `colors` is an array of successive Color4, one per line point
  144605. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  144606. * * When updating an instance, remember that only point positions can change, not the number of points
  144607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  144609. * @param name defines the name of the new line system
  144610. * @param options defines the options used to create the line system
  144611. * @param scene defines the hosting scene
  144612. * @returns a new line mesh
  144613. */
  144614. static CreateLines(name: string, options: {
  144615. points: Vector3[];
  144616. updatable?: boolean;
  144617. instance?: Nullable<LinesMesh>;
  144618. colors?: Color4[];
  144619. useVertexAlpha?: boolean;
  144620. }, scene?: Nullable<Scene>): LinesMesh;
  144621. /**
  144622. * Creates a dashed line mesh
  144623. * * 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
  144624. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  144625. * * The parameter `points` is an array successive Vector3
  144626. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  144627. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  144628. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  144629. * * 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
  144630. * * When updating an instance, remember that only point positions can change, not the number of points
  144631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144632. * @param name defines the name of the mesh
  144633. * @param options defines the options used to create the mesh
  144634. * @param scene defines the hosting scene
  144635. * @returns the dashed line mesh
  144636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  144637. */
  144638. static CreateDashedLines(name: string, options: {
  144639. points: Vector3[];
  144640. dashSize?: number;
  144641. gapSize?: number;
  144642. dashNb?: number;
  144643. updatable?: boolean;
  144644. instance?: LinesMesh;
  144645. }, scene?: Nullable<Scene>): LinesMesh;
  144646. /**
  144647. * 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.
  144648. * * 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.
  144649. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144650. * * 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.
  144651. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  144652. * * 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
  144653. * * 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
  144654. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  144655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  144658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144659. * @param name defines the name of the mesh
  144660. * @param options defines the options used to create the mesh
  144661. * @param scene defines the hosting scene
  144662. * @returns the extruded shape mesh
  144663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144665. */
  144666. static ExtrudeShape(name: string, options: {
  144667. shape: Vector3[];
  144668. path: Vector3[];
  144669. scale?: number;
  144670. rotation?: number;
  144671. cap?: number;
  144672. updatable?: boolean;
  144673. sideOrientation?: number;
  144674. frontUVs?: Vector4;
  144675. backUVs?: Vector4;
  144676. instance?: Mesh;
  144677. invertUV?: boolean;
  144678. }, scene?: Nullable<Scene>): Mesh;
  144679. /**
  144680. * Creates an custom extruded shape mesh.
  144681. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  144682. * * 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.
  144683. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  144684. * * 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
  144685. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  144686. * * 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
  144687. * * It must returns a float value that will be the scale value applied to the shape on each path point
  144688. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  144689. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  144690. * * 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
  144691. * * 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
  144692. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  144693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144695. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144697. * @param name defines the name of the mesh
  144698. * @param options defines the options used to create the mesh
  144699. * @param scene defines the hosting scene
  144700. * @returns the custom extruded shape mesh
  144701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  144702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  144704. */
  144705. static ExtrudeShapeCustom(name: string, options: {
  144706. shape: Vector3[];
  144707. path: Vector3[];
  144708. scaleFunction?: any;
  144709. rotationFunction?: any;
  144710. ribbonCloseArray?: boolean;
  144711. ribbonClosePath?: boolean;
  144712. cap?: number;
  144713. updatable?: boolean;
  144714. sideOrientation?: number;
  144715. frontUVs?: Vector4;
  144716. backUVs?: Vector4;
  144717. instance?: Mesh;
  144718. invertUV?: boolean;
  144719. }, scene?: Nullable<Scene>): Mesh;
  144720. /**
  144721. * Creates lathe mesh.
  144722. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  144723. * * 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
  144724. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  144725. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  144726. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  144727. * * 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
  144728. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  144729. * * 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
  144730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144732. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144734. * @param name defines the name of the mesh
  144735. * @param options defines the options used to create the mesh
  144736. * @param scene defines the hosting scene
  144737. * @returns the lathe mesh
  144738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  144739. */
  144740. static CreateLathe(name: string, options: {
  144741. shape: Vector3[];
  144742. radius?: number;
  144743. tessellation?: number;
  144744. clip?: number;
  144745. arc?: number;
  144746. closed?: boolean;
  144747. updatable?: boolean;
  144748. sideOrientation?: number;
  144749. frontUVs?: Vector4;
  144750. backUVs?: Vector4;
  144751. cap?: number;
  144752. invertUV?: boolean;
  144753. }, scene?: Nullable<Scene>): Mesh;
  144754. /**
  144755. * Creates a tiled plane mesh
  144756. * * You can set a limited pattern arrangement with the tiles
  144757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144760. * @param name defines the name of the mesh
  144761. * @param options defines the options used to create the mesh
  144762. * @param scene defines the hosting scene
  144763. * @returns the plane mesh
  144764. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144765. */
  144766. static CreateTiledPlane(name: string, options: {
  144767. pattern?: number;
  144768. tileSize?: number;
  144769. tileWidth?: number;
  144770. tileHeight?: number;
  144771. size?: number;
  144772. width?: number;
  144773. height?: number;
  144774. alignHorizontal?: number;
  144775. alignVertical?: number;
  144776. sideOrientation?: number;
  144777. frontUVs?: Vector4;
  144778. backUVs?: Vector4;
  144779. updatable?: boolean;
  144780. }, scene?: Nullable<Scene>): Mesh;
  144781. /**
  144782. * Creates a plane mesh
  144783. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  144784. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  144785. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  144786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144789. * @param name defines the name of the mesh
  144790. * @param options defines the options used to create the mesh
  144791. * @param scene defines the hosting scene
  144792. * @returns the plane mesh
  144793. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  144794. */
  144795. static CreatePlane(name: string, options: {
  144796. size?: number;
  144797. width?: number;
  144798. height?: number;
  144799. sideOrientation?: number;
  144800. frontUVs?: Vector4;
  144801. backUVs?: Vector4;
  144802. updatable?: boolean;
  144803. sourcePlane?: Plane;
  144804. }, scene?: Nullable<Scene>): Mesh;
  144805. /**
  144806. * Creates a ground mesh
  144807. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  144808. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  144809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144810. * @param name defines the name of the mesh
  144811. * @param options defines the options used to create the mesh
  144812. * @param scene defines the hosting scene
  144813. * @returns the ground mesh
  144814. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  144815. */
  144816. static CreateGround(name: string, options: {
  144817. width?: number;
  144818. height?: number;
  144819. subdivisions?: number;
  144820. subdivisionsX?: number;
  144821. subdivisionsY?: number;
  144822. updatable?: boolean;
  144823. }, scene?: Nullable<Scene>): Mesh;
  144824. /**
  144825. * Creates a tiled ground mesh
  144826. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  144827. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  144828. * * 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
  144829. * * 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
  144830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144831. * @param name defines the name of the mesh
  144832. * @param options defines the options used to create the mesh
  144833. * @param scene defines the hosting scene
  144834. * @returns the tiled ground mesh
  144835. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  144836. */
  144837. static CreateTiledGround(name: string, options: {
  144838. xmin: number;
  144839. zmin: number;
  144840. xmax: number;
  144841. zmax: number;
  144842. subdivisions?: {
  144843. w: number;
  144844. h: number;
  144845. };
  144846. precision?: {
  144847. w: number;
  144848. h: number;
  144849. };
  144850. updatable?: boolean;
  144851. }, scene?: Nullable<Scene>): Mesh;
  144852. /**
  144853. * Creates a ground mesh from a height map
  144854. * * The parameter `url` sets the URL of the height map image resource.
  144855. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  144856. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  144857. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  144858. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  144859. * * 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.
  144860. * * 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).
  144861. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  144862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  144863. * @param name defines the name of the mesh
  144864. * @param url defines the url to the height map
  144865. * @param options defines the options used to create the mesh
  144866. * @param scene defines the hosting scene
  144867. * @returns the ground mesh
  144868. * @see https://doc.babylonjs.com/babylon101/height_map
  144869. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  144870. */
  144871. static CreateGroundFromHeightMap(name: string, url: string, options: {
  144872. width?: number;
  144873. height?: number;
  144874. subdivisions?: number;
  144875. minHeight?: number;
  144876. maxHeight?: number;
  144877. colorFilter?: Color3;
  144878. alphaFilter?: number;
  144879. updatable?: boolean;
  144880. onReady?: (mesh: GroundMesh) => void;
  144881. }, scene?: Nullable<Scene>): GroundMesh;
  144882. /**
  144883. * Creates a polygon mesh
  144884. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  144885. * * 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
  144886. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  144887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  144889. * * Remember you can only change the shape positions, not their number when updating a polygon
  144890. * @param name defines the name of the mesh
  144891. * @param options defines the options used to create the mesh
  144892. * @param scene defines the hosting scene
  144893. * @param earcutInjection can be used to inject your own earcut reference
  144894. * @returns the polygon mesh
  144895. */
  144896. static CreatePolygon(name: string, options: {
  144897. shape: Vector3[];
  144898. holes?: Vector3[][];
  144899. depth?: number;
  144900. faceUV?: Vector4[];
  144901. faceColors?: Color4[];
  144902. updatable?: boolean;
  144903. sideOrientation?: number;
  144904. frontUVs?: Vector4;
  144905. backUVs?: Vector4;
  144906. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144907. /**
  144908. * Creates an extruded polygon mesh, with depth in the Y direction.
  144909. * * 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)
  144910. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  144911. * @param name defines the name of the mesh
  144912. * @param options defines the options used to create the mesh
  144913. * @param scene defines the hosting scene
  144914. * @param earcutInjection can be used to inject your own earcut reference
  144915. * @returns the polygon mesh
  144916. */
  144917. static ExtrudePolygon(name: string, options: {
  144918. shape: Vector3[];
  144919. holes?: Vector3[][];
  144920. depth?: number;
  144921. faceUV?: Vector4[];
  144922. faceColors?: Color4[];
  144923. updatable?: boolean;
  144924. sideOrientation?: number;
  144925. frontUVs?: Vector4;
  144926. backUVs?: Vector4;
  144927. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  144928. /**
  144929. * Creates a tube mesh.
  144930. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  144931. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  144932. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  144933. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  144934. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  144935. * * 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)
  144936. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  144937. * * 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
  144938. * * 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
  144939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144941. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  144942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144943. * @param name defines the name of the mesh
  144944. * @param options defines the options used to create the mesh
  144945. * @param scene defines the hosting scene
  144946. * @returns the tube mesh
  144947. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  144948. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  144949. */
  144950. static CreateTube(name: string, options: {
  144951. path: Vector3[];
  144952. radius?: number;
  144953. tessellation?: number;
  144954. radiusFunction?: {
  144955. (i: number, distance: number): number;
  144956. };
  144957. cap?: number;
  144958. arc?: number;
  144959. updatable?: boolean;
  144960. sideOrientation?: number;
  144961. frontUVs?: Vector4;
  144962. backUVs?: Vector4;
  144963. instance?: Mesh;
  144964. invertUV?: boolean;
  144965. }, scene?: Nullable<Scene>): Mesh;
  144966. /**
  144967. * Creates a polyhedron mesh
  144968. * * 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
  144969. * * The parameter `size` (positive float, default 1) sets the polygon size
  144970. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  144971. * * 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`
  144972. * * 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
  144973. * * 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)`)
  144974. * * 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
  144975. * * 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
  144976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  144977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  144978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  144979. * @param name defines the name of the mesh
  144980. * @param options defines the options used to create the mesh
  144981. * @param scene defines the hosting scene
  144982. * @returns the polyhedron mesh
  144983. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  144984. */
  144985. static CreatePolyhedron(name: string, options: {
  144986. type?: number;
  144987. size?: number;
  144988. sizeX?: number;
  144989. sizeY?: number;
  144990. sizeZ?: number;
  144991. custom?: any;
  144992. faceUV?: Vector4[];
  144993. faceColors?: Color4[];
  144994. flat?: boolean;
  144995. updatable?: boolean;
  144996. sideOrientation?: number;
  144997. frontUVs?: Vector4;
  144998. backUVs?: Vector4;
  144999. }, scene?: Nullable<Scene>): Mesh;
  145000. /**
  145001. * Creates a decal mesh.
  145002. * 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
  145003. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145004. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145005. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145006. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145007. * @param name defines the name of the mesh
  145008. * @param sourceMesh defines the mesh where the decal must be applied
  145009. * @param options defines the options used to create the mesh
  145010. * @param scene defines the hosting scene
  145011. * @returns the decal mesh
  145012. * @see https://doc.babylonjs.com/how_to/decals
  145013. */
  145014. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145015. position?: Vector3;
  145016. normal?: Vector3;
  145017. size?: Vector3;
  145018. angle?: number;
  145019. }): Mesh;
  145020. }
  145021. }
  145022. declare module BABYLON {
  145023. /**
  145024. * A simplifier interface for future simplification implementations
  145025. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145026. */
  145027. export interface ISimplifier {
  145028. /**
  145029. * Simplification of a given mesh according to the given settings.
  145030. * Since this requires computation, it is assumed that the function runs async.
  145031. * @param settings The settings of the simplification, including quality and distance
  145032. * @param successCallback A callback that will be called after the mesh was simplified.
  145033. * @param errorCallback in case of an error, this callback will be called. optional.
  145034. */
  145035. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  145036. }
  145037. /**
  145038. * Expected simplification settings.
  145039. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  145040. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145041. */
  145042. export interface ISimplificationSettings {
  145043. /**
  145044. * Gets or sets the expected quality
  145045. */
  145046. quality: number;
  145047. /**
  145048. * Gets or sets the distance when this optimized version should be used
  145049. */
  145050. distance: number;
  145051. /**
  145052. * Gets an already optimized mesh
  145053. */
  145054. optimizeMesh?: boolean;
  145055. }
  145056. /**
  145057. * Class used to specify simplification options
  145058. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145059. */
  145060. export class SimplificationSettings implements ISimplificationSettings {
  145061. /** expected quality */
  145062. quality: number;
  145063. /** distance when this optimized version should be used */
  145064. distance: number;
  145065. /** already optimized mesh */
  145066. optimizeMesh?: boolean | undefined;
  145067. /**
  145068. * Creates a SimplificationSettings
  145069. * @param quality expected quality
  145070. * @param distance distance when this optimized version should be used
  145071. * @param optimizeMesh already optimized mesh
  145072. */
  145073. constructor(
  145074. /** expected quality */
  145075. quality: number,
  145076. /** distance when this optimized version should be used */
  145077. distance: number,
  145078. /** already optimized mesh */
  145079. optimizeMesh?: boolean | undefined);
  145080. }
  145081. /**
  145082. * Interface used to define a simplification task
  145083. */
  145084. export interface ISimplificationTask {
  145085. /**
  145086. * Array of settings
  145087. */
  145088. settings: Array<ISimplificationSettings>;
  145089. /**
  145090. * Simplification type
  145091. */
  145092. simplificationType: SimplificationType;
  145093. /**
  145094. * Mesh to simplify
  145095. */
  145096. mesh: Mesh;
  145097. /**
  145098. * Callback called on success
  145099. */
  145100. successCallback?: () => void;
  145101. /**
  145102. * Defines if parallel processing can be used
  145103. */
  145104. parallelProcessing: boolean;
  145105. }
  145106. /**
  145107. * Queue used to order the simplification tasks
  145108. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145109. */
  145110. export class SimplificationQueue {
  145111. private _simplificationArray;
  145112. /**
  145113. * Gets a boolean indicating that the process is still running
  145114. */
  145115. running: boolean;
  145116. /**
  145117. * Creates a new queue
  145118. */
  145119. constructor();
  145120. /**
  145121. * Adds a new simplification task
  145122. * @param task defines a task to add
  145123. */
  145124. addTask(task: ISimplificationTask): void;
  145125. /**
  145126. * Execute next task
  145127. */
  145128. executeNext(): void;
  145129. /**
  145130. * Execute a simplification task
  145131. * @param task defines the task to run
  145132. */
  145133. runSimplification(task: ISimplificationTask): void;
  145134. private getSimplifier;
  145135. }
  145136. /**
  145137. * The implemented types of simplification
  145138. * At the moment only Quadratic Error Decimation is implemented
  145139. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145140. */
  145141. export enum SimplificationType {
  145142. /** Quadratic error decimation */
  145143. QUADRATIC = 0
  145144. }
  145145. /**
  145146. * An implementation of the Quadratic Error simplification algorithm.
  145147. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  145148. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  145149. * @author RaananW
  145150. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145151. */
  145152. export class QuadraticErrorSimplification implements ISimplifier {
  145153. private _mesh;
  145154. private triangles;
  145155. private vertices;
  145156. private references;
  145157. private _reconstructedMesh;
  145158. /** Gets or sets the number pf sync interations */
  145159. syncIterations: number;
  145160. /** Gets or sets the aggressiveness of the simplifier */
  145161. aggressiveness: number;
  145162. /** Gets or sets the number of allowed iterations for decimation */
  145163. decimationIterations: number;
  145164. /** Gets or sets the espilon to use for bounding box computation */
  145165. boundingBoxEpsilon: number;
  145166. /**
  145167. * Creates a new QuadraticErrorSimplification
  145168. * @param _mesh defines the target mesh
  145169. */
  145170. constructor(_mesh: Mesh);
  145171. /**
  145172. * Simplification of a given mesh according to the given settings.
  145173. * Since this requires computation, it is assumed that the function runs async.
  145174. * @param settings The settings of the simplification, including quality and distance
  145175. * @param successCallback A callback that will be called after the mesh was simplified.
  145176. */
  145177. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  145178. private runDecimation;
  145179. private initWithMesh;
  145180. private init;
  145181. private reconstructMesh;
  145182. private initDecimatedMesh;
  145183. private isFlipped;
  145184. private updateTriangles;
  145185. private identifyBorder;
  145186. private updateMesh;
  145187. private vertexError;
  145188. private calculateError;
  145189. }
  145190. }
  145191. declare module BABYLON {
  145192. interface Scene {
  145193. /** @hidden (Backing field) */
  145194. _simplificationQueue: SimplificationQueue;
  145195. /**
  145196. * Gets or sets the simplification queue attached to the scene
  145197. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  145198. */
  145199. simplificationQueue: SimplificationQueue;
  145200. }
  145201. interface Mesh {
  145202. /**
  145203. * Simplify the mesh according to the given array of settings.
  145204. * Function will return immediately and will simplify async
  145205. * @param settings a collection of simplification settings
  145206. * @param parallelProcessing should all levels calculate parallel or one after the other
  145207. * @param simplificationType the type of simplification to run
  145208. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  145209. * @returns the current mesh
  145210. */
  145211. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  145212. }
  145213. /**
  145214. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  145215. * created in a scene
  145216. */
  145217. export class SimplicationQueueSceneComponent implements ISceneComponent {
  145218. /**
  145219. * The component name helpfull to identify the component in the list of scene components.
  145220. */
  145221. readonly name: string;
  145222. /**
  145223. * The scene the component belongs to.
  145224. */
  145225. scene: Scene;
  145226. /**
  145227. * Creates a new instance of the component for the given scene
  145228. * @param scene Defines the scene to register the component in
  145229. */
  145230. constructor(scene: Scene);
  145231. /**
  145232. * Registers the component in a given scene
  145233. */
  145234. register(): void;
  145235. /**
  145236. * Rebuilds the elements related to this component in case of
  145237. * context lost for instance.
  145238. */
  145239. rebuild(): void;
  145240. /**
  145241. * Disposes the component and the associated ressources
  145242. */
  145243. dispose(): void;
  145244. private _beforeCameraUpdate;
  145245. }
  145246. }
  145247. declare module BABYLON {
  145248. interface Mesh {
  145249. /**
  145250. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  145251. */
  145252. thinInstanceEnablePicking: boolean;
  145253. /**
  145254. * Creates a new thin instance
  145255. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  145256. * @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
  145257. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  145258. */
  145259. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  145260. /**
  145261. * Adds the transformation (matrix) of the current mesh as a thin instance
  145262. * @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
  145263. * @returns the thin instance index number
  145264. */
  145265. thinInstanceAddSelf(refresh: boolean): number;
  145266. /**
  145267. * Registers a custom attribute to be used with thin instances
  145268. * @param kind name of the attribute
  145269. * @param stride size in floats of the attribute
  145270. */
  145271. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  145272. /**
  145273. * Sets the matrix of a thin instance
  145274. * @param index index of the thin instance
  145275. * @param matrix matrix to set
  145276. * @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
  145277. */
  145278. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  145279. /**
  145280. * Sets the value of a custom attribute for a thin instance
  145281. * @param kind name of the attribute
  145282. * @param index index of the thin instance
  145283. * @param value value to set
  145284. * @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
  145285. */
  145286. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  145287. /**
  145288. * 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.
  145289. */
  145290. thinInstanceCount: number;
  145291. /**
  145292. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  145293. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  145294. * @param buffer buffer to set
  145295. * @param stride size in floats of each value of the buffer
  145296. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  145297. */
  145298. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  145299. /**
  145300. * Gets the list of world matrices
  145301. * @return an array containing all the world matrices from the thin instances
  145302. */
  145303. thinInstanceGetWorldMatrices(): Matrix[];
  145304. /**
  145305. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  145306. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  145307. */
  145308. thinInstanceBufferUpdated(kind: string): void;
  145309. /**
  145310. * Refreshes the bounding info, taking into account all the thin instances defined
  145311. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  145312. */
  145313. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  145314. /** @hidden */
  145315. _thinInstanceInitializeUserStorage(): void;
  145316. /** @hidden */
  145317. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  145318. /** @hidden */
  145319. _userThinInstanceBuffersStorage: {
  145320. data: {
  145321. [key: string]: Float32Array;
  145322. };
  145323. sizes: {
  145324. [key: string]: number;
  145325. };
  145326. vertexBuffers: {
  145327. [key: string]: Nullable<VertexBuffer>;
  145328. };
  145329. strides: {
  145330. [key: string]: number;
  145331. };
  145332. };
  145333. }
  145334. }
  145335. declare module BABYLON {
  145336. /**
  145337. * Navigation plugin interface to add navigation constrained by a navigation mesh
  145338. */
  145339. export interface INavigationEnginePlugin {
  145340. /**
  145341. * plugin name
  145342. */
  145343. name: string;
  145344. /**
  145345. * Creates a navigation mesh
  145346. * @param meshes array of all the geometry used to compute the navigatio mesh
  145347. * @param parameters bunch of parameters used to filter geometry
  145348. */
  145349. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145350. /**
  145351. * Create a navigation mesh debug mesh
  145352. * @param scene is where the mesh will be added
  145353. * @returns debug display mesh
  145354. */
  145355. createDebugNavMesh(scene: Scene): Mesh;
  145356. /**
  145357. * Get a navigation mesh constrained position, closest to the parameter position
  145358. * @param position world position
  145359. * @returns the closest point to position constrained by the navigation mesh
  145360. */
  145361. getClosestPoint(position: Vector3): Vector3;
  145362. /**
  145363. * Get a navigation mesh constrained position, closest to the parameter position
  145364. * @param position world position
  145365. * @param result output the closest point to position constrained by the navigation mesh
  145366. */
  145367. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145368. /**
  145369. * Get a navigation mesh constrained position, within a particular radius
  145370. * @param position world position
  145371. * @param maxRadius the maximum distance to the constrained world position
  145372. * @returns the closest point to position constrained by the navigation mesh
  145373. */
  145374. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145375. /**
  145376. * Get a navigation mesh constrained position, within a particular radius
  145377. * @param position world position
  145378. * @param maxRadius the maximum distance to the constrained world position
  145379. * @param result output the closest point to position constrained by the navigation mesh
  145380. */
  145381. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145382. /**
  145383. * Compute the final position from a segment made of destination-position
  145384. * @param position world position
  145385. * @param destination world position
  145386. * @returns the resulting point along the navmesh
  145387. */
  145388. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145389. /**
  145390. * Compute the final position from a segment made of destination-position
  145391. * @param position world position
  145392. * @param destination world position
  145393. * @param result output the resulting point along the navmesh
  145394. */
  145395. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145396. /**
  145397. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145398. * @param start world position
  145399. * @param end world position
  145400. * @returns array containing world position composing the path
  145401. */
  145402. computePath(start: Vector3, end: Vector3): Vector3[];
  145403. /**
  145404. * If this plugin is supported
  145405. * @returns true if plugin is supported
  145406. */
  145407. isSupported(): boolean;
  145408. /**
  145409. * Create a new Crowd so you can add agents
  145410. * @param maxAgents the maximum agent count in the crowd
  145411. * @param maxAgentRadius the maximum radius an agent can have
  145412. * @param scene to attach the crowd to
  145413. * @returns the crowd you can add agents to
  145414. */
  145415. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145416. /**
  145417. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145418. * The queries will try to find a solution within those bounds
  145419. * default is (1,1,1)
  145420. * @param extent x,y,z value that define the extent around the queries point of reference
  145421. */
  145422. setDefaultQueryExtent(extent: Vector3): void;
  145423. /**
  145424. * Get the Bounding box extent specified by setDefaultQueryExtent
  145425. * @returns the box extent values
  145426. */
  145427. getDefaultQueryExtent(): Vector3;
  145428. /**
  145429. * build the navmesh from a previously saved state using getNavmeshData
  145430. * @param data the Uint8Array returned by getNavmeshData
  145431. */
  145432. buildFromNavmeshData(data: Uint8Array): void;
  145433. /**
  145434. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145435. * @returns data the Uint8Array that can be saved and reused
  145436. */
  145437. getNavmeshData(): Uint8Array;
  145438. /**
  145439. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145440. * @param result output the box extent values
  145441. */
  145442. getDefaultQueryExtentToRef(result: Vector3): void;
  145443. /**
  145444. * Release all resources
  145445. */
  145446. dispose(): void;
  145447. }
  145448. /**
  145449. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  145450. */
  145451. export interface ICrowd {
  145452. /**
  145453. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145454. * You can attach anything to that node. The node position is updated in the scene update tick.
  145455. * @param pos world position that will be constrained by the navigation mesh
  145456. * @param parameters agent parameters
  145457. * @param transform hooked to the agent that will be update by the scene
  145458. * @returns agent index
  145459. */
  145460. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145461. /**
  145462. * Returns the agent position in world space
  145463. * @param index agent index returned by addAgent
  145464. * @returns world space position
  145465. */
  145466. getAgentPosition(index: number): Vector3;
  145467. /**
  145468. * Gets the agent position result in world space
  145469. * @param index agent index returned by addAgent
  145470. * @param result output world space position
  145471. */
  145472. getAgentPositionToRef(index: number, result: Vector3): void;
  145473. /**
  145474. * Gets the agent velocity in world space
  145475. * @param index agent index returned by addAgent
  145476. * @returns world space velocity
  145477. */
  145478. getAgentVelocity(index: number): Vector3;
  145479. /**
  145480. * Gets the agent velocity result in world space
  145481. * @param index agent index returned by addAgent
  145482. * @param result output world space velocity
  145483. */
  145484. getAgentVelocityToRef(index: number, result: Vector3): void;
  145485. /**
  145486. * remove a particular agent previously created
  145487. * @param index agent index returned by addAgent
  145488. */
  145489. removeAgent(index: number): void;
  145490. /**
  145491. * get the list of all agents attached to this crowd
  145492. * @returns list of agent indices
  145493. */
  145494. getAgents(): number[];
  145495. /**
  145496. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145497. * @param deltaTime in seconds
  145498. */
  145499. update(deltaTime: number): void;
  145500. /**
  145501. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145502. * @param index agent index returned by addAgent
  145503. * @param destination targeted world position
  145504. */
  145505. agentGoto(index: number, destination: Vector3): void;
  145506. /**
  145507. * Teleport the agent to a new position
  145508. * @param index agent index returned by addAgent
  145509. * @param destination targeted world position
  145510. */
  145511. agentTeleport(index: number, destination: Vector3): void;
  145512. /**
  145513. * Update agent parameters
  145514. * @param index agent index returned by addAgent
  145515. * @param parameters agent parameters
  145516. */
  145517. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145518. /**
  145519. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145520. * The queries will try to find a solution within those bounds
  145521. * default is (1,1,1)
  145522. * @param extent x,y,z value that define the extent around the queries point of reference
  145523. */
  145524. setDefaultQueryExtent(extent: Vector3): void;
  145525. /**
  145526. * Get the Bounding box extent specified by setDefaultQueryExtent
  145527. * @returns the box extent values
  145528. */
  145529. getDefaultQueryExtent(): Vector3;
  145530. /**
  145531. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145532. * @param result output the box extent values
  145533. */
  145534. getDefaultQueryExtentToRef(result: Vector3): void;
  145535. /**
  145536. * Release all resources
  145537. */
  145538. dispose(): void;
  145539. }
  145540. /**
  145541. * Configures an agent
  145542. */
  145543. export interface IAgentParameters {
  145544. /**
  145545. * Agent radius. [Limit: >= 0]
  145546. */
  145547. radius: number;
  145548. /**
  145549. * Agent height. [Limit: > 0]
  145550. */
  145551. height: number;
  145552. /**
  145553. * Maximum allowed acceleration. [Limit: >= 0]
  145554. */
  145555. maxAcceleration: number;
  145556. /**
  145557. * Maximum allowed speed. [Limit: >= 0]
  145558. */
  145559. maxSpeed: number;
  145560. /**
  145561. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  145562. */
  145563. collisionQueryRange: number;
  145564. /**
  145565. * The path visibility optimization range. [Limit: > 0]
  145566. */
  145567. pathOptimizationRange: number;
  145568. /**
  145569. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  145570. */
  145571. separationWeight: number;
  145572. }
  145573. /**
  145574. * Configures the navigation mesh creation
  145575. */
  145576. export interface INavMeshParameters {
  145577. /**
  145578. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  145579. */
  145580. cs: number;
  145581. /**
  145582. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  145583. */
  145584. ch: number;
  145585. /**
  145586. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  145587. */
  145588. walkableSlopeAngle: number;
  145589. /**
  145590. * Minimum floor to 'ceiling' height that will still allow the floor area to
  145591. * be considered walkable. [Limit: >= 3] [Units: vx]
  145592. */
  145593. walkableHeight: number;
  145594. /**
  145595. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  145596. */
  145597. walkableClimb: number;
  145598. /**
  145599. * The distance to erode/shrink the walkable area of the heightfield away from
  145600. * obstructions. [Limit: >=0] [Units: vx]
  145601. */
  145602. walkableRadius: number;
  145603. /**
  145604. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  145605. */
  145606. maxEdgeLen: number;
  145607. /**
  145608. * The maximum distance a simplfied contour's border edges should deviate
  145609. * the original raw contour. [Limit: >=0] [Units: vx]
  145610. */
  145611. maxSimplificationError: number;
  145612. /**
  145613. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  145614. */
  145615. minRegionArea: number;
  145616. /**
  145617. * Any regions with a span count smaller than this value will, if possible,
  145618. * be merged with larger regions. [Limit: >=0] [Units: vx]
  145619. */
  145620. mergeRegionArea: number;
  145621. /**
  145622. * The maximum number of vertices allowed for polygons generated during the
  145623. * contour to polygon conversion process. [Limit: >= 3]
  145624. */
  145625. maxVertsPerPoly: number;
  145626. /**
  145627. * Sets the sampling distance to use when generating the detail mesh.
  145628. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  145629. */
  145630. detailSampleDist: number;
  145631. /**
  145632. * The maximum distance the detail mesh surface should deviate from heightfield
  145633. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  145634. */
  145635. detailSampleMaxError: number;
  145636. }
  145637. }
  145638. declare module BABYLON {
  145639. /**
  145640. * RecastJS navigation plugin
  145641. */
  145642. export class RecastJSPlugin implements INavigationEnginePlugin {
  145643. /**
  145644. * Reference to the Recast library
  145645. */
  145646. bjsRECAST: any;
  145647. /**
  145648. * plugin name
  145649. */
  145650. name: string;
  145651. /**
  145652. * the first navmesh created. We might extend this to support multiple navmeshes
  145653. */
  145654. navMesh: any;
  145655. /**
  145656. * Initializes the recastJS plugin
  145657. * @param recastInjection can be used to inject your own recast reference
  145658. */
  145659. constructor(recastInjection?: any);
  145660. /**
  145661. * Creates a navigation mesh
  145662. * @param meshes array of all the geometry used to compute the navigatio mesh
  145663. * @param parameters bunch of parameters used to filter geometry
  145664. */
  145665. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  145666. /**
  145667. * Create a navigation mesh debug mesh
  145668. * @param scene is where the mesh will be added
  145669. * @returns debug display mesh
  145670. */
  145671. createDebugNavMesh(scene: Scene): Mesh;
  145672. /**
  145673. * Get a navigation mesh constrained position, closest to the parameter position
  145674. * @param position world position
  145675. * @returns the closest point to position constrained by the navigation mesh
  145676. */
  145677. getClosestPoint(position: Vector3): Vector3;
  145678. /**
  145679. * Get a navigation mesh constrained position, closest to the parameter position
  145680. * @param position world position
  145681. * @param result output the closest point to position constrained by the navigation mesh
  145682. */
  145683. getClosestPointToRef(position: Vector3, result: Vector3): void;
  145684. /**
  145685. * Get a navigation mesh constrained position, within a particular radius
  145686. * @param position world position
  145687. * @param maxRadius the maximum distance to the constrained world position
  145688. * @returns the closest point to position constrained by the navigation mesh
  145689. */
  145690. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  145691. /**
  145692. * Get a navigation mesh constrained position, within a particular radius
  145693. * @param position world position
  145694. * @param maxRadius the maximum distance to the constrained world position
  145695. * @param result output the closest point to position constrained by the navigation mesh
  145696. */
  145697. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  145698. /**
  145699. * Compute the final position from a segment made of destination-position
  145700. * @param position world position
  145701. * @param destination world position
  145702. * @returns the resulting point along the navmesh
  145703. */
  145704. moveAlong(position: Vector3, destination: Vector3): Vector3;
  145705. /**
  145706. * Compute the final position from a segment made of destination-position
  145707. * @param position world position
  145708. * @param destination world position
  145709. * @param result output the resulting point along the navmesh
  145710. */
  145711. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  145712. /**
  145713. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  145714. * @param start world position
  145715. * @param end world position
  145716. * @returns array containing world position composing the path
  145717. */
  145718. computePath(start: Vector3, end: Vector3): Vector3[];
  145719. /**
  145720. * Create a new Crowd so you can add agents
  145721. * @param maxAgents the maximum agent count in the crowd
  145722. * @param maxAgentRadius the maximum radius an agent can have
  145723. * @param scene to attach the crowd to
  145724. * @returns the crowd you can add agents to
  145725. */
  145726. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  145727. /**
  145728. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145729. * The queries will try to find a solution within those bounds
  145730. * default is (1,1,1)
  145731. * @param extent x,y,z value that define the extent around the queries point of reference
  145732. */
  145733. setDefaultQueryExtent(extent: Vector3): void;
  145734. /**
  145735. * Get the Bounding box extent specified by setDefaultQueryExtent
  145736. * @returns the box extent values
  145737. */
  145738. getDefaultQueryExtent(): Vector3;
  145739. /**
  145740. * build the navmesh from a previously saved state using getNavmeshData
  145741. * @param data the Uint8Array returned by getNavmeshData
  145742. */
  145743. buildFromNavmeshData(data: Uint8Array): void;
  145744. /**
  145745. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  145746. * @returns data the Uint8Array that can be saved and reused
  145747. */
  145748. getNavmeshData(): Uint8Array;
  145749. /**
  145750. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145751. * @param result output the box extent values
  145752. */
  145753. getDefaultQueryExtentToRef(result: Vector3): void;
  145754. /**
  145755. * Disposes
  145756. */
  145757. dispose(): void;
  145758. /**
  145759. * If this plugin is supported
  145760. * @returns true if plugin is supported
  145761. */
  145762. isSupported(): boolean;
  145763. }
  145764. /**
  145765. * Recast detour crowd implementation
  145766. */
  145767. export class RecastJSCrowd implements ICrowd {
  145768. /**
  145769. * Recast/detour plugin
  145770. */
  145771. bjsRECASTPlugin: RecastJSPlugin;
  145772. /**
  145773. * Link to the detour crowd
  145774. */
  145775. recastCrowd: any;
  145776. /**
  145777. * One transform per agent
  145778. */
  145779. transforms: TransformNode[];
  145780. /**
  145781. * All agents created
  145782. */
  145783. agents: number[];
  145784. /**
  145785. * Link to the scene is kept to unregister the crowd from the scene
  145786. */
  145787. private _scene;
  145788. /**
  145789. * Observer for crowd updates
  145790. */
  145791. private _onBeforeAnimationsObserver;
  145792. /**
  145793. * Constructor
  145794. * @param plugin recastJS plugin
  145795. * @param maxAgents the maximum agent count in the crowd
  145796. * @param maxAgentRadius the maximum radius an agent can have
  145797. * @param scene to attach the crowd to
  145798. * @returns the crowd you can add agents to
  145799. */
  145800. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  145801. /**
  145802. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  145803. * You can attach anything to that node. The node position is updated in the scene update tick.
  145804. * @param pos world position that will be constrained by the navigation mesh
  145805. * @param parameters agent parameters
  145806. * @param transform hooked to the agent that will be update by the scene
  145807. * @returns agent index
  145808. */
  145809. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  145810. /**
  145811. * Returns the agent position in world space
  145812. * @param index agent index returned by addAgent
  145813. * @returns world space position
  145814. */
  145815. getAgentPosition(index: number): Vector3;
  145816. /**
  145817. * Returns the agent position result in world space
  145818. * @param index agent index returned by addAgent
  145819. * @param result output world space position
  145820. */
  145821. getAgentPositionToRef(index: number, result: Vector3): void;
  145822. /**
  145823. * Returns the agent velocity in world space
  145824. * @param index agent index returned by addAgent
  145825. * @returns world space velocity
  145826. */
  145827. getAgentVelocity(index: number): Vector3;
  145828. /**
  145829. * Returns the agent velocity result in world space
  145830. * @param index agent index returned by addAgent
  145831. * @param result output world space velocity
  145832. */
  145833. getAgentVelocityToRef(index: number, result: Vector3): void;
  145834. /**
  145835. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  145836. * @param index agent index returned by addAgent
  145837. * @param destination targeted world position
  145838. */
  145839. agentGoto(index: number, destination: Vector3): void;
  145840. /**
  145841. * Teleport the agent to a new position
  145842. * @param index agent index returned by addAgent
  145843. * @param destination targeted world position
  145844. */
  145845. agentTeleport(index: number, destination: Vector3): void;
  145846. /**
  145847. * Update agent parameters
  145848. * @param index agent index returned by addAgent
  145849. * @param parameters agent parameters
  145850. */
  145851. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  145852. /**
  145853. * remove a particular agent previously created
  145854. * @param index agent index returned by addAgent
  145855. */
  145856. removeAgent(index: number): void;
  145857. /**
  145858. * get the list of all agents attached to this crowd
  145859. * @returns list of agent indices
  145860. */
  145861. getAgents(): number[];
  145862. /**
  145863. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  145864. * @param deltaTime in seconds
  145865. */
  145866. update(deltaTime: number): void;
  145867. /**
  145868. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  145869. * The queries will try to find a solution within those bounds
  145870. * default is (1,1,1)
  145871. * @param extent x,y,z value that define the extent around the queries point of reference
  145872. */
  145873. setDefaultQueryExtent(extent: Vector3): void;
  145874. /**
  145875. * Get the Bounding box extent specified by setDefaultQueryExtent
  145876. * @returns the box extent values
  145877. */
  145878. getDefaultQueryExtent(): Vector3;
  145879. /**
  145880. * Get the Bounding box extent result specified by setDefaultQueryExtent
  145881. * @param result output the box extent values
  145882. */
  145883. getDefaultQueryExtentToRef(result: Vector3): void;
  145884. /**
  145885. * Release all resources
  145886. */
  145887. dispose(): void;
  145888. }
  145889. }
  145890. declare module BABYLON {
  145891. /**
  145892. * Class used to enable access to IndexedDB
  145893. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  145894. */
  145895. export class Database implements IOfflineProvider {
  145896. private _callbackManifestChecked;
  145897. private _currentSceneUrl;
  145898. private _db;
  145899. private _enableSceneOffline;
  145900. private _enableTexturesOffline;
  145901. private _manifestVersionFound;
  145902. private _mustUpdateRessources;
  145903. private _hasReachedQuota;
  145904. private _isSupported;
  145905. private _idbFactory;
  145906. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  145907. private static IsUASupportingBlobStorage;
  145908. /**
  145909. * Gets a boolean indicating if Database storate is enabled (off by default)
  145910. */
  145911. static IDBStorageEnabled: boolean;
  145912. /**
  145913. * Gets a boolean indicating if scene must be saved in the database
  145914. */
  145915. get enableSceneOffline(): boolean;
  145916. /**
  145917. * Gets a boolean indicating if textures must be saved in the database
  145918. */
  145919. get enableTexturesOffline(): boolean;
  145920. /**
  145921. * Creates a new Database
  145922. * @param urlToScene defines the url to load the scene
  145923. * @param callbackManifestChecked defines the callback to use when manifest is checked
  145924. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  145925. */
  145926. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  145927. private static _ParseURL;
  145928. private static _ReturnFullUrlLocation;
  145929. private _checkManifestFile;
  145930. /**
  145931. * Open the database and make it available
  145932. * @param successCallback defines the callback to call on success
  145933. * @param errorCallback defines the callback to call on error
  145934. */
  145935. open(successCallback: () => void, errorCallback: () => void): void;
  145936. /**
  145937. * Loads an image from the database
  145938. * @param url defines the url to load from
  145939. * @param image defines the target DOM image
  145940. */
  145941. loadImage(url: string, image: HTMLImageElement): void;
  145942. private _loadImageFromDBAsync;
  145943. private _saveImageIntoDBAsync;
  145944. private _checkVersionFromDB;
  145945. private _loadVersionFromDBAsync;
  145946. private _saveVersionIntoDBAsync;
  145947. /**
  145948. * Loads a file from database
  145949. * @param url defines the URL to load from
  145950. * @param sceneLoaded defines a callback to call on success
  145951. * @param progressCallBack defines a callback to call when progress changed
  145952. * @param errorCallback defines a callback to call on error
  145953. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  145954. */
  145955. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  145956. private _loadFileAsync;
  145957. private _saveFileAsync;
  145958. /**
  145959. * Validates if xhr data is correct
  145960. * @param xhr defines the request to validate
  145961. * @param dataType defines the expected data type
  145962. * @returns true if data is correct
  145963. */
  145964. private static _ValidateXHRData;
  145965. }
  145966. }
  145967. declare module BABYLON {
  145968. /** @hidden */
  145969. export var gpuUpdateParticlesPixelShader: {
  145970. name: string;
  145971. shader: string;
  145972. };
  145973. }
  145974. declare module BABYLON {
  145975. /** @hidden */
  145976. export var gpuUpdateParticlesVertexShader: {
  145977. name: string;
  145978. shader: string;
  145979. };
  145980. }
  145981. declare module BABYLON {
  145982. /** @hidden */
  145983. export var clipPlaneFragmentDeclaration2: {
  145984. name: string;
  145985. shader: string;
  145986. };
  145987. }
  145988. declare module BABYLON {
  145989. /** @hidden */
  145990. export var gpuRenderParticlesPixelShader: {
  145991. name: string;
  145992. shader: string;
  145993. };
  145994. }
  145995. declare module BABYLON {
  145996. /** @hidden */
  145997. export var clipPlaneVertexDeclaration2: {
  145998. name: string;
  145999. shader: string;
  146000. };
  146001. }
  146002. declare module BABYLON {
  146003. /** @hidden */
  146004. export var gpuRenderParticlesVertexShader: {
  146005. name: string;
  146006. shader: string;
  146007. };
  146008. }
  146009. declare module BABYLON {
  146010. /**
  146011. * This represents a GPU particle system in Babylon
  146012. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  146013. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  146014. */
  146015. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  146016. /**
  146017. * The layer mask we are rendering the particles through.
  146018. */
  146019. layerMask: number;
  146020. private _capacity;
  146021. private _activeCount;
  146022. private _currentActiveCount;
  146023. private _accumulatedCount;
  146024. private _renderEffect;
  146025. private _updateEffect;
  146026. private _buffer0;
  146027. private _buffer1;
  146028. private _spriteBuffer;
  146029. private _updateVAO;
  146030. private _renderVAO;
  146031. private _targetIndex;
  146032. private _sourceBuffer;
  146033. private _targetBuffer;
  146034. private _currentRenderId;
  146035. private _started;
  146036. private _stopped;
  146037. private _timeDelta;
  146038. private _randomTexture;
  146039. private _randomTexture2;
  146040. private _attributesStrideSize;
  146041. private _updateEffectOptions;
  146042. private _randomTextureSize;
  146043. private _actualFrame;
  146044. private _customEffect;
  146045. private readonly _rawTextureWidth;
  146046. /**
  146047. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  146048. */
  146049. static get IsSupported(): boolean;
  146050. /**
  146051. * An event triggered when the system is disposed.
  146052. */
  146053. onDisposeObservable: Observable<IParticleSystem>;
  146054. /**
  146055. * Gets the maximum number of particles active at the same time.
  146056. * @returns The max number of active particles.
  146057. */
  146058. getCapacity(): number;
  146059. /**
  146060. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  146061. * to override the particles.
  146062. */
  146063. forceDepthWrite: boolean;
  146064. /**
  146065. * Gets or set the number of active particles
  146066. */
  146067. get activeParticleCount(): number;
  146068. set activeParticleCount(value: number);
  146069. private _preWarmDone;
  146070. /**
  146071. * Specifies if the particles are updated in emitter local space or world space.
  146072. */
  146073. isLocal: boolean;
  146074. /** Gets or sets a matrix to use to compute projection */
  146075. defaultProjectionMatrix: Matrix;
  146076. /**
  146077. * Is this system ready to be used/rendered
  146078. * @return true if the system is ready
  146079. */
  146080. isReady(): boolean;
  146081. /**
  146082. * Gets if the system has been started. (Note: this will still be true after stop is called)
  146083. * @returns True if it has been started, otherwise false.
  146084. */
  146085. isStarted(): boolean;
  146086. /**
  146087. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  146088. * @returns True if it has been stopped, otherwise false.
  146089. */
  146090. isStopped(): boolean;
  146091. /**
  146092. * Gets a boolean indicating that the system is stopping
  146093. * @returns true if the system is currently stopping
  146094. */
  146095. isStopping(): boolean;
  146096. /**
  146097. * Gets the number of particles active at the same time.
  146098. * @returns The number of active particles.
  146099. */
  146100. getActiveCount(): number;
  146101. /**
  146102. * Starts the particle system and begins to emit
  146103. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  146104. */
  146105. start(delay?: number): void;
  146106. /**
  146107. * Stops the particle system.
  146108. */
  146109. stop(): void;
  146110. /**
  146111. * Remove all active particles
  146112. */
  146113. reset(): void;
  146114. /**
  146115. * Returns the string "GPUParticleSystem"
  146116. * @returns a string containing the class name
  146117. */
  146118. getClassName(): string;
  146119. /**
  146120. * Gets the custom effect used to render the particles
  146121. * @param blendMode Blend mode for which the effect should be retrieved
  146122. * @returns The effect
  146123. */
  146124. getCustomEffect(blendMode?: number): Nullable<Effect>;
  146125. /**
  146126. * Sets the custom effect used to render the particles
  146127. * @param effect The effect to set
  146128. * @param blendMode Blend mode for which the effect should be set
  146129. */
  146130. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  146131. /** @hidden */
  146132. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  146133. /**
  146134. * Observable that will be called just before the particles are drawn
  146135. */
  146136. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  146137. /**
  146138. * Gets the name of the particle vertex shader
  146139. */
  146140. get vertexShaderName(): string;
  146141. private _colorGradientsTexture;
  146142. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  146143. /**
  146144. * Adds a new color gradient
  146145. * @param gradient defines the gradient to use (between 0 and 1)
  146146. * @param color1 defines the color to affect to the specified gradient
  146147. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  146148. * @returns the current particle system
  146149. */
  146150. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  146151. private _refreshColorGradient;
  146152. /** Force the system to rebuild all gradients that need to be resync */
  146153. forceRefreshGradients(): void;
  146154. /**
  146155. * Remove a specific color gradient
  146156. * @param gradient defines the gradient to remove
  146157. * @returns the current particle system
  146158. */
  146159. removeColorGradient(gradient: number): GPUParticleSystem;
  146160. private _angularSpeedGradientsTexture;
  146161. private _sizeGradientsTexture;
  146162. private _velocityGradientsTexture;
  146163. private _limitVelocityGradientsTexture;
  146164. private _dragGradientsTexture;
  146165. private _addFactorGradient;
  146166. /**
  146167. * Adds a new size gradient
  146168. * @param gradient defines the gradient to use (between 0 and 1)
  146169. * @param factor defines the size factor to affect to the specified gradient
  146170. * @returns the current particle system
  146171. */
  146172. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  146173. /**
  146174. * Remove a specific size gradient
  146175. * @param gradient defines the gradient to remove
  146176. * @returns the current particle system
  146177. */
  146178. removeSizeGradient(gradient: number): GPUParticleSystem;
  146179. private _refreshFactorGradient;
  146180. /**
  146181. * Adds a new angular speed gradient
  146182. * @param gradient defines the gradient to use (between 0 and 1)
  146183. * @param factor defines the angular speed to affect to the specified gradient
  146184. * @returns the current particle system
  146185. */
  146186. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  146187. /**
  146188. * Remove a specific angular speed gradient
  146189. * @param gradient defines the gradient to remove
  146190. * @returns the current particle system
  146191. */
  146192. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  146193. /**
  146194. * Adds a new velocity gradient
  146195. * @param gradient defines the gradient to use (between 0 and 1)
  146196. * @param factor defines the velocity to affect to the specified gradient
  146197. * @returns the current particle system
  146198. */
  146199. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146200. /**
  146201. * Remove a specific velocity gradient
  146202. * @param gradient defines the gradient to remove
  146203. * @returns the current particle system
  146204. */
  146205. removeVelocityGradient(gradient: number): GPUParticleSystem;
  146206. /**
  146207. * Adds a new limit velocity gradient
  146208. * @param gradient defines the gradient to use (between 0 and 1)
  146209. * @param factor defines the limit velocity value to affect to the specified gradient
  146210. * @returns the current particle system
  146211. */
  146212. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  146213. /**
  146214. * Remove a specific limit velocity gradient
  146215. * @param gradient defines the gradient to remove
  146216. * @returns the current particle system
  146217. */
  146218. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  146219. /**
  146220. * Adds a new drag gradient
  146221. * @param gradient defines the gradient to use (between 0 and 1)
  146222. * @param factor defines the drag value to affect to the specified gradient
  146223. * @returns the current particle system
  146224. */
  146225. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  146226. /**
  146227. * Remove a specific drag gradient
  146228. * @param gradient defines the gradient to remove
  146229. * @returns the current particle system
  146230. */
  146231. removeDragGradient(gradient: number): GPUParticleSystem;
  146232. /**
  146233. * Not supported by GPUParticleSystem
  146234. * @param gradient defines the gradient to use (between 0 and 1)
  146235. * @param factor defines the emit rate value to affect to the specified gradient
  146236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146237. * @returns the current particle system
  146238. */
  146239. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146240. /**
  146241. * Not supported by GPUParticleSystem
  146242. * @param gradient defines the gradient to remove
  146243. * @returns the current particle system
  146244. */
  146245. removeEmitRateGradient(gradient: number): IParticleSystem;
  146246. /**
  146247. * Not supported by GPUParticleSystem
  146248. * @param gradient defines the gradient to use (between 0 and 1)
  146249. * @param factor defines the start size value to affect to the specified gradient
  146250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146251. * @returns the current particle system
  146252. */
  146253. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146254. /**
  146255. * Not supported by GPUParticleSystem
  146256. * @param gradient defines the gradient to remove
  146257. * @returns the current particle system
  146258. */
  146259. removeStartSizeGradient(gradient: number): IParticleSystem;
  146260. /**
  146261. * Not supported by GPUParticleSystem
  146262. * @param gradient defines the gradient to use (between 0 and 1)
  146263. * @param min defines the color remap minimal range
  146264. * @param max defines the color remap maximal range
  146265. * @returns the current particle system
  146266. */
  146267. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146268. /**
  146269. * Not supported by GPUParticleSystem
  146270. * @param gradient defines the gradient to remove
  146271. * @returns the current particle system
  146272. */
  146273. removeColorRemapGradient(): IParticleSystem;
  146274. /**
  146275. * Not supported by GPUParticleSystem
  146276. * @param gradient defines the gradient to use (between 0 and 1)
  146277. * @param min defines the alpha remap minimal range
  146278. * @param max defines the alpha remap maximal range
  146279. * @returns the current particle system
  146280. */
  146281. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  146282. /**
  146283. * Not supported by GPUParticleSystem
  146284. * @param gradient defines the gradient to remove
  146285. * @returns the current particle system
  146286. */
  146287. removeAlphaRemapGradient(): IParticleSystem;
  146288. /**
  146289. * Not supported by GPUParticleSystem
  146290. * @param gradient defines the gradient to use (between 0 and 1)
  146291. * @param color defines the color to affect to the specified gradient
  146292. * @returns the current particle system
  146293. */
  146294. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  146295. /**
  146296. * Not supported by GPUParticleSystem
  146297. * @param gradient defines the gradient to remove
  146298. * @returns the current particle system
  146299. */
  146300. removeRampGradient(): IParticleSystem;
  146301. /**
  146302. * Not supported by GPUParticleSystem
  146303. * @returns the list of ramp gradients
  146304. */
  146305. getRampGradients(): Nullable<Array<Color3Gradient>>;
  146306. /**
  146307. * Not supported by GPUParticleSystem
  146308. * Gets or sets a boolean indicating that ramp gradients must be used
  146309. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  146310. */
  146311. get useRampGradients(): boolean;
  146312. set useRampGradients(value: boolean);
  146313. /**
  146314. * Not supported by GPUParticleSystem
  146315. * @param gradient defines the gradient to use (between 0 and 1)
  146316. * @param factor defines the life time factor to affect to the specified gradient
  146317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  146318. * @returns the current particle system
  146319. */
  146320. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  146321. /**
  146322. * Not supported by GPUParticleSystem
  146323. * @param gradient defines the gradient to remove
  146324. * @returns the current particle system
  146325. */
  146326. removeLifeTimeGradient(gradient: number): IParticleSystem;
  146327. /**
  146328. * Instantiates a GPU particle system.
  146329. * 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.
  146330. * @param name The name of the particle system
  146331. * @param options The options used to create the system
  146332. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  146333. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  146334. * @param customEffect a custom effect used to change the way particles are rendered by default
  146335. */
  146336. constructor(name: string, options: Partial<{
  146337. capacity: number;
  146338. randomTextureSize: number;
  146339. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  146340. protected _reset(): void;
  146341. private _createUpdateVAO;
  146342. private _createRenderVAO;
  146343. private _initialize;
  146344. /** @hidden */
  146345. _recreateUpdateEffect(): void;
  146346. private _getEffect;
  146347. /**
  146348. * Fill the defines array according to the current settings of the particle system
  146349. * @param defines Array to be updated
  146350. * @param blendMode blend mode to take into account when updating the array
  146351. */
  146352. fillDefines(defines: Array<string>, blendMode?: number): void;
  146353. /**
  146354. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  146355. * @param uniforms Uniforms array to fill
  146356. * @param attributes Attributes array to fill
  146357. * @param samplers Samplers array to fill
  146358. */
  146359. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  146360. /** @hidden */
  146361. _recreateRenderEffect(): Effect;
  146362. /**
  146363. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  146364. * @param preWarm defines if we are in the pre-warmimg phase
  146365. */
  146366. animate(preWarm?: boolean): void;
  146367. private _createFactorGradientTexture;
  146368. private _createSizeGradientTexture;
  146369. private _createAngularSpeedGradientTexture;
  146370. private _createVelocityGradientTexture;
  146371. private _createLimitVelocityGradientTexture;
  146372. private _createDragGradientTexture;
  146373. private _createColorGradientTexture;
  146374. /**
  146375. * Renders the particle system in its current state
  146376. * @param preWarm defines if the system should only update the particles but not render them
  146377. * @returns the current number of particles
  146378. */
  146379. render(preWarm?: boolean): number;
  146380. /**
  146381. * Rebuilds the particle system
  146382. */
  146383. rebuild(): void;
  146384. private _releaseBuffers;
  146385. private _releaseVAOs;
  146386. /**
  146387. * Disposes the particle system and free the associated resources
  146388. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  146389. */
  146390. dispose(disposeTexture?: boolean): void;
  146391. /**
  146392. * Clones the particle system.
  146393. * @param name The name of the cloned object
  146394. * @param newEmitter The new emitter to use
  146395. * @returns the cloned particle system
  146396. */
  146397. clone(name: string, newEmitter: any): GPUParticleSystem;
  146398. /**
  146399. * Serializes the particle system to a JSON object
  146400. * @param serializeTexture defines if the texture must be serialized as well
  146401. * @returns the JSON object
  146402. */
  146403. serialize(serializeTexture?: boolean): any;
  146404. /**
  146405. * Parses a JSON object to create a GPU particle system.
  146406. * @param parsedParticleSystem The JSON object to parse
  146407. * @param sceneOrEngine The scene or the engine to create the particle system in
  146408. * @param rootUrl The root url to use to load external dependencies like texture
  146409. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  146410. * @returns the parsed GPU particle system
  146411. */
  146412. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  146413. }
  146414. }
  146415. declare module BABYLON {
  146416. /**
  146417. * Represents a set of particle systems working together to create a specific effect
  146418. */
  146419. export class ParticleSystemSet implements IDisposable {
  146420. /**
  146421. * Gets or sets base Assets URL
  146422. */
  146423. static BaseAssetsUrl: string;
  146424. private _emitterCreationOptions;
  146425. private _emitterNode;
  146426. /**
  146427. * Gets the particle system list
  146428. */
  146429. systems: IParticleSystem[];
  146430. /**
  146431. * Gets the emitter node used with this set
  146432. */
  146433. get emitterNode(): Nullable<TransformNode>;
  146434. /**
  146435. * Creates a new emitter mesh as a sphere
  146436. * @param options defines the options used to create the sphere
  146437. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  146438. * @param scene defines the hosting scene
  146439. */
  146440. setEmitterAsSphere(options: {
  146441. diameter: number;
  146442. segments: number;
  146443. color: Color3;
  146444. }, renderingGroupId: number, scene: Scene): void;
  146445. /**
  146446. * Starts all particle systems of the set
  146447. * @param emitter defines an optional mesh to use as emitter for the particle systems
  146448. */
  146449. start(emitter?: AbstractMesh): void;
  146450. /**
  146451. * Release all associated resources
  146452. */
  146453. dispose(): void;
  146454. /**
  146455. * Serialize the set into a JSON compatible object
  146456. * @param serializeTexture defines if the texture must be serialized as well
  146457. * @returns a JSON compatible representation of the set
  146458. */
  146459. serialize(serializeTexture?: boolean): any;
  146460. /**
  146461. * Parse a new ParticleSystemSet from a serialized source
  146462. * @param data defines a JSON compatible representation of the set
  146463. * @param scene defines the hosting scene
  146464. * @param gpu defines if we want GPU particles or CPU particles
  146465. * @returns a new ParticleSystemSet
  146466. */
  146467. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  146468. }
  146469. }
  146470. declare module BABYLON {
  146471. /**
  146472. * This class is made for on one-liner static method to help creating particle system set.
  146473. */
  146474. export class ParticleHelper {
  146475. /**
  146476. * Gets or sets base Assets URL
  146477. */
  146478. static BaseAssetsUrl: string;
  146479. /** Define the Url to load snippets */
  146480. static SnippetUrl: string;
  146481. /**
  146482. * Create a default particle system that you can tweak
  146483. * @param emitter defines the emitter to use
  146484. * @param capacity defines the system capacity (default is 500 particles)
  146485. * @param scene defines the hosting scene
  146486. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  146487. * @returns the new Particle system
  146488. */
  146489. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  146490. /**
  146491. * This is the main static method (one-liner) of this helper to create different particle systems
  146492. * @param type This string represents the type to the particle system to create
  146493. * @param scene The scene where the particle system should live
  146494. * @param gpu If the system will use gpu
  146495. * @returns the ParticleSystemSet created
  146496. */
  146497. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  146498. /**
  146499. * Static function used to export a particle system to a ParticleSystemSet variable.
  146500. * Please note that the emitter shape is not exported
  146501. * @param systems defines the particle systems to export
  146502. * @returns the created particle system set
  146503. */
  146504. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  146505. /**
  146506. * Creates a particle system from a snippet saved in a remote file
  146507. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  146508. * @param url defines the url to load from
  146509. * @param scene defines the hosting scene
  146510. * @param gpu If the system will use gpu
  146511. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146512. * @returns a promise that will resolve to the new particle system
  146513. */
  146514. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146515. /**
  146516. * Creates a particle system from a snippet saved by the particle system editor
  146517. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  146518. * @param scene defines the hosting scene
  146519. * @param gpu If the system will use gpu
  146520. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  146521. * @returns a promise that will resolve to the new particle system
  146522. */
  146523. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  146524. }
  146525. }
  146526. declare module BABYLON {
  146527. interface Engine {
  146528. /**
  146529. * Create an effect to use with particle systems.
  146530. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  146531. * the particle system for which you want to create a custom effect in the last parameter
  146532. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  146533. * @param uniformsNames defines a list of attribute names
  146534. * @param samplers defines an array of string used to represent textures
  146535. * @param defines defines the string containing the defines to use to compile the shaders
  146536. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  146537. * @param onCompiled defines a function to call when the effect creation is successful
  146538. * @param onError defines a function to call when the effect creation has failed
  146539. * @param particleSystem the particle system you want to create the effect for
  146540. * @returns the new Effect
  146541. */
  146542. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  146543. }
  146544. interface Mesh {
  146545. /**
  146546. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  146547. * @returns an array of IParticleSystem
  146548. */
  146549. getEmittedParticleSystems(): IParticleSystem[];
  146550. /**
  146551. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  146552. * @returns an array of IParticleSystem
  146553. */
  146554. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  146555. }
  146556. }
  146557. declare module BABYLON {
  146558. /** Defines the 4 color options */
  146559. export enum PointColor {
  146560. /** color value */
  146561. Color = 2,
  146562. /** uv value */
  146563. UV = 1,
  146564. /** random value */
  146565. Random = 0,
  146566. /** stated value */
  146567. Stated = 3
  146568. }
  146569. /**
  146570. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  146571. * 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.
  146572. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  146573. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  146574. *
  146575. * Full documentation here : TO BE ENTERED
  146576. */
  146577. export class PointsCloudSystem implements IDisposable {
  146578. /**
  146579. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  146580. * Example : var p = SPS.particles[i];
  146581. */
  146582. particles: CloudPoint[];
  146583. /**
  146584. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  146585. */
  146586. nbParticles: number;
  146587. /**
  146588. * This a counter for your own usage. It's not set by any SPS functions.
  146589. */
  146590. counter: number;
  146591. /**
  146592. * The PCS name. This name is also given to the underlying mesh.
  146593. */
  146594. name: string;
  146595. /**
  146596. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  146597. */
  146598. mesh: Mesh;
  146599. /**
  146600. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  146601. * Please read :
  146602. */
  146603. vars: any;
  146604. /**
  146605. * @hidden
  146606. */
  146607. _size: number;
  146608. private _scene;
  146609. private _promises;
  146610. private _positions;
  146611. private _indices;
  146612. private _normals;
  146613. private _colors;
  146614. private _uvs;
  146615. private _indices32;
  146616. private _positions32;
  146617. private _colors32;
  146618. private _uvs32;
  146619. private _updatable;
  146620. private _isVisibilityBoxLocked;
  146621. private _alwaysVisible;
  146622. private _groups;
  146623. private _groupCounter;
  146624. private _computeParticleColor;
  146625. private _computeParticleTexture;
  146626. private _computeParticleRotation;
  146627. private _computeBoundingBox;
  146628. private _isReady;
  146629. /**
  146630. * Creates a PCS (Points Cloud System) object
  146631. * @param name (String) is the PCS name, this will be the underlying mesh name
  146632. * @param pointSize (number) is the size for each point
  146633. * @param scene (Scene) is the scene in which the PCS is added
  146634. * @param options defines the options of the PCS e.g.
  146635. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  146636. */
  146637. constructor(name: string, pointSize: number, scene: Scene, options?: {
  146638. updatable?: boolean;
  146639. });
  146640. /**
  146641. * Builds the PCS underlying mesh. Returns a standard Mesh.
  146642. * If no points were added to the PCS, the returned mesh is just a single point.
  146643. * @returns a promise for the created mesh
  146644. */
  146645. buildMeshAsync(): Promise<Mesh>;
  146646. /**
  146647. * @hidden
  146648. */
  146649. private _buildMesh;
  146650. private _addParticle;
  146651. private _randomUnitVector;
  146652. private _getColorIndicesForCoord;
  146653. private _setPointsColorOrUV;
  146654. private _colorFromTexture;
  146655. private _calculateDensity;
  146656. /**
  146657. * Adds points to the PCS in random positions within a unit sphere
  146658. * @param nb (positive integer) the number of particles to be created from this model
  146659. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  146660. * @returns the number of groups in the system
  146661. */
  146662. addPoints(nb: number, pointFunction?: any): number;
  146663. /**
  146664. * Adds points to the PCS from the surface of the model shape
  146665. * @param mesh is any Mesh object that will be used as a surface model for the points
  146666. * @param nb (positive integer) the number of particles to be created from this model
  146667. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146668. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146669. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146670. * @returns the number of groups in the system
  146671. */
  146672. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146673. /**
  146674. * Adds points to the PCS inside the model shape
  146675. * @param mesh is any Mesh object that will be used as a surface model for the points
  146676. * @param nb (positive integer) the number of particles to be created from this model
  146677. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  146678. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  146679. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  146680. * @returns the number of groups in the system
  146681. */
  146682. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  146683. /**
  146684. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  146685. * This method calls `updateParticle()` for each particle of the SPS.
  146686. * For an animated SPS, it is usually called within the render loop.
  146687. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  146688. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  146689. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  146690. * @returns the PCS.
  146691. */
  146692. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  146693. /**
  146694. * Disposes the PCS.
  146695. */
  146696. dispose(): void;
  146697. /**
  146698. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  146699. * doc :
  146700. * @returns the PCS.
  146701. */
  146702. refreshVisibleSize(): PointsCloudSystem;
  146703. /**
  146704. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  146705. * @param size the size (float) of the visibility box
  146706. * note : this doesn't lock the PCS mesh bounding box.
  146707. * doc :
  146708. */
  146709. setVisibilityBox(size: number): void;
  146710. /**
  146711. * Gets whether the PCS is always visible or not
  146712. * doc :
  146713. */
  146714. get isAlwaysVisible(): boolean;
  146715. /**
  146716. * Sets the PCS as always visible or not
  146717. * doc :
  146718. */
  146719. set isAlwaysVisible(val: boolean);
  146720. /**
  146721. * Tells to `setParticles()` to compute the particle rotations or not
  146722. * Default value : false. The PCS is faster when it's set to false
  146723. * Note : particle rotations are only applied to parent particles
  146724. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  146725. */
  146726. set computeParticleRotation(val: boolean);
  146727. /**
  146728. * Tells to `setParticles()` to compute the particle colors or not.
  146729. * Default value : true. The PCS is faster when it's set to false.
  146730. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146731. */
  146732. set computeParticleColor(val: boolean);
  146733. set computeParticleTexture(val: boolean);
  146734. /**
  146735. * Gets if `setParticles()` computes the particle colors or not.
  146736. * Default value : false. The PCS is faster when it's set to false.
  146737. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  146738. */
  146739. get computeParticleColor(): boolean;
  146740. /**
  146741. * Gets if `setParticles()` computes the particle textures or not.
  146742. * Default value : false. The PCS is faster when it's set to false.
  146743. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  146744. */
  146745. get computeParticleTexture(): boolean;
  146746. /**
  146747. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  146748. */
  146749. set computeBoundingBox(val: boolean);
  146750. /**
  146751. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  146752. */
  146753. get computeBoundingBox(): boolean;
  146754. /**
  146755. * This function does nothing. It may be overwritten to set all the particle first values.
  146756. * The PCS doesn't call this function, you may have to call it by your own.
  146757. * doc :
  146758. */
  146759. initParticles(): void;
  146760. /**
  146761. * This function does nothing. It may be overwritten to recycle a particle
  146762. * The PCS doesn't call this function, you can to call it
  146763. * doc :
  146764. * @param particle The particle to recycle
  146765. * @returns the recycled particle
  146766. */
  146767. recycleParticle(particle: CloudPoint): CloudPoint;
  146768. /**
  146769. * Updates a particle : this function should be overwritten by the user.
  146770. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  146771. * doc :
  146772. * @example : just set a particle position or velocity and recycle conditions
  146773. * @param particle The particle to update
  146774. * @returns the updated particle
  146775. */
  146776. updateParticle(particle: CloudPoint): CloudPoint;
  146777. /**
  146778. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  146779. * This does nothing and may be overwritten by the user.
  146780. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146782. * @param update the boolean update value actually passed to setParticles()
  146783. */
  146784. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146785. /**
  146786. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  146787. * This will be passed three parameters.
  146788. * This does nothing and may be overwritten by the user.
  146789. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  146790. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  146791. * @param update the boolean update value actually passed to setParticles()
  146792. */
  146793. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  146794. }
  146795. }
  146796. declare module BABYLON {
  146797. /**
  146798. * Represents one particle of a points cloud system.
  146799. */
  146800. export class CloudPoint {
  146801. /**
  146802. * particle global index
  146803. */
  146804. idx: number;
  146805. /**
  146806. * The color of the particle
  146807. */
  146808. color: Nullable<Color4>;
  146809. /**
  146810. * The world space position of the particle.
  146811. */
  146812. position: Vector3;
  146813. /**
  146814. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  146815. */
  146816. rotation: Vector3;
  146817. /**
  146818. * The world space rotation quaternion of the particle.
  146819. */
  146820. rotationQuaternion: Nullable<Quaternion>;
  146821. /**
  146822. * The uv of the particle.
  146823. */
  146824. uv: Nullable<Vector2>;
  146825. /**
  146826. * The current speed of the particle.
  146827. */
  146828. velocity: Vector3;
  146829. /**
  146830. * The pivot point in the particle local space.
  146831. */
  146832. pivot: Vector3;
  146833. /**
  146834. * Must the particle be translated from its pivot point in its local space ?
  146835. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  146836. * Default : false
  146837. */
  146838. translateFromPivot: boolean;
  146839. /**
  146840. * Index of this particle in the global "positions" array (Internal use)
  146841. * @hidden
  146842. */
  146843. _pos: number;
  146844. /**
  146845. * @hidden Index of this particle in the global "indices" array (Internal use)
  146846. */
  146847. _ind: number;
  146848. /**
  146849. * Group this particle belongs to
  146850. */
  146851. _group: PointsGroup;
  146852. /**
  146853. * Group id of this particle
  146854. */
  146855. groupId: number;
  146856. /**
  146857. * Index of the particle in its group id (Internal use)
  146858. */
  146859. idxInGroup: number;
  146860. /**
  146861. * @hidden Particle BoundingInfo object (Internal use)
  146862. */
  146863. _boundingInfo: BoundingInfo;
  146864. /**
  146865. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  146866. */
  146867. _pcs: PointsCloudSystem;
  146868. /**
  146869. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  146870. */
  146871. _stillInvisible: boolean;
  146872. /**
  146873. * @hidden Last computed particle rotation matrix
  146874. */
  146875. _rotationMatrix: number[];
  146876. /**
  146877. * Parent particle Id, if any.
  146878. * Default null.
  146879. */
  146880. parentId: Nullable<number>;
  146881. /**
  146882. * @hidden Internal global position in the PCS.
  146883. */
  146884. _globalPosition: Vector3;
  146885. /**
  146886. * Creates a Point Cloud object.
  146887. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  146888. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  146889. * @param group (PointsGroup) is the group the particle belongs to
  146890. * @param groupId (integer) is the group identifier in the PCS.
  146891. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  146892. * @param pcs defines the PCS it is associated to
  146893. */
  146894. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  146895. /**
  146896. * get point size
  146897. */
  146898. get size(): Vector3;
  146899. /**
  146900. * Set point size
  146901. */
  146902. set size(scale: Vector3);
  146903. /**
  146904. * Legacy support, changed quaternion to rotationQuaternion
  146905. */
  146906. get quaternion(): Nullable<Quaternion>;
  146907. /**
  146908. * Legacy support, changed quaternion to rotationQuaternion
  146909. */
  146910. set quaternion(q: Nullable<Quaternion>);
  146911. /**
  146912. * Returns a boolean. True if the particle intersects a mesh, else false
  146913. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  146914. * @param target is the object (point or mesh) what the intersection is computed against
  146915. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  146916. * @returns true if it intersects
  146917. */
  146918. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  146919. /**
  146920. * get the rotation matrix of the particle
  146921. * @hidden
  146922. */
  146923. getRotationMatrix(m: Matrix): void;
  146924. }
  146925. /**
  146926. * Represents a group of points in a points cloud system
  146927. * * PCS internal tool, don't use it manually.
  146928. */
  146929. export class PointsGroup {
  146930. /**
  146931. * The group id
  146932. * @hidden
  146933. */
  146934. groupID: number;
  146935. /**
  146936. * image data for group (internal use)
  146937. * @hidden
  146938. */
  146939. _groupImageData: Nullable<ArrayBufferView>;
  146940. /**
  146941. * Image Width (internal use)
  146942. * @hidden
  146943. */
  146944. _groupImgWidth: number;
  146945. /**
  146946. * Image Height (internal use)
  146947. * @hidden
  146948. */
  146949. _groupImgHeight: number;
  146950. /**
  146951. * Custom position function (internal use)
  146952. * @hidden
  146953. */
  146954. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  146955. /**
  146956. * density per facet for surface points
  146957. * @hidden
  146958. */
  146959. _groupDensity: number[];
  146960. /**
  146961. * Only when points are colored by texture carries pointer to texture list array
  146962. * @hidden
  146963. */
  146964. _textureNb: number;
  146965. /**
  146966. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  146967. * PCS internal tool, don't use it manually.
  146968. * @hidden
  146969. */
  146970. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  146971. }
  146972. }
  146973. declare module BABYLON {
  146974. interface Scene {
  146975. /** @hidden (Backing field) */
  146976. _physicsEngine: Nullable<IPhysicsEngine>;
  146977. /** @hidden */
  146978. _physicsTimeAccumulator: number;
  146979. /**
  146980. * Gets the current physics engine
  146981. * @returns a IPhysicsEngine or null if none attached
  146982. */
  146983. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  146984. /**
  146985. * Enables physics to the current scene
  146986. * @param gravity defines the scene's gravity for the physics engine
  146987. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  146988. * @return a boolean indicating if the physics engine was initialized
  146989. */
  146990. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  146991. /**
  146992. * Disables and disposes the physics engine associated with the scene
  146993. */
  146994. disablePhysicsEngine(): void;
  146995. /**
  146996. * Gets a boolean indicating if there is an active physics engine
  146997. * @returns a boolean indicating if there is an active physics engine
  146998. */
  146999. isPhysicsEnabled(): boolean;
  147000. /**
  147001. * Deletes a physics compound impostor
  147002. * @param compound defines the compound to delete
  147003. */
  147004. deleteCompoundImpostor(compound: any): void;
  147005. /**
  147006. * An event triggered when physic simulation is about to be run
  147007. */
  147008. onBeforePhysicsObservable: Observable<Scene>;
  147009. /**
  147010. * An event triggered when physic simulation has been done
  147011. */
  147012. onAfterPhysicsObservable: Observable<Scene>;
  147013. }
  147014. interface AbstractMesh {
  147015. /** @hidden */
  147016. _physicsImpostor: Nullable<PhysicsImpostor>;
  147017. /**
  147018. * Gets or sets impostor used for physic simulation
  147019. * @see https://doc.babylonjs.com/features/physics_engine
  147020. */
  147021. physicsImpostor: Nullable<PhysicsImpostor>;
  147022. /**
  147023. * Gets the current physics impostor
  147024. * @see https://doc.babylonjs.com/features/physics_engine
  147025. * @returns a physics impostor or null
  147026. */
  147027. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  147028. /** Apply a physic impulse to the mesh
  147029. * @param force defines the force to apply
  147030. * @param contactPoint defines where to apply the force
  147031. * @returns the current mesh
  147032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  147033. */
  147034. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  147035. /**
  147036. * Creates a physic joint between two meshes
  147037. * @param otherMesh defines the other mesh to use
  147038. * @param pivot1 defines the pivot to use on this mesh
  147039. * @param pivot2 defines the pivot to use on the other mesh
  147040. * @param options defines additional options (can be plugin dependent)
  147041. * @returns the current mesh
  147042. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  147043. */
  147044. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  147045. /** @hidden */
  147046. _disposePhysicsObserver: Nullable<Observer<Node>>;
  147047. }
  147048. /**
  147049. * Defines the physics engine scene component responsible to manage a physics engine
  147050. */
  147051. export class PhysicsEngineSceneComponent implements ISceneComponent {
  147052. /**
  147053. * The component name helpful to identify the component in the list of scene components.
  147054. */
  147055. readonly name: string;
  147056. /**
  147057. * The scene the component belongs to.
  147058. */
  147059. scene: Scene;
  147060. /**
  147061. * Creates a new instance of the component for the given scene
  147062. * @param scene Defines the scene to register the component in
  147063. */
  147064. constructor(scene: Scene);
  147065. /**
  147066. * Registers the component in a given scene
  147067. */
  147068. register(): void;
  147069. /**
  147070. * Rebuilds the elements related to this component in case of
  147071. * context lost for instance.
  147072. */
  147073. rebuild(): void;
  147074. /**
  147075. * Disposes the component and the associated ressources
  147076. */
  147077. dispose(): void;
  147078. }
  147079. }
  147080. declare module BABYLON {
  147081. /**
  147082. * A helper for physics simulations
  147083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147084. */
  147085. export class PhysicsHelper {
  147086. private _scene;
  147087. private _physicsEngine;
  147088. /**
  147089. * Initializes the Physics helper
  147090. * @param scene Babylon.js scene
  147091. */
  147092. constructor(scene: Scene);
  147093. /**
  147094. * Applies a radial explosion impulse
  147095. * @param origin the origin of the explosion
  147096. * @param radiusOrEventOptions the radius or the options of radial explosion
  147097. * @param strength the explosion strength
  147098. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147099. * @returns A physics radial explosion event, or null
  147100. */
  147101. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147102. /**
  147103. * Applies a radial explosion force
  147104. * @param origin the origin of the explosion
  147105. * @param radiusOrEventOptions the radius or the options of radial explosion
  147106. * @param strength the explosion strength
  147107. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147108. * @returns A physics radial explosion event, or null
  147109. */
  147110. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  147111. /**
  147112. * Creates a gravitational field
  147113. * @param origin the origin of the explosion
  147114. * @param radiusOrEventOptions the radius or the options of radial explosion
  147115. * @param strength the explosion strength
  147116. * @param falloff possible options: Constant & Linear. Defaults to Constant
  147117. * @returns A physics gravitational field event, or null
  147118. */
  147119. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  147120. /**
  147121. * Creates a physics updraft event
  147122. * @param origin the origin of the updraft
  147123. * @param radiusOrEventOptions the radius or the options of the updraft
  147124. * @param strength the strength of the updraft
  147125. * @param height the height of the updraft
  147126. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  147127. * @returns A physics updraft event, or null
  147128. */
  147129. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  147130. /**
  147131. * Creates a physics vortex event
  147132. * @param origin the of the vortex
  147133. * @param radiusOrEventOptions the radius or the options of the vortex
  147134. * @param strength the strength of the vortex
  147135. * @param height the height of the vortex
  147136. * @returns a Physics vortex event, or null
  147137. * A physics vortex event or null
  147138. */
  147139. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  147140. }
  147141. /**
  147142. * Represents a physics radial explosion event
  147143. */
  147144. class PhysicsRadialExplosionEvent {
  147145. private _scene;
  147146. private _options;
  147147. private _sphere;
  147148. private _dataFetched;
  147149. /**
  147150. * Initializes a radial explosioin event
  147151. * @param _scene BabylonJS scene
  147152. * @param _options The options for the vortex event
  147153. */
  147154. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  147155. /**
  147156. * Returns the data related to the radial explosion event (sphere).
  147157. * @returns The radial explosion event data
  147158. */
  147159. getData(): PhysicsRadialExplosionEventData;
  147160. /**
  147161. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  147162. * @param impostor A physics imposter
  147163. * @param origin the origin of the explosion
  147164. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  147165. */
  147166. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  147167. /**
  147168. * Triggers affecterd impostors callbacks
  147169. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  147170. */
  147171. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  147172. /**
  147173. * Disposes the sphere.
  147174. * @param force Specifies if the sphere should be disposed by force
  147175. */
  147176. dispose(force?: boolean): void;
  147177. /*** Helpers ***/
  147178. private _prepareSphere;
  147179. private _intersectsWithSphere;
  147180. }
  147181. /**
  147182. * Represents a gravitational field event
  147183. */
  147184. class PhysicsGravitationalFieldEvent {
  147185. private _physicsHelper;
  147186. private _scene;
  147187. private _origin;
  147188. private _options;
  147189. private _tickCallback;
  147190. private _sphere;
  147191. private _dataFetched;
  147192. /**
  147193. * Initializes the physics gravitational field event
  147194. * @param _physicsHelper A physics helper
  147195. * @param _scene BabylonJS scene
  147196. * @param _origin The origin position of the gravitational field event
  147197. * @param _options The options for the vortex event
  147198. */
  147199. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  147200. /**
  147201. * Returns the data related to the gravitational field event (sphere).
  147202. * @returns A gravitational field event
  147203. */
  147204. getData(): PhysicsGravitationalFieldEventData;
  147205. /**
  147206. * Enables the gravitational field.
  147207. */
  147208. enable(): void;
  147209. /**
  147210. * Disables the gravitational field.
  147211. */
  147212. disable(): void;
  147213. /**
  147214. * Disposes the sphere.
  147215. * @param force The force to dispose from the gravitational field event
  147216. */
  147217. dispose(force?: boolean): void;
  147218. private _tick;
  147219. }
  147220. /**
  147221. * Represents a physics updraft event
  147222. */
  147223. class PhysicsUpdraftEvent {
  147224. private _scene;
  147225. private _origin;
  147226. private _options;
  147227. private _physicsEngine;
  147228. private _originTop;
  147229. private _originDirection;
  147230. private _tickCallback;
  147231. private _cylinder;
  147232. private _cylinderPosition;
  147233. private _dataFetched;
  147234. /**
  147235. * Initializes the physics updraft event
  147236. * @param _scene BabylonJS scene
  147237. * @param _origin The origin position of the updraft
  147238. * @param _options The options for the updraft event
  147239. */
  147240. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  147241. /**
  147242. * Returns the data related to the updraft event (cylinder).
  147243. * @returns A physics updraft event
  147244. */
  147245. getData(): PhysicsUpdraftEventData;
  147246. /**
  147247. * Enables the updraft.
  147248. */
  147249. enable(): void;
  147250. /**
  147251. * Disables the updraft.
  147252. */
  147253. disable(): void;
  147254. /**
  147255. * Disposes the cylinder.
  147256. * @param force Specifies if the updraft should be disposed by force
  147257. */
  147258. dispose(force?: boolean): void;
  147259. private getImpostorHitData;
  147260. private _tick;
  147261. /*** Helpers ***/
  147262. private _prepareCylinder;
  147263. private _intersectsWithCylinder;
  147264. }
  147265. /**
  147266. * Represents a physics vortex event
  147267. */
  147268. class PhysicsVortexEvent {
  147269. private _scene;
  147270. private _origin;
  147271. private _options;
  147272. private _physicsEngine;
  147273. private _originTop;
  147274. private _tickCallback;
  147275. private _cylinder;
  147276. private _cylinderPosition;
  147277. private _dataFetched;
  147278. /**
  147279. * Initializes the physics vortex event
  147280. * @param _scene The BabylonJS scene
  147281. * @param _origin The origin position of the vortex
  147282. * @param _options The options for the vortex event
  147283. */
  147284. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  147285. /**
  147286. * Returns the data related to the vortex event (cylinder).
  147287. * @returns The physics vortex event data
  147288. */
  147289. getData(): PhysicsVortexEventData;
  147290. /**
  147291. * Enables the vortex.
  147292. */
  147293. enable(): void;
  147294. /**
  147295. * Disables the cortex.
  147296. */
  147297. disable(): void;
  147298. /**
  147299. * Disposes the sphere.
  147300. * @param force
  147301. */
  147302. dispose(force?: boolean): void;
  147303. private getImpostorHitData;
  147304. private _tick;
  147305. /*** Helpers ***/
  147306. private _prepareCylinder;
  147307. private _intersectsWithCylinder;
  147308. }
  147309. /**
  147310. * Options fot the radial explosion event
  147311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147312. */
  147313. export class PhysicsRadialExplosionEventOptions {
  147314. /**
  147315. * The radius of the sphere for the radial explosion.
  147316. */
  147317. radius: number;
  147318. /**
  147319. * The strenth of the explosion.
  147320. */
  147321. strength: number;
  147322. /**
  147323. * The strenght of the force in correspondence to the distance of the affected object
  147324. */
  147325. falloff: PhysicsRadialImpulseFalloff;
  147326. /**
  147327. * Sphere options for the radial explosion.
  147328. */
  147329. sphere: {
  147330. segments: number;
  147331. diameter: number;
  147332. };
  147333. /**
  147334. * Sphere options for the radial explosion.
  147335. */
  147336. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  147337. }
  147338. /**
  147339. * Options fot the updraft event
  147340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147341. */
  147342. export class PhysicsUpdraftEventOptions {
  147343. /**
  147344. * The radius of the cylinder for the vortex
  147345. */
  147346. radius: number;
  147347. /**
  147348. * The strenth of the updraft.
  147349. */
  147350. strength: number;
  147351. /**
  147352. * The height of the cylinder for the updraft.
  147353. */
  147354. height: number;
  147355. /**
  147356. * The mode for the the updraft.
  147357. */
  147358. updraftMode: PhysicsUpdraftMode;
  147359. }
  147360. /**
  147361. * Options fot the vortex event
  147362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147363. */
  147364. export class PhysicsVortexEventOptions {
  147365. /**
  147366. * The radius of the cylinder for the vortex
  147367. */
  147368. radius: number;
  147369. /**
  147370. * The strenth of the vortex.
  147371. */
  147372. strength: number;
  147373. /**
  147374. * The height of the cylinder for the vortex.
  147375. */
  147376. height: number;
  147377. /**
  147378. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  147379. */
  147380. centripetalForceThreshold: number;
  147381. /**
  147382. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  147383. */
  147384. centripetalForceMultiplier: number;
  147385. /**
  147386. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  147387. */
  147388. centrifugalForceMultiplier: number;
  147389. /**
  147390. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  147391. */
  147392. updraftForceMultiplier: number;
  147393. }
  147394. /**
  147395. * The strenght of the force in correspondence to the distance of the affected object
  147396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147397. */
  147398. export enum PhysicsRadialImpulseFalloff {
  147399. /** Defines that impulse is constant in strength across it's whole radius */
  147400. Constant = 0,
  147401. /** Defines that impulse gets weaker if it's further from the origin */
  147402. Linear = 1
  147403. }
  147404. /**
  147405. * The strength of the force in correspondence to the distance of the affected object
  147406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147407. */
  147408. export enum PhysicsUpdraftMode {
  147409. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  147410. Center = 0,
  147411. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  147412. Perpendicular = 1
  147413. }
  147414. /**
  147415. * Interface for a physics hit data
  147416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147417. */
  147418. export interface PhysicsHitData {
  147419. /**
  147420. * The force applied at the contact point
  147421. */
  147422. force: Vector3;
  147423. /**
  147424. * The contact point
  147425. */
  147426. contactPoint: Vector3;
  147427. /**
  147428. * The distance from the origin to the contact point
  147429. */
  147430. distanceFromOrigin: number;
  147431. }
  147432. /**
  147433. * Interface for radial explosion event data
  147434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147435. */
  147436. export interface PhysicsRadialExplosionEventData {
  147437. /**
  147438. * A sphere used for the radial explosion event
  147439. */
  147440. sphere: Mesh;
  147441. }
  147442. /**
  147443. * Interface for gravitational field event data
  147444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147445. */
  147446. export interface PhysicsGravitationalFieldEventData {
  147447. /**
  147448. * A sphere mesh used for the gravitational field event
  147449. */
  147450. sphere: Mesh;
  147451. }
  147452. /**
  147453. * Interface for updraft event data
  147454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147455. */
  147456. export interface PhysicsUpdraftEventData {
  147457. /**
  147458. * A cylinder used for the updraft event
  147459. */
  147460. cylinder: Mesh;
  147461. }
  147462. /**
  147463. * Interface for vortex event data
  147464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147465. */
  147466. export interface PhysicsVortexEventData {
  147467. /**
  147468. * A cylinder used for the vortex event
  147469. */
  147470. cylinder: Mesh;
  147471. }
  147472. /**
  147473. * Interface for an affected physics impostor
  147474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  147475. */
  147476. export interface PhysicsAffectedImpostorWithData {
  147477. /**
  147478. * The impostor affected by the effect
  147479. */
  147480. impostor: PhysicsImpostor;
  147481. /**
  147482. * The data about the hit/horce from the explosion
  147483. */
  147484. hitData: PhysicsHitData;
  147485. }
  147486. }
  147487. declare module BABYLON {
  147488. /** @hidden */
  147489. export var blackAndWhitePixelShader: {
  147490. name: string;
  147491. shader: string;
  147492. };
  147493. }
  147494. declare module BABYLON {
  147495. /**
  147496. * Post process used to render in black and white
  147497. */
  147498. export class BlackAndWhitePostProcess extends PostProcess {
  147499. /**
  147500. * Linear about to convert he result to black and white (default: 1)
  147501. */
  147502. degree: number;
  147503. /**
  147504. * Creates a black and white post process
  147505. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  147506. * @param name The name of the effect.
  147507. * @param options The required width/height ratio to downsize to before computing the render pass.
  147508. * @param camera The camera to apply the render pass to.
  147509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147510. * @param engine The engine which the post process will be applied. (default: current engine)
  147511. * @param reusable If the post process can be reused on the same frame. (default: false)
  147512. */
  147513. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147514. }
  147515. }
  147516. declare module BABYLON {
  147517. /**
  147518. * This represents a set of one or more post processes in Babylon.
  147519. * A post process can be used to apply a shader to a texture after it is rendered.
  147520. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147521. */
  147522. export class PostProcessRenderEffect {
  147523. private _postProcesses;
  147524. private _getPostProcesses;
  147525. private _singleInstance;
  147526. private _cameras;
  147527. private _indicesForCamera;
  147528. /**
  147529. * Name of the effect
  147530. * @hidden
  147531. */
  147532. _name: string;
  147533. /**
  147534. * Instantiates a post process render effect.
  147535. * A post process can be used to apply a shader to a texture after it is rendered.
  147536. * @param engine The engine the effect is tied to
  147537. * @param name The name of the effect
  147538. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  147539. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  147540. */
  147541. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  147542. /**
  147543. * Checks if all the post processes in the effect are supported.
  147544. */
  147545. get isSupported(): boolean;
  147546. /**
  147547. * Updates the current state of the effect
  147548. * @hidden
  147549. */
  147550. _update(): void;
  147551. /**
  147552. * Attaches the effect on cameras
  147553. * @param cameras The camera to attach to.
  147554. * @hidden
  147555. */
  147556. _attachCameras(cameras: Camera): void;
  147557. /**
  147558. * Attaches the effect on cameras
  147559. * @param cameras The camera to attach to.
  147560. * @hidden
  147561. */
  147562. _attachCameras(cameras: Camera[]): void;
  147563. /**
  147564. * Detaches the effect on cameras
  147565. * @param cameras The camera to detatch from.
  147566. * @hidden
  147567. */
  147568. _detachCameras(cameras: Camera): void;
  147569. /**
  147570. * Detatches the effect on cameras
  147571. * @param cameras The camera to detatch from.
  147572. * @hidden
  147573. */
  147574. _detachCameras(cameras: Camera[]): void;
  147575. /**
  147576. * Enables the effect on given cameras
  147577. * @param cameras The camera to enable.
  147578. * @hidden
  147579. */
  147580. _enable(cameras: Camera): void;
  147581. /**
  147582. * Enables the effect on given cameras
  147583. * @param cameras The camera to enable.
  147584. * @hidden
  147585. */
  147586. _enable(cameras: Nullable<Camera[]>): void;
  147587. /**
  147588. * Disables the effect on the given cameras
  147589. * @param cameras The camera to disable.
  147590. * @hidden
  147591. */
  147592. _disable(cameras: Camera): void;
  147593. /**
  147594. * Disables the effect on the given cameras
  147595. * @param cameras The camera to disable.
  147596. * @hidden
  147597. */
  147598. _disable(cameras: Nullable<Camera[]>): void;
  147599. /**
  147600. * Gets a list of the post processes contained in the effect.
  147601. * @param camera The camera to get the post processes on.
  147602. * @returns The list of the post processes in the effect.
  147603. */
  147604. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  147605. }
  147606. }
  147607. declare module BABYLON {
  147608. /** @hidden */
  147609. export var extractHighlightsPixelShader: {
  147610. name: string;
  147611. shader: string;
  147612. };
  147613. }
  147614. declare module BABYLON {
  147615. /**
  147616. * 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.
  147617. */
  147618. export class ExtractHighlightsPostProcess extends PostProcess {
  147619. /**
  147620. * The luminance threshold, pixels below this value will be set to black.
  147621. */
  147622. threshold: number;
  147623. /** @hidden */
  147624. _exposure: number;
  147625. /**
  147626. * Post process which has the input texture to be used when performing highlight extraction
  147627. * @hidden
  147628. */
  147629. _inputPostProcess: Nullable<PostProcess>;
  147630. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147631. }
  147632. }
  147633. declare module BABYLON {
  147634. /** @hidden */
  147635. export var bloomMergePixelShader: {
  147636. name: string;
  147637. shader: string;
  147638. };
  147639. }
  147640. declare module BABYLON {
  147641. /**
  147642. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147643. */
  147644. export class BloomMergePostProcess extends PostProcess {
  147645. /** Weight of the bloom to be added to the original input. */
  147646. weight: number;
  147647. /**
  147648. * Creates a new instance of @see BloomMergePostProcess
  147649. * @param name The name of the effect.
  147650. * @param originalFromInput Post process which's input will be used for the merge.
  147651. * @param blurred Blurred highlights post process which's output will be used.
  147652. * @param weight Weight of the bloom to be added to the original input.
  147653. * @param options The required width/height ratio to downsize to before computing the render pass.
  147654. * @param camera The camera to apply the render pass to.
  147655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147656. * @param engine The engine which the post process will be applied. (default: current engine)
  147657. * @param reusable If the post process can be reused on the same frame. (default: false)
  147658. * @param textureType Type of textures used when performing the post process. (default: 0)
  147659. * @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)
  147660. */
  147661. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  147662. /** Weight of the bloom to be added to the original input. */
  147663. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147664. }
  147665. }
  147666. declare module BABYLON {
  147667. /**
  147668. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  147669. */
  147670. export class BloomEffect extends PostProcessRenderEffect {
  147671. private bloomScale;
  147672. /**
  147673. * @hidden Internal
  147674. */
  147675. _effects: Array<PostProcess>;
  147676. /**
  147677. * @hidden Internal
  147678. */
  147679. _downscale: ExtractHighlightsPostProcess;
  147680. private _blurX;
  147681. private _blurY;
  147682. private _merge;
  147683. /**
  147684. * The luminance threshold to find bright areas of the image to bloom.
  147685. */
  147686. get threshold(): number;
  147687. set threshold(value: number);
  147688. /**
  147689. * The strength of the bloom.
  147690. */
  147691. get weight(): number;
  147692. set weight(value: number);
  147693. /**
  147694. * Specifies the size of the bloom blur kernel, relative to the final output size
  147695. */
  147696. get kernel(): number;
  147697. set kernel(value: number);
  147698. /**
  147699. * Creates a new instance of @see BloomEffect
  147700. * @param scene The scene the effect belongs to.
  147701. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  147702. * @param bloomKernel The size of the kernel to be used when applying the blur.
  147703. * @param bloomWeight The the strength of bloom.
  147704. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  147705. * @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)
  147706. */
  147707. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  147708. /**
  147709. * Disposes each of the internal effects for a given camera.
  147710. * @param camera The camera to dispose the effect on.
  147711. */
  147712. disposeEffects(camera: Camera): void;
  147713. /**
  147714. * @hidden Internal
  147715. */
  147716. _updateEffects(): void;
  147717. /**
  147718. * Internal
  147719. * @returns if all the contained post processes are ready.
  147720. * @hidden
  147721. */
  147722. _isReady(): boolean;
  147723. }
  147724. }
  147725. declare module BABYLON {
  147726. /** @hidden */
  147727. export var chromaticAberrationPixelShader: {
  147728. name: string;
  147729. shader: string;
  147730. };
  147731. }
  147732. declare module BABYLON {
  147733. /**
  147734. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  147735. */
  147736. export class ChromaticAberrationPostProcess extends PostProcess {
  147737. /**
  147738. * The amount of seperation of rgb channels (default: 30)
  147739. */
  147740. aberrationAmount: number;
  147741. /**
  147742. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  147743. */
  147744. radialIntensity: number;
  147745. /**
  147746. * 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))
  147747. */
  147748. direction: Vector2;
  147749. /**
  147750. * 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))
  147751. */
  147752. centerPosition: Vector2;
  147753. /**
  147754. * Creates a new instance ChromaticAberrationPostProcess
  147755. * @param name The name of the effect.
  147756. * @param screenWidth The width of the screen to apply the effect on.
  147757. * @param screenHeight The height of the screen to apply the effect on.
  147758. * @param options The required width/height ratio to downsize to before computing the render pass.
  147759. * @param camera The camera to apply the render pass to.
  147760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147761. * @param engine The engine which the post process will be applied. (default: current engine)
  147762. * @param reusable If the post process can be reused on the same frame. (default: false)
  147763. * @param textureType Type of textures used when performing the post process. (default: 0)
  147764. * @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)
  147765. */
  147766. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147767. }
  147768. }
  147769. declare module BABYLON {
  147770. /** @hidden */
  147771. export var circleOfConfusionPixelShader: {
  147772. name: string;
  147773. shader: string;
  147774. };
  147775. }
  147776. declare module BABYLON {
  147777. /**
  147778. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  147779. */
  147780. export class CircleOfConfusionPostProcess extends PostProcess {
  147781. /**
  147782. * 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.
  147783. */
  147784. lensSize: number;
  147785. /**
  147786. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  147787. */
  147788. fStop: number;
  147789. /**
  147790. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  147791. */
  147792. focusDistance: number;
  147793. /**
  147794. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  147795. */
  147796. focalLength: number;
  147797. private _depthTexture;
  147798. /**
  147799. * Creates a new instance CircleOfConfusionPostProcess
  147800. * @param name The name of the effect.
  147801. * @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.
  147802. * @param options The required width/height ratio to downsize to before computing the render pass.
  147803. * @param camera The camera to apply the render pass to.
  147804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147805. * @param engine The engine which the post process will be applied. (default: current engine)
  147806. * @param reusable If the post process can be reused on the same frame. (default: false)
  147807. * @param textureType Type of textures used when performing the post process. (default: 0)
  147808. * @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)
  147809. */
  147810. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147811. /**
  147812. * 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.
  147813. */
  147814. set depthTexture(value: RenderTargetTexture);
  147815. }
  147816. }
  147817. declare module BABYLON {
  147818. /** @hidden */
  147819. export var colorCorrectionPixelShader: {
  147820. name: string;
  147821. shader: string;
  147822. };
  147823. }
  147824. declare module BABYLON {
  147825. /**
  147826. *
  147827. * This post-process allows the modification of rendered colors by using
  147828. * a 'look-up table' (LUT). This effect is also called Color Grading.
  147829. *
  147830. * The object needs to be provided an url to a texture containing the color
  147831. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  147832. * Use an image editing software to tweak the LUT to match your needs.
  147833. *
  147834. * For an example of a color LUT, see here:
  147835. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  147836. * For explanations on color grading, see here:
  147837. * @see http://udn.epicgames.com/Three/ColorGrading.html
  147838. *
  147839. */
  147840. export class ColorCorrectionPostProcess extends PostProcess {
  147841. private _colorTableTexture;
  147842. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147843. }
  147844. }
  147845. declare module BABYLON {
  147846. /** @hidden */
  147847. export var convolutionPixelShader: {
  147848. name: string;
  147849. shader: string;
  147850. };
  147851. }
  147852. declare module BABYLON {
  147853. /**
  147854. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  147855. * input texture to perform effects such as edge detection or sharpening
  147856. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147857. */
  147858. export class ConvolutionPostProcess extends PostProcess {
  147859. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147860. kernel: number[];
  147861. /**
  147862. * Creates a new instance ConvolutionPostProcess
  147863. * @param name The name of the effect.
  147864. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  147865. * @param options The required width/height ratio to downsize to before computing the render pass.
  147866. * @param camera The camera to apply the render pass to.
  147867. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147868. * @param engine The engine which the post process will be applied. (default: current engine)
  147869. * @param reusable If the post process can be reused on the same frame. (default: false)
  147870. * @param textureType Type of textures used when performing the post process. (default: 0)
  147871. */
  147872. constructor(name: string,
  147873. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  147874. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147875. /**
  147876. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147877. */
  147878. static EdgeDetect0Kernel: number[];
  147879. /**
  147880. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147881. */
  147882. static EdgeDetect1Kernel: number[];
  147883. /**
  147884. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147885. */
  147886. static EdgeDetect2Kernel: number[];
  147887. /**
  147888. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147889. */
  147890. static SharpenKernel: number[];
  147891. /**
  147892. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147893. */
  147894. static EmbossKernel: number[];
  147895. /**
  147896. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  147897. */
  147898. static GaussianKernel: number[];
  147899. }
  147900. }
  147901. declare module BABYLON {
  147902. /**
  147903. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  147904. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  147905. * based on samples that have a large difference in distance than the center pixel.
  147906. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  147907. */
  147908. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  147909. direction: Vector2;
  147910. /**
  147911. * Creates a new instance CircleOfConfusionPostProcess
  147912. * @param name The name of the effect.
  147913. * @param scene The scene the effect belongs to.
  147914. * @param direction The direction the blur should be applied.
  147915. * @param kernel The size of the kernel used to blur.
  147916. * @param options The required width/height ratio to downsize to before computing the render pass.
  147917. * @param camera The camera to apply the render pass to.
  147918. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  147919. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  147920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147921. * @param engine The engine which the post process will be applied. (default: current engine)
  147922. * @param reusable If the post process can be reused on the same frame. (default: false)
  147923. * @param textureType Type of textures used when performing the post process. (default: 0)
  147924. * @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)
  147925. */
  147926. 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);
  147927. }
  147928. }
  147929. declare module BABYLON {
  147930. /** @hidden */
  147931. export var depthOfFieldMergePixelShader: {
  147932. name: string;
  147933. shader: string;
  147934. };
  147935. }
  147936. declare module BABYLON {
  147937. /**
  147938. * Options to be set when merging outputs from the default pipeline.
  147939. */
  147940. export class DepthOfFieldMergePostProcessOptions {
  147941. /**
  147942. * The original image to merge on top of
  147943. */
  147944. originalFromInput: PostProcess;
  147945. /**
  147946. * Parameters to perform the merge of the depth of field effect
  147947. */
  147948. depthOfField?: {
  147949. circleOfConfusion: PostProcess;
  147950. blurSteps: Array<PostProcess>;
  147951. };
  147952. /**
  147953. * Parameters to perform the merge of bloom effect
  147954. */
  147955. bloom?: {
  147956. blurred: PostProcess;
  147957. weight: number;
  147958. };
  147959. }
  147960. /**
  147961. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  147962. */
  147963. export class DepthOfFieldMergePostProcess extends PostProcess {
  147964. private blurSteps;
  147965. /**
  147966. * Creates a new instance of DepthOfFieldMergePostProcess
  147967. * @param name The name of the effect.
  147968. * @param originalFromInput Post process which's input will be used for the merge.
  147969. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  147970. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  147971. * @param options The required width/height ratio to downsize to before computing the render pass.
  147972. * @param camera The camera to apply the render pass to.
  147973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147974. * @param engine The engine which the post process will be applied. (default: current engine)
  147975. * @param reusable If the post process can be reused on the same frame. (default: false)
  147976. * @param textureType Type of textures used when performing the post process. (default: 0)
  147977. * @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)
  147978. */
  147979. 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);
  147980. /**
  147981. * Updates the effect with the current post process compile time values and recompiles the shader.
  147982. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  147983. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  147984. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  147985. * @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
  147986. * @param onCompiled Called when the shader has been compiled.
  147987. * @param onError Called if there is an error when compiling a shader.
  147988. */
  147989. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  147990. }
  147991. }
  147992. declare module BABYLON {
  147993. /**
  147994. * Specifies the level of max blur that should be applied when using the depth of field effect
  147995. */
  147996. export enum DepthOfFieldEffectBlurLevel {
  147997. /**
  147998. * Subtle blur
  147999. */
  148000. Low = 0,
  148001. /**
  148002. * Medium blur
  148003. */
  148004. Medium = 1,
  148005. /**
  148006. * Large blur
  148007. */
  148008. High = 2
  148009. }
  148010. /**
  148011. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  148012. */
  148013. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  148014. private _circleOfConfusion;
  148015. /**
  148016. * @hidden Internal, blurs from high to low
  148017. */
  148018. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  148019. private _depthOfFieldBlurY;
  148020. private _dofMerge;
  148021. /**
  148022. * @hidden Internal post processes in depth of field effect
  148023. */
  148024. _effects: Array<PostProcess>;
  148025. /**
  148026. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  148027. */
  148028. set focalLength(value: number);
  148029. get focalLength(): number;
  148030. /**
  148031. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  148032. */
  148033. set fStop(value: number);
  148034. get fStop(): number;
  148035. /**
  148036. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  148037. */
  148038. set focusDistance(value: number);
  148039. get focusDistance(): number;
  148040. /**
  148041. * 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.
  148042. */
  148043. set lensSize(value: number);
  148044. get lensSize(): number;
  148045. /**
  148046. * Creates a new instance DepthOfFieldEffect
  148047. * @param scene The scene the effect belongs to.
  148048. * @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.
  148049. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148050. * @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)
  148051. */
  148052. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  148053. /**
  148054. * Get the current class name of the current effet
  148055. * @returns "DepthOfFieldEffect"
  148056. */
  148057. getClassName(): string;
  148058. /**
  148059. * 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.
  148060. */
  148061. set depthTexture(value: RenderTargetTexture);
  148062. /**
  148063. * Disposes each of the internal effects for a given camera.
  148064. * @param camera The camera to dispose the effect on.
  148065. */
  148066. disposeEffects(camera: Camera): void;
  148067. /**
  148068. * @hidden Internal
  148069. */
  148070. _updateEffects(): void;
  148071. /**
  148072. * Internal
  148073. * @returns if all the contained post processes are ready.
  148074. * @hidden
  148075. */
  148076. _isReady(): boolean;
  148077. }
  148078. }
  148079. declare module BABYLON {
  148080. /** @hidden */
  148081. export var displayPassPixelShader: {
  148082. name: string;
  148083. shader: string;
  148084. };
  148085. }
  148086. declare module BABYLON {
  148087. /**
  148088. * DisplayPassPostProcess which produces an output the same as it's input
  148089. */
  148090. export class DisplayPassPostProcess extends PostProcess {
  148091. /**
  148092. * Creates the DisplayPassPostProcess
  148093. * @param name The name of the effect.
  148094. * @param options The required width/height ratio to downsize to before computing the render pass.
  148095. * @param camera The camera to apply the render pass to.
  148096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148097. * @param engine The engine which the post process will be applied. (default: current engine)
  148098. * @param reusable If the post process can be reused on the same frame. (default: false)
  148099. */
  148100. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148101. }
  148102. }
  148103. declare module BABYLON {
  148104. /** @hidden */
  148105. export var filterPixelShader: {
  148106. name: string;
  148107. shader: string;
  148108. };
  148109. }
  148110. declare module BABYLON {
  148111. /**
  148112. * Applies a kernel filter to the image
  148113. */
  148114. export class FilterPostProcess extends PostProcess {
  148115. /** The matrix to be applied to the image */
  148116. kernelMatrix: Matrix;
  148117. /**
  148118. *
  148119. * @param name The name of the effect.
  148120. * @param kernelMatrix The matrix to be applied to the image
  148121. * @param options The required width/height ratio to downsize to before computing the render pass.
  148122. * @param camera The camera to apply the render pass to.
  148123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148124. * @param engine The engine which the post process will be applied. (default: current engine)
  148125. * @param reusable If the post process can be reused on the same frame. (default: false)
  148126. */
  148127. constructor(name: string,
  148128. /** The matrix to be applied to the image */
  148129. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148130. }
  148131. }
  148132. declare module BABYLON {
  148133. /** @hidden */
  148134. export var fxaaPixelShader: {
  148135. name: string;
  148136. shader: string;
  148137. };
  148138. }
  148139. declare module BABYLON {
  148140. /** @hidden */
  148141. export var fxaaVertexShader: {
  148142. name: string;
  148143. shader: string;
  148144. };
  148145. }
  148146. declare module BABYLON {
  148147. /**
  148148. * Fxaa post process
  148149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  148150. */
  148151. export class FxaaPostProcess extends PostProcess {
  148152. /** @hidden */
  148153. texelWidth: number;
  148154. /** @hidden */
  148155. texelHeight: number;
  148156. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148157. private _getDefines;
  148158. }
  148159. }
  148160. declare module BABYLON {
  148161. /** @hidden */
  148162. export var grainPixelShader: {
  148163. name: string;
  148164. shader: string;
  148165. };
  148166. }
  148167. declare module BABYLON {
  148168. /**
  148169. * The GrainPostProcess adds noise to the image at mid luminance levels
  148170. */
  148171. export class GrainPostProcess extends PostProcess {
  148172. /**
  148173. * The intensity of the grain added (default: 30)
  148174. */
  148175. intensity: number;
  148176. /**
  148177. * If the grain should be randomized on every frame
  148178. */
  148179. animated: boolean;
  148180. /**
  148181. * Creates a new instance of @see GrainPostProcess
  148182. * @param name The name of the effect.
  148183. * @param options The required width/height ratio to downsize to before computing the render pass.
  148184. * @param camera The camera to apply the render pass to.
  148185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148186. * @param engine The engine which the post process will be applied. (default: current engine)
  148187. * @param reusable If the post process can be reused on the same frame. (default: false)
  148188. * @param textureType Type of textures used when performing the post process. (default: 0)
  148189. * @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)
  148190. */
  148191. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148192. }
  148193. }
  148194. declare module BABYLON {
  148195. /** @hidden */
  148196. export var highlightsPixelShader: {
  148197. name: string;
  148198. shader: string;
  148199. };
  148200. }
  148201. declare module BABYLON {
  148202. /**
  148203. * Extracts highlights from the image
  148204. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148205. */
  148206. export class HighlightsPostProcess extends PostProcess {
  148207. /**
  148208. * Extracts highlights from the image
  148209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  148210. * @param name The name of the effect.
  148211. * @param options The required width/height ratio to downsize to before computing the render pass.
  148212. * @param camera The camera to apply the render pass to.
  148213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148214. * @param engine The engine which the post process will be applied. (default: current engine)
  148215. * @param reusable If the post process can be reused on the same frame. (default: false)
  148216. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  148217. */
  148218. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148219. }
  148220. }
  148221. declare module BABYLON {
  148222. /** @hidden */
  148223. export var mrtFragmentDeclaration: {
  148224. name: string;
  148225. shader: string;
  148226. };
  148227. }
  148228. declare module BABYLON {
  148229. /** @hidden */
  148230. export var geometryPixelShader: {
  148231. name: string;
  148232. shader: string;
  148233. };
  148234. }
  148235. declare module BABYLON {
  148236. /** @hidden */
  148237. export var geometryVertexShader: {
  148238. name: string;
  148239. shader: string;
  148240. };
  148241. }
  148242. declare module BABYLON {
  148243. /** @hidden */
  148244. interface ISavedTransformationMatrix {
  148245. world: Matrix;
  148246. viewProjection: Matrix;
  148247. }
  148248. /**
  148249. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  148250. */
  148251. export class GeometryBufferRenderer {
  148252. /**
  148253. * Constant used to retrieve the position texture index in the G-Buffer textures array
  148254. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  148255. */
  148256. static readonly POSITION_TEXTURE_TYPE: number;
  148257. /**
  148258. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  148259. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  148260. */
  148261. static readonly VELOCITY_TEXTURE_TYPE: number;
  148262. /**
  148263. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  148264. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  148265. */
  148266. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  148267. /**
  148268. * Dictionary used to store the previous transformation matrices of each rendered mesh
  148269. * in order to compute objects velocities when enableVelocity is set to "true"
  148270. * @hidden
  148271. */
  148272. _previousTransformationMatrices: {
  148273. [index: number]: ISavedTransformationMatrix;
  148274. };
  148275. /**
  148276. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  148277. * in order to compute objects velocities when enableVelocity is set to "true"
  148278. * @hidden
  148279. */
  148280. _previousBonesTransformationMatrices: {
  148281. [index: number]: Float32Array;
  148282. };
  148283. /**
  148284. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  148285. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  148286. */
  148287. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  148288. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  148289. renderTransparentMeshes: boolean;
  148290. private _scene;
  148291. private _resizeObserver;
  148292. private _multiRenderTarget;
  148293. private _ratio;
  148294. private _enablePosition;
  148295. private _enableVelocity;
  148296. private _enableReflectivity;
  148297. private _positionIndex;
  148298. private _velocityIndex;
  148299. private _reflectivityIndex;
  148300. protected _effect: Effect;
  148301. protected _cachedDefines: string;
  148302. /**
  148303. * Set the render list (meshes to be rendered) used in the G buffer.
  148304. */
  148305. set renderList(meshes: Mesh[]);
  148306. /**
  148307. * Gets wether or not G buffer are supported by the running hardware.
  148308. * This requires draw buffer supports
  148309. */
  148310. get isSupported(): boolean;
  148311. /**
  148312. * Returns the index of the given texture type in the G-Buffer textures array
  148313. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  148314. * @returns the index of the given texture type in the G-Buffer textures array
  148315. */
  148316. getTextureIndex(textureType: number): number;
  148317. /**
  148318. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  148319. */
  148320. get enablePosition(): boolean;
  148321. /**
  148322. * Sets whether or not objects positions are enabled for the G buffer.
  148323. */
  148324. set enablePosition(enable: boolean);
  148325. /**
  148326. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  148327. */
  148328. get enableVelocity(): boolean;
  148329. /**
  148330. * Sets wether or not objects velocities are enabled for the G buffer.
  148331. */
  148332. set enableVelocity(enable: boolean);
  148333. /**
  148334. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  148335. */
  148336. get enableReflectivity(): boolean;
  148337. /**
  148338. * Sets wether or not objects roughness are enabled for the G buffer.
  148339. */
  148340. set enableReflectivity(enable: boolean);
  148341. /**
  148342. * Gets the scene associated with the buffer.
  148343. */
  148344. get scene(): Scene;
  148345. /**
  148346. * Gets the ratio used by the buffer during its creation.
  148347. * How big is the buffer related to the main canvas.
  148348. */
  148349. get ratio(): number;
  148350. /** @hidden */
  148351. static _SceneComponentInitialization: (scene: Scene) => void;
  148352. /**
  148353. * Creates a new G Buffer for the scene
  148354. * @param scene The scene the buffer belongs to
  148355. * @param ratio How big is the buffer related to the main canvas.
  148356. */
  148357. constructor(scene: Scene, ratio?: number);
  148358. /**
  148359. * Checks wether everything is ready to render a submesh to the G buffer.
  148360. * @param subMesh the submesh to check readiness for
  148361. * @param useInstances is the mesh drawn using instance or not
  148362. * @returns true if ready otherwise false
  148363. */
  148364. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148365. /**
  148366. * Gets the current underlying G Buffer.
  148367. * @returns the buffer
  148368. */
  148369. getGBuffer(): MultiRenderTarget;
  148370. /**
  148371. * Gets the number of samples used to render the buffer (anti aliasing).
  148372. */
  148373. get samples(): number;
  148374. /**
  148375. * Sets the number of samples used to render the buffer (anti aliasing).
  148376. */
  148377. set samples(value: number);
  148378. /**
  148379. * Disposes the renderer and frees up associated resources.
  148380. */
  148381. dispose(): void;
  148382. protected _createRenderTargets(): void;
  148383. private _copyBonesTransformationMatrices;
  148384. }
  148385. }
  148386. declare module BABYLON {
  148387. interface Scene {
  148388. /** @hidden (Backing field) */
  148389. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148390. /**
  148391. * Gets or Sets the current geometry buffer associated to the scene.
  148392. */
  148393. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  148394. /**
  148395. * Enables a GeometryBufferRender and associates it with the scene
  148396. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  148397. * @returns the GeometryBufferRenderer
  148398. */
  148399. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  148400. /**
  148401. * Disables the GeometryBufferRender associated with the scene
  148402. */
  148403. disableGeometryBufferRenderer(): void;
  148404. }
  148405. /**
  148406. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  148407. * in several rendering techniques.
  148408. */
  148409. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  148410. /**
  148411. * The component name helpful to identify the component in the list of scene components.
  148412. */
  148413. readonly name: string;
  148414. /**
  148415. * The scene the component belongs to.
  148416. */
  148417. scene: Scene;
  148418. /**
  148419. * Creates a new instance of the component for the given scene
  148420. * @param scene Defines the scene to register the component in
  148421. */
  148422. constructor(scene: Scene);
  148423. /**
  148424. * Registers the component in a given scene
  148425. */
  148426. register(): void;
  148427. /**
  148428. * Rebuilds the elements related to this component in case of
  148429. * context lost for instance.
  148430. */
  148431. rebuild(): void;
  148432. /**
  148433. * Disposes the component and the associated ressources
  148434. */
  148435. dispose(): void;
  148436. private _gatherRenderTargets;
  148437. }
  148438. }
  148439. declare module BABYLON {
  148440. /** @hidden */
  148441. export var motionBlurPixelShader: {
  148442. name: string;
  148443. shader: string;
  148444. };
  148445. }
  148446. declare module BABYLON {
  148447. /**
  148448. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  148449. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  148450. * As an example, all you have to do is to create the post-process:
  148451. * var mb = new BABYLON.MotionBlurPostProcess(
  148452. * 'mb', // The name of the effect.
  148453. * scene, // The scene containing the objects to blur according to their velocity.
  148454. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  148455. * camera // The camera to apply the render pass to.
  148456. * );
  148457. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  148458. */
  148459. export class MotionBlurPostProcess extends PostProcess {
  148460. /**
  148461. * Defines how much the image is blurred by the movement. Default value is equal to 1
  148462. */
  148463. motionStrength: number;
  148464. /**
  148465. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  148466. */
  148467. get motionBlurSamples(): number;
  148468. /**
  148469. * Sets the number of iterations to be used for motion blur quality
  148470. */
  148471. set motionBlurSamples(samples: number);
  148472. private _motionBlurSamples;
  148473. private _geometryBufferRenderer;
  148474. /**
  148475. * Creates a new instance MotionBlurPostProcess
  148476. * @param name The name of the effect.
  148477. * @param scene The scene containing the objects to blur according to their velocity.
  148478. * @param options The required width/height ratio to downsize to before computing the render pass.
  148479. * @param camera The camera to apply the render pass to.
  148480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148481. * @param engine The engine which the post process will be applied. (default: current engine)
  148482. * @param reusable If the post process can be reused on the same frame. (default: false)
  148483. * @param textureType Type of textures used when performing the post process. (default: 0)
  148484. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  148485. */
  148486. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148487. /**
  148488. * Excludes the given skinned mesh from computing bones velocities.
  148489. * 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.
  148490. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  148491. */
  148492. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148493. /**
  148494. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  148495. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  148496. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  148497. */
  148498. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  148499. /**
  148500. * Disposes the post process.
  148501. * @param camera The camera to dispose the post process on.
  148502. */
  148503. dispose(camera?: Camera): void;
  148504. }
  148505. }
  148506. declare module BABYLON {
  148507. /** @hidden */
  148508. export var refractionPixelShader: {
  148509. name: string;
  148510. shader: string;
  148511. };
  148512. }
  148513. declare module BABYLON {
  148514. /**
  148515. * Post process which applies a refractin texture
  148516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148517. */
  148518. export class RefractionPostProcess extends PostProcess {
  148519. /** the base color of the refraction (used to taint the rendering) */
  148520. color: Color3;
  148521. /** simulated refraction depth */
  148522. depth: number;
  148523. /** the coefficient of the base color (0 to remove base color tainting) */
  148524. colorLevel: number;
  148525. private _refTexture;
  148526. private _ownRefractionTexture;
  148527. /**
  148528. * Gets or sets the refraction texture
  148529. * Please note that you are responsible for disposing the texture if you set it manually
  148530. */
  148531. get refractionTexture(): Texture;
  148532. set refractionTexture(value: Texture);
  148533. /**
  148534. * Initializes the RefractionPostProcess
  148535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  148536. * @param name The name of the effect.
  148537. * @param refractionTextureUrl Url of the refraction texture to use
  148538. * @param color the base color of the refraction (used to taint the rendering)
  148539. * @param depth simulated refraction depth
  148540. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  148541. * @param camera The camera to apply the render pass to.
  148542. * @param options The required width/height ratio to downsize to before computing the render pass.
  148543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148544. * @param engine The engine which the post process will be applied. (default: current engine)
  148545. * @param reusable If the post process can be reused on the same frame. (default: false)
  148546. */
  148547. constructor(name: string, refractionTextureUrl: string,
  148548. /** the base color of the refraction (used to taint the rendering) */
  148549. color: Color3,
  148550. /** simulated refraction depth */
  148551. depth: number,
  148552. /** the coefficient of the base color (0 to remove base color tainting) */
  148553. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148554. /**
  148555. * Disposes of the post process
  148556. * @param camera Camera to dispose post process on
  148557. */
  148558. dispose(camera: Camera): void;
  148559. }
  148560. }
  148561. declare module BABYLON {
  148562. /** @hidden */
  148563. export var sharpenPixelShader: {
  148564. name: string;
  148565. shader: string;
  148566. };
  148567. }
  148568. declare module BABYLON {
  148569. /**
  148570. * The SharpenPostProcess applies a sharpen kernel to every pixel
  148571. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  148572. */
  148573. export class SharpenPostProcess extends PostProcess {
  148574. /**
  148575. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  148576. */
  148577. colorAmount: number;
  148578. /**
  148579. * How much sharpness should be applied (default: 0.3)
  148580. */
  148581. edgeAmount: number;
  148582. /**
  148583. * Creates a new instance ConvolutionPostProcess
  148584. * @param name The name of the effect.
  148585. * @param options The required width/height ratio to downsize to before computing the render pass.
  148586. * @param camera The camera to apply the render pass to.
  148587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148588. * @param engine The engine which the post process will be applied. (default: current engine)
  148589. * @param reusable If the post process can be reused on the same frame. (default: false)
  148590. * @param textureType Type of textures used when performing the post process. (default: 0)
  148591. * @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)
  148592. */
  148593. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148594. }
  148595. }
  148596. declare module BABYLON {
  148597. /**
  148598. * PostProcessRenderPipeline
  148599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148600. */
  148601. export class PostProcessRenderPipeline {
  148602. private engine;
  148603. private _renderEffects;
  148604. private _renderEffectsForIsolatedPass;
  148605. /**
  148606. * List of inspectable custom properties (used by the Inspector)
  148607. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  148608. */
  148609. inspectableCustomProperties: IInspectable[];
  148610. /**
  148611. * @hidden
  148612. */
  148613. protected _cameras: Camera[];
  148614. /** @hidden */
  148615. _name: string;
  148616. /**
  148617. * Gets pipeline name
  148618. */
  148619. get name(): string;
  148620. /** Gets the list of attached cameras */
  148621. get cameras(): Camera[];
  148622. /**
  148623. * Initializes a PostProcessRenderPipeline
  148624. * @param engine engine to add the pipeline to
  148625. * @param name name of the pipeline
  148626. */
  148627. constructor(engine: Engine, name: string);
  148628. /**
  148629. * Gets the class name
  148630. * @returns "PostProcessRenderPipeline"
  148631. */
  148632. getClassName(): string;
  148633. /**
  148634. * If all the render effects in the pipeline are supported
  148635. */
  148636. get isSupported(): boolean;
  148637. /**
  148638. * Adds an effect to the pipeline
  148639. * @param renderEffect the effect to add
  148640. */
  148641. addEffect(renderEffect: PostProcessRenderEffect): void;
  148642. /** @hidden */
  148643. _rebuild(): void;
  148644. /** @hidden */
  148645. _enableEffect(renderEffectName: string, cameras: Camera): void;
  148646. /** @hidden */
  148647. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  148648. /** @hidden */
  148649. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148650. /** @hidden */
  148651. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  148652. /** @hidden */
  148653. _attachCameras(cameras: Camera, unique: boolean): void;
  148654. /** @hidden */
  148655. _attachCameras(cameras: Camera[], unique: boolean): void;
  148656. /** @hidden */
  148657. _detachCameras(cameras: Camera): void;
  148658. /** @hidden */
  148659. _detachCameras(cameras: Nullable<Camera[]>): void;
  148660. /** @hidden */
  148661. _update(): void;
  148662. /** @hidden */
  148663. _reset(): void;
  148664. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  148665. /**
  148666. * Sets the required values to the prepass renderer.
  148667. * @param prePassRenderer defines the prepass renderer to setup.
  148668. * @returns true if the pre pass is needed.
  148669. */
  148670. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  148671. /**
  148672. * Disposes of the pipeline
  148673. */
  148674. dispose(): void;
  148675. }
  148676. }
  148677. declare module BABYLON {
  148678. /**
  148679. * PostProcessRenderPipelineManager class
  148680. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148681. */
  148682. export class PostProcessRenderPipelineManager {
  148683. private _renderPipelines;
  148684. /**
  148685. * Initializes a PostProcessRenderPipelineManager
  148686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148687. */
  148688. constructor();
  148689. /**
  148690. * Gets the list of supported render pipelines
  148691. */
  148692. get supportedPipelines(): PostProcessRenderPipeline[];
  148693. /**
  148694. * Adds a pipeline to the manager
  148695. * @param renderPipeline The pipeline to add
  148696. */
  148697. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  148698. /**
  148699. * Attaches a camera to the pipeline
  148700. * @param renderPipelineName The name of the pipeline to attach to
  148701. * @param cameras the camera to attach
  148702. * @param unique if the camera can be attached multiple times to the pipeline
  148703. */
  148704. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  148705. /**
  148706. * Detaches a camera from the pipeline
  148707. * @param renderPipelineName The name of the pipeline to detach from
  148708. * @param cameras the camera to detach
  148709. */
  148710. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  148711. /**
  148712. * Enables an effect by name on a pipeline
  148713. * @param renderPipelineName the name of the pipeline to enable the effect in
  148714. * @param renderEffectName the name of the effect to enable
  148715. * @param cameras the cameras that the effect should be enabled on
  148716. */
  148717. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148718. /**
  148719. * Disables an effect by name on a pipeline
  148720. * @param renderPipelineName the name of the pipeline to disable the effect in
  148721. * @param renderEffectName the name of the effect to disable
  148722. * @param cameras the cameras that the effect should be disabled on
  148723. */
  148724. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  148725. /**
  148726. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  148727. */
  148728. update(): void;
  148729. /** @hidden */
  148730. _rebuild(): void;
  148731. /**
  148732. * Disposes of the manager and pipelines
  148733. */
  148734. dispose(): void;
  148735. }
  148736. }
  148737. declare module BABYLON {
  148738. interface Scene {
  148739. /** @hidden (Backing field) */
  148740. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148741. /**
  148742. * Gets the postprocess render pipeline manager
  148743. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148744. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148745. */
  148746. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  148747. }
  148748. /**
  148749. * Defines the Render Pipeline scene component responsible to rendering pipelines
  148750. */
  148751. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  148752. /**
  148753. * The component name helpfull to identify the component in the list of scene components.
  148754. */
  148755. readonly name: string;
  148756. /**
  148757. * The scene the component belongs to.
  148758. */
  148759. scene: Scene;
  148760. /**
  148761. * Creates a new instance of the component for the given scene
  148762. * @param scene Defines the scene to register the component in
  148763. */
  148764. constructor(scene: Scene);
  148765. /**
  148766. * Registers the component in a given scene
  148767. */
  148768. register(): void;
  148769. /**
  148770. * Rebuilds the elements related to this component in case of
  148771. * context lost for instance.
  148772. */
  148773. rebuild(): void;
  148774. /**
  148775. * Disposes the component and the associated ressources
  148776. */
  148777. dispose(): void;
  148778. private _gatherRenderTargets;
  148779. }
  148780. }
  148781. declare module BABYLON {
  148782. /**
  148783. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  148784. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  148785. */
  148786. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148787. private _scene;
  148788. private _camerasToBeAttached;
  148789. /**
  148790. * ID of the sharpen post process,
  148791. */
  148792. private readonly SharpenPostProcessId;
  148793. /**
  148794. * @ignore
  148795. * ID of the image processing post process;
  148796. */
  148797. readonly ImageProcessingPostProcessId: string;
  148798. /**
  148799. * @ignore
  148800. * ID of the Fast Approximate Anti-Aliasing post process;
  148801. */
  148802. readonly FxaaPostProcessId: string;
  148803. /**
  148804. * ID of the chromatic aberration post process,
  148805. */
  148806. private readonly ChromaticAberrationPostProcessId;
  148807. /**
  148808. * ID of the grain post process
  148809. */
  148810. private readonly GrainPostProcessId;
  148811. /**
  148812. * Sharpen post process which will apply a sharpen convolution to enhance edges
  148813. */
  148814. sharpen: SharpenPostProcess;
  148815. private _sharpenEffect;
  148816. private bloom;
  148817. /**
  148818. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  148819. */
  148820. depthOfField: DepthOfFieldEffect;
  148821. /**
  148822. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148823. */
  148824. fxaa: FxaaPostProcess;
  148825. /**
  148826. * Image post processing pass used to perform operations such as tone mapping or color grading.
  148827. */
  148828. imageProcessing: ImageProcessingPostProcess;
  148829. /**
  148830. * Chromatic aberration post process which will shift rgb colors in the image
  148831. */
  148832. chromaticAberration: ChromaticAberrationPostProcess;
  148833. private _chromaticAberrationEffect;
  148834. /**
  148835. * Grain post process which add noise to the image
  148836. */
  148837. grain: GrainPostProcess;
  148838. private _grainEffect;
  148839. /**
  148840. * Glow post process which adds a glow to emissive areas of the image
  148841. */
  148842. private _glowLayer;
  148843. /**
  148844. * Animations which can be used to tweak settings over a period of time
  148845. */
  148846. animations: Animation[];
  148847. private _imageProcessingConfigurationObserver;
  148848. private _sharpenEnabled;
  148849. private _bloomEnabled;
  148850. private _depthOfFieldEnabled;
  148851. private _depthOfFieldBlurLevel;
  148852. private _fxaaEnabled;
  148853. private _imageProcessingEnabled;
  148854. private _defaultPipelineTextureType;
  148855. private _bloomScale;
  148856. private _chromaticAberrationEnabled;
  148857. private _grainEnabled;
  148858. private _buildAllowed;
  148859. /**
  148860. * Gets active scene
  148861. */
  148862. get scene(): Scene;
  148863. /**
  148864. * Enable or disable the sharpen process from the pipeline
  148865. */
  148866. set sharpenEnabled(enabled: boolean);
  148867. get sharpenEnabled(): boolean;
  148868. private _resizeObserver;
  148869. private _hardwareScaleLevel;
  148870. private _bloomKernel;
  148871. /**
  148872. * Specifies the size of the bloom blur kernel, relative to the final output size
  148873. */
  148874. get bloomKernel(): number;
  148875. set bloomKernel(value: number);
  148876. /**
  148877. * Specifies the weight of the bloom in the final rendering
  148878. */
  148879. private _bloomWeight;
  148880. /**
  148881. * Specifies the luma threshold for the area that will be blurred by the bloom
  148882. */
  148883. private _bloomThreshold;
  148884. private _hdr;
  148885. /**
  148886. * The strength of the bloom.
  148887. */
  148888. set bloomWeight(value: number);
  148889. get bloomWeight(): number;
  148890. /**
  148891. * The strength of the bloom.
  148892. */
  148893. set bloomThreshold(value: number);
  148894. get bloomThreshold(): number;
  148895. /**
  148896. * The scale of the bloom, lower value will provide better performance.
  148897. */
  148898. set bloomScale(value: number);
  148899. get bloomScale(): number;
  148900. /**
  148901. * Enable or disable the bloom from the pipeline
  148902. */
  148903. set bloomEnabled(enabled: boolean);
  148904. get bloomEnabled(): boolean;
  148905. private _rebuildBloom;
  148906. /**
  148907. * If the depth of field is enabled.
  148908. */
  148909. get depthOfFieldEnabled(): boolean;
  148910. set depthOfFieldEnabled(enabled: boolean);
  148911. /**
  148912. * Blur level of the depth of field effect. (Higher blur will effect performance)
  148913. */
  148914. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  148915. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  148916. /**
  148917. * If the anti aliasing is enabled.
  148918. */
  148919. set fxaaEnabled(enabled: boolean);
  148920. get fxaaEnabled(): boolean;
  148921. private _samples;
  148922. /**
  148923. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148924. */
  148925. set samples(sampleCount: number);
  148926. get samples(): number;
  148927. /**
  148928. * If image processing is enabled.
  148929. */
  148930. set imageProcessingEnabled(enabled: boolean);
  148931. get imageProcessingEnabled(): boolean;
  148932. /**
  148933. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  148934. */
  148935. set glowLayerEnabled(enabled: boolean);
  148936. get glowLayerEnabled(): boolean;
  148937. /**
  148938. * Gets the glow layer (or null if not defined)
  148939. */
  148940. get glowLayer(): Nullable<GlowLayer>;
  148941. /**
  148942. * Enable or disable the chromaticAberration process from the pipeline
  148943. */
  148944. set chromaticAberrationEnabled(enabled: boolean);
  148945. get chromaticAberrationEnabled(): boolean;
  148946. /**
  148947. * Enable or disable the grain process from the pipeline
  148948. */
  148949. set grainEnabled(enabled: boolean);
  148950. get grainEnabled(): boolean;
  148951. /**
  148952. * @constructor
  148953. * @param name - The rendering pipeline name (default: "")
  148954. * @param hdr - If high dynamic range textures should be used (default: true)
  148955. * @param scene - The scene linked to this pipeline (default: the last created scene)
  148956. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  148957. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  148958. */
  148959. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  148960. /**
  148961. * Get the class name
  148962. * @returns "DefaultRenderingPipeline"
  148963. */
  148964. getClassName(): string;
  148965. /**
  148966. * Force the compilation of the entire pipeline.
  148967. */
  148968. prepare(): void;
  148969. private _hasCleared;
  148970. private _prevPostProcess;
  148971. private _prevPrevPostProcess;
  148972. private _setAutoClearAndTextureSharing;
  148973. private _depthOfFieldSceneObserver;
  148974. private _buildPipeline;
  148975. private _disposePostProcesses;
  148976. /**
  148977. * Adds a camera to the pipeline
  148978. * @param camera the camera to be added
  148979. */
  148980. addCamera(camera: Camera): void;
  148981. /**
  148982. * Removes a camera from the pipeline
  148983. * @param camera the camera to remove
  148984. */
  148985. removeCamera(camera: Camera): void;
  148986. /**
  148987. * Dispose of the pipeline and stop all post processes
  148988. */
  148989. dispose(): void;
  148990. /**
  148991. * Serialize the rendering pipeline (Used when exporting)
  148992. * @returns the serialized object
  148993. */
  148994. serialize(): any;
  148995. /**
  148996. * Parse the serialized pipeline
  148997. * @param source Source pipeline.
  148998. * @param scene The scene to load the pipeline to.
  148999. * @param rootUrl The URL of the serialized pipeline.
  149000. * @returns An instantiated pipeline from the serialized object.
  149001. */
  149002. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  149003. }
  149004. }
  149005. declare module BABYLON {
  149006. /** @hidden */
  149007. export var lensHighlightsPixelShader: {
  149008. name: string;
  149009. shader: string;
  149010. };
  149011. }
  149012. declare module BABYLON {
  149013. /** @hidden */
  149014. export var depthOfFieldPixelShader: {
  149015. name: string;
  149016. shader: string;
  149017. };
  149018. }
  149019. declare module BABYLON {
  149020. /**
  149021. * BABYLON.JS Chromatic Aberration GLSL Shader
  149022. * Author: Olivier Guyot
  149023. * Separates very slightly R, G and B colors on the edges of the screen
  149024. * Inspired by Francois Tarlier & Martins Upitis
  149025. */
  149026. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  149027. /**
  149028. * @ignore
  149029. * The chromatic aberration PostProcess id in the pipeline
  149030. */
  149031. LensChromaticAberrationEffect: string;
  149032. /**
  149033. * @ignore
  149034. * The highlights enhancing PostProcess id in the pipeline
  149035. */
  149036. HighlightsEnhancingEffect: string;
  149037. /**
  149038. * @ignore
  149039. * The depth-of-field PostProcess id in the pipeline
  149040. */
  149041. LensDepthOfFieldEffect: string;
  149042. private _scene;
  149043. private _depthTexture;
  149044. private _grainTexture;
  149045. private _chromaticAberrationPostProcess;
  149046. private _highlightsPostProcess;
  149047. private _depthOfFieldPostProcess;
  149048. private _edgeBlur;
  149049. private _grainAmount;
  149050. private _chromaticAberration;
  149051. private _distortion;
  149052. private _highlightsGain;
  149053. private _highlightsThreshold;
  149054. private _dofDistance;
  149055. private _dofAperture;
  149056. private _dofDarken;
  149057. private _dofPentagon;
  149058. private _blurNoise;
  149059. /**
  149060. * @constructor
  149061. *
  149062. * Effect parameters are as follow:
  149063. * {
  149064. * chromatic_aberration: number; // from 0 to x (1 for realism)
  149065. * edge_blur: number; // from 0 to x (1 for realism)
  149066. * distortion: number; // from 0 to x (1 for realism)
  149067. * grain_amount: number; // from 0 to 1
  149068. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  149069. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  149070. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  149071. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  149072. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  149073. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  149074. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  149075. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  149076. * }
  149077. * Note: if an effect parameter is unset, effect is disabled
  149078. *
  149079. * @param name The rendering pipeline name
  149080. * @param parameters - An object containing all parameters (see above)
  149081. * @param scene The scene linked to this pipeline
  149082. * @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)
  149083. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149084. */
  149085. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  149086. /**
  149087. * Get the class name
  149088. * @returns "LensRenderingPipeline"
  149089. */
  149090. getClassName(): string;
  149091. /**
  149092. * Gets associated scene
  149093. */
  149094. get scene(): Scene;
  149095. /**
  149096. * Gets or sets the edge blur
  149097. */
  149098. get edgeBlur(): number;
  149099. set edgeBlur(value: number);
  149100. /**
  149101. * Gets or sets the grain amount
  149102. */
  149103. get grainAmount(): number;
  149104. set grainAmount(value: number);
  149105. /**
  149106. * Gets or sets the chromatic aberration amount
  149107. */
  149108. get chromaticAberration(): number;
  149109. set chromaticAberration(value: number);
  149110. /**
  149111. * Gets or sets the depth of field aperture
  149112. */
  149113. get dofAperture(): number;
  149114. set dofAperture(value: number);
  149115. /**
  149116. * Gets or sets the edge distortion
  149117. */
  149118. get edgeDistortion(): number;
  149119. set edgeDistortion(value: number);
  149120. /**
  149121. * Gets or sets the depth of field distortion
  149122. */
  149123. get dofDistortion(): number;
  149124. set dofDistortion(value: number);
  149125. /**
  149126. * Gets or sets the darken out of focus amount
  149127. */
  149128. get darkenOutOfFocus(): number;
  149129. set darkenOutOfFocus(value: number);
  149130. /**
  149131. * Gets or sets a boolean indicating if blur noise is enabled
  149132. */
  149133. get blurNoise(): boolean;
  149134. set blurNoise(value: boolean);
  149135. /**
  149136. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  149137. */
  149138. get pentagonBokeh(): boolean;
  149139. set pentagonBokeh(value: boolean);
  149140. /**
  149141. * Gets or sets the highlight grain amount
  149142. */
  149143. get highlightsGain(): number;
  149144. set highlightsGain(value: number);
  149145. /**
  149146. * Gets or sets the highlight threshold
  149147. */
  149148. get highlightsThreshold(): number;
  149149. set highlightsThreshold(value: number);
  149150. /**
  149151. * Sets the amount of blur at the edges
  149152. * @param amount blur amount
  149153. */
  149154. setEdgeBlur(amount: number): void;
  149155. /**
  149156. * Sets edge blur to 0
  149157. */
  149158. disableEdgeBlur(): void;
  149159. /**
  149160. * Sets the amout of grain
  149161. * @param amount Amount of grain
  149162. */
  149163. setGrainAmount(amount: number): void;
  149164. /**
  149165. * Set grain amount to 0
  149166. */
  149167. disableGrain(): void;
  149168. /**
  149169. * Sets the chromatic aberration amount
  149170. * @param amount amount of chromatic aberration
  149171. */
  149172. setChromaticAberration(amount: number): void;
  149173. /**
  149174. * Sets chromatic aberration amount to 0
  149175. */
  149176. disableChromaticAberration(): void;
  149177. /**
  149178. * Sets the EdgeDistortion amount
  149179. * @param amount amount of EdgeDistortion
  149180. */
  149181. setEdgeDistortion(amount: number): void;
  149182. /**
  149183. * Sets edge distortion to 0
  149184. */
  149185. disableEdgeDistortion(): void;
  149186. /**
  149187. * Sets the FocusDistance amount
  149188. * @param amount amount of FocusDistance
  149189. */
  149190. setFocusDistance(amount: number): void;
  149191. /**
  149192. * Disables depth of field
  149193. */
  149194. disableDepthOfField(): void;
  149195. /**
  149196. * Sets the Aperture amount
  149197. * @param amount amount of Aperture
  149198. */
  149199. setAperture(amount: number): void;
  149200. /**
  149201. * Sets the DarkenOutOfFocus amount
  149202. * @param amount amount of DarkenOutOfFocus
  149203. */
  149204. setDarkenOutOfFocus(amount: number): void;
  149205. private _pentagonBokehIsEnabled;
  149206. /**
  149207. * Creates a pentagon bokeh effect
  149208. */
  149209. enablePentagonBokeh(): void;
  149210. /**
  149211. * Disables the pentagon bokeh effect
  149212. */
  149213. disablePentagonBokeh(): void;
  149214. /**
  149215. * Enables noise blur
  149216. */
  149217. enableNoiseBlur(): void;
  149218. /**
  149219. * Disables noise blur
  149220. */
  149221. disableNoiseBlur(): void;
  149222. /**
  149223. * Sets the HighlightsGain amount
  149224. * @param amount amount of HighlightsGain
  149225. */
  149226. setHighlightsGain(amount: number): void;
  149227. /**
  149228. * Sets the HighlightsThreshold amount
  149229. * @param amount amount of HighlightsThreshold
  149230. */
  149231. setHighlightsThreshold(amount: number): void;
  149232. /**
  149233. * Disables highlights
  149234. */
  149235. disableHighlights(): void;
  149236. /**
  149237. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  149238. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  149239. */
  149240. dispose(disableDepthRender?: boolean): void;
  149241. private _createChromaticAberrationPostProcess;
  149242. private _createHighlightsPostProcess;
  149243. private _createDepthOfFieldPostProcess;
  149244. private _createGrainTexture;
  149245. }
  149246. }
  149247. declare module BABYLON {
  149248. /** @hidden */
  149249. export var ssao2PixelShader: {
  149250. name: string;
  149251. shader: string;
  149252. };
  149253. }
  149254. declare module BABYLON {
  149255. /** @hidden */
  149256. export var ssaoCombinePixelShader: {
  149257. name: string;
  149258. shader: string;
  149259. };
  149260. }
  149261. declare module BABYLON {
  149262. /**
  149263. * Render pipeline to produce ssao effect
  149264. */
  149265. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  149266. /**
  149267. * @ignore
  149268. * The PassPostProcess id in the pipeline that contains the original scene color
  149269. */
  149270. SSAOOriginalSceneColorEffect: string;
  149271. /**
  149272. * @ignore
  149273. * The SSAO PostProcess id in the pipeline
  149274. */
  149275. SSAORenderEffect: string;
  149276. /**
  149277. * @ignore
  149278. * The horizontal blur PostProcess id in the pipeline
  149279. */
  149280. SSAOBlurHRenderEffect: string;
  149281. /**
  149282. * @ignore
  149283. * The vertical blur PostProcess id in the pipeline
  149284. */
  149285. SSAOBlurVRenderEffect: string;
  149286. /**
  149287. * @ignore
  149288. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149289. */
  149290. SSAOCombineRenderEffect: string;
  149291. /**
  149292. * The output strength of the SSAO post-process. Default value is 1.0.
  149293. */
  149294. totalStrength: number;
  149295. /**
  149296. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  149297. */
  149298. maxZ: number;
  149299. /**
  149300. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  149301. */
  149302. minZAspect: number;
  149303. private _samples;
  149304. /**
  149305. * Number of samples used for the SSAO calculations. Default value is 8
  149306. */
  149307. set samples(n: number);
  149308. get samples(): number;
  149309. private _textureSamples;
  149310. /**
  149311. * Number of samples to use for antialiasing
  149312. */
  149313. set textureSamples(n: number);
  149314. get textureSamples(): number;
  149315. /**
  149316. * Force rendering the geometry through geometry buffer
  149317. */
  149318. private _forceGeometryBuffer;
  149319. /**
  149320. * Ratio object used for SSAO ratio and blur ratio
  149321. */
  149322. private _ratio;
  149323. /**
  149324. * Dynamically generated sphere sampler.
  149325. */
  149326. private _sampleSphere;
  149327. /**
  149328. * Blur filter offsets
  149329. */
  149330. private _samplerOffsets;
  149331. private _expensiveBlur;
  149332. /**
  149333. * If bilateral blur should be used
  149334. */
  149335. set expensiveBlur(b: boolean);
  149336. get expensiveBlur(): boolean;
  149337. /**
  149338. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  149339. */
  149340. radius: number;
  149341. /**
  149342. * The base color of the SSAO post-process
  149343. * The final result is "base + ssao" between [0, 1]
  149344. */
  149345. base: number;
  149346. /**
  149347. * Support test.
  149348. */
  149349. static get IsSupported(): boolean;
  149350. private _scene;
  149351. private _randomTexture;
  149352. private _originalColorPostProcess;
  149353. private _ssaoPostProcess;
  149354. private _blurHPostProcess;
  149355. private _blurVPostProcess;
  149356. private _ssaoCombinePostProcess;
  149357. private _prePassRenderer;
  149358. /**
  149359. * Gets active scene
  149360. */
  149361. get scene(): Scene;
  149362. /**
  149363. * @constructor
  149364. * @param name The rendering pipeline name
  149365. * @param scene The scene linked to this pipeline
  149366. * @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 }
  149367. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149368. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  149369. */
  149370. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  149371. /**
  149372. * Get the class name
  149373. * @returns "SSAO2RenderingPipeline"
  149374. */
  149375. getClassName(): string;
  149376. /**
  149377. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149378. */
  149379. dispose(disableGeometryBufferRenderer?: boolean): void;
  149380. private _createBlurPostProcess;
  149381. /** @hidden */
  149382. _rebuild(): void;
  149383. private _bits;
  149384. private _radicalInverse_VdC;
  149385. private _hammersley;
  149386. private _hemisphereSample_uniform;
  149387. private _generateHemisphere;
  149388. private _getDefinesForSSAO;
  149389. private _createSSAOPostProcess;
  149390. private _createSSAOCombinePostProcess;
  149391. private _createRandomTexture;
  149392. /**
  149393. * Serialize the rendering pipeline (Used when exporting)
  149394. * @returns the serialized object
  149395. */
  149396. serialize(): any;
  149397. /**
  149398. * Parse the serialized pipeline
  149399. * @param source Source pipeline.
  149400. * @param scene The scene to load the pipeline to.
  149401. * @param rootUrl The URL of the serialized pipeline.
  149402. * @returns An instantiated pipeline from the serialized object.
  149403. */
  149404. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  149405. /**
  149406. * Sets the required values to the prepass renderer.
  149407. * @param prePassRenderer defines the prepass renderer to setup
  149408. * @returns true if the pre pass is needed.
  149409. */
  149410. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  149411. }
  149412. }
  149413. declare module BABYLON {
  149414. /** @hidden */
  149415. export var ssaoPixelShader: {
  149416. name: string;
  149417. shader: string;
  149418. };
  149419. }
  149420. declare module BABYLON {
  149421. /**
  149422. * Render pipeline to produce ssao effect
  149423. */
  149424. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  149425. /**
  149426. * @ignore
  149427. * The PassPostProcess id in the pipeline that contains the original scene color
  149428. */
  149429. SSAOOriginalSceneColorEffect: string;
  149430. /**
  149431. * @ignore
  149432. * The SSAO PostProcess id in the pipeline
  149433. */
  149434. SSAORenderEffect: string;
  149435. /**
  149436. * @ignore
  149437. * The horizontal blur PostProcess id in the pipeline
  149438. */
  149439. SSAOBlurHRenderEffect: string;
  149440. /**
  149441. * @ignore
  149442. * The vertical blur PostProcess id in the pipeline
  149443. */
  149444. SSAOBlurVRenderEffect: string;
  149445. /**
  149446. * @ignore
  149447. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  149448. */
  149449. SSAOCombineRenderEffect: string;
  149450. /**
  149451. * The output strength of the SSAO post-process. Default value is 1.0.
  149452. */
  149453. totalStrength: number;
  149454. /**
  149455. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  149456. */
  149457. radius: number;
  149458. /**
  149459. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  149460. * Must not be equal to fallOff and superior to fallOff.
  149461. * Default value is 0.0075
  149462. */
  149463. area: number;
  149464. /**
  149465. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  149466. * Must not be equal to area and inferior to area.
  149467. * Default value is 0.000001
  149468. */
  149469. fallOff: number;
  149470. /**
  149471. * The base color of the SSAO post-process
  149472. * The final result is "base + ssao" between [0, 1]
  149473. */
  149474. base: number;
  149475. private _scene;
  149476. private _depthTexture;
  149477. private _randomTexture;
  149478. private _originalColorPostProcess;
  149479. private _ssaoPostProcess;
  149480. private _blurHPostProcess;
  149481. private _blurVPostProcess;
  149482. private _ssaoCombinePostProcess;
  149483. private _firstUpdate;
  149484. /**
  149485. * Gets active scene
  149486. */
  149487. get scene(): Scene;
  149488. /**
  149489. * @constructor
  149490. * @param name - The rendering pipeline name
  149491. * @param scene - The scene linked to this pipeline
  149492. * @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 }
  149493. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  149494. */
  149495. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  149496. /**
  149497. * Get the class name
  149498. * @returns "SSAORenderingPipeline"
  149499. */
  149500. getClassName(): string;
  149501. /**
  149502. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  149503. */
  149504. dispose(disableDepthRender?: boolean): void;
  149505. private _createBlurPostProcess;
  149506. /** @hidden */
  149507. _rebuild(): void;
  149508. private _createSSAOPostProcess;
  149509. private _createSSAOCombinePostProcess;
  149510. private _createRandomTexture;
  149511. }
  149512. }
  149513. declare module BABYLON {
  149514. /** @hidden */
  149515. export var screenSpaceReflectionPixelShader: {
  149516. name: string;
  149517. shader: string;
  149518. };
  149519. }
  149520. declare module BABYLON {
  149521. /**
  149522. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  149523. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  149524. */
  149525. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  149526. /**
  149527. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  149528. */
  149529. threshold: number;
  149530. /**
  149531. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  149532. */
  149533. strength: number;
  149534. /**
  149535. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  149536. */
  149537. reflectionSpecularFalloffExponent: number;
  149538. /**
  149539. * 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]
  149540. */
  149541. step: number;
  149542. /**
  149543. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  149544. */
  149545. roughnessFactor: number;
  149546. private _geometryBufferRenderer;
  149547. private _enableSmoothReflections;
  149548. private _reflectionSamples;
  149549. private _smoothSteps;
  149550. /**
  149551. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  149552. * @param name The name of the effect.
  149553. * @param scene The scene containing the objects to calculate reflections.
  149554. * @param options The required width/height ratio to downsize to before computing the render pass.
  149555. * @param camera The camera to apply the render pass to.
  149556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149557. * @param engine The engine which the post process will be applied. (default: current engine)
  149558. * @param reusable If the post process can be reused on the same frame. (default: false)
  149559. * @param textureType Type of textures used when performing the post process. (default: 0)
  149560. * @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)
  149561. */
  149562. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149563. /**
  149564. * Gets wether or not smoothing reflections is enabled.
  149565. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149566. */
  149567. get enableSmoothReflections(): boolean;
  149568. /**
  149569. * Sets wether or not smoothing reflections is enabled.
  149570. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  149571. */
  149572. set enableSmoothReflections(enabled: boolean);
  149573. /**
  149574. * Gets the number of samples taken while computing reflections. More samples count is high,
  149575. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149576. */
  149577. get reflectionSamples(): number;
  149578. /**
  149579. * Sets the number of samples taken while computing reflections. More samples count is high,
  149580. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  149581. */
  149582. set reflectionSamples(samples: number);
  149583. /**
  149584. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  149585. * more the post-process will require GPU power and can generate a drop in FPS.
  149586. * Default value (5.0) work pretty well in all cases but can be adjusted.
  149587. */
  149588. get smoothSteps(): number;
  149589. set smoothSteps(steps: number);
  149590. private _updateEffectDefines;
  149591. }
  149592. }
  149593. declare module BABYLON {
  149594. /** @hidden */
  149595. export var standardPixelShader: {
  149596. name: string;
  149597. shader: string;
  149598. };
  149599. }
  149600. declare module BABYLON {
  149601. /**
  149602. * Standard rendering pipeline
  149603. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149604. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  149605. */
  149606. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  149607. /**
  149608. * Public members
  149609. */
  149610. /**
  149611. * Post-process which contains the original scene color before the pipeline applies all the effects
  149612. */
  149613. originalPostProcess: Nullable<PostProcess>;
  149614. /**
  149615. * Post-process used to down scale an image x4
  149616. */
  149617. downSampleX4PostProcess: Nullable<PostProcess>;
  149618. /**
  149619. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  149620. */
  149621. brightPassPostProcess: Nullable<PostProcess>;
  149622. /**
  149623. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  149624. */
  149625. blurHPostProcesses: PostProcess[];
  149626. /**
  149627. * Post-process array storing all the vertical blur post-processes used by the pipeline
  149628. */
  149629. blurVPostProcesses: PostProcess[];
  149630. /**
  149631. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  149632. */
  149633. textureAdderPostProcess: Nullable<PostProcess>;
  149634. /**
  149635. * Post-process used to create volumetric lighting effect
  149636. */
  149637. volumetricLightPostProcess: Nullable<PostProcess>;
  149638. /**
  149639. * Post-process used to smooth the previous volumetric light post-process on the X axis
  149640. */
  149641. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  149642. /**
  149643. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  149644. */
  149645. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  149646. /**
  149647. * Post-process used to merge the volumetric light effect and the real scene color
  149648. */
  149649. volumetricLightMergePostProces: Nullable<PostProcess>;
  149650. /**
  149651. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  149652. */
  149653. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  149654. /**
  149655. * Base post-process used to calculate the average luminance of the final image for HDR
  149656. */
  149657. luminancePostProcess: Nullable<PostProcess>;
  149658. /**
  149659. * Post-processes used to create down sample post-processes in order to get
  149660. * the average luminance of the final image for HDR
  149661. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  149662. */
  149663. luminanceDownSamplePostProcesses: PostProcess[];
  149664. /**
  149665. * Post-process used to create a HDR effect (light adaptation)
  149666. */
  149667. hdrPostProcess: Nullable<PostProcess>;
  149668. /**
  149669. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  149670. */
  149671. textureAdderFinalPostProcess: Nullable<PostProcess>;
  149672. /**
  149673. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  149674. */
  149675. lensFlareFinalPostProcess: Nullable<PostProcess>;
  149676. /**
  149677. * Post-process used to merge the final HDR post-process and the real scene color
  149678. */
  149679. hdrFinalPostProcess: Nullable<PostProcess>;
  149680. /**
  149681. * Post-process used to create a lens flare effect
  149682. */
  149683. lensFlarePostProcess: Nullable<PostProcess>;
  149684. /**
  149685. * Post-process that merges the result of the lens flare post-process and the real scene color
  149686. */
  149687. lensFlareComposePostProcess: Nullable<PostProcess>;
  149688. /**
  149689. * Post-process used to create a motion blur effect
  149690. */
  149691. motionBlurPostProcess: Nullable<PostProcess>;
  149692. /**
  149693. * Post-process used to create a depth of field effect
  149694. */
  149695. depthOfFieldPostProcess: Nullable<PostProcess>;
  149696. /**
  149697. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  149698. */
  149699. fxaaPostProcess: Nullable<FxaaPostProcess>;
  149700. /**
  149701. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  149702. */
  149703. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  149704. /**
  149705. * Represents the brightness threshold in order to configure the illuminated surfaces
  149706. */
  149707. brightThreshold: number;
  149708. /**
  149709. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  149710. */
  149711. blurWidth: number;
  149712. /**
  149713. * Sets if the blur for highlighted surfaces must be only horizontal
  149714. */
  149715. horizontalBlur: boolean;
  149716. /**
  149717. * Gets the overall exposure used by the pipeline
  149718. */
  149719. get exposure(): number;
  149720. /**
  149721. * Sets the overall exposure used by the pipeline
  149722. */
  149723. set exposure(value: number);
  149724. /**
  149725. * Texture used typically to simulate "dirty" on camera lens
  149726. */
  149727. lensTexture: Nullable<Texture>;
  149728. /**
  149729. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  149730. */
  149731. volumetricLightCoefficient: number;
  149732. /**
  149733. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  149734. */
  149735. volumetricLightPower: number;
  149736. /**
  149737. * Used the set the blur intensity to smooth the volumetric lights
  149738. */
  149739. volumetricLightBlurScale: number;
  149740. /**
  149741. * Light (spot or directional) used to generate the volumetric lights rays
  149742. * The source light must have a shadow generate so the pipeline can get its
  149743. * depth map
  149744. */
  149745. sourceLight: Nullable<SpotLight | DirectionalLight>;
  149746. /**
  149747. * For eye adaptation, represents the minimum luminance the eye can see
  149748. */
  149749. hdrMinimumLuminance: number;
  149750. /**
  149751. * For eye adaptation, represents the decrease luminance speed
  149752. */
  149753. hdrDecreaseRate: number;
  149754. /**
  149755. * For eye adaptation, represents the increase luminance speed
  149756. */
  149757. hdrIncreaseRate: number;
  149758. /**
  149759. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149760. */
  149761. get hdrAutoExposure(): boolean;
  149762. /**
  149763. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  149764. */
  149765. set hdrAutoExposure(value: boolean);
  149766. /**
  149767. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  149768. */
  149769. lensColorTexture: Nullable<Texture>;
  149770. /**
  149771. * The overall strengh for the lens flare effect
  149772. */
  149773. lensFlareStrength: number;
  149774. /**
  149775. * Dispersion coefficient for lens flare ghosts
  149776. */
  149777. lensFlareGhostDispersal: number;
  149778. /**
  149779. * Main lens flare halo width
  149780. */
  149781. lensFlareHaloWidth: number;
  149782. /**
  149783. * Based on the lens distortion effect, defines how much the lens flare result
  149784. * is distorted
  149785. */
  149786. lensFlareDistortionStrength: number;
  149787. /**
  149788. * Configures the blur intensity used for for lens flare (halo)
  149789. */
  149790. lensFlareBlurWidth: number;
  149791. /**
  149792. * Lens star texture must be used to simulate rays on the flares and is available
  149793. * in the documentation
  149794. */
  149795. lensStarTexture: Nullable<Texture>;
  149796. /**
  149797. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  149798. * flare effect by taking account of the dirt texture
  149799. */
  149800. lensFlareDirtTexture: Nullable<Texture>;
  149801. /**
  149802. * Represents the focal length for the depth of field effect
  149803. */
  149804. depthOfFieldDistance: number;
  149805. /**
  149806. * Represents the blur intensity for the blurred part of the depth of field effect
  149807. */
  149808. depthOfFieldBlurWidth: number;
  149809. /**
  149810. * Gets how much the image is blurred by the movement while using the motion blur post-process
  149811. */
  149812. get motionStrength(): number;
  149813. /**
  149814. * Sets how much the image is blurred by the movement while using the motion blur post-process
  149815. */
  149816. set motionStrength(strength: number);
  149817. /**
  149818. * Gets wether or not the motion blur post-process is object based or screen based.
  149819. */
  149820. get objectBasedMotionBlur(): boolean;
  149821. /**
  149822. * Sets wether or not the motion blur post-process should be object based or screen based
  149823. */
  149824. set objectBasedMotionBlur(value: boolean);
  149825. /**
  149826. * List of animations for the pipeline (IAnimatable implementation)
  149827. */
  149828. animations: Animation[];
  149829. /**
  149830. * Private members
  149831. */
  149832. private _scene;
  149833. private _currentDepthOfFieldSource;
  149834. private _basePostProcess;
  149835. private _fixedExposure;
  149836. private _currentExposure;
  149837. private _hdrAutoExposure;
  149838. private _hdrCurrentLuminance;
  149839. private _motionStrength;
  149840. private _isObjectBasedMotionBlur;
  149841. private _floatTextureType;
  149842. private _camerasToBeAttached;
  149843. private _ratio;
  149844. private _bloomEnabled;
  149845. private _depthOfFieldEnabled;
  149846. private _vlsEnabled;
  149847. private _lensFlareEnabled;
  149848. private _hdrEnabled;
  149849. private _motionBlurEnabled;
  149850. private _fxaaEnabled;
  149851. private _screenSpaceReflectionsEnabled;
  149852. private _motionBlurSamples;
  149853. private _volumetricLightStepsCount;
  149854. private _samples;
  149855. /**
  149856. * @ignore
  149857. * Specifies if the bloom pipeline is enabled
  149858. */
  149859. get BloomEnabled(): boolean;
  149860. set BloomEnabled(enabled: boolean);
  149861. /**
  149862. * @ignore
  149863. * Specifies if the depth of field pipeline is enabed
  149864. */
  149865. get DepthOfFieldEnabled(): boolean;
  149866. set DepthOfFieldEnabled(enabled: boolean);
  149867. /**
  149868. * @ignore
  149869. * Specifies if the lens flare pipeline is enabed
  149870. */
  149871. get LensFlareEnabled(): boolean;
  149872. set LensFlareEnabled(enabled: boolean);
  149873. /**
  149874. * @ignore
  149875. * Specifies if the HDR pipeline is enabled
  149876. */
  149877. get HDREnabled(): boolean;
  149878. set HDREnabled(enabled: boolean);
  149879. /**
  149880. * @ignore
  149881. * Specifies if the volumetric lights scattering effect is enabled
  149882. */
  149883. get VLSEnabled(): boolean;
  149884. set VLSEnabled(enabled: boolean);
  149885. /**
  149886. * @ignore
  149887. * Specifies if the motion blur effect is enabled
  149888. */
  149889. get MotionBlurEnabled(): boolean;
  149890. set MotionBlurEnabled(enabled: boolean);
  149891. /**
  149892. * Specifies if anti-aliasing is enabled
  149893. */
  149894. get fxaaEnabled(): boolean;
  149895. set fxaaEnabled(enabled: boolean);
  149896. /**
  149897. * Specifies if screen space reflections are enabled.
  149898. */
  149899. get screenSpaceReflectionsEnabled(): boolean;
  149900. set screenSpaceReflectionsEnabled(enabled: boolean);
  149901. /**
  149902. * Specifies the number of steps used to calculate the volumetric lights
  149903. * Typically in interval [50, 200]
  149904. */
  149905. get volumetricLightStepsCount(): number;
  149906. set volumetricLightStepsCount(count: number);
  149907. /**
  149908. * Specifies the number of samples used for the motion blur effect
  149909. * Typically in interval [16, 64]
  149910. */
  149911. get motionBlurSamples(): number;
  149912. set motionBlurSamples(samples: number);
  149913. /**
  149914. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  149915. */
  149916. get samples(): number;
  149917. set samples(sampleCount: number);
  149918. /**
  149919. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  149920. * @constructor
  149921. * @param name The rendering pipeline name
  149922. * @param scene The scene linked to this pipeline
  149923. * @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)
  149924. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  149925. * @param cameras The array of cameras that the rendering pipeline will be attached to
  149926. */
  149927. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  149928. private _buildPipeline;
  149929. private _createDownSampleX4PostProcess;
  149930. private _createBrightPassPostProcess;
  149931. private _createBlurPostProcesses;
  149932. private _createTextureAdderPostProcess;
  149933. private _createVolumetricLightPostProcess;
  149934. private _createLuminancePostProcesses;
  149935. private _createHdrPostProcess;
  149936. private _createLensFlarePostProcess;
  149937. private _createDepthOfFieldPostProcess;
  149938. private _createMotionBlurPostProcess;
  149939. private _getDepthTexture;
  149940. private _disposePostProcesses;
  149941. /**
  149942. * Dispose of the pipeline and stop all post processes
  149943. */
  149944. dispose(): void;
  149945. /**
  149946. * Serialize the rendering pipeline (Used when exporting)
  149947. * @returns the serialized object
  149948. */
  149949. serialize(): any;
  149950. /**
  149951. * Parse the serialized pipeline
  149952. * @param source Source pipeline.
  149953. * @param scene The scene to load the pipeline to.
  149954. * @param rootUrl The URL of the serialized pipeline.
  149955. * @returns An instantiated pipeline from the serialized object.
  149956. */
  149957. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  149958. /**
  149959. * Luminance steps
  149960. */
  149961. static LuminanceSteps: number;
  149962. }
  149963. }
  149964. declare module BABYLON {
  149965. /** @hidden */
  149966. export var stereoscopicInterlacePixelShader: {
  149967. name: string;
  149968. shader: string;
  149969. };
  149970. }
  149971. declare module BABYLON {
  149972. /**
  149973. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  149974. */
  149975. export class StereoscopicInterlacePostProcessI extends PostProcess {
  149976. private _stepSize;
  149977. private _passedProcess;
  149978. /**
  149979. * Initializes a StereoscopicInterlacePostProcessI
  149980. * @param name The name of the effect.
  149981. * @param rigCameras The rig cameras to be appled to the post process
  149982. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  149983. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  149984. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149985. * @param engine The engine which the post process will be applied. (default: current engine)
  149986. * @param reusable If the post process can be reused on the same frame. (default: false)
  149987. */
  149988. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149989. }
  149990. /**
  149991. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  149992. */
  149993. export class StereoscopicInterlacePostProcess extends PostProcess {
  149994. private _stepSize;
  149995. private _passedProcess;
  149996. /**
  149997. * Initializes a StereoscopicInterlacePostProcess
  149998. * @param name The name of the effect.
  149999. * @param rigCameras The rig cameras to be appled to the post process
  150000. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  150001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150002. * @param engine The engine which the post process will be applied. (default: current engine)
  150003. * @param reusable If the post process can be reused on the same frame. (default: false)
  150004. */
  150005. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150006. }
  150007. }
  150008. declare module BABYLON {
  150009. /** @hidden */
  150010. export var tonemapPixelShader: {
  150011. name: string;
  150012. shader: string;
  150013. };
  150014. }
  150015. declare module BABYLON {
  150016. /** Defines operator used for tonemapping */
  150017. export enum TonemappingOperator {
  150018. /** Hable */
  150019. Hable = 0,
  150020. /** Reinhard */
  150021. Reinhard = 1,
  150022. /** HejiDawson */
  150023. HejiDawson = 2,
  150024. /** Photographic */
  150025. Photographic = 3
  150026. }
  150027. /**
  150028. * Defines a post process to apply tone mapping
  150029. */
  150030. export class TonemapPostProcess extends PostProcess {
  150031. private _operator;
  150032. /** Defines the required exposure adjustement */
  150033. exposureAdjustment: number;
  150034. /**
  150035. * Creates a new TonemapPostProcess
  150036. * @param name defines the name of the postprocess
  150037. * @param _operator defines the operator to use
  150038. * @param exposureAdjustment defines the required exposure adjustement
  150039. * @param camera defines the camera to use (can be null)
  150040. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  150041. * @param engine defines the hosting engine (can be ignore if camera is set)
  150042. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  150043. */
  150044. constructor(name: string, _operator: TonemappingOperator,
  150045. /** Defines the required exposure adjustement */
  150046. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  150047. }
  150048. }
  150049. declare module BABYLON {
  150050. /** @hidden */
  150051. export var volumetricLightScatteringPixelShader: {
  150052. name: string;
  150053. shader: string;
  150054. };
  150055. }
  150056. declare module BABYLON {
  150057. /** @hidden */
  150058. export var volumetricLightScatteringPassVertexShader: {
  150059. name: string;
  150060. shader: string;
  150061. };
  150062. }
  150063. declare module BABYLON {
  150064. /** @hidden */
  150065. export var volumetricLightScatteringPassPixelShader: {
  150066. name: string;
  150067. shader: string;
  150068. };
  150069. }
  150070. declare module BABYLON {
  150071. /**
  150072. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  150073. */
  150074. export class VolumetricLightScatteringPostProcess extends PostProcess {
  150075. private _volumetricLightScatteringPass;
  150076. private _volumetricLightScatteringRTT;
  150077. private _viewPort;
  150078. private _screenCoordinates;
  150079. private _cachedDefines;
  150080. /**
  150081. * If not undefined, the mesh position is computed from the attached node position
  150082. */
  150083. attachedNode: {
  150084. position: Vector3;
  150085. };
  150086. /**
  150087. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  150088. */
  150089. customMeshPosition: Vector3;
  150090. /**
  150091. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  150092. */
  150093. useCustomMeshPosition: boolean;
  150094. /**
  150095. * If the post-process should inverse the light scattering direction
  150096. */
  150097. invert: boolean;
  150098. /**
  150099. * The internal mesh used by the post-process
  150100. */
  150101. mesh: Mesh;
  150102. /**
  150103. * @hidden
  150104. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  150105. */
  150106. get useDiffuseColor(): boolean;
  150107. set useDiffuseColor(useDiffuseColor: boolean);
  150108. /**
  150109. * Array containing the excluded meshes not rendered in the internal pass
  150110. */
  150111. excludedMeshes: AbstractMesh[];
  150112. /**
  150113. * Controls the overall intensity of the post-process
  150114. */
  150115. exposure: number;
  150116. /**
  150117. * Dissipates each sample's contribution in range [0, 1]
  150118. */
  150119. decay: number;
  150120. /**
  150121. * Controls the overall intensity of each sample
  150122. */
  150123. weight: number;
  150124. /**
  150125. * Controls the density of each sample
  150126. */
  150127. density: number;
  150128. /**
  150129. * @constructor
  150130. * @param name The post-process name
  150131. * @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)
  150132. * @param camera The camera that the post-process will be attached to
  150133. * @param mesh The mesh used to create the light scattering
  150134. * @param samples The post-process quality, default 100
  150135. * @param samplingModeThe post-process filtering mode
  150136. * @param engine The babylon engine
  150137. * @param reusable If the post-process is reusable
  150138. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  150139. */
  150140. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  150141. /**
  150142. * Returns the string "VolumetricLightScatteringPostProcess"
  150143. * @returns "VolumetricLightScatteringPostProcess"
  150144. */
  150145. getClassName(): string;
  150146. private _isReady;
  150147. /**
  150148. * Sets the new light position for light scattering effect
  150149. * @param position The new custom light position
  150150. */
  150151. setCustomMeshPosition(position: Vector3): void;
  150152. /**
  150153. * Returns the light position for light scattering effect
  150154. * @return Vector3 The custom light position
  150155. */
  150156. getCustomMeshPosition(): Vector3;
  150157. /**
  150158. * Disposes the internal assets and detaches the post-process from the camera
  150159. */
  150160. dispose(camera: Camera): void;
  150161. /**
  150162. * Returns the render target texture used by the post-process
  150163. * @return the render target texture used by the post-process
  150164. */
  150165. getPass(): RenderTargetTexture;
  150166. private _meshExcluded;
  150167. private _createPass;
  150168. private _updateMeshScreenCoordinates;
  150169. /**
  150170. * Creates a default mesh for the Volumeric Light Scattering post-process
  150171. * @param name The mesh name
  150172. * @param scene The scene where to create the mesh
  150173. * @return the default mesh
  150174. */
  150175. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  150176. }
  150177. }
  150178. declare module BABYLON {
  150179. /** @hidden */
  150180. export var screenSpaceCurvaturePixelShader: {
  150181. name: string;
  150182. shader: string;
  150183. };
  150184. }
  150185. declare module BABYLON {
  150186. /**
  150187. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  150188. */
  150189. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  150190. /**
  150191. * Defines how much ridge the curvature effect displays.
  150192. */
  150193. ridge: number;
  150194. /**
  150195. * Defines how much valley the curvature effect displays.
  150196. */
  150197. valley: number;
  150198. private _geometryBufferRenderer;
  150199. /**
  150200. * Creates a new instance ScreenSpaceCurvaturePostProcess
  150201. * @param name The name of the effect.
  150202. * @param scene The scene containing the objects to blur according to their velocity.
  150203. * @param options The required width/height ratio to downsize to before computing the render pass.
  150204. * @param camera The camera to apply the render pass to.
  150205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150206. * @param engine The engine which the post process will be applied. (default: current engine)
  150207. * @param reusable If the post process can be reused on the same frame. (default: false)
  150208. * @param textureType Type of textures used when performing the post process. (default: 0)
  150209. * @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)
  150210. */
  150211. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150212. /**
  150213. * Support test.
  150214. */
  150215. static get IsSupported(): boolean;
  150216. }
  150217. }
  150218. declare module BABYLON {
  150219. interface Scene {
  150220. /** @hidden (Backing field) */
  150221. _boundingBoxRenderer: BoundingBoxRenderer;
  150222. /** @hidden (Backing field) */
  150223. _forceShowBoundingBoxes: boolean;
  150224. /**
  150225. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  150226. */
  150227. forceShowBoundingBoxes: boolean;
  150228. /**
  150229. * Gets the bounding box renderer associated with the scene
  150230. * @returns a BoundingBoxRenderer
  150231. */
  150232. getBoundingBoxRenderer(): BoundingBoxRenderer;
  150233. }
  150234. interface AbstractMesh {
  150235. /** @hidden (Backing field) */
  150236. _showBoundingBox: boolean;
  150237. /**
  150238. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  150239. */
  150240. showBoundingBox: boolean;
  150241. }
  150242. /**
  150243. * Component responsible of rendering the bounding box of the meshes in a scene.
  150244. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  150245. */
  150246. export class BoundingBoxRenderer implements ISceneComponent {
  150247. /**
  150248. * The component name helpfull to identify the component in the list of scene components.
  150249. */
  150250. readonly name: string;
  150251. /**
  150252. * The scene the component belongs to.
  150253. */
  150254. scene: Scene;
  150255. /**
  150256. * Color of the bounding box lines placed in front of an object
  150257. */
  150258. frontColor: Color3;
  150259. /**
  150260. * Color of the bounding box lines placed behind an object
  150261. */
  150262. backColor: Color3;
  150263. /**
  150264. * Defines if the renderer should show the back lines or not
  150265. */
  150266. showBackLines: boolean;
  150267. /**
  150268. * Observable raised before rendering a bounding box
  150269. */
  150270. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  150271. /**
  150272. * Observable raised after rendering a bounding box
  150273. */
  150274. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  150275. /**
  150276. * @hidden
  150277. */
  150278. renderList: SmartArray<BoundingBox>;
  150279. private _colorShader;
  150280. private _vertexBuffers;
  150281. private _indexBuffer;
  150282. private _fillIndexBuffer;
  150283. private _fillIndexData;
  150284. /**
  150285. * Instantiates a new bounding box renderer in a scene.
  150286. * @param scene the scene the renderer renders in
  150287. */
  150288. constructor(scene: Scene);
  150289. /**
  150290. * Registers the component in a given scene
  150291. */
  150292. register(): void;
  150293. private _evaluateSubMesh;
  150294. private _activeMesh;
  150295. private _prepareRessources;
  150296. private _createIndexBuffer;
  150297. /**
  150298. * Rebuilds the elements related to this component in case of
  150299. * context lost for instance.
  150300. */
  150301. rebuild(): void;
  150302. /**
  150303. * @hidden
  150304. */
  150305. reset(): void;
  150306. /**
  150307. * Render the bounding boxes of a specific rendering group
  150308. * @param renderingGroupId defines the rendering group to render
  150309. */
  150310. render(renderingGroupId: number): void;
  150311. /**
  150312. * In case of occlusion queries, we can render the occlusion bounding box through this method
  150313. * @param mesh Define the mesh to render the occlusion bounding box for
  150314. */
  150315. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  150316. /**
  150317. * Dispose and release the resources attached to this renderer.
  150318. */
  150319. dispose(): void;
  150320. }
  150321. }
  150322. declare module BABYLON {
  150323. interface Scene {
  150324. /** @hidden (Backing field) */
  150325. _depthRenderer: {
  150326. [id: string]: DepthRenderer;
  150327. };
  150328. /**
  150329. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  150330. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  150331. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  150332. * @returns the created depth renderer
  150333. */
  150334. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  150335. /**
  150336. * Disables a depth renderer for a given camera
  150337. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  150338. */
  150339. disableDepthRenderer(camera?: Nullable<Camera>): void;
  150340. }
  150341. /**
  150342. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  150343. * in several rendering techniques.
  150344. */
  150345. export class DepthRendererSceneComponent implements ISceneComponent {
  150346. /**
  150347. * The component name helpfull to identify the component in the list of scene components.
  150348. */
  150349. readonly name: string;
  150350. /**
  150351. * The scene the component belongs to.
  150352. */
  150353. scene: Scene;
  150354. /**
  150355. * Creates a new instance of the component for the given scene
  150356. * @param scene Defines the scene to register the component in
  150357. */
  150358. constructor(scene: Scene);
  150359. /**
  150360. * Registers the component in a given scene
  150361. */
  150362. register(): void;
  150363. /**
  150364. * Rebuilds the elements related to this component in case of
  150365. * context lost for instance.
  150366. */
  150367. rebuild(): void;
  150368. /**
  150369. * Disposes the component and the associated ressources
  150370. */
  150371. dispose(): void;
  150372. private _gatherRenderTargets;
  150373. private _gatherActiveCameraRenderTargets;
  150374. }
  150375. }
  150376. declare module BABYLON {
  150377. interface AbstractScene {
  150378. /** @hidden (Backing field) */
  150379. _prePassRenderer: Nullable<PrePassRenderer>;
  150380. /**
  150381. * Gets or Sets the current prepass renderer associated to the scene.
  150382. */
  150383. prePassRenderer: Nullable<PrePassRenderer>;
  150384. /**
  150385. * Enables the prepass and associates it with the scene
  150386. * @returns the PrePassRenderer
  150387. */
  150388. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  150389. /**
  150390. * Disables the prepass associated with the scene
  150391. */
  150392. disablePrePassRenderer(): void;
  150393. }
  150394. /**
  150395. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150396. * in several rendering techniques.
  150397. */
  150398. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  150399. /**
  150400. * The component name helpful to identify the component in the list of scene components.
  150401. */
  150402. readonly name: string;
  150403. /**
  150404. * The scene the component belongs to.
  150405. */
  150406. scene: Scene;
  150407. /**
  150408. * Creates a new instance of the component for the given scene
  150409. * @param scene Defines the scene to register the component in
  150410. */
  150411. constructor(scene: Scene);
  150412. /**
  150413. * Registers the component in a given scene
  150414. */
  150415. register(): void;
  150416. private _beforeCameraDraw;
  150417. private _afterCameraDraw;
  150418. private _beforeClearStage;
  150419. /**
  150420. * Serializes the component data to the specified json object
  150421. * @param serializationObject The object to serialize to
  150422. */
  150423. serialize(serializationObject: any): void;
  150424. /**
  150425. * Adds all the elements from the container to the scene
  150426. * @param container the container holding the elements
  150427. */
  150428. addFromContainer(container: AbstractScene): void;
  150429. /**
  150430. * Removes all the elements in the container from the scene
  150431. * @param container contains the elements to remove
  150432. * @param dispose if the removed element should be disposed (default: false)
  150433. */
  150434. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  150435. /**
  150436. * Rebuilds the elements related to this component in case of
  150437. * context lost for instance.
  150438. */
  150439. rebuild(): void;
  150440. /**
  150441. * Disposes the component and the associated ressources
  150442. */
  150443. dispose(): void;
  150444. }
  150445. }
  150446. declare module BABYLON {
  150447. /** @hidden */
  150448. export var outlinePixelShader: {
  150449. name: string;
  150450. shader: string;
  150451. };
  150452. }
  150453. declare module BABYLON {
  150454. /** @hidden */
  150455. export var outlineVertexShader: {
  150456. name: string;
  150457. shader: string;
  150458. };
  150459. }
  150460. declare module BABYLON {
  150461. interface Scene {
  150462. /** @hidden */
  150463. _outlineRenderer: OutlineRenderer;
  150464. /**
  150465. * Gets the outline renderer associated with the scene
  150466. * @returns a OutlineRenderer
  150467. */
  150468. getOutlineRenderer(): OutlineRenderer;
  150469. }
  150470. interface AbstractMesh {
  150471. /** @hidden (Backing field) */
  150472. _renderOutline: boolean;
  150473. /**
  150474. * Gets or sets a boolean indicating if the outline must be rendered as well
  150475. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  150476. */
  150477. renderOutline: boolean;
  150478. /** @hidden (Backing field) */
  150479. _renderOverlay: boolean;
  150480. /**
  150481. * Gets or sets a boolean indicating if the overlay must be rendered as well
  150482. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  150483. */
  150484. renderOverlay: boolean;
  150485. }
  150486. /**
  150487. * This class is responsible to draw bothe outline/overlay of meshes.
  150488. * It should not be used directly but through the available method on mesh.
  150489. */
  150490. export class OutlineRenderer implements ISceneComponent {
  150491. /**
  150492. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  150493. */
  150494. private static _StencilReference;
  150495. /**
  150496. * The name of the component. Each component must have a unique name.
  150497. */
  150498. name: string;
  150499. /**
  150500. * The scene the component belongs to.
  150501. */
  150502. scene: Scene;
  150503. /**
  150504. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  150505. */
  150506. zOffset: number;
  150507. private _engine;
  150508. private _effect;
  150509. private _cachedDefines;
  150510. private _savedDepthWrite;
  150511. /**
  150512. * Instantiates a new outline renderer. (There could be only one per scene).
  150513. * @param scene Defines the scene it belongs to
  150514. */
  150515. constructor(scene: Scene);
  150516. /**
  150517. * Register the component to one instance of a scene.
  150518. */
  150519. register(): void;
  150520. /**
  150521. * Rebuilds the elements related to this component in case of
  150522. * context lost for instance.
  150523. */
  150524. rebuild(): void;
  150525. /**
  150526. * Disposes the component and the associated ressources.
  150527. */
  150528. dispose(): void;
  150529. /**
  150530. * Renders the outline in the canvas.
  150531. * @param subMesh Defines the sumesh to render
  150532. * @param batch Defines the batch of meshes in case of instances
  150533. * @param useOverlay Defines if the rendering is for the overlay or the outline
  150534. */
  150535. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  150536. /**
  150537. * Returns whether or not the outline renderer is ready for a given submesh.
  150538. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  150539. * @param subMesh Defines the submesh to check readyness for
  150540. * @param useInstances Defines wheter wee are trying to render instances or not
  150541. * @returns true if ready otherwise false
  150542. */
  150543. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150544. private _beforeRenderingMesh;
  150545. private _afterRenderingMesh;
  150546. }
  150547. }
  150548. declare module BABYLON {
  150549. /**
  150550. * Defines the basic options interface of a Sprite Frame Source Size.
  150551. */
  150552. export interface ISpriteJSONSpriteSourceSize {
  150553. /**
  150554. * number of the original width of the Frame
  150555. */
  150556. w: number;
  150557. /**
  150558. * number of the original height of the Frame
  150559. */
  150560. h: number;
  150561. }
  150562. /**
  150563. * Defines the basic options interface of a Sprite Frame Data.
  150564. */
  150565. export interface ISpriteJSONSpriteFrameData {
  150566. /**
  150567. * number of the x offset of the Frame
  150568. */
  150569. x: number;
  150570. /**
  150571. * number of the y offset of the Frame
  150572. */
  150573. y: number;
  150574. /**
  150575. * number of the width of the Frame
  150576. */
  150577. w: number;
  150578. /**
  150579. * number of the height of the Frame
  150580. */
  150581. h: number;
  150582. }
  150583. /**
  150584. * Defines the basic options interface of a JSON Sprite.
  150585. */
  150586. export interface ISpriteJSONSprite {
  150587. /**
  150588. * string name of the Frame
  150589. */
  150590. filename: string;
  150591. /**
  150592. * ISpriteJSONSpriteFrame basic object of the frame data
  150593. */
  150594. frame: ISpriteJSONSpriteFrameData;
  150595. /**
  150596. * boolean to flag is the frame was rotated.
  150597. */
  150598. rotated: boolean;
  150599. /**
  150600. * boolean to flag is the frame was trimmed.
  150601. */
  150602. trimmed: boolean;
  150603. /**
  150604. * ISpriteJSONSpriteFrame basic object of the source data
  150605. */
  150606. spriteSourceSize: ISpriteJSONSpriteFrameData;
  150607. /**
  150608. * ISpriteJSONSpriteFrame basic object of the source data
  150609. */
  150610. sourceSize: ISpriteJSONSpriteSourceSize;
  150611. }
  150612. /**
  150613. * Defines the basic options interface of a JSON atlas.
  150614. */
  150615. export interface ISpriteJSONAtlas {
  150616. /**
  150617. * Array of objects that contain the frame data.
  150618. */
  150619. frames: Array<ISpriteJSONSprite>;
  150620. /**
  150621. * object basic object containing the sprite meta data.
  150622. */
  150623. meta?: object;
  150624. }
  150625. }
  150626. declare module BABYLON {
  150627. /** @hidden */
  150628. export var spriteMapPixelShader: {
  150629. name: string;
  150630. shader: string;
  150631. };
  150632. }
  150633. declare module BABYLON {
  150634. /** @hidden */
  150635. export var spriteMapVertexShader: {
  150636. name: string;
  150637. shader: string;
  150638. };
  150639. }
  150640. declare module BABYLON {
  150641. /**
  150642. * Defines the basic options interface of a SpriteMap
  150643. */
  150644. export interface ISpriteMapOptions {
  150645. /**
  150646. * Vector2 of the number of cells in the grid.
  150647. */
  150648. stageSize?: Vector2;
  150649. /**
  150650. * Vector2 of the size of the output plane in World Units.
  150651. */
  150652. outputSize?: Vector2;
  150653. /**
  150654. * Vector3 of the position of the output plane in World Units.
  150655. */
  150656. outputPosition?: Vector3;
  150657. /**
  150658. * Vector3 of the rotation of the output plane.
  150659. */
  150660. outputRotation?: Vector3;
  150661. /**
  150662. * number of layers that the system will reserve in resources.
  150663. */
  150664. layerCount?: number;
  150665. /**
  150666. * number of max animation frames a single cell will reserve in resources.
  150667. */
  150668. maxAnimationFrames?: number;
  150669. /**
  150670. * number cell index of the base tile when the system compiles.
  150671. */
  150672. baseTile?: number;
  150673. /**
  150674. * boolean flip the sprite after its been repositioned by the framing data.
  150675. */
  150676. flipU?: boolean;
  150677. /**
  150678. * Vector3 scalar of the global RGB values of the SpriteMap.
  150679. */
  150680. colorMultiply?: Vector3;
  150681. }
  150682. /**
  150683. * Defines the IDisposable interface in order to be cleanable from resources.
  150684. */
  150685. export interface ISpriteMap extends IDisposable {
  150686. /**
  150687. * String name of the SpriteMap.
  150688. */
  150689. name: string;
  150690. /**
  150691. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  150692. */
  150693. atlasJSON: ISpriteJSONAtlas;
  150694. /**
  150695. * Texture of the SpriteMap.
  150696. */
  150697. spriteSheet: Texture;
  150698. /**
  150699. * The parameters to initialize the SpriteMap with.
  150700. */
  150701. options: ISpriteMapOptions;
  150702. }
  150703. /**
  150704. * Class used to manage a grid restricted sprite deployment on an Output plane.
  150705. */
  150706. export class SpriteMap implements ISpriteMap {
  150707. /** The Name of the spriteMap */
  150708. name: string;
  150709. /** The JSON file with the frame and meta data */
  150710. atlasJSON: ISpriteJSONAtlas;
  150711. /** The systems Sprite Sheet Texture */
  150712. spriteSheet: Texture;
  150713. /** Arguments passed with the Constructor */
  150714. options: ISpriteMapOptions;
  150715. /** Public Sprite Storage array, parsed from atlasJSON */
  150716. sprites: Array<ISpriteJSONSprite>;
  150717. /** Returns the Number of Sprites in the System */
  150718. get spriteCount(): number;
  150719. /** Returns the Position of Output Plane*/
  150720. get position(): Vector3;
  150721. /** Returns the Position of Output Plane*/
  150722. set position(v: Vector3);
  150723. /** Returns the Rotation of Output Plane*/
  150724. get rotation(): Vector3;
  150725. /** Returns the Rotation of Output Plane*/
  150726. set rotation(v: Vector3);
  150727. /** Sets the AnimationMap*/
  150728. get animationMap(): RawTexture;
  150729. /** Sets the AnimationMap*/
  150730. set animationMap(v: RawTexture);
  150731. /** Scene that the SpriteMap was created in */
  150732. private _scene;
  150733. /** Texture Buffer of Float32 that holds tile frame data*/
  150734. private _frameMap;
  150735. /** Texture Buffers of Float32 that holds tileMap data*/
  150736. private _tileMaps;
  150737. /** Texture Buffer of Float32 that holds Animation Data*/
  150738. private _animationMap;
  150739. /** Custom ShaderMaterial Central to the System*/
  150740. private _material;
  150741. /** Custom ShaderMaterial Central to the System*/
  150742. private _output;
  150743. /** Systems Time Ticker*/
  150744. private _time;
  150745. /**
  150746. * Creates a new SpriteMap
  150747. * @param name defines the SpriteMaps Name
  150748. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  150749. * @param spriteSheet is the Texture that the Sprites are on.
  150750. * @param options a basic deployment configuration
  150751. * @param scene The Scene that the map is deployed on
  150752. */
  150753. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  150754. /**
  150755. * Returns tileID location
  150756. * @returns Vector2 the cell position ID
  150757. */
  150758. getTileID(): Vector2;
  150759. /**
  150760. * Gets the UV location of the mouse over the SpriteMap.
  150761. * @returns Vector2 the UV position of the mouse interaction
  150762. */
  150763. getMousePosition(): Vector2;
  150764. /**
  150765. * Creates the "frame" texture Buffer
  150766. * -------------------------------------
  150767. * Structure of frames
  150768. * "filename": "Falling-Water-2.png",
  150769. * "frame": {"x":69,"y":103,"w":24,"h":32},
  150770. * "rotated": true,
  150771. * "trimmed": true,
  150772. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  150773. * "sourceSize": {"w":32,"h":32}
  150774. * @returns RawTexture of the frameMap
  150775. */
  150776. private _createFrameBuffer;
  150777. /**
  150778. * Creates the tileMap texture Buffer
  150779. * @param buffer normally and array of numbers, or a false to generate from scratch
  150780. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  150781. * @returns RawTexture of the tileMap
  150782. */
  150783. private _createTileBuffer;
  150784. /**
  150785. * Modifies the data of the tileMaps
  150786. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  150787. * @param pos is the iVector2 Coordinates of the Tile
  150788. * @param tile The SpriteIndex of the new Tile
  150789. */
  150790. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  150791. /**
  150792. * Creates the animationMap texture Buffer
  150793. * @param buffer normally and array of numbers, or a false to generate from scratch
  150794. * @returns RawTexture of the animationMap
  150795. */
  150796. private _createTileAnimationBuffer;
  150797. /**
  150798. * Modifies the data of the animationMap
  150799. * @param cellID is the Index of the Sprite
  150800. * @param _frame is the target Animation frame
  150801. * @param toCell is the Target Index of the next frame of the animation
  150802. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  150803. * @param speed is a global scalar of the time variable on the map.
  150804. */
  150805. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  150806. /**
  150807. * Exports the .tilemaps file
  150808. */
  150809. saveTileMaps(): void;
  150810. /**
  150811. * Imports the .tilemaps file
  150812. * @param url of the .tilemaps file
  150813. */
  150814. loadTileMaps(url: string): void;
  150815. /**
  150816. * Release associated resources
  150817. */
  150818. dispose(): void;
  150819. }
  150820. }
  150821. declare module BABYLON {
  150822. /**
  150823. * Class used to manage multiple sprites of different sizes on the same spritesheet
  150824. * @see https://doc.babylonjs.com/babylon101/sprites
  150825. */
  150826. export class SpritePackedManager extends SpriteManager {
  150827. /** defines the packed manager's name */
  150828. name: string;
  150829. /**
  150830. * Creates a new sprite manager from a packed sprite sheet
  150831. * @param name defines the manager's name
  150832. * @param imgUrl defines the sprite sheet url
  150833. * @param capacity defines the maximum allowed number of sprites
  150834. * @param scene defines the hosting scene
  150835. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  150836. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  150837. * @param samplingMode defines the smapling mode to use with spritesheet
  150838. * @param fromPacked set to true; do not alter
  150839. */
  150840. constructor(
  150841. /** defines the packed manager's name */
  150842. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  150843. }
  150844. }
  150845. declare module BABYLON {
  150846. /**
  150847. * Defines the list of states available for a task inside a AssetsManager
  150848. */
  150849. export enum AssetTaskState {
  150850. /**
  150851. * Initialization
  150852. */
  150853. INIT = 0,
  150854. /**
  150855. * Running
  150856. */
  150857. RUNNING = 1,
  150858. /**
  150859. * Done
  150860. */
  150861. DONE = 2,
  150862. /**
  150863. * Error
  150864. */
  150865. ERROR = 3
  150866. }
  150867. /**
  150868. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  150869. */
  150870. export abstract class AbstractAssetTask {
  150871. /**
  150872. * Task name
  150873. */ name: string;
  150874. /**
  150875. * Callback called when the task is successful
  150876. */
  150877. onSuccess: (task: any) => void;
  150878. /**
  150879. * Callback called when the task is not successful
  150880. */
  150881. onError: (task: any, message?: string, exception?: any) => void;
  150882. /**
  150883. * Creates a new AssetsManager
  150884. * @param name defines the name of the task
  150885. */
  150886. constructor(
  150887. /**
  150888. * Task name
  150889. */ name: string);
  150890. private _isCompleted;
  150891. private _taskState;
  150892. private _errorObject;
  150893. /**
  150894. * Get if the task is completed
  150895. */
  150896. get isCompleted(): boolean;
  150897. /**
  150898. * Gets the current state of the task
  150899. */
  150900. get taskState(): AssetTaskState;
  150901. /**
  150902. * Gets the current error object (if task is in error)
  150903. */
  150904. get errorObject(): {
  150905. message?: string;
  150906. exception?: any;
  150907. };
  150908. /**
  150909. * Internal only
  150910. * @hidden
  150911. */
  150912. _setErrorObject(message?: string, exception?: any): void;
  150913. /**
  150914. * Execute the current task
  150915. * @param scene defines the scene where you want your assets to be loaded
  150916. * @param onSuccess is a callback called when the task is successfully executed
  150917. * @param onError is a callback called if an error occurs
  150918. */
  150919. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150920. /**
  150921. * Execute the current task
  150922. * @param scene defines the scene where you want your assets to be loaded
  150923. * @param onSuccess is a callback called when the task is successfully executed
  150924. * @param onError is a callback called if an error occurs
  150925. */
  150926. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150927. /**
  150928. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  150929. * This can be used with failed tasks that have the reason for failure fixed.
  150930. */
  150931. reset(): void;
  150932. private onErrorCallback;
  150933. private onDoneCallback;
  150934. }
  150935. /**
  150936. * Define the interface used by progress events raised during assets loading
  150937. */
  150938. export interface IAssetsProgressEvent {
  150939. /**
  150940. * Defines the number of remaining tasks to process
  150941. */
  150942. remainingCount: number;
  150943. /**
  150944. * Defines the total number of tasks
  150945. */
  150946. totalCount: number;
  150947. /**
  150948. * Defines the task that was just processed
  150949. */
  150950. task: AbstractAssetTask;
  150951. }
  150952. /**
  150953. * Class used to share progress information about assets loading
  150954. */
  150955. export class AssetsProgressEvent implements IAssetsProgressEvent {
  150956. /**
  150957. * Defines the number of remaining tasks to process
  150958. */
  150959. remainingCount: number;
  150960. /**
  150961. * Defines the total number of tasks
  150962. */
  150963. totalCount: number;
  150964. /**
  150965. * Defines the task that was just processed
  150966. */
  150967. task: AbstractAssetTask;
  150968. /**
  150969. * Creates a AssetsProgressEvent
  150970. * @param remainingCount defines the number of remaining tasks to process
  150971. * @param totalCount defines the total number of tasks
  150972. * @param task defines the task that was just processed
  150973. */
  150974. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  150975. }
  150976. /**
  150977. * Define a task used by AssetsManager to load assets into a container
  150978. */
  150979. export class ContainerAssetTask extends AbstractAssetTask {
  150980. /**
  150981. * Defines the name of the task
  150982. */
  150983. name: string;
  150984. /**
  150985. * Defines the list of mesh's names you want to load
  150986. */
  150987. meshesNames: any;
  150988. /**
  150989. * Defines the root url to use as a base to load your meshes and associated resources
  150990. */
  150991. rootUrl: string;
  150992. /**
  150993. * Defines the filename or File of the scene to load from
  150994. */
  150995. sceneFilename: string | File;
  150996. /**
  150997. * Get the loaded asset container
  150998. */
  150999. loadedContainer: AssetContainer;
  151000. /**
  151001. * Gets the list of loaded meshes
  151002. */
  151003. loadedMeshes: Array<AbstractMesh>;
  151004. /**
  151005. * Gets the list of loaded particle systems
  151006. */
  151007. loadedParticleSystems: Array<IParticleSystem>;
  151008. /**
  151009. * Gets the list of loaded skeletons
  151010. */
  151011. loadedSkeletons: Array<Skeleton>;
  151012. /**
  151013. * Gets the list of loaded animation groups
  151014. */
  151015. loadedAnimationGroups: Array<AnimationGroup>;
  151016. /**
  151017. * Callback called when the task is successful
  151018. */
  151019. onSuccess: (task: ContainerAssetTask) => void;
  151020. /**
  151021. * Callback called when the task is successful
  151022. */
  151023. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  151024. /**
  151025. * Creates a new ContainerAssetTask
  151026. * @param name defines the name of the task
  151027. * @param meshesNames defines the list of mesh's names you want to load
  151028. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151029. * @param sceneFilename defines the filename or File of the scene to load from
  151030. */
  151031. constructor(
  151032. /**
  151033. * Defines the name of the task
  151034. */
  151035. name: string,
  151036. /**
  151037. * Defines the list of mesh's names you want to load
  151038. */
  151039. meshesNames: any,
  151040. /**
  151041. * Defines the root url to use as a base to load your meshes and associated resources
  151042. */
  151043. rootUrl: string,
  151044. /**
  151045. * Defines the filename or File of the scene to load from
  151046. */
  151047. sceneFilename: string | File);
  151048. /**
  151049. * Execute the current task
  151050. * @param scene defines the scene where you want your assets to be loaded
  151051. * @param onSuccess is a callback called when the task is successfully executed
  151052. * @param onError is a callback called if an error occurs
  151053. */
  151054. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151055. }
  151056. /**
  151057. * Define a task used by AssetsManager to load meshes
  151058. */
  151059. export class MeshAssetTask extends AbstractAssetTask {
  151060. /**
  151061. * Defines the name of the task
  151062. */
  151063. name: string;
  151064. /**
  151065. * Defines the list of mesh's names you want to load
  151066. */
  151067. meshesNames: any;
  151068. /**
  151069. * Defines the root url to use as a base to load your meshes and associated resources
  151070. */
  151071. rootUrl: string;
  151072. /**
  151073. * Defines the filename or File of the scene to load from
  151074. */
  151075. sceneFilename: string | File;
  151076. /**
  151077. * Gets the list of loaded meshes
  151078. */
  151079. loadedMeshes: Array<AbstractMesh>;
  151080. /**
  151081. * Gets the list of loaded particle systems
  151082. */
  151083. loadedParticleSystems: Array<IParticleSystem>;
  151084. /**
  151085. * Gets the list of loaded skeletons
  151086. */
  151087. loadedSkeletons: Array<Skeleton>;
  151088. /**
  151089. * Gets the list of loaded animation groups
  151090. */
  151091. loadedAnimationGroups: Array<AnimationGroup>;
  151092. /**
  151093. * Callback called when the task is successful
  151094. */
  151095. onSuccess: (task: MeshAssetTask) => void;
  151096. /**
  151097. * Callback called when the task is successful
  151098. */
  151099. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  151100. /**
  151101. * Creates a new MeshAssetTask
  151102. * @param name defines the name of the task
  151103. * @param meshesNames defines the list of mesh's names you want to load
  151104. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  151105. * @param sceneFilename defines the filename or File of the scene to load from
  151106. */
  151107. constructor(
  151108. /**
  151109. * Defines the name of the task
  151110. */
  151111. name: string,
  151112. /**
  151113. * Defines the list of mesh's names you want to load
  151114. */
  151115. meshesNames: any,
  151116. /**
  151117. * Defines the root url to use as a base to load your meshes and associated resources
  151118. */
  151119. rootUrl: string,
  151120. /**
  151121. * Defines the filename or File of the scene to load from
  151122. */
  151123. sceneFilename: string | File);
  151124. /**
  151125. * Execute the current task
  151126. * @param scene defines the scene where you want your assets to be loaded
  151127. * @param onSuccess is a callback called when the task is successfully executed
  151128. * @param onError is a callback called if an error occurs
  151129. */
  151130. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151131. }
  151132. /**
  151133. * Define a task used by AssetsManager to load text content
  151134. */
  151135. export class TextFileAssetTask extends AbstractAssetTask {
  151136. /**
  151137. * Defines the name of the task
  151138. */
  151139. name: string;
  151140. /**
  151141. * Defines the location of the file to load
  151142. */
  151143. url: string;
  151144. /**
  151145. * Gets the loaded text string
  151146. */
  151147. text: string;
  151148. /**
  151149. * Callback called when the task is successful
  151150. */
  151151. onSuccess: (task: TextFileAssetTask) => void;
  151152. /**
  151153. * Callback called when the task is successful
  151154. */
  151155. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  151156. /**
  151157. * Creates a new TextFileAssetTask object
  151158. * @param name defines the name of the task
  151159. * @param url defines the location of the file to load
  151160. */
  151161. constructor(
  151162. /**
  151163. * Defines the name of the task
  151164. */
  151165. name: string,
  151166. /**
  151167. * Defines the location of the file to load
  151168. */
  151169. url: string);
  151170. /**
  151171. * Execute the current task
  151172. * @param scene defines the scene where you want your assets to be loaded
  151173. * @param onSuccess is a callback called when the task is successfully executed
  151174. * @param onError is a callback called if an error occurs
  151175. */
  151176. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151177. }
  151178. /**
  151179. * Define a task used by AssetsManager to load binary data
  151180. */
  151181. export class BinaryFileAssetTask extends AbstractAssetTask {
  151182. /**
  151183. * Defines the name of the task
  151184. */
  151185. name: string;
  151186. /**
  151187. * Defines the location of the file to load
  151188. */
  151189. url: string;
  151190. /**
  151191. * Gets the lodaded data (as an array buffer)
  151192. */
  151193. data: ArrayBuffer;
  151194. /**
  151195. * Callback called when the task is successful
  151196. */
  151197. onSuccess: (task: BinaryFileAssetTask) => void;
  151198. /**
  151199. * Callback called when the task is successful
  151200. */
  151201. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  151202. /**
  151203. * Creates a new BinaryFileAssetTask object
  151204. * @param name defines the name of the new task
  151205. * @param url defines the location of the file to load
  151206. */
  151207. constructor(
  151208. /**
  151209. * Defines the name of the task
  151210. */
  151211. name: string,
  151212. /**
  151213. * Defines the location of the file to load
  151214. */
  151215. url: string);
  151216. /**
  151217. * Execute the current task
  151218. * @param scene defines the scene where you want your assets to be loaded
  151219. * @param onSuccess is a callback called when the task is successfully executed
  151220. * @param onError is a callback called if an error occurs
  151221. */
  151222. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151223. }
  151224. /**
  151225. * Define a task used by AssetsManager to load images
  151226. */
  151227. export class ImageAssetTask extends AbstractAssetTask {
  151228. /**
  151229. * Defines the name of the task
  151230. */
  151231. name: string;
  151232. /**
  151233. * Defines the location of the image to load
  151234. */
  151235. url: string;
  151236. /**
  151237. * Gets the loaded images
  151238. */
  151239. image: HTMLImageElement;
  151240. /**
  151241. * Callback called when the task is successful
  151242. */
  151243. onSuccess: (task: ImageAssetTask) => void;
  151244. /**
  151245. * Callback called when the task is successful
  151246. */
  151247. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  151248. /**
  151249. * Creates a new ImageAssetTask
  151250. * @param name defines the name of the task
  151251. * @param url defines the location of the image to load
  151252. */
  151253. constructor(
  151254. /**
  151255. * Defines the name of the task
  151256. */
  151257. name: string,
  151258. /**
  151259. * Defines the location of the image to load
  151260. */
  151261. url: string);
  151262. /**
  151263. * Execute the current task
  151264. * @param scene defines the scene where you want your assets to be loaded
  151265. * @param onSuccess is a callback called when the task is successfully executed
  151266. * @param onError is a callback called if an error occurs
  151267. */
  151268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151269. }
  151270. /**
  151271. * Defines the interface used by texture loading tasks
  151272. */
  151273. export interface ITextureAssetTask<TEX extends BaseTexture> {
  151274. /**
  151275. * Gets the loaded texture
  151276. */
  151277. texture: TEX;
  151278. }
  151279. /**
  151280. * Define a task used by AssetsManager to load 2D textures
  151281. */
  151282. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  151283. /**
  151284. * Defines the name of the task
  151285. */
  151286. name: string;
  151287. /**
  151288. * Defines the location of the file to load
  151289. */
  151290. url: string;
  151291. /**
  151292. * Defines if mipmap should not be generated (default is false)
  151293. */
  151294. noMipmap?: boolean | undefined;
  151295. /**
  151296. * Defines if texture must be inverted on Y axis (default is true)
  151297. */
  151298. invertY: boolean;
  151299. /**
  151300. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151301. */
  151302. samplingMode: number;
  151303. /**
  151304. * Gets the loaded texture
  151305. */
  151306. texture: Texture;
  151307. /**
  151308. * Callback called when the task is successful
  151309. */
  151310. onSuccess: (task: TextureAssetTask) => void;
  151311. /**
  151312. * Callback called when the task is successful
  151313. */
  151314. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  151315. /**
  151316. * Creates a new TextureAssetTask object
  151317. * @param name defines the name of the task
  151318. * @param url defines the location of the file to load
  151319. * @param noMipmap defines if mipmap should not be generated (default is false)
  151320. * @param invertY defines if texture must be inverted on Y axis (default is true)
  151321. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151322. */
  151323. constructor(
  151324. /**
  151325. * Defines the name of the task
  151326. */
  151327. name: string,
  151328. /**
  151329. * Defines the location of the file to load
  151330. */
  151331. url: string,
  151332. /**
  151333. * Defines if mipmap should not be generated (default is false)
  151334. */
  151335. noMipmap?: boolean | undefined,
  151336. /**
  151337. * Defines if texture must be inverted on Y axis (default is true)
  151338. */
  151339. invertY?: boolean,
  151340. /**
  151341. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  151342. */
  151343. samplingMode?: number);
  151344. /**
  151345. * Execute the current task
  151346. * @param scene defines the scene where you want your assets to be loaded
  151347. * @param onSuccess is a callback called when the task is successfully executed
  151348. * @param onError is a callback called if an error occurs
  151349. */
  151350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151351. }
  151352. /**
  151353. * Define a task used by AssetsManager to load cube textures
  151354. */
  151355. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  151356. /**
  151357. * Defines the name of the task
  151358. */
  151359. name: string;
  151360. /**
  151361. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151362. */
  151363. url: string;
  151364. /**
  151365. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151366. */
  151367. extensions?: string[] | undefined;
  151368. /**
  151369. * Defines if mipmaps should not be generated (default is false)
  151370. */
  151371. noMipmap?: boolean | undefined;
  151372. /**
  151373. * Defines the explicit list of files (undefined by default)
  151374. */
  151375. files?: string[] | undefined;
  151376. /**
  151377. * Gets the loaded texture
  151378. */
  151379. texture: CubeTexture;
  151380. /**
  151381. * Callback called when the task is successful
  151382. */
  151383. onSuccess: (task: CubeTextureAssetTask) => void;
  151384. /**
  151385. * Callback called when the task is successful
  151386. */
  151387. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  151388. /**
  151389. * Creates a new CubeTextureAssetTask
  151390. * @param name defines the name of the task
  151391. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151392. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151393. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151394. * @param files defines the explicit list of files (undefined by default)
  151395. */
  151396. constructor(
  151397. /**
  151398. * Defines the name of the task
  151399. */
  151400. name: string,
  151401. /**
  151402. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  151403. */
  151404. url: string,
  151405. /**
  151406. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  151407. */
  151408. extensions?: string[] | undefined,
  151409. /**
  151410. * Defines if mipmaps should not be generated (default is false)
  151411. */
  151412. noMipmap?: boolean | undefined,
  151413. /**
  151414. * Defines the explicit list of files (undefined by default)
  151415. */
  151416. files?: string[] | undefined);
  151417. /**
  151418. * Execute the current task
  151419. * @param scene defines the scene where you want your assets to be loaded
  151420. * @param onSuccess is a callback called when the task is successfully executed
  151421. * @param onError is a callback called if an error occurs
  151422. */
  151423. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151424. }
  151425. /**
  151426. * Define a task used by AssetsManager to load HDR cube textures
  151427. */
  151428. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  151429. /**
  151430. * Defines the name of the task
  151431. */
  151432. name: string;
  151433. /**
  151434. * Defines the location of the file to load
  151435. */
  151436. url: string;
  151437. /**
  151438. * Defines the desired size (the more it increases the longer the generation will be)
  151439. */
  151440. size: number;
  151441. /**
  151442. * Defines if mipmaps should not be generated (default is false)
  151443. */
  151444. noMipmap: boolean;
  151445. /**
  151446. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151447. */
  151448. generateHarmonics: boolean;
  151449. /**
  151450. * 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)
  151451. */
  151452. gammaSpace: boolean;
  151453. /**
  151454. * Internal Use Only
  151455. */
  151456. reserved: boolean;
  151457. /**
  151458. * Gets the loaded texture
  151459. */
  151460. texture: HDRCubeTexture;
  151461. /**
  151462. * Callback called when the task is successful
  151463. */
  151464. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  151465. /**
  151466. * Callback called when the task is successful
  151467. */
  151468. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  151469. /**
  151470. * Creates a new HDRCubeTextureAssetTask object
  151471. * @param name defines the name of the task
  151472. * @param url defines the location of the file to load
  151473. * @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.
  151474. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151475. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151476. * @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)
  151477. * @param reserved Internal use only
  151478. */
  151479. constructor(
  151480. /**
  151481. * Defines the name of the task
  151482. */
  151483. name: string,
  151484. /**
  151485. * Defines the location of the file to load
  151486. */
  151487. url: string,
  151488. /**
  151489. * Defines the desired size (the more it increases the longer the generation will be)
  151490. */
  151491. size: number,
  151492. /**
  151493. * Defines if mipmaps should not be generated (default is false)
  151494. */
  151495. noMipmap?: boolean,
  151496. /**
  151497. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  151498. */
  151499. generateHarmonics?: boolean,
  151500. /**
  151501. * 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)
  151502. */
  151503. gammaSpace?: boolean,
  151504. /**
  151505. * Internal Use Only
  151506. */
  151507. reserved?: boolean);
  151508. /**
  151509. * Execute the current task
  151510. * @param scene defines the scene where you want your assets to be loaded
  151511. * @param onSuccess is a callback called when the task is successfully executed
  151512. * @param onError is a callback called if an error occurs
  151513. */
  151514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151515. }
  151516. /**
  151517. * Define a task used by AssetsManager to load Equirectangular cube textures
  151518. */
  151519. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  151520. /**
  151521. * Defines the name of the task
  151522. */
  151523. name: string;
  151524. /**
  151525. * Defines the location of the file to load
  151526. */
  151527. url: string;
  151528. /**
  151529. * Defines the desired size (the more it increases the longer the generation will be)
  151530. */
  151531. size: number;
  151532. /**
  151533. * Defines if mipmaps should not be generated (default is false)
  151534. */
  151535. noMipmap: boolean;
  151536. /**
  151537. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151538. * but the standard material would require them in Gamma space) (default is true)
  151539. */
  151540. gammaSpace: boolean;
  151541. /**
  151542. * Gets the loaded texture
  151543. */
  151544. texture: EquiRectangularCubeTexture;
  151545. /**
  151546. * Callback called when the task is successful
  151547. */
  151548. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  151549. /**
  151550. * Callback called when the task is successful
  151551. */
  151552. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  151553. /**
  151554. * Creates a new EquiRectangularCubeTextureAssetTask object
  151555. * @param name defines the name of the task
  151556. * @param url defines the location of the file to load
  151557. * @param size defines the desired size (the more it increases the longer the generation will be)
  151558. * If the size is omitted this implies you are using a preprocessed cubemap.
  151559. * @param noMipmap defines if mipmaps should not be generated (default is false)
  151560. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  151561. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  151562. * (default is true)
  151563. */
  151564. constructor(
  151565. /**
  151566. * Defines the name of the task
  151567. */
  151568. name: string,
  151569. /**
  151570. * Defines the location of the file to load
  151571. */
  151572. url: string,
  151573. /**
  151574. * Defines the desired size (the more it increases the longer the generation will be)
  151575. */
  151576. size: number,
  151577. /**
  151578. * Defines if mipmaps should not be generated (default is false)
  151579. */
  151580. noMipmap?: boolean,
  151581. /**
  151582. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  151583. * but the standard material would require them in Gamma space) (default is true)
  151584. */
  151585. gammaSpace?: boolean);
  151586. /**
  151587. * Execute the current task
  151588. * @param scene defines the scene where you want your assets to be loaded
  151589. * @param onSuccess is a callback called when the task is successfully executed
  151590. * @param onError is a callback called if an error occurs
  151591. */
  151592. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  151593. }
  151594. /**
  151595. * This class can be used to easily import assets into a scene
  151596. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  151597. */
  151598. export class AssetsManager {
  151599. private _scene;
  151600. private _isLoading;
  151601. protected _tasks: AbstractAssetTask[];
  151602. protected _waitingTasksCount: number;
  151603. protected _totalTasksCount: number;
  151604. /**
  151605. * Callback called when all tasks are processed
  151606. */
  151607. onFinish: (tasks: AbstractAssetTask[]) => void;
  151608. /**
  151609. * Callback called when a task is successful
  151610. */
  151611. onTaskSuccess: (task: AbstractAssetTask) => void;
  151612. /**
  151613. * Callback called when a task had an error
  151614. */
  151615. onTaskError: (task: AbstractAssetTask) => void;
  151616. /**
  151617. * Callback called when a task is done (whatever the result is)
  151618. */
  151619. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  151620. /**
  151621. * Observable called when all tasks are processed
  151622. */
  151623. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  151624. /**
  151625. * Observable called when a task had an error
  151626. */
  151627. onTaskErrorObservable: Observable<AbstractAssetTask>;
  151628. /**
  151629. * Observable called when all tasks were executed
  151630. */
  151631. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  151632. /**
  151633. * Observable called when a task is done (whatever the result is)
  151634. */
  151635. onProgressObservable: Observable<IAssetsProgressEvent>;
  151636. /**
  151637. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  151638. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  151639. */
  151640. useDefaultLoadingScreen: boolean;
  151641. /**
  151642. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  151643. * when all assets have been downloaded.
  151644. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  151645. */
  151646. autoHideLoadingUI: boolean;
  151647. /**
  151648. * Creates a new AssetsManager
  151649. * @param scene defines the scene to work on
  151650. */
  151651. constructor(scene: Scene);
  151652. /**
  151653. * Add a ContainerAssetTask to the list of active tasks
  151654. * @param taskName defines the name of the new task
  151655. * @param meshesNames defines the name of meshes to load
  151656. * @param rootUrl defines the root url to use to locate files
  151657. * @param sceneFilename defines the filename of the scene file
  151658. * @returns a new ContainerAssetTask object
  151659. */
  151660. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  151661. /**
  151662. * Add a MeshAssetTask to the list of active tasks
  151663. * @param taskName defines the name of the new task
  151664. * @param meshesNames defines the name of meshes to load
  151665. * @param rootUrl defines the root url to use to locate files
  151666. * @param sceneFilename defines the filename of the scene file
  151667. * @returns a new MeshAssetTask object
  151668. */
  151669. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  151670. /**
  151671. * Add a TextFileAssetTask to the list of active tasks
  151672. * @param taskName defines the name of the new task
  151673. * @param url defines the url of the file to load
  151674. * @returns a new TextFileAssetTask object
  151675. */
  151676. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  151677. /**
  151678. * Add a BinaryFileAssetTask to the list of active tasks
  151679. * @param taskName defines the name of the new task
  151680. * @param url defines the url of the file to load
  151681. * @returns a new BinaryFileAssetTask object
  151682. */
  151683. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  151684. /**
  151685. * Add a ImageAssetTask to the list of active tasks
  151686. * @param taskName defines the name of the new task
  151687. * @param url defines the url of the file to load
  151688. * @returns a new ImageAssetTask object
  151689. */
  151690. addImageTask(taskName: string, url: string): ImageAssetTask;
  151691. /**
  151692. * Add a TextureAssetTask to the list of active tasks
  151693. * @param taskName defines the name of the new task
  151694. * @param url defines the url of the file to load
  151695. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151696. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  151697. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  151698. * @returns a new TextureAssetTask object
  151699. */
  151700. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  151701. /**
  151702. * Add a CubeTextureAssetTask to the list of active tasks
  151703. * @param taskName defines the name of the new task
  151704. * @param url defines the url of the file to load
  151705. * @param extensions defines the extension to use to load the cube map (can be null)
  151706. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151707. * @param files defines the list of files to load (can be null)
  151708. * @returns a new CubeTextureAssetTask object
  151709. */
  151710. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  151711. /**
  151712. *
  151713. * Add a HDRCubeTextureAssetTask to the list of active tasks
  151714. * @param taskName defines the name of the new task
  151715. * @param url defines the url of the file to load
  151716. * @param size defines the size you want for the cubemap (can be null)
  151717. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151718. * @param generateHarmonics defines if you want to automatically generate (true by default)
  151719. * @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)
  151720. * @param reserved Internal use only
  151721. * @returns a new HDRCubeTextureAssetTask object
  151722. */
  151723. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  151724. /**
  151725. *
  151726. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  151727. * @param taskName defines the name of the new task
  151728. * @param url defines the url of the file to load
  151729. * @param size defines the size you want for the cubemap (can be null)
  151730. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  151731. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  151732. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  151733. * @returns a new EquiRectangularCubeTextureAssetTask object
  151734. */
  151735. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  151736. /**
  151737. * Remove a task from the assets manager.
  151738. * @param task the task to remove
  151739. */
  151740. removeTask(task: AbstractAssetTask): void;
  151741. private _decreaseWaitingTasksCount;
  151742. private _runTask;
  151743. /**
  151744. * Reset the AssetsManager and remove all tasks
  151745. * @return the current instance of the AssetsManager
  151746. */
  151747. reset(): AssetsManager;
  151748. /**
  151749. * Start the loading process
  151750. * @return the current instance of the AssetsManager
  151751. */
  151752. load(): AssetsManager;
  151753. /**
  151754. * Start the loading process as an async operation
  151755. * @return a promise returning the list of failed tasks
  151756. */
  151757. loadAsync(): Promise<void>;
  151758. }
  151759. }
  151760. declare module BABYLON {
  151761. /**
  151762. * Wrapper class for promise with external resolve and reject.
  151763. */
  151764. export class Deferred<T> {
  151765. /**
  151766. * The promise associated with this deferred object.
  151767. */
  151768. readonly promise: Promise<T>;
  151769. private _resolve;
  151770. private _reject;
  151771. /**
  151772. * The resolve method of the promise associated with this deferred object.
  151773. */
  151774. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  151775. /**
  151776. * The reject method of the promise associated with this deferred object.
  151777. */
  151778. get reject(): (reason?: any) => void;
  151779. /**
  151780. * Constructor for this deferred object.
  151781. */
  151782. constructor();
  151783. }
  151784. }
  151785. declare module BABYLON {
  151786. /**
  151787. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  151788. */
  151789. export class MeshExploder {
  151790. private _centerMesh;
  151791. private _meshes;
  151792. private _meshesOrigins;
  151793. private _toCenterVectors;
  151794. private _scaledDirection;
  151795. private _newPosition;
  151796. private _centerPosition;
  151797. /**
  151798. * Explodes meshes from a center mesh.
  151799. * @param meshes The meshes to explode.
  151800. * @param centerMesh The mesh to be center of explosion.
  151801. */
  151802. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  151803. private _setCenterMesh;
  151804. /**
  151805. * Get class name
  151806. * @returns "MeshExploder"
  151807. */
  151808. getClassName(): string;
  151809. /**
  151810. * "Exploded meshes"
  151811. * @returns Array of meshes with the centerMesh at index 0.
  151812. */
  151813. getMeshes(): Array<Mesh>;
  151814. /**
  151815. * Explodes meshes giving a specific direction
  151816. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  151817. */
  151818. explode(direction?: number): void;
  151819. }
  151820. }
  151821. declare module BABYLON {
  151822. /**
  151823. * Class used to help managing file picking and drag'n'drop
  151824. */
  151825. export class FilesInput {
  151826. /**
  151827. * List of files ready to be loaded
  151828. */
  151829. static get FilesToLoad(): {
  151830. [key: string]: File;
  151831. };
  151832. /**
  151833. * Callback called when a file is processed
  151834. */
  151835. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  151836. private _engine;
  151837. private _currentScene;
  151838. private _sceneLoadedCallback;
  151839. private _progressCallback;
  151840. private _additionalRenderLoopLogicCallback;
  151841. private _textureLoadingCallback;
  151842. private _startingProcessingFilesCallback;
  151843. private _onReloadCallback;
  151844. private _errorCallback;
  151845. private _elementToMonitor;
  151846. private _sceneFileToLoad;
  151847. private _filesToLoad;
  151848. /**
  151849. * Creates a new FilesInput
  151850. * @param engine defines the rendering engine
  151851. * @param scene defines the hosting scene
  151852. * @param sceneLoadedCallback callback called when scene is loaded
  151853. * @param progressCallback callback called to track progress
  151854. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  151855. * @param textureLoadingCallback callback called when a texture is loading
  151856. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  151857. * @param onReloadCallback callback called when a reload is requested
  151858. * @param errorCallback callback call if an error occurs
  151859. */
  151860. 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>);
  151861. private _dragEnterHandler;
  151862. private _dragOverHandler;
  151863. private _dropHandler;
  151864. /**
  151865. * Calls this function to listen to drag'n'drop events on a specific DOM element
  151866. * @param elementToMonitor defines the DOM element to track
  151867. */
  151868. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  151869. /** Gets the current list of files to load */
  151870. get filesToLoad(): File[];
  151871. /**
  151872. * Release all associated resources
  151873. */
  151874. dispose(): void;
  151875. private renderFunction;
  151876. private drag;
  151877. private drop;
  151878. private _traverseFolder;
  151879. private _processFiles;
  151880. /**
  151881. * Load files from a drop event
  151882. * @param event defines the drop event to use as source
  151883. */
  151884. loadFiles(event: any): void;
  151885. private _processReload;
  151886. /**
  151887. * Reload the current scene from the loaded files
  151888. */
  151889. reload(): void;
  151890. }
  151891. }
  151892. declare module BABYLON {
  151893. /**
  151894. * Defines the root class used to create scene optimization to use with SceneOptimizer
  151895. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151896. */
  151897. export class SceneOptimization {
  151898. /**
  151899. * Defines the priority of this optimization (0 by default which means first in the list)
  151900. */
  151901. priority: number;
  151902. /**
  151903. * Gets a string describing the action executed by the current optimization
  151904. * @returns description string
  151905. */
  151906. getDescription(): string;
  151907. /**
  151908. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151909. * @param scene defines the current scene where to apply this optimization
  151910. * @param optimizer defines the current optimizer
  151911. * @returns true if everything that can be done was applied
  151912. */
  151913. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151914. /**
  151915. * Creates the SceneOptimization object
  151916. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151917. * @param desc defines the description associated with the optimization
  151918. */
  151919. constructor(
  151920. /**
  151921. * Defines the priority of this optimization (0 by default which means first in the list)
  151922. */
  151923. priority?: number);
  151924. }
  151925. /**
  151926. * Defines an optimization used to reduce the size of render target textures
  151927. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151928. */
  151929. export class TextureOptimization extends SceneOptimization {
  151930. /**
  151931. * Defines the priority of this optimization (0 by default which means first in the list)
  151932. */
  151933. priority: number;
  151934. /**
  151935. * 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
  151936. */
  151937. maximumSize: number;
  151938. /**
  151939. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151940. */
  151941. step: number;
  151942. /**
  151943. * Gets a string describing the action executed by the current optimization
  151944. * @returns description string
  151945. */
  151946. getDescription(): string;
  151947. /**
  151948. * Creates the TextureOptimization object
  151949. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151950. * @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
  151951. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151952. */
  151953. constructor(
  151954. /**
  151955. * Defines the priority of this optimization (0 by default which means first in the list)
  151956. */
  151957. priority?: number,
  151958. /**
  151959. * 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
  151960. */
  151961. maximumSize?: number,
  151962. /**
  151963. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  151964. */
  151965. step?: number);
  151966. /**
  151967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151968. * @param scene defines the current scene where to apply this optimization
  151969. * @param optimizer defines the current optimizer
  151970. * @returns true if everything that can be done was applied
  151971. */
  151972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151973. }
  151974. /**
  151975. * Defines an optimization used to increase or decrease the rendering resolution
  151976. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151977. */
  151978. export class HardwareScalingOptimization extends SceneOptimization {
  151979. /**
  151980. * Defines the priority of this optimization (0 by default which means first in the list)
  151981. */
  151982. priority: number;
  151983. /**
  151984. * Defines the maximum scale to use (2 by default)
  151985. */
  151986. maximumScale: number;
  151987. /**
  151988. * Defines the step to use between two passes (0.5 by default)
  151989. */
  151990. step: number;
  151991. private _currentScale;
  151992. private _directionOffset;
  151993. /**
  151994. * Gets a string describing the action executed by the current optimization
  151995. * @return description string
  151996. */
  151997. getDescription(): string;
  151998. /**
  151999. * Creates the HardwareScalingOptimization object
  152000. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152001. * @param maximumScale defines the maximum scale to use (2 by default)
  152002. * @param step defines the step to use between two passes (0.5 by default)
  152003. */
  152004. constructor(
  152005. /**
  152006. * Defines the priority of this optimization (0 by default which means first in the list)
  152007. */
  152008. priority?: number,
  152009. /**
  152010. * Defines the maximum scale to use (2 by default)
  152011. */
  152012. maximumScale?: number,
  152013. /**
  152014. * Defines the step to use between two passes (0.5 by default)
  152015. */
  152016. step?: number);
  152017. /**
  152018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152019. * @param scene defines the current scene where to apply this optimization
  152020. * @param optimizer defines the current optimizer
  152021. * @returns true if everything that can be done was applied
  152022. */
  152023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152024. }
  152025. /**
  152026. * Defines an optimization used to remove shadows
  152027. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152028. */
  152029. export class ShadowsOptimization extends SceneOptimization {
  152030. /**
  152031. * Gets a string describing the action executed by the current optimization
  152032. * @return description string
  152033. */
  152034. getDescription(): string;
  152035. /**
  152036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152037. * @param scene defines the current scene where to apply this optimization
  152038. * @param optimizer defines the current optimizer
  152039. * @returns true if everything that can be done was applied
  152040. */
  152041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152042. }
  152043. /**
  152044. * Defines an optimization used to turn post-processes off
  152045. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152046. */
  152047. export class PostProcessesOptimization extends SceneOptimization {
  152048. /**
  152049. * Gets a string describing the action executed by the current optimization
  152050. * @return description string
  152051. */
  152052. getDescription(): string;
  152053. /**
  152054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152055. * @param scene defines the current scene where to apply this optimization
  152056. * @param optimizer defines the current optimizer
  152057. * @returns true if everything that can be done was applied
  152058. */
  152059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152060. }
  152061. /**
  152062. * Defines an optimization used to turn lens flares off
  152063. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152064. */
  152065. export class LensFlaresOptimization extends SceneOptimization {
  152066. /**
  152067. * Gets a string describing the action executed by the current optimization
  152068. * @return description string
  152069. */
  152070. getDescription(): string;
  152071. /**
  152072. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152073. * @param scene defines the current scene where to apply this optimization
  152074. * @param optimizer defines the current optimizer
  152075. * @returns true if everything that can be done was applied
  152076. */
  152077. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152078. }
  152079. /**
  152080. * Defines an optimization based on user defined callback.
  152081. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152082. */
  152083. export class CustomOptimization extends SceneOptimization {
  152084. /**
  152085. * Callback called to apply the custom optimization.
  152086. */
  152087. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  152088. /**
  152089. * Callback called to get custom description
  152090. */
  152091. onGetDescription: () => string;
  152092. /**
  152093. * Gets a string describing the action executed by the current optimization
  152094. * @returns description string
  152095. */
  152096. getDescription(): string;
  152097. /**
  152098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152099. * @param scene defines the current scene where to apply this optimization
  152100. * @param optimizer defines the current optimizer
  152101. * @returns true if everything that can be done was applied
  152102. */
  152103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152104. }
  152105. /**
  152106. * Defines an optimization used to turn particles off
  152107. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152108. */
  152109. export class ParticlesOptimization extends SceneOptimization {
  152110. /**
  152111. * Gets a string describing the action executed by the current optimization
  152112. * @return description string
  152113. */
  152114. getDescription(): string;
  152115. /**
  152116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152117. * @param scene defines the current scene where to apply this optimization
  152118. * @param optimizer defines the current optimizer
  152119. * @returns true if everything that can be done was applied
  152120. */
  152121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152122. }
  152123. /**
  152124. * Defines an optimization used to turn render targets off
  152125. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152126. */
  152127. export class RenderTargetsOptimization extends SceneOptimization {
  152128. /**
  152129. * Gets a string describing the action executed by the current optimization
  152130. * @return description string
  152131. */
  152132. getDescription(): string;
  152133. /**
  152134. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152135. * @param scene defines the current scene where to apply this optimization
  152136. * @param optimizer defines the current optimizer
  152137. * @returns true if everything that can be done was applied
  152138. */
  152139. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  152140. }
  152141. /**
  152142. * Defines an optimization used to merge meshes with compatible materials
  152143. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152144. */
  152145. export class MergeMeshesOptimization extends SceneOptimization {
  152146. private static _UpdateSelectionTree;
  152147. /**
  152148. * Gets or sets a boolean which defines if optimization octree has to be updated
  152149. */
  152150. static get UpdateSelectionTree(): boolean;
  152151. /**
  152152. * Gets or sets a boolean which defines if optimization octree has to be updated
  152153. */
  152154. static set UpdateSelectionTree(value: boolean);
  152155. /**
  152156. * Gets a string describing the action executed by the current optimization
  152157. * @return description string
  152158. */
  152159. getDescription(): string;
  152160. private _canBeMerged;
  152161. /**
  152162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  152163. * @param scene defines the current scene where to apply this optimization
  152164. * @param optimizer defines the current optimizer
  152165. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  152166. * @returns true if everything that can be done was applied
  152167. */
  152168. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  152169. }
  152170. /**
  152171. * Defines a list of options used by SceneOptimizer
  152172. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152173. */
  152174. export class SceneOptimizerOptions {
  152175. /**
  152176. * Defines the target frame rate to reach (60 by default)
  152177. */
  152178. targetFrameRate: number;
  152179. /**
  152180. * Defines the interval between two checkes (2000ms by default)
  152181. */
  152182. trackerDuration: number;
  152183. /**
  152184. * Gets the list of optimizations to apply
  152185. */
  152186. optimizations: SceneOptimization[];
  152187. /**
  152188. * Creates a new list of options used by SceneOptimizer
  152189. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  152190. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  152191. */
  152192. constructor(
  152193. /**
  152194. * Defines the target frame rate to reach (60 by default)
  152195. */
  152196. targetFrameRate?: number,
  152197. /**
  152198. * Defines the interval between two checkes (2000ms by default)
  152199. */
  152200. trackerDuration?: number);
  152201. /**
  152202. * Add a new optimization
  152203. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  152204. * @returns the current SceneOptimizerOptions
  152205. */
  152206. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  152207. /**
  152208. * Add a new custom optimization
  152209. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  152210. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  152211. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  152212. * @returns the current SceneOptimizerOptions
  152213. */
  152214. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  152215. /**
  152216. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  152217. * @param targetFrameRate defines the target frame rate (60 by default)
  152218. * @returns a SceneOptimizerOptions object
  152219. */
  152220. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152221. /**
  152222. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  152223. * @param targetFrameRate defines the target frame rate (60 by default)
  152224. * @returns a SceneOptimizerOptions object
  152225. */
  152226. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152227. /**
  152228. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  152229. * @param targetFrameRate defines the target frame rate (60 by default)
  152230. * @returns a SceneOptimizerOptions object
  152231. */
  152232. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  152233. }
  152234. /**
  152235. * Class used to run optimizations in order to reach a target frame rate
  152236. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  152237. */
  152238. export class SceneOptimizer implements IDisposable {
  152239. private _isRunning;
  152240. private _options;
  152241. private _scene;
  152242. private _currentPriorityLevel;
  152243. private _targetFrameRate;
  152244. private _trackerDuration;
  152245. private _currentFrameRate;
  152246. private _sceneDisposeObserver;
  152247. private _improvementMode;
  152248. /**
  152249. * Defines an observable called when the optimizer reaches the target frame rate
  152250. */
  152251. onSuccessObservable: Observable<SceneOptimizer>;
  152252. /**
  152253. * Defines an observable called when the optimizer enables an optimization
  152254. */
  152255. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  152256. /**
  152257. * Defines an observable called when the optimizer is not able to reach the target frame rate
  152258. */
  152259. onFailureObservable: Observable<SceneOptimizer>;
  152260. /**
  152261. * Gets a boolean indicating if the optimizer is in improvement mode
  152262. */
  152263. get isInImprovementMode(): boolean;
  152264. /**
  152265. * Gets the current priority level (0 at start)
  152266. */
  152267. get currentPriorityLevel(): number;
  152268. /**
  152269. * Gets the current frame rate checked by the SceneOptimizer
  152270. */
  152271. get currentFrameRate(): number;
  152272. /**
  152273. * Gets or sets the current target frame rate (60 by default)
  152274. */
  152275. get targetFrameRate(): number;
  152276. /**
  152277. * Gets or sets the current target frame rate (60 by default)
  152278. */
  152279. set targetFrameRate(value: number);
  152280. /**
  152281. * Gets or sets the current interval between two checks (every 2000ms by default)
  152282. */
  152283. get trackerDuration(): number;
  152284. /**
  152285. * Gets or sets the current interval between two checks (every 2000ms by default)
  152286. */
  152287. set trackerDuration(value: number);
  152288. /**
  152289. * Gets the list of active optimizations
  152290. */
  152291. get optimizations(): SceneOptimization[];
  152292. /**
  152293. * Creates a new SceneOptimizer
  152294. * @param scene defines the scene to work on
  152295. * @param options defines the options to use with the SceneOptimizer
  152296. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  152297. * @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)
  152298. */
  152299. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  152300. /**
  152301. * Stops the current optimizer
  152302. */
  152303. stop(): void;
  152304. /**
  152305. * Reset the optimizer to initial step (current priority level = 0)
  152306. */
  152307. reset(): void;
  152308. /**
  152309. * Start the optimizer. By default it will try to reach a specific framerate
  152310. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  152311. */
  152312. start(): void;
  152313. private _checkCurrentState;
  152314. /**
  152315. * Release all resources
  152316. */
  152317. dispose(): void;
  152318. /**
  152319. * Helper function to create a SceneOptimizer with one single line of code
  152320. * @param scene defines the scene to work on
  152321. * @param options defines the options to use with the SceneOptimizer
  152322. * @param onSuccess defines a callback to call on success
  152323. * @param onFailure defines a callback to call on failure
  152324. * @returns the new SceneOptimizer object
  152325. */
  152326. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  152327. }
  152328. }
  152329. declare module BABYLON {
  152330. /**
  152331. * Class used to serialize a scene into a string
  152332. */
  152333. export class SceneSerializer {
  152334. /**
  152335. * Clear cache used by a previous serialization
  152336. */
  152337. static ClearCache(): void;
  152338. /**
  152339. * Serialize a scene into a JSON compatible object
  152340. * @param scene defines the scene to serialize
  152341. * @returns a JSON compatible object
  152342. */
  152343. static Serialize(scene: Scene): any;
  152344. /**
  152345. * Serialize a mesh into a JSON compatible object
  152346. * @param toSerialize defines the mesh to serialize
  152347. * @param withParents defines if parents must be serialized as well
  152348. * @param withChildren defines if children must be serialized as well
  152349. * @returns a JSON compatible object
  152350. */
  152351. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  152352. }
  152353. }
  152354. declare module BABYLON {
  152355. /**
  152356. * Class used to host texture specific utilities
  152357. */
  152358. export class TextureTools {
  152359. /**
  152360. * Uses the GPU to create a copy texture rescaled at a given size
  152361. * @param texture Texture to copy from
  152362. * @param width defines the desired width
  152363. * @param height defines the desired height
  152364. * @param useBilinearMode defines if bilinear mode has to be used
  152365. * @return the generated texture
  152366. */
  152367. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  152368. }
  152369. }
  152370. declare module BABYLON {
  152371. /**
  152372. * This represents the different options available for the video capture.
  152373. */
  152374. export interface VideoRecorderOptions {
  152375. /** Defines the mime type of the video. */
  152376. mimeType: string;
  152377. /** Defines the FPS the video should be recorded at. */
  152378. fps: number;
  152379. /** Defines the chunk size for the recording data. */
  152380. recordChunckSize: number;
  152381. /** The audio tracks to attach to the recording. */
  152382. audioTracks?: MediaStreamTrack[];
  152383. }
  152384. /**
  152385. * This can help with recording videos from BabylonJS.
  152386. * This is based on the available WebRTC functionalities of the browser.
  152387. *
  152388. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  152389. */
  152390. export class VideoRecorder {
  152391. private static readonly _defaultOptions;
  152392. /**
  152393. * Returns whether or not the VideoRecorder is available in your browser.
  152394. * @param engine Defines the Babylon Engine.
  152395. * @returns true if supported otherwise false.
  152396. */
  152397. static IsSupported(engine: Engine): boolean;
  152398. private readonly _options;
  152399. private _canvas;
  152400. private _mediaRecorder;
  152401. private _recordedChunks;
  152402. private _fileName;
  152403. private _resolve;
  152404. private _reject;
  152405. /**
  152406. * True when a recording is already in progress.
  152407. */
  152408. get isRecording(): boolean;
  152409. /**
  152410. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  152411. * @param engine Defines the BabylonJS Engine you wish to record.
  152412. * @param options Defines options that can be used to customize the capture.
  152413. */
  152414. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  152415. /**
  152416. * Stops the current recording before the default capture timeout passed in the startRecording function.
  152417. */
  152418. stopRecording(): void;
  152419. /**
  152420. * Starts recording the canvas for a max duration specified in parameters.
  152421. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  152422. * If null no automatic download will start and you can rely on the promise to get the data back.
  152423. * @param maxDuration Defines the maximum recording time in seconds.
  152424. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  152425. * @return A promise callback at the end of the recording with the video data in Blob.
  152426. */
  152427. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  152428. /**
  152429. * Releases internal resources used during the recording.
  152430. */
  152431. dispose(): void;
  152432. private _handleDataAvailable;
  152433. private _handleError;
  152434. private _handleStop;
  152435. }
  152436. }
  152437. declare module BABYLON {
  152438. /**
  152439. * Class containing a set of static utilities functions for screenshots
  152440. */
  152441. export class ScreenshotTools {
  152442. /**
  152443. * Captures a screenshot of the current rendering
  152444. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152445. * @param engine defines the rendering engine
  152446. * @param camera defines the source camera
  152447. * @param size This parameter can be set to a single number or to an object with the
  152448. * following (optional) properties: precision, width, height. If a single number is passed,
  152449. * it will be used for both width and height. If an object is passed, the screenshot size
  152450. * will be derived from the parameters. The precision property is a multiplier allowing
  152451. * rendering at a higher or lower resolution
  152452. * @param successCallback defines the callback receives a single parameter which contains the
  152453. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152454. * src parameter of an <img> to display it
  152455. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152456. * Check your browser for supported MIME types
  152457. */
  152458. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  152459. /**
  152460. * Captures a screenshot of the current rendering
  152461. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152462. * @param engine defines the rendering engine
  152463. * @param camera defines the source camera
  152464. * @param size This parameter can be set to a single number or to an object with the
  152465. * following (optional) properties: precision, width, height. If a single number is passed,
  152466. * it will be used for both width and height. If an object is passed, the screenshot size
  152467. * will be derived from the parameters. The precision property is a multiplier allowing
  152468. * rendering at a higher or lower resolution
  152469. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  152470. * Check your browser for supported MIME types
  152471. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152472. * to the src parameter of an <img> to display it
  152473. */
  152474. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  152475. /**
  152476. * Generates an image screenshot from the specified camera.
  152477. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152478. * @param engine The engine to use for rendering
  152479. * @param camera The camera to use for rendering
  152480. * @param size This parameter can be set to a single number or to an object with the
  152481. * following (optional) properties: precision, width, height. If a single number is passed,
  152482. * it will be used for both width and height. If an object is passed, the screenshot size
  152483. * will be derived from the parameters. The precision property is a multiplier allowing
  152484. * rendering at a higher or lower resolution
  152485. * @param successCallback The callback receives a single parameter which contains the
  152486. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  152487. * src parameter of an <img> to display it
  152488. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152489. * Check your browser for supported MIME types
  152490. * @param samples Texture samples (default: 1)
  152491. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152492. * @param fileName A name for for the downloaded file.
  152493. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152494. */
  152495. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  152496. /**
  152497. * Generates an image screenshot from the specified camera.
  152498. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  152499. * @param engine The engine to use for rendering
  152500. * @param camera The camera to use for rendering
  152501. * @param size This parameter can be set to a single number or to an object with the
  152502. * following (optional) properties: precision, width, height. If a single number is passed,
  152503. * it will be used for both width and height. If an object is passed, the screenshot size
  152504. * will be derived from the parameters. The precision property is a multiplier allowing
  152505. * rendering at a higher or lower resolution
  152506. * @param mimeType The MIME type of the screenshot image (default: image/png).
  152507. * Check your browser for supported MIME types
  152508. * @param samples Texture samples (default: 1)
  152509. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  152510. * @param fileName A name for for the downloaded file.
  152511. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  152512. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  152513. * to the src parameter of an <img> to display it
  152514. */
  152515. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  152516. /**
  152517. * Gets height and width for screenshot size
  152518. * @private
  152519. */
  152520. private static _getScreenshotSize;
  152521. }
  152522. }
  152523. declare module BABYLON {
  152524. /**
  152525. * Interface for a data buffer
  152526. */
  152527. export interface IDataBuffer {
  152528. /**
  152529. * Reads bytes from the data buffer.
  152530. * @param byteOffset The byte offset to read
  152531. * @param byteLength The byte length to read
  152532. * @returns A promise that resolves when the bytes are read
  152533. */
  152534. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  152535. /**
  152536. * The byte length of the buffer.
  152537. */
  152538. readonly byteLength: number;
  152539. }
  152540. /**
  152541. * Utility class for reading from a data buffer
  152542. */
  152543. export class DataReader {
  152544. /**
  152545. * The data buffer associated with this data reader.
  152546. */
  152547. readonly buffer: IDataBuffer;
  152548. /**
  152549. * The current byte offset from the beginning of the data buffer.
  152550. */
  152551. byteOffset: number;
  152552. private _dataView;
  152553. private _dataByteOffset;
  152554. /**
  152555. * Constructor
  152556. * @param buffer The buffer to read
  152557. */
  152558. constructor(buffer: IDataBuffer);
  152559. /**
  152560. * Loads the given byte length.
  152561. * @param byteLength The byte length to load
  152562. * @returns A promise that resolves when the load is complete
  152563. */
  152564. loadAsync(byteLength: number): Promise<void>;
  152565. /**
  152566. * Read a unsigned 32-bit integer from the currently loaded data range.
  152567. * @returns The 32-bit integer read
  152568. */
  152569. readUint32(): number;
  152570. /**
  152571. * Read a byte array from the currently loaded data range.
  152572. * @param byteLength The byte length to read
  152573. * @returns The byte array read
  152574. */
  152575. readUint8Array(byteLength: number): Uint8Array;
  152576. /**
  152577. * Read a string from the currently loaded data range.
  152578. * @param byteLength The byte length to read
  152579. * @returns The string read
  152580. */
  152581. readString(byteLength: number): string;
  152582. /**
  152583. * Skips the given byte length the currently loaded data range.
  152584. * @param byteLength The byte length to skip
  152585. */
  152586. skipBytes(byteLength: number): void;
  152587. }
  152588. }
  152589. declare module BABYLON {
  152590. /**
  152591. * Class for storing data to local storage if available or in-memory storage otherwise
  152592. */
  152593. export class DataStorage {
  152594. private static _Storage;
  152595. private static _GetStorage;
  152596. /**
  152597. * Reads a string from the data storage
  152598. * @param key The key to read
  152599. * @param defaultValue The value if the key doesn't exist
  152600. * @returns The string value
  152601. */
  152602. static ReadString(key: string, defaultValue: string): string;
  152603. /**
  152604. * Writes a string to the data storage
  152605. * @param key The key to write
  152606. * @param value The value to write
  152607. */
  152608. static WriteString(key: string, value: string): void;
  152609. /**
  152610. * Reads a boolean from the data storage
  152611. * @param key The key to read
  152612. * @param defaultValue The value if the key doesn't exist
  152613. * @returns The boolean value
  152614. */
  152615. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  152616. /**
  152617. * Writes a boolean to the data storage
  152618. * @param key The key to write
  152619. * @param value The value to write
  152620. */
  152621. static WriteBoolean(key: string, value: boolean): void;
  152622. /**
  152623. * Reads a number from the data storage
  152624. * @param key The key to read
  152625. * @param defaultValue The value if the key doesn't exist
  152626. * @returns The number value
  152627. */
  152628. static ReadNumber(key: string, defaultValue: number): number;
  152629. /**
  152630. * Writes a number to the data storage
  152631. * @param key The key to write
  152632. * @param value The value to write
  152633. */
  152634. static WriteNumber(key: string, value: number): void;
  152635. }
  152636. }
  152637. declare module BABYLON {
  152638. /**
  152639. * Class used to record delta files between 2 scene states
  152640. */
  152641. export class SceneRecorder {
  152642. private _trackedScene;
  152643. private _savedJSON;
  152644. /**
  152645. * Track a given scene. This means the current scene state will be considered the original state
  152646. * @param scene defines the scene to track
  152647. */
  152648. track(scene: Scene): void;
  152649. /**
  152650. * Get the delta between current state and original state
  152651. * @returns a string containing the delta
  152652. */
  152653. getDelta(): any;
  152654. private _compareArray;
  152655. private _compareObjects;
  152656. private _compareCollections;
  152657. private static GetShadowGeneratorById;
  152658. /**
  152659. * Apply a given delta to a given scene
  152660. * @param deltaJSON defines the JSON containing the delta
  152661. * @param scene defines the scene to apply the delta to
  152662. */
  152663. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  152664. private static _ApplyPropertiesToEntity;
  152665. private static _ApplyDeltaForEntity;
  152666. }
  152667. }
  152668. declare module BABYLON {
  152669. /**
  152670. * An interface for all Hit test features
  152671. */
  152672. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  152673. /**
  152674. * Triggered when new babylon (transformed) hit test results are available
  152675. */
  152676. onHitTestResultObservable: Observable<T[]>;
  152677. }
  152678. /**
  152679. * Options used for hit testing
  152680. */
  152681. export interface IWebXRLegacyHitTestOptions {
  152682. /**
  152683. * Only test when user interacted with the scene. Default - hit test every frame
  152684. */
  152685. testOnPointerDownOnly?: boolean;
  152686. /**
  152687. * The node to use to transform the local results to world coordinates
  152688. */
  152689. worldParentNode?: TransformNode;
  152690. }
  152691. /**
  152692. * Interface defining the babylon result of raycasting/hit-test
  152693. */
  152694. export interface IWebXRLegacyHitResult {
  152695. /**
  152696. * Transformation matrix that can be applied to a node that will put it in the hit point location
  152697. */
  152698. transformationMatrix: Matrix;
  152699. /**
  152700. * The native hit test result
  152701. */
  152702. xrHitResult: XRHitResult | XRHitTestResult;
  152703. }
  152704. /**
  152705. * The currently-working hit-test module.
  152706. * Hit test (or Ray-casting) is used to interact with the real world.
  152707. * For further information read here - https://github.com/immersive-web/hit-test
  152708. */
  152709. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  152710. /**
  152711. * options to use when constructing this feature
  152712. */
  152713. readonly options: IWebXRLegacyHitTestOptions;
  152714. private _direction;
  152715. private _mat;
  152716. private _onSelectEnabled;
  152717. private _origin;
  152718. /**
  152719. * The module's name
  152720. */
  152721. static readonly Name: string;
  152722. /**
  152723. * The (Babylon) version of this module.
  152724. * This is an integer representing the implementation version.
  152725. * This number does not correspond to the WebXR specs version
  152726. */
  152727. static readonly Version: number;
  152728. /**
  152729. * Populated with the last native XR Hit Results
  152730. */
  152731. lastNativeXRHitResults: XRHitResult[];
  152732. /**
  152733. * Triggered when new babylon (transformed) hit test results are available
  152734. */
  152735. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  152736. /**
  152737. * Creates a new instance of the (legacy version) hit test feature
  152738. * @param _xrSessionManager an instance of WebXRSessionManager
  152739. * @param options options to use when constructing this feature
  152740. */
  152741. constructor(_xrSessionManager: WebXRSessionManager,
  152742. /**
  152743. * options to use when constructing this feature
  152744. */
  152745. options?: IWebXRLegacyHitTestOptions);
  152746. /**
  152747. * execute a hit test with an XR Ray
  152748. *
  152749. * @param xrSession a native xrSession that will execute this hit test
  152750. * @param xrRay the ray (position and direction) to use for ray-casting
  152751. * @param referenceSpace native XR reference space to use for the hit-test
  152752. * @param filter filter function that will filter the results
  152753. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152754. */
  152755. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  152756. /**
  152757. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  152758. * @param event the (select) event to use to select with
  152759. * @param referenceSpace the reference space to use for this hit test
  152760. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  152761. */
  152762. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  152763. /**
  152764. * attach this feature
  152765. * Will usually be called by the features manager
  152766. *
  152767. * @returns true if successful.
  152768. */
  152769. attach(): boolean;
  152770. /**
  152771. * detach this feature.
  152772. * Will usually be called by the features manager
  152773. *
  152774. * @returns true if successful.
  152775. */
  152776. detach(): boolean;
  152777. /**
  152778. * Dispose this feature and all of the resources attached
  152779. */
  152780. dispose(): void;
  152781. protected _onXRFrame(frame: XRFrame): void;
  152782. private _onHitTestResults;
  152783. private _onSelect;
  152784. }
  152785. }
  152786. declare module BABYLON {
  152787. /**
  152788. * Options used for hit testing (version 2)
  152789. */
  152790. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  152791. /**
  152792. * Do not create a permanent hit test. Will usually be used when only
  152793. * transient inputs are needed.
  152794. */
  152795. disablePermanentHitTest?: boolean;
  152796. /**
  152797. * Enable transient (for example touch-based) hit test inspections
  152798. */
  152799. enableTransientHitTest?: boolean;
  152800. /**
  152801. * Offset ray for the permanent hit test
  152802. */
  152803. offsetRay?: Vector3;
  152804. /**
  152805. * Offset ray for the transient hit test
  152806. */
  152807. transientOffsetRay?: Vector3;
  152808. /**
  152809. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  152810. */
  152811. useReferenceSpace?: boolean;
  152812. }
  152813. /**
  152814. * Interface defining the babylon result of hit-test
  152815. */
  152816. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  152817. /**
  152818. * The input source that generated this hit test (if transient)
  152819. */
  152820. inputSource?: XRInputSource;
  152821. /**
  152822. * Is this a transient hit test
  152823. */
  152824. isTransient?: boolean;
  152825. /**
  152826. * Position of the hit test result
  152827. */
  152828. position: Vector3;
  152829. /**
  152830. * Rotation of the hit test result
  152831. */
  152832. rotationQuaternion: Quaternion;
  152833. /**
  152834. * The native hit test result
  152835. */
  152836. xrHitResult: XRHitTestResult;
  152837. }
  152838. /**
  152839. * The currently-working hit-test module.
  152840. * Hit test (or Ray-casting) is used to interact with the real world.
  152841. * For further information read here - https://github.com/immersive-web/hit-test
  152842. *
  152843. * Tested on chrome (mobile) 80.
  152844. */
  152845. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  152846. /**
  152847. * options to use when constructing this feature
  152848. */
  152849. readonly options: IWebXRHitTestOptions;
  152850. private _tmpMat;
  152851. private _tmpPos;
  152852. private _tmpQuat;
  152853. private _transientXrHitTestSource;
  152854. private _xrHitTestSource;
  152855. private initHitTestSource;
  152856. /**
  152857. * The module's name
  152858. */
  152859. static readonly Name: string;
  152860. /**
  152861. * The (Babylon) version of this module.
  152862. * This is an integer representing the implementation version.
  152863. * This number does not correspond to the WebXR specs version
  152864. */
  152865. static readonly Version: number;
  152866. /**
  152867. * When set to true, each hit test will have its own position/rotation objects
  152868. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  152869. * the developers will clone them or copy them as they see fit.
  152870. */
  152871. autoCloneTransformation: boolean;
  152872. /**
  152873. * Triggered when new babylon (transformed) hit test results are available
  152874. */
  152875. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  152876. /**
  152877. * Use this to temporarily pause hit test checks.
  152878. */
  152879. paused: boolean;
  152880. /**
  152881. * Creates a new instance of the hit test feature
  152882. * @param _xrSessionManager an instance of WebXRSessionManager
  152883. * @param options options to use when constructing this feature
  152884. */
  152885. constructor(_xrSessionManager: WebXRSessionManager,
  152886. /**
  152887. * options to use when constructing this feature
  152888. */
  152889. options?: IWebXRHitTestOptions);
  152890. /**
  152891. * attach this feature
  152892. * Will usually be called by the features manager
  152893. *
  152894. * @returns true if successful.
  152895. */
  152896. attach(): boolean;
  152897. /**
  152898. * detach this feature.
  152899. * Will usually be called by the features manager
  152900. *
  152901. * @returns true if successful.
  152902. */
  152903. detach(): boolean;
  152904. /**
  152905. * Dispose this feature and all of the resources attached
  152906. */
  152907. dispose(): void;
  152908. protected _onXRFrame(frame: XRFrame): void;
  152909. private _processWebXRHitTestResult;
  152910. }
  152911. }
  152912. declare module BABYLON {
  152913. /**
  152914. * Configuration options of the anchor system
  152915. */
  152916. export interface IWebXRAnchorSystemOptions {
  152917. /**
  152918. * a node that will be used to convert local to world coordinates
  152919. */
  152920. worldParentNode?: TransformNode;
  152921. /**
  152922. * If set to true a reference of the created anchors will be kept until the next session starts
  152923. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  152924. */
  152925. doNotRemoveAnchorsOnSessionEnded?: boolean;
  152926. }
  152927. /**
  152928. * A babylon container for an XR Anchor
  152929. */
  152930. export interface IWebXRAnchor {
  152931. /**
  152932. * A babylon-assigned ID for this anchor
  152933. */
  152934. id: number;
  152935. /**
  152936. * Transformation matrix to apply to an object attached to this anchor
  152937. */
  152938. transformationMatrix: Matrix;
  152939. /**
  152940. * The native anchor object
  152941. */
  152942. xrAnchor: XRAnchor;
  152943. /**
  152944. * if defined, this object will be constantly updated by the anchor's position and rotation
  152945. */
  152946. attachedNode?: TransformNode;
  152947. }
  152948. /**
  152949. * An implementation of the anchor system for WebXR.
  152950. * For further information see https://github.com/immersive-web/anchors/
  152951. */
  152952. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  152953. private _options;
  152954. private _lastFrameDetected;
  152955. private _trackedAnchors;
  152956. private _referenceSpaceForFrameAnchors;
  152957. private _futureAnchors;
  152958. /**
  152959. * The module's name
  152960. */
  152961. static readonly Name: string;
  152962. /**
  152963. * The (Babylon) version of this module.
  152964. * This is an integer representing the implementation version.
  152965. * This number does not correspond to the WebXR specs version
  152966. */
  152967. static readonly Version: number;
  152968. /**
  152969. * Observers registered here will be executed when a new anchor was added to the session
  152970. */
  152971. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  152972. /**
  152973. * Observers registered here will be executed when an anchor was removed from the session
  152974. */
  152975. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  152976. /**
  152977. * Observers registered here will be executed when an existing anchor updates
  152978. * This can execute N times every frame
  152979. */
  152980. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  152981. /**
  152982. * Set the reference space to use for anchor creation, when not using a hit test.
  152983. * Will default to the session's reference space if not defined
  152984. */
  152985. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  152986. /**
  152987. * constructs a new anchor system
  152988. * @param _xrSessionManager an instance of WebXRSessionManager
  152989. * @param _options configuration object for this feature
  152990. */
  152991. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  152992. private _tmpVector;
  152993. private _tmpQuaternion;
  152994. private _populateTmpTransformation;
  152995. /**
  152996. * Create a new anchor point using a hit test result at a specific point in the scene
  152997. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  152998. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  152999. *
  153000. * @param hitTestResult The hit test result to use for this anchor creation
  153001. * @param position an optional position offset for this anchor
  153002. * @param rotationQuaternion an optional rotation offset for this anchor
  153003. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153004. */
  153005. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  153006. /**
  153007. * Add a new anchor at a specific position and rotation
  153008. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  153009. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  153010. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  153011. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  153012. *
  153013. * @param position the position in which to add an anchor
  153014. * @param rotationQuaternion an optional rotation for the anchor transformation
  153015. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  153016. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  153017. */
  153018. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  153019. /**
  153020. * detach this feature.
  153021. * Will usually be called by the features manager
  153022. *
  153023. * @returns true if successful.
  153024. */
  153025. detach(): boolean;
  153026. /**
  153027. * Dispose this feature and all of the resources attached
  153028. */
  153029. dispose(): void;
  153030. protected _onXRFrame(frame: XRFrame): void;
  153031. /**
  153032. * avoiding using Array.find for global support.
  153033. * @param xrAnchor the plane to find in the array
  153034. */
  153035. private _findIndexInAnchorArray;
  153036. private _updateAnchorWithXRFrame;
  153037. private _createAnchorAtTransformation;
  153038. }
  153039. }
  153040. declare module BABYLON {
  153041. /**
  153042. * Options used in the plane detector module
  153043. */
  153044. export interface IWebXRPlaneDetectorOptions {
  153045. /**
  153046. * The node to use to transform the local results to world coordinates
  153047. */
  153048. worldParentNode?: TransformNode;
  153049. /**
  153050. * If set to true a reference of the created planes will be kept until the next session starts
  153051. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  153052. */
  153053. doNotRemovePlanesOnSessionEnded?: boolean;
  153054. }
  153055. /**
  153056. * A babylon interface for a WebXR plane.
  153057. * A Plane is actually a polygon, built from N points in space
  153058. *
  153059. * Supported in chrome 79, not supported in canary 81 ATM
  153060. */
  153061. export interface IWebXRPlane {
  153062. /**
  153063. * a babylon-assigned ID for this polygon
  153064. */
  153065. id: number;
  153066. /**
  153067. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  153068. */
  153069. polygonDefinition: Array<Vector3>;
  153070. /**
  153071. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  153072. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  153073. */
  153074. transformationMatrix: Matrix;
  153075. /**
  153076. * the native xr-plane object
  153077. */
  153078. xrPlane: XRPlane;
  153079. }
  153080. /**
  153081. * The plane detector is used to detect planes in the real world when in AR
  153082. * For more information see https://github.com/immersive-web/real-world-geometry/
  153083. */
  153084. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  153085. private _options;
  153086. private _detectedPlanes;
  153087. private _enabled;
  153088. private _lastFrameDetected;
  153089. /**
  153090. * The module's name
  153091. */
  153092. static readonly Name: string;
  153093. /**
  153094. * The (Babylon) version of this module.
  153095. * This is an integer representing the implementation version.
  153096. * This number does not correspond to the WebXR specs version
  153097. */
  153098. static readonly Version: number;
  153099. /**
  153100. * Observers registered here will be executed when a new plane was added to the session
  153101. */
  153102. onPlaneAddedObservable: Observable<IWebXRPlane>;
  153103. /**
  153104. * Observers registered here will be executed when a plane is no longer detected in the session
  153105. */
  153106. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  153107. /**
  153108. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  153109. * This can execute N times every frame
  153110. */
  153111. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  153112. /**
  153113. * construct a new Plane Detector
  153114. * @param _xrSessionManager an instance of xr Session manager
  153115. * @param _options configuration to use when constructing this feature
  153116. */
  153117. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  153118. /**
  153119. * detach this feature.
  153120. * Will usually be called by the features manager
  153121. *
  153122. * @returns true if successful.
  153123. */
  153124. detach(): boolean;
  153125. /**
  153126. * Dispose this feature and all of the resources attached
  153127. */
  153128. dispose(): void;
  153129. protected _onXRFrame(frame: XRFrame): void;
  153130. private _init;
  153131. private _updatePlaneWithXRPlane;
  153132. /**
  153133. * avoiding using Array.find for global support.
  153134. * @param xrPlane the plane to find in the array
  153135. */
  153136. private findIndexInPlaneArray;
  153137. }
  153138. }
  153139. declare module BABYLON {
  153140. /**
  153141. * Options interface for the background remover plugin
  153142. */
  153143. export interface IWebXRBackgroundRemoverOptions {
  153144. /**
  153145. * Further background meshes to disable when entering AR
  153146. */
  153147. backgroundMeshes?: AbstractMesh[];
  153148. /**
  153149. * flags to configure the removal of the environment helper.
  153150. * If not set, the entire background will be removed. If set, flags should be set as well.
  153151. */
  153152. environmentHelperRemovalFlags?: {
  153153. /**
  153154. * Should the skybox be removed (default false)
  153155. */
  153156. skyBox?: boolean;
  153157. /**
  153158. * Should the ground be removed (default false)
  153159. */
  153160. ground?: boolean;
  153161. };
  153162. /**
  153163. * don't disable the environment helper
  153164. */
  153165. ignoreEnvironmentHelper?: boolean;
  153166. }
  153167. /**
  153168. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  153169. */
  153170. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  153171. /**
  153172. * read-only options to be used in this module
  153173. */
  153174. readonly options: IWebXRBackgroundRemoverOptions;
  153175. /**
  153176. * The module's name
  153177. */
  153178. static readonly Name: string;
  153179. /**
  153180. * The (Babylon) version of this module.
  153181. * This is an integer representing the implementation version.
  153182. * This number does not correspond to the WebXR specs version
  153183. */
  153184. static readonly Version: number;
  153185. /**
  153186. * registered observers will be triggered when the background state changes
  153187. */
  153188. onBackgroundStateChangedObservable: Observable<boolean>;
  153189. /**
  153190. * constructs a new background remover module
  153191. * @param _xrSessionManager the session manager for this module
  153192. * @param options read-only options to be used in this module
  153193. */
  153194. constructor(_xrSessionManager: WebXRSessionManager,
  153195. /**
  153196. * read-only options to be used in this module
  153197. */
  153198. options?: IWebXRBackgroundRemoverOptions);
  153199. /**
  153200. * attach this feature
  153201. * Will usually be called by the features manager
  153202. *
  153203. * @returns true if successful.
  153204. */
  153205. attach(): boolean;
  153206. /**
  153207. * detach this feature.
  153208. * Will usually be called by the features manager
  153209. *
  153210. * @returns true if successful.
  153211. */
  153212. detach(): boolean;
  153213. /**
  153214. * Dispose this feature and all of the resources attached
  153215. */
  153216. dispose(): void;
  153217. protected _onXRFrame(_xrFrame: XRFrame): void;
  153218. private _setBackgroundState;
  153219. }
  153220. }
  153221. declare module BABYLON {
  153222. /**
  153223. * Options for the controller physics feature
  153224. */
  153225. export class IWebXRControllerPhysicsOptions {
  153226. /**
  153227. * Should the headset get its own impostor
  153228. */
  153229. enableHeadsetImpostor?: boolean;
  153230. /**
  153231. * Optional parameters for the headset impostor
  153232. */
  153233. headsetImpostorParams?: {
  153234. /**
  153235. * The type of impostor to create. Default is sphere
  153236. */
  153237. impostorType: number;
  153238. /**
  153239. * the size of the impostor. Defaults to 10cm
  153240. */
  153241. impostorSize?: number | {
  153242. width: number;
  153243. height: number;
  153244. depth: number;
  153245. };
  153246. /**
  153247. * Friction definitions
  153248. */
  153249. friction?: number;
  153250. /**
  153251. * Restitution
  153252. */
  153253. restitution?: number;
  153254. };
  153255. /**
  153256. * The physics properties of the future impostors
  153257. */
  153258. physicsProperties?: {
  153259. /**
  153260. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  153261. * Note that this requires a physics engine that supports mesh impostors!
  153262. */
  153263. useControllerMesh?: boolean;
  153264. /**
  153265. * The type of impostor to create. Default is sphere
  153266. */
  153267. impostorType?: number;
  153268. /**
  153269. * the size of the impostor. Defaults to 10cm
  153270. */
  153271. impostorSize?: number | {
  153272. width: number;
  153273. height: number;
  153274. depth: number;
  153275. };
  153276. /**
  153277. * Friction definitions
  153278. */
  153279. friction?: number;
  153280. /**
  153281. * Restitution
  153282. */
  153283. restitution?: number;
  153284. };
  153285. /**
  153286. * the xr input to use with this pointer selection
  153287. */
  153288. xrInput: WebXRInput;
  153289. }
  153290. /**
  153291. * Add physics impostor to your webxr controllers,
  153292. * including naive calculation of their linear and angular velocity
  153293. */
  153294. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  153295. private readonly _options;
  153296. private _attachController;
  153297. private _controllers;
  153298. private _debugMode;
  153299. private _delta;
  153300. private _headsetImpostor?;
  153301. private _headsetMesh?;
  153302. private _lastTimestamp;
  153303. private _tmpQuaternion;
  153304. private _tmpVector;
  153305. /**
  153306. * The module's name
  153307. */
  153308. static readonly Name: string;
  153309. /**
  153310. * The (Babylon) version of this module.
  153311. * This is an integer representing the implementation version.
  153312. * This number does not correspond to the webxr specs version
  153313. */
  153314. static readonly Version: number;
  153315. /**
  153316. * Construct a new Controller Physics Feature
  153317. * @param _xrSessionManager the corresponding xr session manager
  153318. * @param _options options to create this feature with
  153319. */
  153320. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  153321. /**
  153322. * @hidden
  153323. * enable debugging - will show console outputs and the impostor mesh
  153324. */
  153325. _enablePhysicsDebug(): void;
  153326. /**
  153327. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  153328. * @param xrController the controller to add
  153329. */
  153330. addController(xrController: WebXRInputSource): void;
  153331. /**
  153332. * attach this feature
  153333. * Will usually be called by the features manager
  153334. *
  153335. * @returns true if successful.
  153336. */
  153337. attach(): boolean;
  153338. /**
  153339. * detach this feature.
  153340. * Will usually be called by the features manager
  153341. *
  153342. * @returns true if successful.
  153343. */
  153344. detach(): boolean;
  153345. /**
  153346. * Get the headset impostor, if enabled
  153347. * @returns the impostor
  153348. */
  153349. getHeadsetImpostor(): PhysicsImpostor | undefined;
  153350. /**
  153351. * Get the physics impostor of a specific controller.
  153352. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  153353. * @param controller the controller or the controller id of which to get the impostor
  153354. * @returns the impostor or null
  153355. */
  153356. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  153357. /**
  153358. * Update the physics properties provided in the constructor
  153359. * @param newProperties the new properties object
  153360. */
  153361. setPhysicsProperties(newProperties: {
  153362. impostorType?: number;
  153363. impostorSize?: number | {
  153364. width: number;
  153365. height: number;
  153366. depth: number;
  153367. };
  153368. friction?: number;
  153369. restitution?: number;
  153370. }): void;
  153371. protected _onXRFrame(_xrFrame: any): void;
  153372. private _detachController;
  153373. }
  153374. }
  153375. declare module BABYLON {
  153376. /**
  153377. * The motion controller class for all microsoft mixed reality controllers
  153378. */
  153379. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  153380. protected readonly _mapping: {
  153381. defaultButton: {
  153382. valueNodeName: string;
  153383. unpressedNodeName: string;
  153384. pressedNodeName: string;
  153385. };
  153386. defaultAxis: {
  153387. valueNodeName: string;
  153388. minNodeName: string;
  153389. maxNodeName: string;
  153390. };
  153391. buttons: {
  153392. "xr-standard-trigger": {
  153393. rootNodeName: string;
  153394. componentProperty: string;
  153395. states: string[];
  153396. };
  153397. "xr-standard-squeeze": {
  153398. rootNodeName: string;
  153399. componentProperty: string;
  153400. states: string[];
  153401. };
  153402. "xr-standard-touchpad": {
  153403. rootNodeName: string;
  153404. labelAnchorNodeName: string;
  153405. touchPointNodeName: string;
  153406. };
  153407. "xr-standard-thumbstick": {
  153408. rootNodeName: string;
  153409. componentProperty: string;
  153410. states: string[];
  153411. };
  153412. };
  153413. axes: {
  153414. "xr-standard-touchpad": {
  153415. "x-axis": {
  153416. rootNodeName: string;
  153417. };
  153418. "y-axis": {
  153419. rootNodeName: string;
  153420. };
  153421. };
  153422. "xr-standard-thumbstick": {
  153423. "x-axis": {
  153424. rootNodeName: string;
  153425. };
  153426. "y-axis": {
  153427. rootNodeName: string;
  153428. };
  153429. };
  153430. };
  153431. };
  153432. /**
  153433. * The base url used to load the left and right controller models
  153434. */
  153435. static MODEL_BASE_URL: string;
  153436. /**
  153437. * The name of the left controller model file
  153438. */
  153439. static MODEL_LEFT_FILENAME: string;
  153440. /**
  153441. * The name of the right controller model file
  153442. */
  153443. static MODEL_RIGHT_FILENAME: string;
  153444. profileId: string;
  153445. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153446. protected _getFilenameAndPath(): {
  153447. filename: string;
  153448. path: string;
  153449. };
  153450. protected _getModelLoadingConstraints(): boolean;
  153451. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153452. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153453. protected _updateModel(): void;
  153454. }
  153455. }
  153456. declare module BABYLON {
  153457. /**
  153458. * The motion controller class for oculus touch (quest, rift).
  153459. * This class supports legacy mapping as well the standard xr mapping
  153460. */
  153461. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  153462. private _forceLegacyControllers;
  153463. private _modelRootNode;
  153464. /**
  153465. * The base url used to load the left and right controller models
  153466. */
  153467. static MODEL_BASE_URL: string;
  153468. /**
  153469. * The name of the left controller model file
  153470. */
  153471. static MODEL_LEFT_FILENAME: string;
  153472. /**
  153473. * The name of the right controller model file
  153474. */
  153475. static MODEL_RIGHT_FILENAME: string;
  153476. /**
  153477. * Base Url for the Quest controller model.
  153478. */
  153479. static QUEST_MODEL_BASE_URL: string;
  153480. profileId: string;
  153481. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  153482. protected _getFilenameAndPath(): {
  153483. filename: string;
  153484. path: string;
  153485. };
  153486. protected _getModelLoadingConstraints(): boolean;
  153487. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153488. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153489. protected _updateModel(): void;
  153490. /**
  153491. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  153492. * between the touch and touch 2.
  153493. */
  153494. private _isQuest;
  153495. }
  153496. }
  153497. declare module BABYLON {
  153498. /**
  153499. * The motion controller class for the standard HTC-Vive controllers
  153500. */
  153501. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  153502. private _modelRootNode;
  153503. /**
  153504. * The base url used to load the left and right controller models
  153505. */
  153506. static MODEL_BASE_URL: string;
  153507. /**
  153508. * File name for the controller model.
  153509. */
  153510. static MODEL_FILENAME: string;
  153511. profileId: string;
  153512. /**
  153513. * Create a new Vive motion controller object
  153514. * @param scene the scene to use to create this controller
  153515. * @param gamepadObject the corresponding gamepad object
  153516. * @param handedness the handedness of the controller
  153517. */
  153518. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  153519. protected _getFilenameAndPath(): {
  153520. filename: string;
  153521. path: string;
  153522. };
  153523. protected _getModelLoadingConstraints(): boolean;
  153524. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  153525. protected _setRootMesh(meshes: AbstractMesh[]): void;
  153526. protected _updateModel(): void;
  153527. }
  153528. }
  153529. declare module BABYLON {
  153530. /**
  153531. * A cursor which tracks a point on a path
  153532. */
  153533. export class PathCursor {
  153534. private path;
  153535. /**
  153536. * Stores path cursor callbacks for when an onchange event is triggered
  153537. */
  153538. private _onchange;
  153539. /**
  153540. * The value of the path cursor
  153541. */
  153542. value: number;
  153543. /**
  153544. * The animation array of the path cursor
  153545. */
  153546. animations: Animation[];
  153547. /**
  153548. * Initializes the path cursor
  153549. * @param path The path to track
  153550. */
  153551. constructor(path: Path2);
  153552. /**
  153553. * Gets the cursor point on the path
  153554. * @returns A point on the path cursor at the cursor location
  153555. */
  153556. getPoint(): Vector3;
  153557. /**
  153558. * Moves the cursor ahead by the step amount
  153559. * @param step The amount to move the cursor forward
  153560. * @returns This path cursor
  153561. */
  153562. moveAhead(step?: number): PathCursor;
  153563. /**
  153564. * Moves the cursor behind by the step amount
  153565. * @param step The amount to move the cursor back
  153566. * @returns This path cursor
  153567. */
  153568. moveBack(step?: number): PathCursor;
  153569. /**
  153570. * Moves the cursor by the step amount
  153571. * If the step amount is greater than one, an exception is thrown
  153572. * @param step The amount to move the cursor
  153573. * @returns This path cursor
  153574. */
  153575. move(step: number): PathCursor;
  153576. /**
  153577. * Ensures that the value is limited between zero and one
  153578. * @returns This path cursor
  153579. */
  153580. private ensureLimits;
  153581. /**
  153582. * Runs onchange callbacks on change (used by the animation engine)
  153583. * @returns This path cursor
  153584. */
  153585. private raiseOnChange;
  153586. /**
  153587. * Executes a function on change
  153588. * @param f A path cursor onchange callback
  153589. * @returns This path cursor
  153590. */
  153591. onchange(f: (cursor: PathCursor) => void): PathCursor;
  153592. }
  153593. }
  153594. declare module BABYLON {
  153595. /** @hidden */
  153596. export var blurPixelShader: {
  153597. name: string;
  153598. shader: string;
  153599. };
  153600. }
  153601. declare module BABYLON {
  153602. /** @hidden */
  153603. export var pointCloudVertexDeclaration: {
  153604. name: string;
  153605. shader: string;
  153606. };
  153607. }
  153608. // Mixins
  153609. interface Window {
  153610. mozIndexedDB: IDBFactory;
  153611. webkitIndexedDB: IDBFactory;
  153612. msIndexedDB: IDBFactory;
  153613. webkitURL: typeof URL;
  153614. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  153615. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  153616. WebGLRenderingContext: WebGLRenderingContext;
  153617. MSGesture: MSGesture;
  153618. CANNON: any;
  153619. AudioContext: AudioContext;
  153620. webkitAudioContext: AudioContext;
  153621. PointerEvent: any;
  153622. Math: Math;
  153623. Uint8Array: Uint8ArrayConstructor;
  153624. Float32Array: Float32ArrayConstructor;
  153625. mozURL: typeof URL;
  153626. msURL: typeof URL;
  153627. VRFrameData: any; // WebVR, from specs 1.1
  153628. DracoDecoderModule: any;
  153629. setImmediate(handler: (...args: any[]) => void): number;
  153630. }
  153631. interface HTMLCanvasElement {
  153632. requestPointerLock(): void;
  153633. msRequestPointerLock?(): void;
  153634. mozRequestPointerLock?(): void;
  153635. webkitRequestPointerLock?(): void;
  153636. /** Track wether a record is in progress */
  153637. isRecording: boolean;
  153638. /** Capture Stream method defined by some browsers */
  153639. captureStream(fps?: number): MediaStream;
  153640. }
  153641. interface CanvasRenderingContext2D {
  153642. msImageSmoothingEnabled: boolean;
  153643. }
  153644. interface MouseEvent {
  153645. mozMovementX: number;
  153646. mozMovementY: number;
  153647. webkitMovementX: number;
  153648. webkitMovementY: number;
  153649. msMovementX: number;
  153650. msMovementY: number;
  153651. }
  153652. interface Navigator {
  153653. mozGetVRDevices: (any: any) => any;
  153654. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153655. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153656. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  153657. webkitGetGamepads(): Gamepad[];
  153658. msGetGamepads(): Gamepad[];
  153659. webkitGamepads(): Gamepad[];
  153660. }
  153661. interface HTMLVideoElement {
  153662. mozSrcObject: any;
  153663. }
  153664. interface Math {
  153665. fround(x: number): number;
  153666. imul(a: number, b: number): number;
  153667. }
  153668. interface WebGLRenderingContext {
  153669. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  153670. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  153671. vertexAttribDivisor(index: number, divisor: number): void;
  153672. createVertexArray(): any;
  153673. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  153674. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  153675. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  153676. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  153677. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  153678. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  153679. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  153680. // Queries
  153681. createQuery(): WebGLQuery;
  153682. deleteQuery(query: WebGLQuery): void;
  153683. beginQuery(target: number, query: WebGLQuery): void;
  153684. endQuery(target: number): void;
  153685. getQueryParameter(query: WebGLQuery, pname: number): any;
  153686. getQuery(target: number, pname: number): any;
  153687. MAX_SAMPLES: number;
  153688. RGBA8: number;
  153689. READ_FRAMEBUFFER: number;
  153690. DRAW_FRAMEBUFFER: number;
  153691. UNIFORM_BUFFER: number;
  153692. HALF_FLOAT_OES: number;
  153693. RGBA16F: number;
  153694. RGBA32F: number;
  153695. R32F: number;
  153696. RG32F: number;
  153697. RGB32F: number;
  153698. R16F: number;
  153699. RG16F: number;
  153700. RGB16F: number;
  153701. RED: number;
  153702. RG: number;
  153703. R8: number;
  153704. RG8: number;
  153705. UNSIGNED_INT_24_8: number;
  153706. DEPTH24_STENCIL8: number;
  153707. MIN: number;
  153708. MAX: number;
  153709. /* Multiple Render Targets */
  153710. drawBuffers(buffers: number[]): void;
  153711. readBuffer(src: number): void;
  153712. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  153713. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  153714. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  153715. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  153716. // Occlusion Query
  153717. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  153718. ANY_SAMPLES_PASSED: number;
  153719. QUERY_RESULT_AVAILABLE: number;
  153720. QUERY_RESULT: number;
  153721. }
  153722. interface WebGLProgram {
  153723. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  153724. }
  153725. interface EXT_disjoint_timer_query {
  153726. QUERY_COUNTER_BITS_EXT: number;
  153727. TIME_ELAPSED_EXT: number;
  153728. TIMESTAMP_EXT: number;
  153729. GPU_DISJOINT_EXT: number;
  153730. QUERY_RESULT_EXT: number;
  153731. QUERY_RESULT_AVAILABLE_EXT: number;
  153732. queryCounterEXT(query: WebGLQuery, target: number): void;
  153733. createQueryEXT(): WebGLQuery;
  153734. beginQueryEXT(target: number, query: WebGLQuery): void;
  153735. endQueryEXT(target: number): void;
  153736. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  153737. deleteQueryEXT(query: WebGLQuery): void;
  153738. }
  153739. interface WebGLUniformLocation {
  153740. _currentState: any;
  153741. }
  153742. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  153743. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  153744. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  153745. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153746. interface WebGLRenderingContext {
  153747. readonly RASTERIZER_DISCARD: number;
  153748. readonly DEPTH_COMPONENT24: number;
  153749. readonly TEXTURE_3D: number;
  153750. readonly TEXTURE_2D_ARRAY: number;
  153751. readonly TEXTURE_COMPARE_FUNC: number;
  153752. readonly TEXTURE_COMPARE_MODE: number;
  153753. readonly COMPARE_REF_TO_TEXTURE: number;
  153754. readonly TEXTURE_WRAP_R: number;
  153755. readonly HALF_FLOAT: number;
  153756. readonly RGB8: number;
  153757. readonly RED_INTEGER: number;
  153758. readonly RG_INTEGER: number;
  153759. readonly RGB_INTEGER: number;
  153760. readonly RGBA_INTEGER: number;
  153761. readonly R8_SNORM: number;
  153762. readonly RG8_SNORM: number;
  153763. readonly RGB8_SNORM: number;
  153764. readonly RGBA8_SNORM: number;
  153765. readonly R8I: number;
  153766. readonly RG8I: number;
  153767. readonly RGB8I: number;
  153768. readonly RGBA8I: number;
  153769. readonly R8UI: number;
  153770. readonly RG8UI: number;
  153771. readonly RGB8UI: number;
  153772. readonly RGBA8UI: number;
  153773. readonly R16I: number;
  153774. readonly RG16I: number;
  153775. readonly RGB16I: number;
  153776. readonly RGBA16I: number;
  153777. readonly R16UI: number;
  153778. readonly RG16UI: number;
  153779. readonly RGB16UI: number;
  153780. readonly RGBA16UI: number;
  153781. readonly R32I: number;
  153782. readonly RG32I: number;
  153783. readonly RGB32I: number;
  153784. readonly RGBA32I: number;
  153785. readonly R32UI: number;
  153786. readonly RG32UI: number;
  153787. readonly RGB32UI: number;
  153788. readonly RGBA32UI: number;
  153789. readonly RGB10_A2UI: number;
  153790. readonly R11F_G11F_B10F: number;
  153791. readonly RGB9_E5: number;
  153792. readonly RGB10_A2: number;
  153793. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  153794. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  153795. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  153796. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  153797. readonly DEPTH_COMPONENT32F: number;
  153798. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  153799. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  153800. 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;
  153801. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  153802. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  153803. readonly TRANSFORM_FEEDBACK: number;
  153804. readonly INTERLEAVED_ATTRIBS: number;
  153805. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  153806. createTransformFeedback(): WebGLTransformFeedback;
  153807. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  153808. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  153809. beginTransformFeedback(primitiveMode: number): void;
  153810. endTransformFeedback(): void;
  153811. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  153812. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153813. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153814. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  153815. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  153816. }
  153817. interface ImageBitmap {
  153818. readonly width: number;
  153819. readonly height: number;
  153820. close(): void;
  153821. }
  153822. interface WebGLQuery extends WebGLObject {
  153823. }
  153824. declare var WebGLQuery: {
  153825. prototype: WebGLQuery;
  153826. new(): WebGLQuery;
  153827. };
  153828. interface WebGLSampler extends WebGLObject {
  153829. }
  153830. declare var WebGLSampler: {
  153831. prototype: WebGLSampler;
  153832. new(): WebGLSampler;
  153833. };
  153834. interface WebGLSync extends WebGLObject {
  153835. }
  153836. declare var WebGLSync: {
  153837. prototype: WebGLSync;
  153838. new(): WebGLSync;
  153839. };
  153840. interface WebGLTransformFeedback extends WebGLObject {
  153841. }
  153842. declare var WebGLTransformFeedback: {
  153843. prototype: WebGLTransformFeedback;
  153844. new(): WebGLTransformFeedback;
  153845. };
  153846. interface WebGLVertexArrayObject extends WebGLObject {
  153847. }
  153848. declare var WebGLVertexArrayObject: {
  153849. prototype: WebGLVertexArrayObject;
  153850. new(): WebGLVertexArrayObject;
  153851. };
  153852. // Type definitions for WebVR API
  153853. // Project: https://w3c.github.io/webvr/
  153854. // Definitions by: six a <https://github.com/lostfictions>
  153855. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  153856. interface VRDisplay extends EventTarget {
  153857. /**
  153858. * Dictionary of capabilities describing the VRDisplay.
  153859. */
  153860. readonly capabilities: VRDisplayCapabilities;
  153861. /**
  153862. * z-depth defining the far plane of the eye view frustum
  153863. * enables mapping of values in the render target depth
  153864. * attachment to scene coordinates. Initially set to 10000.0.
  153865. */
  153866. depthFar: number;
  153867. /**
  153868. * z-depth defining the near plane of the eye view frustum
  153869. * enables mapping of values in the render target depth
  153870. * attachment to scene coordinates. Initially set to 0.01.
  153871. */
  153872. depthNear: number;
  153873. /**
  153874. * An identifier for this distinct VRDisplay. Used as an
  153875. * association point in the Gamepad API.
  153876. */
  153877. readonly displayId: number;
  153878. /**
  153879. * A display name, a user-readable name identifying it.
  153880. */
  153881. readonly displayName: string;
  153882. readonly isConnected: boolean;
  153883. readonly isPresenting: boolean;
  153884. /**
  153885. * If this VRDisplay supports room-scale experiences, the optional
  153886. * stage attribute contains details on the room-scale parameters.
  153887. */
  153888. readonly stageParameters: VRStageParameters | null;
  153889. /**
  153890. * Passing the value returned by `requestAnimationFrame` to
  153891. * `cancelAnimationFrame` will unregister the callback.
  153892. * @param handle Define the hanle of the request to cancel
  153893. */
  153894. cancelAnimationFrame(handle: number): void;
  153895. /**
  153896. * Stops presenting to the VRDisplay.
  153897. * @returns a promise to know when it stopped
  153898. */
  153899. exitPresent(): Promise<void>;
  153900. /**
  153901. * Return the current VREyeParameters for the given eye.
  153902. * @param whichEye Define the eye we want the parameter for
  153903. * @returns the eye parameters
  153904. */
  153905. getEyeParameters(whichEye: string): VREyeParameters;
  153906. /**
  153907. * Populates the passed VRFrameData with the information required to render
  153908. * the current frame.
  153909. * @param frameData Define the data structure to populate
  153910. * @returns true if ok otherwise false
  153911. */
  153912. getFrameData(frameData: VRFrameData): boolean;
  153913. /**
  153914. * Get the layers currently being presented.
  153915. * @returns the list of VR layers
  153916. */
  153917. getLayers(): VRLayer[];
  153918. /**
  153919. * Return a VRPose containing the future predicted pose of the VRDisplay
  153920. * when the current frame will be presented. The value returned will not
  153921. * change until JavaScript has returned control to the browser.
  153922. *
  153923. * The VRPose will contain the position, orientation, velocity,
  153924. * and acceleration of each of these properties.
  153925. * @returns the pose object
  153926. */
  153927. getPose(): VRPose;
  153928. /**
  153929. * Return the current instantaneous pose of the VRDisplay, with no
  153930. * prediction applied.
  153931. * @returns the current instantaneous pose
  153932. */
  153933. getImmediatePose(): VRPose;
  153934. /**
  153935. * The callback passed to `requestAnimationFrame` will be called
  153936. * any time a new frame should be rendered. When the VRDisplay is
  153937. * presenting the callback will be called at the native refresh
  153938. * rate of the HMD. When not presenting this function acts
  153939. * identically to how window.requestAnimationFrame acts. Content should
  153940. * make no assumptions of frame rate or vsync behavior as the HMD runs
  153941. * asynchronously from other displays and at differing refresh rates.
  153942. * @param callback Define the eaction to run next frame
  153943. * @returns the request handle it
  153944. */
  153945. requestAnimationFrame(callback: FrameRequestCallback): number;
  153946. /**
  153947. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  153948. * Repeat calls while already presenting will update the VRLayers being displayed.
  153949. * @param layers Define the list of layer to present
  153950. * @returns a promise to know when the request has been fulfilled
  153951. */
  153952. requestPresent(layers: VRLayer[]): Promise<void>;
  153953. /**
  153954. * Reset the pose for this display, treating its current position and
  153955. * orientation as the "origin/zero" values. VRPose.position,
  153956. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  153957. * updated when calling resetPose(). This should be called in only
  153958. * sitting-space experiences.
  153959. */
  153960. resetPose(): void;
  153961. /**
  153962. * The VRLayer provided to the VRDisplay will be captured and presented
  153963. * in the HMD. Calling this function has the same effect on the source
  153964. * canvas as any other operation that uses its source image, and canvases
  153965. * created without preserveDrawingBuffer set to true will be cleared.
  153966. * @param pose Define the pose to submit
  153967. */
  153968. submitFrame(pose?: VRPose): void;
  153969. }
  153970. declare var VRDisplay: {
  153971. prototype: VRDisplay;
  153972. new(): VRDisplay;
  153973. };
  153974. interface VRLayer {
  153975. leftBounds?: number[] | Float32Array | null;
  153976. rightBounds?: number[] | Float32Array | null;
  153977. source?: HTMLCanvasElement | null;
  153978. }
  153979. interface VRDisplayCapabilities {
  153980. readonly canPresent: boolean;
  153981. readonly hasExternalDisplay: boolean;
  153982. readonly hasOrientation: boolean;
  153983. readonly hasPosition: boolean;
  153984. readonly maxLayers: number;
  153985. }
  153986. interface VREyeParameters {
  153987. /** @deprecated */
  153988. readonly fieldOfView: VRFieldOfView;
  153989. readonly offset: Float32Array;
  153990. readonly renderHeight: number;
  153991. readonly renderWidth: number;
  153992. }
  153993. interface VRFieldOfView {
  153994. readonly downDegrees: number;
  153995. readonly leftDegrees: number;
  153996. readonly rightDegrees: number;
  153997. readonly upDegrees: number;
  153998. }
  153999. interface VRFrameData {
  154000. readonly leftProjectionMatrix: Float32Array;
  154001. readonly leftViewMatrix: Float32Array;
  154002. readonly pose: VRPose;
  154003. readonly rightProjectionMatrix: Float32Array;
  154004. readonly rightViewMatrix: Float32Array;
  154005. readonly timestamp: number;
  154006. }
  154007. interface VRPose {
  154008. readonly angularAcceleration: Float32Array | null;
  154009. readonly angularVelocity: Float32Array | null;
  154010. readonly linearAcceleration: Float32Array | null;
  154011. readonly linearVelocity: Float32Array | null;
  154012. readonly orientation: Float32Array | null;
  154013. readonly position: Float32Array | null;
  154014. readonly timestamp: number;
  154015. }
  154016. interface VRStageParameters {
  154017. sittingToStandingTransform?: Float32Array;
  154018. sizeX?: number;
  154019. sizeY?: number;
  154020. }
  154021. interface Navigator {
  154022. getVRDisplays(): Promise<VRDisplay[]>;
  154023. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  154024. }
  154025. interface Window {
  154026. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  154027. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  154028. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  154029. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154030. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  154031. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  154032. }
  154033. interface Gamepad {
  154034. readonly displayId: number;
  154035. }
  154036. type XRSessionMode =
  154037. | "inline"
  154038. | "immersive-vr"
  154039. | "immersive-ar";
  154040. type XRReferenceSpaceType =
  154041. | "viewer"
  154042. | "local"
  154043. | "local-floor"
  154044. | "bounded-floor"
  154045. | "unbounded";
  154046. type XREnvironmentBlendMode =
  154047. | "opaque"
  154048. | "additive"
  154049. | "alpha-blend";
  154050. type XRVisibilityState =
  154051. | "visible"
  154052. | "visible-blurred"
  154053. | "hidden";
  154054. type XRHandedness =
  154055. | "none"
  154056. | "left"
  154057. | "right";
  154058. type XRTargetRayMode =
  154059. | "gaze"
  154060. | "tracked-pointer"
  154061. | "screen";
  154062. type XREye =
  154063. | "none"
  154064. | "left"
  154065. | "right";
  154066. type XREventType =
  154067. | "devicechange"
  154068. | "visibilitychange"
  154069. | "end"
  154070. | "inputsourceschange"
  154071. | "select"
  154072. | "selectstart"
  154073. | "selectend"
  154074. | "squeeze"
  154075. | "squeezestart"
  154076. | "squeezeend"
  154077. | "reset";
  154078. interface XRSpace extends EventTarget {
  154079. }
  154080. interface XRRenderState {
  154081. depthNear?: number;
  154082. depthFar?: number;
  154083. inlineVerticalFieldOfView?: number;
  154084. baseLayer?: XRWebGLLayer;
  154085. }
  154086. interface XRInputSource {
  154087. handedness: XRHandedness;
  154088. targetRayMode: XRTargetRayMode;
  154089. targetRaySpace: XRSpace;
  154090. gripSpace: XRSpace | undefined;
  154091. gamepad: Gamepad | undefined;
  154092. profiles: Array<string>;
  154093. }
  154094. interface XRSessionInit {
  154095. optionalFeatures?: string[];
  154096. requiredFeatures?: string[];
  154097. }
  154098. interface XRSession {
  154099. addEventListener: Function;
  154100. removeEventListener: Function;
  154101. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  154102. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  154103. requestAnimationFrame: Function;
  154104. end(): Promise<void>;
  154105. renderState: XRRenderState;
  154106. inputSources: Array<XRInputSource>;
  154107. // hit test
  154108. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  154109. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  154110. // legacy AR hit test
  154111. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154112. // legacy plane detection
  154113. updateWorldTrackingState(options: {
  154114. planeDetectionState?: { enabled: boolean; }
  154115. }): void;
  154116. }
  154117. interface XRReferenceSpace extends XRSpace {
  154118. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  154119. onreset: any;
  154120. }
  154121. type XRPlaneSet = Set<XRPlane>;
  154122. type XRAnchorSet = Set<XRAnchor>;
  154123. interface XRFrame {
  154124. session: XRSession;
  154125. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  154126. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  154127. // AR
  154128. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  154129. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  154130. // Anchors
  154131. trackedAnchors?: XRAnchorSet;
  154132. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  154133. // Planes
  154134. worldInformation: {
  154135. detectedPlanes?: XRPlaneSet;
  154136. };
  154137. }
  154138. interface XRViewerPose extends XRPose {
  154139. views: Array<XRView>;
  154140. }
  154141. interface XRPose {
  154142. transform: XRRigidTransform;
  154143. emulatedPosition: boolean;
  154144. }
  154145. interface XRWebGLLayerOptions {
  154146. antialias?: boolean;
  154147. depth?: boolean;
  154148. stencil?: boolean;
  154149. alpha?: boolean;
  154150. multiview?: boolean;
  154151. framebufferScaleFactor?: number;
  154152. }
  154153. declare var XRWebGLLayer: {
  154154. prototype: XRWebGLLayer;
  154155. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  154156. };
  154157. interface XRWebGLLayer {
  154158. framebuffer: WebGLFramebuffer;
  154159. framebufferWidth: number;
  154160. framebufferHeight: number;
  154161. getViewport: Function;
  154162. }
  154163. declare class XRRigidTransform {
  154164. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  154165. position: DOMPointReadOnly;
  154166. orientation: DOMPointReadOnly;
  154167. matrix: Float32Array;
  154168. inverse: XRRigidTransform;
  154169. }
  154170. interface XRView {
  154171. eye: XREye;
  154172. projectionMatrix: Float32Array;
  154173. transform: XRRigidTransform;
  154174. }
  154175. interface XRInputSourceChangeEvent {
  154176. session: XRSession;
  154177. removed: Array<XRInputSource>;
  154178. added: Array<XRInputSource>;
  154179. }
  154180. interface XRInputSourceEvent extends Event {
  154181. readonly frame: XRFrame;
  154182. readonly inputSource: XRInputSource;
  154183. }
  154184. // Experimental(er) features
  154185. declare class XRRay {
  154186. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  154187. origin: DOMPointReadOnly;
  154188. direction: DOMPointReadOnly;
  154189. matrix: Float32Array;
  154190. }
  154191. declare enum XRHitTestTrackableType {
  154192. "point",
  154193. "plane"
  154194. }
  154195. interface XRHitResult {
  154196. hitMatrix: Float32Array;
  154197. }
  154198. interface XRTransientInputHitTestResult {
  154199. readonly inputSource: XRInputSource;
  154200. readonly results: Array<XRHitTestResult>;
  154201. }
  154202. interface XRHitTestResult {
  154203. getPose(baseSpace: XRSpace): XRPose | undefined;
  154204. // When anchor system is enabled
  154205. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  154206. }
  154207. interface XRHitTestSource {
  154208. cancel(): void;
  154209. }
  154210. interface XRTransientInputHitTestSource {
  154211. cancel(): void;
  154212. }
  154213. interface XRHitTestOptionsInit {
  154214. space: XRSpace;
  154215. entityTypes?: Array<XRHitTestTrackableType>;
  154216. offsetRay?: XRRay;
  154217. }
  154218. interface XRTransientInputHitTestOptionsInit {
  154219. profile: string;
  154220. entityTypes?: Array<XRHitTestTrackableType>;
  154221. offsetRay?: XRRay;
  154222. }
  154223. interface XRAnchor {
  154224. anchorSpace: XRSpace;
  154225. delete(): void;
  154226. }
  154227. interface XRPlane {
  154228. orientation: "Horizontal" | "Vertical";
  154229. planeSpace: XRSpace;
  154230. polygon: Array<DOMPointReadOnly>;
  154231. lastChangedTime: number;
  154232. }